babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. import { Nullable } from "babylonjs/types";
  431. /**
  432. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  433. */
  434. export class WebRequest implements IWebRequest {
  435. private _xhr;
  436. /**
  437. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  438. * i.e. when loading files, where the server/service expects an Authorization header
  439. */
  440. static CustomRequestHeaders: {
  441. [key: string]: string;
  442. };
  443. /**
  444. * Add callback functions in this array to update all the requests before they get sent to the network
  445. */
  446. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  447. private _injectCustomRequestHeaders;
  448. /**
  449. * Gets or sets a function to be called when loading progress changes
  450. */
  451. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  452. /**
  453. * Returns client's state
  454. */
  455. readonly readyState: number;
  456. /**
  457. * Returns client's status
  458. */
  459. readonly status: number;
  460. /**
  461. * Returns client's status as a text
  462. */
  463. readonly statusText: string;
  464. /**
  465. * Returns client's response
  466. */
  467. readonly response: any;
  468. /**
  469. * Returns client's response url
  470. */
  471. readonly responseURL: string;
  472. /**
  473. * Returns client's response as text
  474. */
  475. readonly responseText: string;
  476. /**
  477. * Gets or sets the expected response type
  478. */
  479. responseType: XMLHttpRequestResponseType;
  480. /** @hidden */
  481. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  482. /** @hidden */
  483. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  484. /**
  485. * Cancels any network activity
  486. */
  487. abort(): void;
  488. /**
  489. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  490. * @param body defines an optional request body
  491. */
  492. send(body?: Document | BodyInit | null): void;
  493. /**
  494. * Sets the request method, request URL
  495. * @param method defines the method to use (GET, POST, etc..)
  496. * @param url defines the url to connect with
  497. */
  498. open(method: string, url: string): void;
  499. /**
  500. * Sets the value of a request header.
  501. * @param name The name of the header whose value is to be set
  502. * @param value The value to set as the body of the header
  503. */
  504. setRequestHeader(name: string, value: string): void;
  505. /**
  506. * Get the string containing the text of a particular header's value.
  507. * @param name The name of the header
  508. * @returns The string containing the text of the given header name
  509. */
  510. getResponseHeader(name: string): Nullable<string>;
  511. }
  512. }
  513. declare module "babylonjs/Misc/fileRequest" {
  514. import { Observable } from "babylonjs/Misc/observable";
  515. /**
  516. * File request interface
  517. */
  518. export interface IFileRequest {
  519. /**
  520. * Raised when the request is complete (success or error).
  521. */
  522. onCompleteObservable: Observable<IFileRequest>;
  523. /**
  524. * Aborts the request for a file.
  525. */
  526. abort: () => void;
  527. }
  528. }
  529. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  530. /**
  531. * Define options used to create a render target texture
  532. */
  533. export class RenderTargetCreationOptions {
  534. /**
  535. * Specifies is mipmaps must be generated
  536. */
  537. generateMipMaps?: boolean;
  538. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  539. generateDepthBuffer?: boolean;
  540. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  541. generateStencilBuffer?: boolean;
  542. /** Defines texture type (int by default) */
  543. type?: number;
  544. /** Defines sampling mode (trilinear by default) */
  545. samplingMode?: number;
  546. /** Defines format (RGBA by default) */
  547. format?: number;
  548. }
  549. }
  550. declare module "babylonjs/Instrumentation/timeToken" {
  551. import { Nullable } from "babylonjs/types";
  552. /**
  553. * @hidden
  554. **/
  555. export class _TimeToken {
  556. _startTimeQuery: Nullable<WebGLQuery>;
  557. _endTimeQuery: Nullable<WebGLQuery>;
  558. _timeElapsedQuery: Nullable<WebGLQuery>;
  559. _timeElapsedQueryEnded: boolean;
  560. }
  561. }
  562. declare module "babylonjs/Engines/constants" {
  563. /** Defines the cross module used constants to avoid circular dependncies */
  564. export class Constants {
  565. /** Defines that alpha blending is disabled */
  566. static readonly ALPHA_DISABLE: number;
  567. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  568. static readonly ALPHA_ADD: number;
  569. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  570. static readonly ALPHA_COMBINE: number;
  571. /** Defines that alpha blending to DEST - SRC * DEST */
  572. static readonly ALPHA_SUBTRACT: number;
  573. /** Defines that alpha blending to SRC * DEST */
  574. static readonly ALPHA_MULTIPLY: number;
  575. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  576. static readonly ALPHA_MAXIMIZED: number;
  577. /** Defines that alpha blending to SRC + DEST */
  578. static readonly ALPHA_ONEONE: number;
  579. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  580. static readonly ALPHA_PREMULTIPLIED: number;
  581. /**
  582. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  583. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  584. */
  585. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  586. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  587. static readonly ALPHA_INTERPOLATE: number;
  588. /**
  589. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  590. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  591. */
  592. static readonly ALPHA_SCREENMODE: number;
  593. /**
  594. * Defines that alpha blending to SRC + DST
  595. * Alpha will be set to SRC ALPHA + DST ALPHA
  596. */
  597. static readonly ALPHA_ONEONE_ONEONE: number;
  598. /**
  599. * Defines that alpha blending to SRC * DST ALPHA + DST
  600. * Alpha will be set to 0
  601. */
  602. static readonly ALPHA_ALPHATOCOLOR: number;
  603. /**
  604. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  605. */
  606. static readonly ALPHA_REVERSEONEMINUS: number;
  607. /**
  608. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  609. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  610. */
  611. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  612. /**
  613. * Defines that alpha blending to SRC + DST
  614. * Alpha will be set to SRC ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEZERO: number;
  617. /** Defines that alpha blending equation a SUM */
  618. static readonly ALPHA_EQUATION_ADD: number;
  619. /** Defines that alpha blending equation a SUBSTRACTION */
  620. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  621. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  622. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  623. /** Defines that alpha blending equation a MAX operation */
  624. static readonly ALPHA_EQUATION_MAX: number;
  625. /** Defines that alpha blending equation a MIN operation */
  626. static readonly ALPHA_EQUATION_MIN: number;
  627. /**
  628. * Defines that alpha blending equation a DARKEN operation:
  629. * It takes the min of the src and sums the alpha channels.
  630. */
  631. static readonly ALPHA_EQUATION_DARKEN: number;
  632. /** Defines that the ressource is not delayed*/
  633. static readonly DELAYLOADSTATE_NONE: number;
  634. /** Defines that the ressource was successfully delay loaded */
  635. static readonly DELAYLOADSTATE_LOADED: number;
  636. /** Defines that the ressource is currently delay loading */
  637. static readonly DELAYLOADSTATE_LOADING: number;
  638. /** Defines that the ressource is delayed and has not started loading */
  639. static readonly DELAYLOADSTATE_NOTLOADED: number;
  640. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  641. static readonly NEVER: number;
  642. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  643. static readonly ALWAYS: number;
  644. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  645. static readonly LESS: number;
  646. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  647. static readonly EQUAL: number;
  648. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  649. static readonly LEQUAL: number;
  650. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  651. static readonly GREATER: number;
  652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  653. static readonly GEQUAL: number;
  654. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  655. static readonly NOTEQUAL: number;
  656. /** Passed to stencilOperation to specify that stencil value must be kept */
  657. static readonly KEEP: number;
  658. /** Passed to stencilOperation to specify that stencil value must be replaced */
  659. static readonly REPLACE: number;
  660. /** Passed to stencilOperation to specify that stencil value must be incremented */
  661. static readonly INCR: number;
  662. /** Passed to stencilOperation to specify that stencil value must be decremented */
  663. static readonly DECR: number;
  664. /** Passed to stencilOperation to specify that stencil value must be inverted */
  665. static readonly INVERT: number;
  666. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  667. static readonly INCR_WRAP: number;
  668. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  669. static readonly DECR_WRAP: number;
  670. /** Texture is not repeating outside of 0..1 UVs */
  671. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  672. /** Texture is repeating outside of 0..1 UVs */
  673. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  674. /** Texture is repeating and mirrored */
  675. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  676. /** ALPHA */
  677. static readonly TEXTUREFORMAT_ALPHA: number;
  678. /** LUMINANCE */
  679. static readonly TEXTUREFORMAT_LUMINANCE: number;
  680. /** LUMINANCE_ALPHA */
  681. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  682. /** RGB */
  683. static readonly TEXTUREFORMAT_RGB: number;
  684. /** RGBA */
  685. static readonly TEXTUREFORMAT_RGBA: number;
  686. /** RED */
  687. static readonly TEXTUREFORMAT_RED: number;
  688. /** RED (2nd reference) */
  689. static readonly TEXTUREFORMAT_R: number;
  690. /** RG */
  691. static readonly TEXTUREFORMAT_RG: number;
  692. /** RED_INTEGER */
  693. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  694. /** RED_INTEGER (2nd reference) */
  695. static readonly TEXTUREFORMAT_R_INTEGER: number;
  696. /** RG_INTEGER */
  697. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  698. /** RGB_INTEGER */
  699. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  700. /** RGBA_INTEGER */
  701. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  702. /** UNSIGNED_BYTE */
  703. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  704. /** UNSIGNED_BYTE (2nd reference) */
  705. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  706. /** FLOAT */
  707. static readonly TEXTURETYPE_FLOAT: number;
  708. /** HALF_FLOAT */
  709. static readonly TEXTURETYPE_HALF_FLOAT: number;
  710. /** BYTE */
  711. static readonly TEXTURETYPE_BYTE: number;
  712. /** SHORT */
  713. static readonly TEXTURETYPE_SHORT: number;
  714. /** UNSIGNED_SHORT */
  715. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  716. /** INT */
  717. static readonly TEXTURETYPE_INT: number;
  718. /** UNSIGNED_INT */
  719. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  720. /** UNSIGNED_SHORT_4_4_4_4 */
  721. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  722. /** UNSIGNED_SHORT_5_5_5_1 */
  723. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  724. /** UNSIGNED_SHORT_5_6_5 */
  725. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  726. /** UNSIGNED_INT_2_10_10_10_REV */
  727. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  728. /** UNSIGNED_INT_24_8 */
  729. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  730. /** UNSIGNED_INT_10F_11F_11F_REV */
  731. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  732. /** UNSIGNED_INT_5_9_9_9_REV */
  733. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  734. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  735. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  736. /** nearest is mag = nearest and min = nearest and mip = linear */
  737. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  738. /** Bilinear is mag = linear and min = linear and mip = nearest */
  739. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  740. /** Trilinear is mag = linear and min = linear and mip = linear */
  741. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  742. /** nearest is mag = nearest and min = nearest and mip = linear */
  743. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  744. /** Bilinear is mag = linear and min = linear and mip = nearest */
  745. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  746. /** Trilinear is mag = linear and min = linear and mip = linear */
  747. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  748. /** mag = nearest and min = nearest and mip = nearest */
  749. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  750. /** mag = nearest and min = linear and mip = nearest */
  751. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  752. /** mag = nearest and min = linear and mip = linear */
  753. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  754. /** mag = nearest and min = linear and mip = none */
  755. static readonly TEXTURE_NEAREST_LINEAR: number;
  756. /** mag = nearest and min = nearest and mip = none */
  757. static readonly TEXTURE_NEAREST_NEAREST: number;
  758. /** mag = linear and min = nearest and mip = nearest */
  759. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  760. /** mag = linear and min = nearest and mip = linear */
  761. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  762. /** mag = linear and min = linear and mip = none */
  763. static readonly TEXTURE_LINEAR_LINEAR: number;
  764. /** mag = linear and min = nearest and mip = none */
  765. static readonly TEXTURE_LINEAR_NEAREST: number;
  766. /** Explicit coordinates mode */
  767. static readonly TEXTURE_EXPLICIT_MODE: number;
  768. /** Spherical coordinates mode */
  769. static readonly TEXTURE_SPHERICAL_MODE: number;
  770. /** Planar coordinates mode */
  771. static readonly TEXTURE_PLANAR_MODE: number;
  772. /** Cubic coordinates mode */
  773. static readonly TEXTURE_CUBIC_MODE: number;
  774. /** Projection coordinates mode */
  775. static readonly TEXTURE_PROJECTION_MODE: number;
  776. /** Skybox coordinates mode */
  777. static readonly TEXTURE_SKYBOX_MODE: number;
  778. /** Inverse Cubic coordinates mode */
  779. static readonly TEXTURE_INVCUBIC_MODE: number;
  780. /** Equirectangular coordinates mode */
  781. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  782. /** Equirectangular Fixed coordinates mode */
  783. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  784. /** Equirectangular Fixed Mirrored coordinates mode */
  785. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  786. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  787. static readonly SCALEMODE_FLOOR: number;
  788. /** Defines that texture rescaling will look for the nearest power of 2 size */
  789. static readonly SCALEMODE_NEAREST: number;
  790. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  791. static readonly SCALEMODE_CEILING: number;
  792. /**
  793. * The dirty texture flag value
  794. */
  795. static readonly MATERIAL_TextureDirtyFlag: number;
  796. /**
  797. * The dirty light flag value
  798. */
  799. static readonly MATERIAL_LightDirtyFlag: number;
  800. /**
  801. * The dirty fresnel flag value
  802. */
  803. static readonly MATERIAL_FresnelDirtyFlag: number;
  804. /**
  805. * The dirty attribute flag value
  806. */
  807. static readonly MATERIAL_AttributesDirtyFlag: number;
  808. /**
  809. * The dirty misc flag value
  810. */
  811. static readonly MATERIAL_MiscDirtyFlag: number;
  812. /**
  813. * The all dirty flag value
  814. */
  815. static readonly MATERIAL_AllDirtyFlag: number;
  816. /**
  817. * Returns the triangle fill mode
  818. */
  819. static readonly MATERIAL_TriangleFillMode: number;
  820. /**
  821. * Returns the wireframe mode
  822. */
  823. static readonly MATERIAL_WireFrameFillMode: number;
  824. /**
  825. * Returns the point fill mode
  826. */
  827. static readonly MATERIAL_PointFillMode: number;
  828. /**
  829. * Returns the point list draw mode
  830. */
  831. static readonly MATERIAL_PointListDrawMode: number;
  832. /**
  833. * Returns the line list draw mode
  834. */
  835. static readonly MATERIAL_LineListDrawMode: number;
  836. /**
  837. * Returns the line loop draw mode
  838. */
  839. static readonly MATERIAL_LineLoopDrawMode: number;
  840. /**
  841. * Returns the line strip draw mode
  842. */
  843. static readonly MATERIAL_LineStripDrawMode: number;
  844. /**
  845. * Returns the triangle strip draw mode
  846. */
  847. static readonly MATERIAL_TriangleStripDrawMode: number;
  848. /**
  849. * Returns the triangle fan draw mode
  850. */
  851. static readonly MATERIAL_TriangleFanDrawMode: number;
  852. /**
  853. * Stores the clock-wise side orientation
  854. */
  855. static readonly MATERIAL_ClockWiseSideOrientation: number;
  856. /**
  857. * Stores the counter clock-wise side orientation
  858. */
  859. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  860. /**
  861. * Nothing
  862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  863. */
  864. static readonly ACTION_NothingTrigger: number;
  865. /**
  866. * On pick
  867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  868. */
  869. static readonly ACTION_OnPickTrigger: number;
  870. /**
  871. * On left pick
  872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  873. */
  874. static readonly ACTION_OnLeftPickTrigger: number;
  875. /**
  876. * On right pick
  877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  878. */
  879. static readonly ACTION_OnRightPickTrigger: number;
  880. /**
  881. * On center pick
  882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  883. */
  884. static readonly ACTION_OnCenterPickTrigger: number;
  885. /**
  886. * On pick down
  887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  888. */
  889. static readonly ACTION_OnPickDownTrigger: number;
  890. /**
  891. * On double pick
  892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  893. */
  894. static readonly ACTION_OnDoublePickTrigger: number;
  895. /**
  896. * On pick up
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_OnPickUpTrigger: number;
  900. /**
  901. * On pick out.
  902. * This trigger will only be raised if you also declared a OnPickDown
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickOutTrigger: number;
  906. /**
  907. * On long press
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLongPressTrigger: number;
  911. /**
  912. * On pointer over
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnPointerOverTrigger: number;
  916. /**
  917. * On pointer out
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPointerOutTrigger: number;
  921. /**
  922. * On every frame
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnEveryFrameTrigger: number;
  926. /**
  927. * On intersection enter
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnIntersectionEnterTrigger: number;
  931. /**
  932. * On intersection exit
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnIntersectionExitTrigger: number;
  936. /**
  937. * On key down
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnKeyDownTrigger: number;
  941. /**
  942. * On key up
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnKeyUpTrigger: number;
  946. /**
  947. * Billboard mode will only apply to Y axis
  948. */
  949. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  950. /**
  951. * Billboard mode will apply to all axes
  952. */
  953. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  954. /**
  955. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  956. */
  957. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  958. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  959. * Test order :
  960. * Is the bounding sphere outside the frustum ?
  961. * If not, are the bounding box vertices outside the frustum ?
  962. * It not, then the cullable object is in the frustum.
  963. */
  964. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  965. /** Culling strategy : Bounding Sphere Only.
  966. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  967. * It's also less accurate than the standard because some not visible objects can still be selected.
  968. * Test : is the bounding sphere outside the frustum ?
  969. * If not, then the cullable object is in the frustum.
  970. */
  971. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  972. /** Culling strategy : Optimistic Inclusion.
  973. * This in an inclusion test first, then the standard exclusion test.
  974. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  975. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  976. * Anyway, it's as accurate as the standard strategy.
  977. * Test :
  978. * Is the cullable object bounding sphere center in the frustum ?
  979. * If not, apply the default culling strategy.
  980. */
  981. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  982. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  983. * This in an inclusion test first, then the bounding sphere only exclusion test.
  984. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  985. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  986. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  987. * Test :
  988. * Is the cullable object bounding sphere center in the frustum ?
  989. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  990. */
  991. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  992. /**
  993. * No logging while loading
  994. */
  995. static readonly SCENELOADER_NO_LOGGING: number;
  996. /**
  997. * Minimal logging while loading
  998. */
  999. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1000. /**
  1001. * Summary logging while loading
  1002. */
  1003. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1004. /**
  1005. * Detailled logging while loading
  1006. */
  1007. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1008. }
  1009. }
  1010. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1011. import { Nullable } from "babylonjs/types";
  1012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1013. /**
  1014. * This represents the required contract to create a new type of texture loader.
  1015. */
  1016. export interface IInternalTextureLoader {
  1017. /**
  1018. * Defines wether the loader supports cascade loading the different faces.
  1019. */
  1020. supportCascades: boolean;
  1021. /**
  1022. * This returns if the loader support the current file information.
  1023. * @param extension defines the file extension of the file being loaded
  1024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1025. * @param fallback defines the fallback internal texture if any
  1026. * @param isBase64 defines whether the texture is encoded as a base64
  1027. * @param isBuffer defines whether the texture data are stored as a buffer
  1028. * @returns true if the loader can load the specified file
  1029. */
  1030. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1031. /**
  1032. * Transform the url before loading if required.
  1033. * @param rootUrl the url of the texture
  1034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1035. * @returns the transformed texture
  1036. */
  1037. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1038. /**
  1039. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1040. * @param rootUrl the url of the texture
  1041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1042. * @returns the fallback texture
  1043. */
  1044. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1045. /**
  1046. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param createPolynomials will be true if polynomials have been requested
  1050. * @param onLoad defines the callback to trigger once the texture is ready
  1051. * @param onError defines the callback to trigger in case of error
  1052. */
  1053. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1054. /**
  1055. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1056. * @param data contains the texture data
  1057. * @param texture defines the BabylonJS internal texture
  1058. * @param callback defines the method to call once ready to upload
  1059. */
  1060. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1061. }
  1062. }
  1063. declare module "babylonjs/Engines/IPipelineContext" {
  1064. /**
  1065. * Class used to store and describe the pipeline context associated with an effect
  1066. */
  1067. export interface IPipelineContext {
  1068. /**
  1069. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1070. */
  1071. isAsync: boolean;
  1072. /**
  1073. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1074. */
  1075. isReady: boolean;
  1076. /** @hidden */
  1077. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Meshes/dataBuffer" {
  1081. /**
  1082. * Class used to store gfx data (like WebGLBuffer)
  1083. */
  1084. export class DataBuffer {
  1085. /**
  1086. * Gets or sets the number of objects referencing this buffer
  1087. */
  1088. references: number;
  1089. /** Gets or sets the size of the underlying buffer */
  1090. capacity: number;
  1091. /**
  1092. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1093. */
  1094. is32Bits: boolean;
  1095. /**
  1096. * Gets the underlying buffer
  1097. */
  1098. readonly underlyingResource: any;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1102. /** @hidden */
  1103. export interface IShaderProcessor {
  1104. attributeProcessor?: (attribute: string) => string;
  1105. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1106. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1107. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1108. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1109. lineProcessor?: (line: string, isFragment: boolean) => string;
  1110. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1111. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1112. }
  1113. }
  1114. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1115. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1116. /** @hidden */
  1117. export interface ProcessingOptions {
  1118. defines: string[];
  1119. indexParameters: any;
  1120. isFragment: boolean;
  1121. shouldUseHighPrecisionShader: boolean;
  1122. supportsUniformBuffers: boolean;
  1123. shadersRepository: string;
  1124. includesShadersStore: {
  1125. [key: string]: string;
  1126. };
  1127. processor?: IShaderProcessor;
  1128. version: string;
  1129. platformName: string;
  1130. lookForClosingBracketForUniformBuffer?: boolean;
  1131. }
  1132. }
  1133. declare module "babylonjs/Misc/stringTools" {
  1134. /**
  1135. * Helper to manipulate strings
  1136. */
  1137. export class StringTools {
  1138. /**
  1139. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1140. * @param str Source string
  1141. * @param suffix Suffix to search for in the source string
  1142. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1143. */
  1144. static EndsWith(str: string, suffix: string): boolean;
  1145. /**
  1146. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1147. * @param str Source string
  1148. * @param suffix Suffix to search for in the source string
  1149. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1150. */
  1151. static StartsWith(str: string, suffix: string): boolean;
  1152. /**
  1153. * Decodes a buffer into a string
  1154. * @param buffer The buffer to decode
  1155. * @returns The decoded string
  1156. */
  1157. static Decode(buffer: Uint8Array | Uint16Array): string;
  1158. /**
  1159. * Encode a buffer to a base64 string
  1160. * @param buffer defines the buffer to encode
  1161. * @returns the encoded string
  1162. */
  1163. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. 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;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. 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;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. /**
  7583. * @hidden
  7584. */
  7585. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7586. }
  7587. }
  7588. }
  7589. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7590. import { Nullable } from "babylonjs/types";
  7591. import { Scene } from "babylonjs/scene";
  7592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7594. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7595. /**
  7596. * Class for creating a cube texture
  7597. */
  7598. export class CubeTexture extends BaseTexture {
  7599. private _delayedOnLoad;
  7600. /**
  7601. * The url of the texture
  7602. */
  7603. url: string;
  7604. /**
  7605. * Gets or sets the center of the bounding box associated with the cube texture.
  7606. * It must define where the camera used to render the texture was set
  7607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7608. */
  7609. boundingBoxPosition: Vector3;
  7610. private _boundingBoxSize;
  7611. /**
  7612. * Gets or sets the size of the bounding box associated with the cube texture
  7613. * When defined, the cubemap will switch to local mode
  7614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7615. * @example https://www.babylonjs-playground.com/#RNASML
  7616. */
  7617. /**
  7618. * Returns the bounding box size
  7619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7620. */
  7621. boundingBoxSize: Vector3;
  7622. protected _rotationY: number;
  7623. /**
  7624. * Sets texture matrix rotation angle around Y axis in radians.
  7625. */
  7626. /**
  7627. * Gets texture matrix rotation angle around Y axis radians.
  7628. */
  7629. rotationY: number;
  7630. /**
  7631. * Are mip maps generated for this texture or not.
  7632. */
  7633. readonly noMipmap: boolean;
  7634. private _noMipmap;
  7635. private _files;
  7636. protected _forcedExtension: Nullable<string>;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. 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);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module "babylonjs/Materials/materialDefines" {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module "babylonjs/Materials/colorCurves" {
  7826. import { Effect } from "babylonjs/Materials/effect";
  7827. /**
  7828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7830. * 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;
  7831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7832. */
  7833. export class ColorCurves {
  7834. private _dirty;
  7835. private _tempColor;
  7836. private _globalCurve;
  7837. private _highlightsCurve;
  7838. private _midtonesCurve;
  7839. private _shadowsCurve;
  7840. private _positiveCurve;
  7841. private _negativeCurve;
  7842. private _globalHue;
  7843. private _globalDensity;
  7844. private _globalSaturation;
  7845. private _globalExposure;
  7846. /**
  7847. * Gets the global Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the global Hue value.
  7852. * 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).
  7853. */
  7854. globalHue: number;
  7855. /**
  7856. * Gets the global Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the global Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. globalDensity: number;
  7866. /**
  7867. * Gets the global Saturation value.
  7868. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7869. */
  7870. /**
  7871. * Sets the global Saturation value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7873. */
  7874. globalSaturation: number;
  7875. /**
  7876. * Gets the global Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the global Exposure value.
  7881. * 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.
  7882. */
  7883. globalExposure: number;
  7884. private _highlightsHue;
  7885. private _highlightsDensity;
  7886. private _highlightsSaturation;
  7887. private _highlightsExposure;
  7888. /**
  7889. * Gets the highlights Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the highlights Hue value.
  7894. * 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).
  7895. */
  7896. highlightsHue: number;
  7897. /**
  7898. * Gets the highlights Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the highlights Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. highlightsDensity: number;
  7908. /**
  7909. * Gets the highlights Saturation value.
  7910. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7911. */
  7912. /**
  7913. * Sets the highlights Saturation value.
  7914. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7915. */
  7916. highlightsSaturation: number;
  7917. /**
  7918. * Gets the highlights Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the highlights Exposure value.
  7923. * 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.
  7924. */
  7925. highlightsExposure: number;
  7926. private _midtonesHue;
  7927. private _midtonesDensity;
  7928. private _midtonesSaturation;
  7929. private _midtonesExposure;
  7930. /**
  7931. * Gets the midtones 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 midtones 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. midtonesHue: number;
  7939. /**
  7940. * Gets the midtones 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 midtones 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. midtonesDensity: number;
  7950. /**
  7951. * Gets the midtones 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 midtones 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. midtonesSaturation: number;
  7959. /**
  7960. * Gets the midtones 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 midtones 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. midtonesExposure: number;
  7968. private _shadowsHue;
  7969. private _shadowsDensity;
  7970. private _shadowsSaturation;
  7971. private _shadowsExposure;
  7972. /**
  7973. * Gets the shadows 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 shadows 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. shadowsHue: number;
  7981. /**
  7982. * Gets the shadows 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 shadows 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. shadowsDensity: number;
  7992. /**
  7993. * Gets the shadows 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 shadows 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. shadowsSaturation: number;
  8001. /**
  8002. * Gets the shadows 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 shadows 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. shadowsExposure: number;
  8010. /**
  8011. * Returns the class name
  8012. * @returns The class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Binds the color curves to the shader.
  8017. * @param colorCurves The color curve to bind
  8018. * @param effect The effect to bind to
  8019. * @param positiveUniform The positive uniform shader parameter
  8020. * @param neutralUniform The neutral uniform shader parameter
  8021. * @param negativeUniform The negative uniform shader parameter
  8022. */
  8023. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8024. /**
  8025. * Prepare the list of uniforms associated with the ColorCurves effects.
  8026. * @param uniformsList The list of uniforms used in the effect
  8027. */
  8028. static PrepareUniforms(uniformsList: string[]): void;
  8029. /**
  8030. * Returns color grading data based on a hue, density, saturation and exposure value.
  8031. * @param filterHue The hue of the color filter.
  8032. * @param filterDensity The density of the color filter.
  8033. * @param saturation The saturation.
  8034. * @param exposure The exposure.
  8035. * @param result The result data container.
  8036. */
  8037. private getColorGradingDataToRef;
  8038. /**
  8039. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8040. * @param value The input slider value in range [-100,100].
  8041. * @returns Adjusted value.
  8042. */
  8043. private static applyColorGradingSliderNonlinear;
  8044. /**
  8045. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8046. * @param hue The hue (H) input.
  8047. * @param saturation The saturation (S) input.
  8048. * @param brightness The brightness (B) input.
  8049. * @result An RGBA color represented as Vector4.
  8050. */
  8051. private static fromHSBToRef;
  8052. /**
  8053. * Returns a value clamped between min and max
  8054. * @param value The value to clamp
  8055. * @param min The minimum of value
  8056. * @param max The maximum of value
  8057. * @returns The clamped value.
  8058. */
  8059. private static clamp;
  8060. /**
  8061. * Clones the current color curve instance.
  8062. * @return The cloned curves
  8063. */
  8064. clone(): ColorCurves;
  8065. /**
  8066. * Serializes the current color curve instance to a json representation.
  8067. * @return a JSON representation
  8068. */
  8069. serialize(): any;
  8070. /**
  8071. * Parses the color curve from a json representation.
  8072. * @param source the JSON source to parse
  8073. * @return The parsed curves
  8074. */
  8075. static Parse(source: any): ColorCurves;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8079. import { Observable } from "babylonjs/Misc/observable";
  8080. import { Nullable } from "babylonjs/types";
  8081. import { Color4 } from "babylonjs/Maths/math.color";
  8082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8083. import { Effect } from "babylonjs/Materials/effect";
  8084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8086. /**
  8087. * Interface to follow in your material defines to integrate easily the
  8088. * Image proccessing functions.
  8089. * @hidden
  8090. */
  8091. export interface IImageProcessingConfigurationDefines {
  8092. IMAGEPROCESSING: boolean;
  8093. VIGNETTE: boolean;
  8094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8095. VIGNETTEBLENDMODEOPAQUE: boolean;
  8096. TONEMAPPING: boolean;
  8097. TONEMAPPING_ACES: boolean;
  8098. CONTRAST: boolean;
  8099. EXPOSURE: boolean;
  8100. COLORCURVES: boolean;
  8101. COLORGRADING: boolean;
  8102. COLORGRADING3D: boolean;
  8103. SAMPLER3DGREENDEPTH: boolean;
  8104. SAMPLER3DBGRMAP: boolean;
  8105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8106. }
  8107. /**
  8108. * @hidden
  8109. */
  8110. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. COLORCURVES: boolean;
  8119. COLORGRADING: boolean;
  8120. COLORGRADING3D: boolean;
  8121. SAMPLER3DGREENDEPTH: boolean;
  8122. SAMPLER3DBGRMAP: boolean;
  8123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8124. EXPOSURE: boolean;
  8125. constructor();
  8126. }
  8127. /**
  8128. * This groups together the common properties used for image processing either in direct forward pass
  8129. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8130. * or not.
  8131. */
  8132. export class ImageProcessingConfiguration {
  8133. /**
  8134. * Default tone mapping applied in BabylonJS.
  8135. */
  8136. static readonly TONEMAPPING_STANDARD: number;
  8137. /**
  8138. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8139. * to other engines rendering to increase portability.
  8140. */
  8141. static readonly TONEMAPPING_ACES: number;
  8142. /**
  8143. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8144. */
  8145. colorCurves: Nullable<ColorCurves>;
  8146. private _colorCurvesEnabled;
  8147. /**
  8148. * Gets wether the color curves effect is enabled.
  8149. */
  8150. /**
  8151. * Sets wether the color curves effect is enabled.
  8152. */
  8153. colorCurvesEnabled: boolean;
  8154. private _colorGradingTexture;
  8155. /**
  8156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8157. */
  8158. /**
  8159. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8160. */
  8161. colorGradingTexture: Nullable<BaseTexture>;
  8162. private _colorGradingEnabled;
  8163. /**
  8164. * Gets wether the color grading effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is enabled.
  8168. */
  8169. colorGradingEnabled: boolean;
  8170. private _colorGradingWithGreenDepth;
  8171. /**
  8172. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8173. */
  8174. /**
  8175. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8176. */
  8177. colorGradingWithGreenDepth: boolean;
  8178. private _colorGradingBGR;
  8179. /**
  8180. * Gets wether the color grading texture contains BGR values.
  8181. */
  8182. /**
  8183. * Sets wether the color grading texture contains BGR values.
  8184. */
  8185. colorGradingBGR: boolean;
  8186. /** @hidden */
  8187. _exposure: number;
  8188. /**
  8189. * Gets the Exposure used in the effect.
  8190. */
  8191. /**
  8192. * Sets the Exposure used in the effect.
  8193. */
  8194. exposure: number;
  8195. private _toneMappingEnabled;
  8196. /**
  8197. * Gets wether the tone mapping effect is enabled.
  8198. */
  8199. /**
  8200. * Sets wether the tone mapping effect is enabled.
  8201. */
  8202. toneMappingEnabled: boolean;
  8203. private _toneMappingType;
  8204. /**
  8205. * Gets the type of tone mapping effect.
  8206. */
  8207. /**
  8208. * Sets the type of tone mapping effect used in BabylonJS.
  8209. */
  8210. toneMappingType: number;
  8211. protected _contrast: number;
  8212. /**
  8213. * Gets the contrast used in the effect.
  8214. */
  8215. /**
  8216. * Sets the contrast used in the effect.
  8217. */
  8218. contrast: number;
  8219. /**
  8220. * Vignette stretch size.
  8221. */
  8222. vignetteStretch: number;
  8223. /**
  8224. * Vignette centre X Offset.
  8225. */
  8226. vignetteCentreX: number;
  8227. /**
  8228. * Vignette centre Y Offset.
  8229. */
  8230. vignetteCentreY: number;
  8231. /**
  8232. * Vignette weight or intensity of the vignette effect.
  8233. */
  8234. vignetteWeight: number;
  8235. /**
  8236. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8237. * if vignetteEnabled is set to true.
  8238. */
  8239. vignetteColor: Color4;
  8240. /**
  8241. * Camera field of view used by the Vignette effect.
  8242. */
  8243. vignetteCameraFov: number;
  8244. private _vignetteBlendMode;
  8245. /**
  8246. * Gets the vignette blend mode allowing different kind of effect.
  8247. */
  8248. /**
  8249. * Sets the vignette blend mode allowing different kind of effect.
  8250. */
  8251. vignetteBlendMode: number;
  8252. private _vignetteEnabled;
  8253. /**
  8254. * Gets wether the vignette effect is enabled.
  8255. */
  8256. /**
  8257. * Sets wether the vignette effect is enabled.
  8258. */
  8259. vignetteEnabled: boolean;
  8260. private _applyByPostProcess;
  8261. /**
  8262. * Gets wether the image processing is applied through a post process or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is applied through a post process or not.
  8266. */
  8267. applyByPostProcess: boolean;
  8268. private _isEnabled;
  8269. /**
  8270. * Gets wether the image processing is enabled or not.
  8271. */
  8272. /**
  8273. * Sets wether the image processing is enabled or not.
  8274. */
  8275. isEnabled: boolean;
  8276. /**
  8277. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8278. */
  8279. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8280. /**
  8281. * Method called each time the image processing information changes requires to recompile the effect.
  8282. */
  8283. protected _updateParameters(): void;
  8284. /**
  8285. * Gets the current class name.
  8286. * @return "ImageProcessingConfiguration"
  8287. */
  8288. getClassName(): string;
  8289. /**
  8290. * Prepare the list of uniforms associated with the Image Processing effects.
  8291. * @param uniforms The list of uniforms used in the effect
  8292. * @param defines the list of defines currently in use
  8293. */
  8294. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8295. /**
  8296. * Prepare the list of samplers associated with the Image Processing effects.
  8297. * @param samplersList The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of defines associated to the shader.
  8303. * @param defines the list of defines to complete
  8304. * @param forPostProcess Define if we are currently in post process mode or not
  8305. */
  8306. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8307. /**
  8308. * Returns true if all the image processing information are ready.
  8309. * @returns True if ready, otherwise, false
  8310. */
  8311. isReady(): boolean;
  8312. /**
  8313. * Binds the image processing to the shader.
  8314. * @param effect The effect to bind to
  8315. * @param aspectRatio Define the current aspect ratio of the effect
  8316. */
  8317. bind(effect: Effect, aspectRatio?: number): void;
  8318. /**
  8319. * Clones the current image processing instance.
  8320. * @return The cloned image processing
  8321. */
  8322. clone(): ImageProcessingConfiguration;
  8323. /**
  8324. * Serializes the current image processing instance to a json representation.
  8325. * @return a JSON representation
  8326. */
  8327. serialize(): any;
  8328. /**
  8329. * Parses the image processing from a json representation.
  8330. * @param source the JSON source to parse
  8331. * @return The parsed image processing
  8332. */
  8333. static Parse(source: any): ImageProcessingConfiguration;
  8334. private static _VIGNETTEMODE_MULTIPLY;
  8335. private static _VIGNETTEMODE_OPAQUE;
  8336. /**
  8337. * Used to apply the vignette as a mix with the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_MULTIPLY: number;
  8340. /**
  8341. * Used to apply the vignette as a replacement of the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_OPAQUE: number;
  8344. }
  8345. }
  8346. declare module "babylonjs/Shaders/postprocess.vertex" {
  8347. /** @hidden */
  8348. export var postprocessVertexShader: {
  8349. name: string;
  8350. shader: string;
  8351. };
  8352. }
  8353. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8356. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8357. module "babylonjs/Engines/thinEngine" {
  8358. interface ThinEngine {
  8359. /**
  8360. * Creates a new render target texture
  8361. * @param size defines the size of the texture
  8362. * @param options defines the options used to create the texture
  8363. * @returns a new render target texture stored in an InternalTexture
  8364. */
  8365. createRenderTargetTexture(size: number | {
  8366. width: number;
  8367. height: number;
  8368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8369. /**
  8370. * Creates a depth stencil texture.
  8371. * This is only available in WebGL 2 or with the depth texture extension available.
  8372. * @param size The size of face edge in the texture.
  8373. * @param options The options defining the texture.
  8374. * @returns The texture
  8375. */
  8376. createDepthStencilTexture(size: number | {
  8377. width: number;
  8378. height: number;
  8379. }, options: DepthTextureCreationOptions): InternalTexture;
  8380. /** @hidden */
  8381. _createDepthStencilTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: DepthTextureCreationOptions): InternalTexture;
  8385. }
  8386. }
  8387. }
  8388. declare module "babylonjs/Maths/math.axis" {
  8389. import { Vector3 } from "babylonjs/Maths/math.vector";
  8390. /** Defines supported spaces */
  8391. export enum Space {
  8392. /** Local (object) space */
  8393. LOCAL = 0,
  8394. /** World space */
  8395. WORLD = 1,
  8396. /** Bone space */
  8397. BONE = 2
  8398. }
  8399. /** Defines the 3 main axes */
  8400. export class Axis {
  8401. /** X axis */
  8402. static X: Vector3;
  8403. /** Y axis */
  8404. static Y: Vector3;
  8405. /** Z axis */
  8406. static Z: Vector3;
  8407. }
  8408. }
  8409. declare module "babylonjs/Cameras/targetCamera" {
  8410. import { Nullable } from "babylonjs/types";
  8411. import { Camera } from "babylonjs/Cameras/camera";
  8412. import { Scene } from "babylonjs/scene";
  8413. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8414. /**
  8415. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8416. * This is the base of the follow, arc rotate cameras and Free camera
  8417. * @see http://doc.babylonjs.com/features/cameras
  8418. */
  8419. export class TargetCamera extends Camera {
  8420. private static _RigCamTransformMatrix;
  8421. private static _TargetTransformMatrix;
  8422. private static _TargetFocalPoint;
  8423. /**
  8424. * Define the current direction the camera is moving to
  8425. */
  8426. cameraDirection: Vector3;
  8427. /**
  8428. * Define the current rotation the camera is rotating to
  8429. */
  8430. cameraRotation: Vector2;
  8431. /**
  8432. * When set, the up vector of the camera will be updated by the rotation of the camera
  8433. */
  8434. updateUpVectorFromRotation: boolean;
  8435. private _tmpQuaternion;
  8436. /**
  8437. * Define the current rotation of the camera
  8438. */
  8439. rotation: Vector3;
  8440. /**
  8441. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8442. */
  8443. rotationQuaternion: Quaternion;
  8444. /**
  8445. * Define the current speed of the camera
  8446. */
  8447. speed: number;
  8448. /**
  8449. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8450. * around all axis.
  8451. */
  8452. noRotationConstraint: boolean;
  8453. /**
  8454. * Define the current target of the camera as an object or a position.
  8455. */
  8456. lockedTarget: any;
  8457. /** @hidden */
  8458. _currentTarget: Vector3;
  8459. /** @hidden */
  8460. _initialFocalDistance: number;
  8461. /** @hidden */
  8462. _viewMatrix: Matrix;
  8463. /** @hidden */
  8464. _camMatrix: Matrix;
  8465. /** @hidden */
  8466. _cameraTransformMatrix: Matrix;
  8467. /** @hidden */
  8468. _cameraRotationMatrix: Matrix;
  8469. /** @hidden */
  8470. _referencePoint: Vector3;
  8471. /** @hidden */
  8472. _transformedReferencePoint: Vector3;
  8473. protected _globalCurrentTarget: Vector3;
  8474. protected _globalCurrentUpVector: Vector3;
  8475. /** @hidden */
  8476. _reset: () => void;
  8477. private _defaultUp;
  8478. /**
  8479. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8480. * This is the base of the follow, arc rotate cameras and Free camera
  8481. * @see http://doc.babylonjs.com/features/cameras
  8482. * @param name Defines the name of the camera in the scene
  8483. * @param position Defines the start position of the camera in the scene
  8484. * @param scene Defines the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Gets the position in front of the camera at a given distance.
  8490. * @param distance The distance from the camera we want the position to be
  8491. * @returns the position
  8492. */
  8493. getFrontPosition(distance: number): Vector3;
  8494. /** @hidden */
  8495. _getLockedTargetPosition(): Nullable<Vector3>;
  8496. private _storedPosition;
  8497. private _storedRotation;
  8498. private _storedRotationQuaternion;
  8499. /**
  8500. * Store current camera state of the camera (fov, position, rotation, etc..)
  8501. * @returns the camera
  8502. */
  8503. storeState(): Camera;
  8504. /**
  8505. * Restored camera state. You must call storeState() first
  8506. * @returns whether it was successful or not
  8507. * @hidden
  8508. */
  8509. _restoreStateValues(): boolean;
  8510. /** @hidden */
  8511. _initCache(): void;
  8512. /** @hidden */
  8513. _updateCache(ignoreParentClass?: boolean): void;
  8514. /** @hidden */
  8515. _isSynchronizedViewMatrix(): boolean;
  8516. /** @hidden */
  8517. _computeLocalCameraSpeed(): number;
  8518. /**
  8519. * Defines the target the camera should look at.
  8520. * @param target Defines the new target as a Vector or a mesh
  8521. */
  8522. setTarget(target: Vector3): void;
  8523. /**
  8524. * Return the current target position of the camera. This value is expressed in local space.
  8525. * @returns the target position
  8526. */
  8527. getTarget(): Vector3;
  8528. /** @hidden */
  8529. _decideIfNeedsToMove(): boolean;
  8530. /** @hidden */
  8531. _updatePosition(): void;
  8532. /** @hidden */
  8533. _checkInputs(): void;
  8534. protected _updateCameraRotationMatrix(): void;
  8535. /**
  8536. * 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)
  8537. * @returns the current camera
  8538. */
  8539. private _rotateUpVectorWithCameraRotationMatrix;
  8540. private _cachedRotationZ;
  8541. private _cachedQuaternionRotationZ;
  8542. /** @hidden */
  8543. _getViewMatrix(): Matrix;
  8544. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8545. /**
  8546. * @hidden
  8547. */
  8548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8549. /**
  8550. * @hidden
  8551. */
  8552. _updateRigCameras(): void;
  8553. private _getRigCamPositionAndTarget;
  8554. /**
  8555. * Gets the current object class name.
  8556. * @return the class name
  8557. */
  8558. getClassName(): string;
  8559. }
  8560. }
  8561. declare module "babylonjs/Events/keyboardEvents" {
  8562. /**
  8563. * Gather the list of keyboard event types as constants.
  8564. */
  8565. export class KeyboardEventTypes {
  8566. /**
  8567. * The keydown event is fired when a key becomes active (pressed).
  8568. */
  8569. static readonly KEYDOWN: number;
  8570. /**
  8571. * The keyup event is fired when a key has been released.
  8572. */
  8573. static readonly KEYUP: number;
  8574. }
  8575. /**
  8576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8577. */
  8578. export class KeyboardInfo {
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number;
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent;
  8587. /**
  8588. * Instantiates a new keyboard info.
  8589. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8590. * @param type Defines the type of event (KeyboardEventTypes)
  8591. * @param event Defines the related dom event
  8592. */
  8593. constructor(
  8594. /**
  8595. * Defines the type of event (KeyboardEventTypes)
  8596. */
  8597. type: number,
  8598. /**
  8599. * Defines the related dom event
  8600. */
  8601. event: KeyboardEvent);
  8602. }
  8603. /**
  8604. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8605. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8606. */
  8607. export class KeyboardInfoPre extends KeyboardInfo {
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number;
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent;
  8616. /**
  8617. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8618. */
  8619. skipOnPointerObservable: boolean;
  8620. /**
  8621. * Instantiates a new keyboard pre info.
  8622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8623. * @param type Defines the type of event (KeyboardEventTypes)
  8624. * @param event Defines the related dom event
  8625. */
  8626. constructor(
  8627. /**
  8628. * Defines the type of event (KeyboardEventTypes)
  8629. */
  8630. type: number,
  8631. /**
  8632. * Defines the related dom event
  8633. */
  8634. event: KeyboardEvent);
  8635. }
  8636. }
  8637. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8638. import { Nullable } from "babylonjs/types";
  8639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8641. /**
  8642. * Manage the keyboard inputs to control the movement of a free camera.
  8643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8644. */
  8645. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8646. /**
  8647. * Defines the camera the input is attached to.
  8648. */
  8649. camera: FreeCamera;
  8650. /**
  8651. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8652. */
  8653. keysUp: number[];
  8654. /**
  8655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8656. */
  8657. keysDown: number[];
  8658. /**
  8659. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8660. */
  8661. keysLeft: number[];
  8662. /**
  8663. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8664. */
  8665. keysRight: number[];
  8666. private _keys;
  8667. private _onCanvasBlurObserver;
  8668. private _onKeyboardObserver;
  8669. private _engine;
  8670. private _scene;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs(): void;
  8687. /**
  8688. * Gets the class name of the current intput.
  8689. * @returns the class name
  8690. */
  8691. getClassName(): string;
  8692. /** @hidden */
  8693. _onLostFocus(): void;
  8694. /**
  8695. * Get the friendly name associated with the input class.
  8696. * @returns the input friendly name
  8697. */
  8698. getSimpleName(): string;
  8699. }
  8700. }
  8701. declare module "babylonjs/Lights/shadowLight" {
  8702. import { Camera } from "babylonjs/Cameras/camera";
  8703. import { Scene } from "babylonjs/scene";
  8704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8706. import { Light } from "babylonjs/Lights/light";
  8707. /**
  8708. * Interface describing all the common properties and methods a shadow light needs to implement.
  8709. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8710. * as well as binding the different shadow properties to the effects.
  8711. */
  8712. export interface IShadowLight extends Light {
  8713. /**
  8714. * The light id in the scene (used in scene.findLighById for instance)
  8715. */
  8716. id: string;
  8717. /**
  8718. * The position the shdow will be casted from.
  8719. */
  8720. position: Vector3;
  8721. /**
  8722. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8723. */
  8724. direction: Vector3;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. /**
  8734. * The friendly name of the light in the scene.
  8735. */
  8736. name: string;
  8737. /**
  8738. * Defines the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. /**
  8742. * Defines the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8747. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8748. */
  8749. computeTransformedInformation(): boolean;
  8750. /**
  8751. * Gets the scene the light belongs to.
  8752. * @returns The scene
  8753. */
  8754. getScene(): Scene;
  8755. /**
  8756. * Callback defining a custom Projection Matrix Builder.
  8757. * This can be used to override the default projection matrix computation.
  8758. */
  8759. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8760. /**
  8761. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8762. * @param matrix The materix to updated with the projection information
  8763. * @param viewMatrix The transform matrix of the light
  8764. * @param renderList The list of mesh to render in the map
  8765. * @returns The current light
  8766. */
  8767. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8768. /**
  8769. * Gets the current depth scale used in ESM.
  8770. * @returns The scale
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8775. * @returns true if a cube texture needs to be use
  8776. */
  8777. needCube(): boolean;
  8778. /**
  8779. * Detects if the projection matrix requires to be recomputed this frame.
  8780. * @returns true if it requires to be recomputed otherwise, false.
  8781. */
  8782. needProjectionMatrixCompute(): boolean;
  8783. /**
  8784. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8785. */
  8786. forceProjectionMatrixCompute(): void;
  8787. /**
  8788. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8789. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8790. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8791. */
  8792. getShadowDirection(faceIndex?: number): Vector3;
  8793. /**
  8794. * Gets the minZ used for shadow according to both the scene and the light.
  8795. * @param activeCamera The camera we are returning the min for
  8796. * @returns the depth min z
  8797. */
  8798. getDepthMinZ(activeCamera: Camera): number;
  8799. /**
  8800. * Gets the maxZ used for shadow according to both the scene and the light.
  8801. * @param activeCamera The camera we are returning the max for
  8802. * @returns the depth max z
  8803. */
  8804. getDepthMaxZ(activeCamera: Camera): number;
  8805. }
  8806. /**
  8807. * Base implementation IShadowLight
  8808. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8809. */
  8810. export abstract class ShadowLight extends Light implements IShadowLight {
  8811. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8812. protected _position: Vector3;
  8813. protected _setPosition(value: Vector3): void;
  8814. /**
  8815. * Sets the position the shadow will be casted from. Also use as the light position for both
  8816. * point and spot lights.
  8817. */
  8818. /**
  8819. * Sets the position the shadow will be casted from. Also use as the light position for both
  8820. * point and spot lights.
  8821. */
  8822. position: Vector3;
  8823. protected _direction: Vector3;
  8824. protected _setDirection(value: Vector3): void;
  8825. /**
  8826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8827. * Also use as the light direction on spot and directional lights.
  8828. */
  8829. /**
  8830. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8831. * Also use as the light direction on spot and directional lights.
  8832. */
  8833. direction: Vector3;
  8834. private _shadowMinZ;
  8835. /**
  8836. * Gets the shadow projection clipping minimum z value.
  8837. */
  8838. /**
  8839. * Sets the shadow projection clipping minimum z value.
  8840. */
  8841. shadowMinZ: number;
  8842. private _shadowMaxZ;
  8843. /**
  8844. * Sets the shadow projection clipping maximum z value.
  8845. */
  8846. /**
  8847. * Gets the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * The transformed position. Position of the light in world space taking parenting in account.
  8857. */
  8858. transformedPosition: Vector3;
  8859. /**
  8860. * The transformed direction. Direction of the light in world space taking parenting in account.
  8861. */
  8862. transformedDirection: Vector3;
  8863. private _needProjectionMatrixCompute;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Return the depth scale used for the shadow map.
  8871. * @returns the depth scale.
  8872. */
  8873. getDepthScale(): number;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Returns the ShadowLight absolute position in the World.
  8882. * @returns the position vector in world space
  8883. */
  8884. getAbsolutePosition(): Vector3;
  8885. /**
  8886. * Sets the ShadowLight direction toward the passed target.
  8887. * @param target The point to target in local space
  8888. * @returns the updated ShadowLight direction
  8889. */
  8890. setDirectionToTarget(target: Vector3): Vector3;
  8891. /**
  8892. * Returns the light rotation in euler definition.
  8893. * @returns the x y z rotation in local space.
  8894. */
  8895. getRotation(): Vector3;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /** @hidden */
  8911. _initCache(): void;
  8912. /** @hidden */
  8913. _isSynchronized(): boolean;
  8914. /**
  8915. * Computes the world matrix of the node
  8916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8917. * @returns the world matrix
  8918. */
  8919. computeWorldMatrix(force?: boolean): Matrix;
  8920. /**
  8921. * Gets the minZ used for shadow according to both the scene and the light.
  8922. * @param activeCamera The camera we are returning the min for
  8923. * @returns the depth min z
  8924. */
  8925. getDepthMinZ(activeCamera: Camera): number;
  8926. /**
  8927. * Gets the maxZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the max for
  8929. * @returns the depth max z
  8930. */
  8931. getDepthMaxZ(activeCamera: Camera): number;
  8932. /**
  8933. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8934. * @param matrix The materix to updated with the projection information
  8935. * @param viewMatrix The transform matrix of the light
  8936. * @param renderList The list of mesh to render in the map
  8937. * @returns The current light
  8938. */
  8939. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8940. }
  8941. }
  8942. declare module "babylonjs/Materials/effectFallbacks" {
  8943. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8944. import { Effect } from "babylonjs/Materials/effect";
  8945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8946. /**
  8947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8949. */
  8950. export class EffectFallbacks implements IEffectFallbacks {
  8951. private _defines;
  8952. private _currentRank;
  8953. private _maxRank;
  8954. private _mesh;
  8955. /**
  8956. * Removes the fallback from the bound mesh.
  8957. */
  8958. unBindMesh(): void;
  8959. /**
  8960. * Adds a fallback on the specified property.
  8961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8962. * @param define The name of the define in the shader
  8963. */
  8964. addFallback(rank: number, define: string): void;
  8965. /**
  8966. * Sets the mesh to use CPU skinning when needing to fallback.
  8967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8968. * @param mesh The mesh to use the fallbacks.
  8969. */
  8970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8971. /**
  8972. * Checks to see if more fallbacks are still availible.
  8973. */
  8974. readonly hasMoreFallbacks: boolean;
  8975. /**
  8976. * Removes the defines that should be removed when falling back.
  8977. * @param currentDefines defines the current define statements for the shader.
  8978. * @param effect defines the current effect we try to compile
  8979. * @returns The resulting defines with defines of the current rank removed.
  8980. */
  8981. reduce(currentDefines: string, effect: Effect): string;
  8982. }
  8983. }
  8984. declare module "babylonjs/Materials/materialHelper" {
  8985. import { Nullable } from "babylonjs/types";
  8986. import { Scene } from "babylonjs/scene";
  8987. import { Engine } from "babylonjs/Engines/engine";
  8988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8989. import { Light } from "babylonjs/Lights/light";
  8990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8991. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8995. /**
  8996. * "Static Class" containing the most commonly used helper while dealing with material for
  8997. * rendering purpose.
  8998. *
  8999. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9000. *
  9001. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9002. */
  9003. export class MaterialHelper {
  9004. /**
  9005. * Bind the current view position to an effect.
  9006. * @param effect The effect to be bound
  9007. * @param scene The scene the eyes position is used from
  9008. */
  9009. static BindEyePosition(effect: Effect, scene: Scene): void;
  9010. /**
  9011. * Helps preparing the defines values about the UVs in used in the effect.
  9012. * UVs are shared as much as we can accross channels in the shaders.
  9013. * @param texture The texture we are preparing the UVs for
  9014. * @param defines The defines to update
  9015. * @param key The channel key "diffuse", "specular"... used in the shader
  9016. */
  9017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9018. /**
  9019. * Binds a texture matrix value to its corrsponding uniform
  9020. * @param texture The texture to bind the matrix for
  9021. * @param uniformBuffer The uniform buffer receivin the data
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9025. /**
  9026. * Gets the current status of the fog (should it be enabled?)
  9027. * @param mesh defines the mesh to evaluate for fog support
  9028. * @param scene defines the hosting scene
  9029. * @returns true if fog must be enabled
  9030. */
  9031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9034. * @param mesh defines the current mesh
  9035. * @param scene defines the current scene
  9036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9037. * @param pointsCloud defines if point cloud rendering has to be turned on
  9038. * @param fogEnabled defines if fog has to be turned on
  9039. * @param alphaTest defines if alpha testing has to be turned on
  9040. * @param defines defines the current list of defines
  9041. */
  9042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9043. /**
  9044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9045. * @param scene defines the current scene
  9046. * @param engine defines the current engine
  9047. * @param defines specifies the list of active defines
  9048. * @param useInstances defines if instances have to be turned on
  9049. * @param useClipPlane defines if clip plane have to be turned on
  9050. */
  9051. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9052. /**
  9053. * Prepares the defines for bones
  9054. * @param mesh The mesh containing the geometry data we will draw
  9055. * @param defines The defines to update
  9056. */
  9057. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9058. /**
  9059. * Prepares the defines for morph targets
  9060. * @param mesh The mesh containing the geometry data we will draw
  9061. * @param defines The defines to update
  9062. */
  9063. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9064. /**
  9065. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9066. * @param mesh The mesh containing the geometry data we will draw
  9067. * @param defines The defines to update
  9068. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9069. * @param useBones Precise whether bones should be used or not (override mesh info)
  9070. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9071. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9072. * @returns false if defines are considered not dirty and have not been checked
  9073. */
  9074. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9075. /**
  9076. * Prepares the defines related to multiview
  9077. * @param scene The scene we are intending to draw
  9078. * @param defines The defines to update
  9079. */
  9080. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9081. /**
  9082. * Prepares the defines related to the light information passed in parameter
  9083. * @param scene The scene we are intending to draw
  9084. * @param mesh The mesh the effect is compiling for
  9085. * @param light The light the effect is compiling for
  9086. * @param lightIndex The index of the light
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param state Defines the current state regarding what is needed (normals, etc...)
  9090. */
  9091. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9092. needNormals: boolean;
  9093. needRebuild: boolean;
  9094. shadowEnabled: boolean;
  9095. specularEnabled: boolean;
  9096. lightmapMode: boolean;
  9097. }): void;
  9098. /**
  9099. * Prepares the defines related to the light information passed in parameter
  9100. * @param scene The scene we are intending to draw
  9101. * @param mesh The mesh the effect is compiling for
  9102. * @param defines The defines to update
  9103. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9104. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9105. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9106. * @returns true if normals will be required for the rest of the effect
  9107. */
  9108. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9109. /**
  9110. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9111. * @param lightIndex defines the light index
  9112. * @param uniformsList The uniform list
  9113. * @param samplersList The sampler list
  9114. * @param projectedLightTexture defines if projected texture must be used
  9115. * @param uniformBuffersList defines an optional list of uniform buffers
  9116. */
  9117. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9118. /**
  9119. * Prepares the uniforms and samplers list to be used in the effect
  9120. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9121. * @param samplersList The sampler list
  9122. * @param defines The defines helping in the list generation
  9123. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9124. */
  9125. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9126. /**
  9127. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9128. * @param defines The defines to update while falling back
  9129. * @param fallbacks The authorized effect fallbacks
  9130. * @param maxSimultaneousLights The maximum number of lights allowed
  9131. * @param rank the current rank of the Effect
  9132. * @returns The newly affected rank
  9133. */
  9134. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9135. private static _TmpMorphInfluencers;
  9136. /**
  9137. * Prepares the list of attributes required for morph targets according to the effect defines.
  9138. * @param attribs The current list of supported attribs
  9139. * @param mesh The mesh to prepare the morph targets attributes for
  9140. * @param influencers The number of influencers
  9141. */
  9142. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param defines The current Defines of the effect
  9148. */
  9149. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9150. /**
  9151. * Prepares the list of attributes required for bones according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the bones attributes for
  9154. * @param defines The current Defines of the effect
  9155. * @param fallbacks The current efffect fallback strategy
  9156. */
  9157. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9158. /**
  9159. * Check and prepare the list of attributes required for instances according to the effect defines.
  9160. * @param attribs The current list of supported attribs
  9161. * @param defines The current MaterialDefines of the effect
  9162. */
  9163. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9164. /**
  9165. * Add the list of attributes required for instances to the attribs array.
  9166. * @param attribs The current list of supported attribs
  9167. */
  9168. static PushAttributesForInstances(attribs: string[]): void;
  9169. /**
  9170. * Binds the light information to the effect.
  9171. * @param light The light containing the generator
  9172. * @param effect The effect we are binding the data to
  9173. * @param lightIndex The light index in the effect used to render
  9174. */
  9175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param light Light to bind
  9179. * @param lightIndex Light index
  9180. * @param scene The scene where the light belongs to
  9181. * @param effect The effect we are binding the data to
  9182. * @param useSpecular Defines if specular is supported
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9196. */
  9197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9198. private static _tempFogColor;
  9199. /**
  9200. * Binds the fog information from the scene to the effect for the given mesh.
  9201. * @param scene The scene the lights belongs to
  9202. * @param mesh The mesh we are binding the information to render
  9203. * @param effect The effect we are binding the data to
  9204. * @param linearSpace Defines if the fog effect is applied in linear space
  9205. */
  9206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9207. /**
  9208. * Binds the bones information from the mesh to the effect.
  9209. * @param mesh The mesh we are binding the information to render
  9210. * @param effect The effect we are binding the data to
  9211. */
  9212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9213. /**
  9214. * Binds the morph targets information from the mesh to the effect.
  9215. * @param abstractMesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. */
  9218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9219. /**
  9220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9221. * @param defines The generated defines used in the effect
  9222. * @param effect The effect we are binding the data to
  9223. * @param scene The scene we are willing to render with logarithmic scale for
  9224. */
  9225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9226. /**
  9227. * Binds the clip plane information from the scene to the effect.
  9228. * @param scene The scene the clip plane information are extracted from
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindClipPlane(effect: Effect, scene: Scene): void;
  9232. }
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9235. /** @hidden */
  9236. export var packingFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. /** @hidden */
  9244. export var shadowMapPixelShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9250. /** @hidden */
  9251. export var bonesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9257. /** @hidden */
  9258. export var morphTargetsVertexGlobalDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9264. /** @hidden */
  9265. export var morphTargetsVertexDeclaration: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9271. /** @hidden */
  9272. export var instancesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9278. /** @hidden */
  9279. export var helperFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9285. /** @hidden */
  9286. export var morphTargetsVertex: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9292. /** @hidden */
  9293. export var instancesVertex: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9299. /** @hidden */
  9300. export var bonesVertex: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9314. /** @hidden */
  9315. export var shadowMapVertexShader: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9321. /** @hidden */
  9322. export var depthBoxBlurPixelShader: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9328. import { Nullable } from "babylonjs/types";
  9329. import { Scene } from "babylonjs/scene";
  9330. import { Matrix } from "babylonjs/Maths/math.vector";
  9331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9333. import { Mesh } from "babylonjs/Meshes/mesh";
  9334. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9336. import { Effect } from "babylonjs/Materials/effect";
  9337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9338. import "babylonjs/Shaders/shadowMap.fragment";
  9339. import "babylonjs/Shaders/shadowMap.vertex";
  9340. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9341. import { Observable } from "babylonjs/Misc/observable";
  9342. /**
  9343. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9344. */
  9345. export interface ICustomShaderOptions {
  9346. /**
  9347. * Gets or sets the custom shader name to use
  9348. */
  9349. shaderName: string;
  9350. /**
  9351. * The list of attribute names used in the shader
  9352. */
  9353. attributes?: string[];
  9354. /**
  9355. * The list of unifrom names used in the shader
  9356. */
  9357. uniforms?: string[];
  9358. /**
  9359. * The list of sampler names used in the shader
  9360. */
  9361. samplers?: string[];
  9362. /**
  9363. * The list of defines used in the shader
  9364. */
  9365. defines?: string[];
  9366. }
  9367. /**
  9368. * Interface to implement to create a shadow generator compatible with BJS.
  9369. */
  9370. export interface IShadowGenerator {
  9371. /**
  9372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9373. * @returns The render target texture if present otherwise, null
  9374. */
  9375. getShadowMap(): Nullable<RenderTargetTexture>;
  9376. /**
  9377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9378. * @returns The render target texture if the shadow map is present otherwise, null
  9379. */
  9380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9381. /**
  9382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9383. * @param subMesh The submesh we want to render in the shadow map
  9384. * @param useInstances Defines wether will draw in the map using instances
  9385. * @returns true if ready otherwise, false
  9386. */
  9387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9388. /**
  9389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9390. * @param defines Defines of the material we want to update
  9391. * @param lightIndex Index of the light in the enabled light list of the material
  9392. */
  9393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9394. /**
  9395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9396. * defined in the generator but impacting the effect).
  9397. * It implies the unifroms available on the materials are the standard BJS ones.
  9398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9399. * @param effect The effect we are binfing the information for
  9400. */
  9401. bindShadowLight(lightIndex: string, effect: Effect): void;
  9402. /**
  9403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9404. * (eq to shadow prjection matrix * light transform matrix)
  9405. * @returns The transform matrix used to create the shadow map
  9406. */
  9407. getTransformMatrix(): Matrix;
  9408. /**
  9409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9410. * Cube and 2D textures for instance.
  9411. */
  9412. recreateShadowMap(): void;
  9413. /**
  9414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9415. * @param onCompiled Callback triggered at the and of the effects compilation
  9416. * @param options Sets of optional options forcing the compilation with different modes
  9417. */
  9418. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9419. useInstances: boolean;
  9420. }>): void;
  9421. /**
  9422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9423. * @param options Sets of optional options forcing the compilation with different modes
  9424. * @returns A promise that resolves when the compilation completes
  9425. */
  9426. forceCompilationAsync(options?: Partial<{
  9427. useInstances: boolean;
  9428. }>): Promise<void>;
  9429. /**
  9430. * Serializes the shadow generator setup to a json object.
  9431. * @returns The serialized JSON object
  9432. */
  9433. serialize(): any;
  9434. /**
  9435. * Disposes the Shadow map and related Textures and effects.
  9436. */
  9437. dispose(): void;
  9438. }
  9439. /**
  9440. * Default implementation IShadowGenerator.
  9441. * This is the main object responsible of generating shadows in the framework.
  9442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9443. */
  9444. export class ShadowGenerator implements IShadowGenerator {
  9445. /**
  9446. * Shadow generator mode None: no filtering applied.
  9447. */
  9448. static readonly FILTER_NONE: number;
  9449. /**
  9450. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9452. */
  9453. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9454. /**
  9455. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9456. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9457. */
  9458. static readonly FILTER_POISSONSAMPLING: number;
  9459. /**
  9460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9462. */
  9463. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9464. /**
  9465. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9466. * edge artifacts on steep falloff.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode PCF: Percentage Closer Filtering
  9478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9479. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9480. */
  9481. static readonly FILTER_PCF: number;
  9482. /**
  9483. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * Contact Hardening
  9486. */
  9487. static readonly FILTER_PCSS: number;
  9488. /**
  9489. * Reserved for PCF and PCSS
  9490. * Highest Quality.
  9491. *
  9492. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9493. *
  9494. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9495. */
  9496. static readonly QUALITY_HIGH: number;
  9497. /**
  9498. * Reserved for PCF and PCSS
  9499. * Good tradeoff for quality/perf cross devices
  9500. *
  9501. * Execute PCF on a 3*3 kernel.
  9502. *
  9503. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9504. */
  9505. static readonly QUALITY_MEDIUM: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * The lowest quality but the fastest.
  9509. *
  9510. * Execute PCF on a 1*1 kernel.
  9511. *
  9512. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9513. */
  9514. static readonly QUALITY_LOW: number;
  9515. /** Gets or sets the custom shader name to use */
  9516. customShaderOptions: ICustomShaderOptions;
  9517. /**
  9518. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9519. */
  9520. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9521. /**
  9522. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9523. */
  9524. onAfterShadowMapRenderObservable: Observable<Effect>;
  9525. /**
  9526. * Observable triggered before a mesh is rendered in the shadow map.
  9527. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9528. */
  9529. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9530. /**
  9531. * Observable triggered after a mesh is rendered in the shadow map.
  9532. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9533. */
  9534. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9535. private _bias;
  9536. /**
  9537. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9538. */
  9539. /**
  9540. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9541. */
  9542. bias: number;
  9543. private _normalBias;
  9544. /**
  9545. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9546. */
  9547. /**
  9548. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9549. */
  9550. normalBias: number;
  9551. private _blurBoxOffset;
  9552. /**
  9553. * Gets the blur box offset: offset applied during the blur pass.
  9554. * Only useful if useKernelBlur = false
  9555. */
  9556. /**
  9557. * Sets the blur box offset: offset applied during the blur pass.
  9558. * Only useful if useKernelBlur = false
  9559. */
  9560. blurBoxOffset: number;
  9561. private _blurScale;
  9562. /**
  9563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9564. * 2 means half of the size.
  9565. */
  9566. /**
  9567. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9568. * 2 means half of the size.
  9569. */
  9570. blurScale: number;
  9571. private _blurKernel;
  9572. /**
  9573. * Gets the blur kernel: kernel size of the blur pass.
  9574. * Only useful if useKernelBlur = true
  9575. */
  9576. /**
  9577. * Sets the blur kernel: kernel size of the blur pass.
  9578. * Only useful if useKernelBlur = true
  9579. */
  9580. blurKernel: number;
  9581. private _useKernelBlur;
  9582. /**
  9583. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9584. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9585. */
  9586. /**
  9587. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9588. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9589. */
  9590. useKernelBlur: boolean;
  9591. private _depthScale;
  9592. /**
  9593. * Gets the depth scale used in ESM mode.
  9594. */
  9595. /**
  9596. * Sets the depth scale used in ESM mode.
  9597. * This can override the scale stored on the light.
  9598. */
  9599. depthScale: number;
  9600. private _filter;
  9601. /**
  9602. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9603. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9604. */
  9605. /**
  9606. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9607. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9608. */
  9609. filter: number;
  9610. /**
  9611. * Gets if the current filter is set to Poisson Sampling.
  9612. */
  9613. /**
  9614. * Sets the current filter to Poisson Sampling.
  9615. */
  9616. usePoissonSampling: boolean;
  9617. /**
  9618. * Gets if the current filter is set to ESM.
  9619. */
  9620. /**
  9621. * Sets the current filter is to ESM.
  9622. */
  9623. useExponentialShadowMap: boolean;
  9624. /**
  9625. * Gets if the current filter is set to filtered ESM.
  9626. */
  9627. /**
  9628. * Gets if the current filter is set to filtered ESM.
  9629. */
  9630. useBlurExponentialShadowMap: boolean;
  9631. /**
  9632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. /**
  9636. * Sets the current filter to "close ESM" (using the inverse of the
  9637. * exponential to prevent steep falloff artifacts).
  9638. */
  9639. useCloseExponentialShadowMap: boolean;
  9640. /**
  9641. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9642. * exponential to prevent steep falloff artifacts).
  9643. */
  9644. /**
  9645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9646. * exponential to prevent steep falloff artifacts).
  9647. */
  9648. useBlurCloseExponentialShadowMap: boolean;
  9649. /**
  9650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCF" (percentage closer filtering).
  9654. */
  9655. usePercentageCloserFiltering: boolean;
  9656. private _filteringQuality;
  9657. /**
  9658. * Gets the PCF or PCSS Quality.
  9659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9660. */
  9661. /**
  9662. * Sets the PCF or PCSS Quality.
  9663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9664. */
  9665. filteringQuality: number;
  9666. /**
  9667. * Gets if the current filter is set to "PCSS" (contact hardening).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCSS" (contact hardening).
  9671. */
  9672. useContactHardeningShadow: boolean;
  9673. private _contactHardeningLightSizeUVRatio;
  9674. /**
  9675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9676. * Using a ratio helps keeping shape stability independently of the map size.
  9677. *
  9678. * It does not account for the light projection as it was having too much
  9679. * instability during the light setup or during light position changes.
  9680. *
  9681. * Only valid if useContactHardeningShadow is true.
  9682. */
  9683. /**
  9684. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9685. * Using a ratio helps keeping shape stability independently of the map size.
  9686. *
  9687. * It does not account for the light projection as it was having too much
  9688. * instability during the light setup or during light position changes.
  9689. *
  9690. * Only valid if useContactHardeningShadow is true.
  9691. */
  9692. contactHardeningLightSizeUVRatio: number;
  9693. private _darkness;
  9694. /** Gets or sets the actual darkness of a shadow */
  9695. darkness: number;
  9696. /**
  9697. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9698. * 0 means strongest and 1 would means no shadow.
  9699. * @returns the darkness.
  9700. */
  9701. getDarkness(): number;
  9702. /**
  9703. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9704. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9705. * @returns the shadow generator allowing fluent coding.
  9706. */
  9707. setDarkness(darkness: number): ShadowGenerator;
  9708. private _transparencyShadow;
  9709. /** Gets or sets the ability to have transparent shadow */
  9710. transparencyShadow: boolean;
  9711. /**
  9712. * Sets the ability to have transparent shadow (boolean).
  9713. * @param transparent True if transparent else False
  9714. * @returns the shadow generator allowing fluent coding
  9715. */
  9716. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9717. private _shadowMap;
  9718. private _shadowMap2;
  9719. /**
  9720. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9721. * @returns The render target texture if present otherwise, null
  9722. */
  9723. getShadowMap(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9726. * @returns The render target texture if the shadow map is present otherwise, null
  9727. */
  9728. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9729. /**
  9730. * Gets the class name of that object
  9731. * @returns "ShadowGenerator"
  9732. */
  9733. getClassName(): string;
  9734. /**
  9735. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9736. * @param mesh Mesh to add
  9737. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9738. * @returns the Shadow Generator itself
  9739. */
  9740. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9741. /**
  9742. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9743. * @param mesh Mesh to remove
  9744. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9745. * @returns the Shadow Generator itself
  9746. */
  9747. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9748. /**
  9749. * Controls the extent to which the shadows fade out at the edge of the frustum
  9750. * Used only by directionals and spots
  9751. */
  9752. frustumEdgeFalloff: number;
  9753. private _light;
  9754. /**
  9755. * Returns the associated light object.
  9756. * @returns the light generating the shadow
  9757. */
  9758. getLight(): IShadowLight;
  9759. /**
  9760. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9761. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9762. * It might on the other hand introduce peter panning.
  9763. */
  9764. forceBackFacesOnly: boolean;
  9765. private _scene;
  9766. private _lightDirection;
  9767. private _effect;
  9768. private _viewMatrix;
  9769. private _projectionMatrix;
  9770. private _transformMatrix;
  9771. private _cachedPosition;
  9772. private _cachedDirection;
  9773. private _cachedDefines;
  9774. private _currentRenderID;
  9775. private _boxBlurPostprocess;
  9776. private _kernelBlurXPostprocess;
  9777. private _kernelBlurYPostprocess;
  9778. private _blurPostProcesses;
  9779. private _mapSize;
  9780. private _currentFaceIndex;
  9781. private _currentFaceIndexCache;
  9782. private _textureType;
  9783. private _defaultTextureMatrix;
  9784. private _storedUniqueId;
  9785. /** @hidden */
  9786. static _SceneComponentInitialization: (scene: Scene) => void;
  9787. /**
  9788. * Creates a ShadowGenerator object.
  9789. * A ShadowGenerator is the required tool to use the shadows.
  9790. * Each light casting shadows needs to use its own ShadowGenerator.
  9791. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9793. * @param light The light object generating the shadows.
  9794. * @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.
  9795. */
  9796. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9797. private _initializeGenerator;
  9798. private _initializeShadowMap;
  9799. private _initializeBlurRTTAndPostProcesses;
  9800. private _renderForShadowMap;
  9801. private _renderSubMeshForShadowMap;
  9802. private _applyFilterValues;
  9803. /**
  9804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9805. * @param onCompiled Callback triggered at the and of the effects compilation
  9806. * @param options Sets of optional options forcing the compilation with different modes
  9807. */
  9808. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9809. useInstances: boolean;
  9810. }>): void;
  9811. /**
  9812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9813. * @param options Sets of optional options forcing the compilation with different modes
  9814. * @returns A promise that resolves when the compilation completes
  9815. */
  9816. forceCompilationAsync(options?: Partial<{
  9817. useInstances: boolean;
  9818. }>): Promise<void>;
  9819. /**
  9820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9821. * @param subMesh The submesh we want to render in the shadow map
  9822. * @param useInstances Defines wether will draw in the map using instances
  9823. * @returns true if ready otherwise, false
  9824. */
  9825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9826. /**
  9827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9828. * @param defines Defines of the material we want to update
  9829. * @param lightIndex Index of the light in the enabled light list of the material
  9830. */
  9831. prepareDefines(defines: any, lightIndex: number): void;
  9832. /**
  9833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9834. * defined in the generator but impacting the effect).
  9835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9836. * @param effect The effect we are binfing the information for
  9837. */
  9838. bindShadowLight(lightIndex: string, effect: Effect): void;
  9839. /**
  9840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9841. * (eq to shadow prjection matrix * light transform matrix)
  9842. * @returns The transform matrix used to create the shadow map
  9843. */
  9844. getTransformMatrix(): Matrix;
  9845. /**
  9846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9847. * Cube and 2D textures for instance.
  9848. */
  9849. recreateShadowMap(): void;
  9850. private _disposeBlurPostProcesses;
  9851. private _disposeRTTandPostProcesses;
  9852. /**
  9853. * Disposes the ShadowGenerator.
  9854. * Returns nothing.
  9855. */
  9856. dispose(): void;
  9857. /**
  9858. * Serializes the shadow generator setup to a json object.
  9859. * @returns The serialized JSON object
  9860. */
  9861. serialize(): any;
  9862. /**
  9863. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9864. * @param parsedShadowGenerator The JSON object to parse
  9865. * @param scene The scene to create the shadow map for
  9866. * @returns The parsed shadow generator
  9867. */
  9868. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9869. }
  9870. }
  9871. declare module "babylonjs/Lights/light" {
  9872. import { Nullable } from "babylonjs/types";
  9873. import { Scene } from "babylonjs/scene";
  9874. import { Vector3 } from "babylonjs/Maths/math.vector";
  9875. import { Color3 } from "babylonjs/Maths/math.color";
  9876. import { Node } from "babylonjs/node";
  9877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9878. import { Effect } from "babylonjs/Materials/effect";
  9879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9881. /**
  9882. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9883. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9884. * 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.
  9885. */
  9886. export abstract class Light extends Node {
  9887. /**
  9888. * Falloff Default: light is falling off following the material specification:
  9889. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9890. */
  9891. static readonly FALLOFF_DEFAULT: number;
  9892. /**
  9893. * Falloff Physical: light is falling off following the inverse squared distance law.
  9894. */
  9895. static readonly FALLOFF_PHYSICAL: number;
  9896. /**
  9897. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9898. * to enhance interoperability with other engines.
  9899. */
  9900. static readonly FALLOFF_GLTF: number;
  9901. /**
  9902. * Falloff Standard: light is falling off like in the standard material
  9903. * to enhance interoperability with other materials.
  9904. */
  9905. static readonly FALLOFF_STANDARD: number;
  9906. /**
  9907. * If every light affecting the material is in this lightmapMode,
  9908. * material.lightmapTexture adds or multiplies
  9909. * (depends on material.useLightmapAsShadowmap)
  9910. * after every other light calculations.
  9911. */
  9912. static readonly LIGHTMAP_DEFAULT: number;
  9913. /**
  9914. * material.lightmapTexture as only diffuse lighting from this light
  9915. * adds only specular lighting from this light
  9916. * adds dynamic shadows
  9917. */
  9918. static readonly LIGHTMAP_SPECULAR: number;
  9919. /**
  9920. * material.lightmapTexture as only lighting
  9921. * no light calculation from this light
  9922. * only adds dynamic shadows from this light
  9923. */
  9924. static readonly LIGHTMAP_SHADOWSONLY: number;
  9925. /**
  9926. * Each light type uses the default quantity according to its type:
  9927. * point/spot lights use luminous intensity
  9928. * directional lights use illuminance
  9929. */
  9930. static readonly INTENSITYMODE_AUTOMATIC: number;
  9931. /**
  9932. * lumen (lm)
  9933. */
  9934. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9935. /**
  9936. * candela (lm/sr)
  9937. */
  9938. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9939. /**
  9940. * lux (lm/m^2)
  9941. */
  9942. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9943. /**
  9944. * nit (cd/m^2)
  9945. */
  9946. static readonly INTENSITYMODE_LUMINANCE: number;
  9947. /**
  9948. * Light type const id of the point light.
  9949. */
  9950. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9951. /**
  9952. * Light type const id of the directional light.
  9953. */
  9954. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9955. /**
  9956. * Light type const id of the spot light.
  9957. */
  9958. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9959. /**
  9960. * Light type const id of the hemispheric light.
  9961. */
  9962. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9963. /**
  9964. * Diffuse gives the basic color to an object.
  9965. */
  9966. diffuse: Color3;
  9967. /**
  9968. * Specular produces a highlight color on an object.
  9969. * Note: This is note affecting PBR materials.
  9970. */
  9971. specular: Color3;
  9972. /**
  9973. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9974. * falling off base on range or angle.
  9975. * This can be set to any values in Light.FALLOFF_x.
  9976. *
  9977. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9978. * other types of materials.
  9979. */
  9980. falloffType: number;
  9981. /**
  9982. * Strength of the light.
  9983. * Note: By default it is define in the framework own unit.
  9984. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9985. */
  9986. intensity: number;
  9987. private _range;
  9988. protected _inverseSquaredRange: number;
  9989. /**
  9990. * Defines how far from the source the light is impacting in scene units.
  9991. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9992. */
  9993. /**
  9994. * Defines how far from the source the light is impacting in scene units.
  9995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9996. */
  9997. range: number;
  9998. /**
  9999. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10000. * of light.
  10001. */
  10002. private _photometricScale;
  10003. private _intensityMode;
  10004. /**
  10005. * Gets the photometric scale used to interpret the intensity.
  10006. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10007. */
  10008. /**
  10009. * Sets the photometric scale used to interpret the intensity.
  10010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10011. */
  10012. intensityMode: number;
  10013. private _radius;
  10014. /**
  10015. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10016. */
  10017. /**
  10018. * sets the light radius used by PBR Materials to simulate soft area lights.
  10019. */
  10020. radius: number;
  10021. private _renderPriority;
  10022. /**
  10023. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10024. * exceeding the number allowed of the materials.
  10025. */
  10026. renderPriority: number;
  10027. private _shadowEnabled;
  10028. /**
  10029. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10030. * the current shadow generator.
  10031. */
  10032. /**
  10033. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10034. * the current shadow generator.
  10035. */
  10036. shadowEnabled: boolean;
  10037. private _includedOnlyMeshes;
  10038. /**
  10039. * Gets the only meshes impacted by this light.
  10040. */
  10041. /**
  10042. * Sets the only meshes impacted by this light.
  10043. */
  10044. includedOnlyMeshes: AbstractMesh[];
  10045. private _excludedMeshes;
  10046. /**
  10047. * Gets the meshes not impacted by this light.
  10048. */
  10049. /**
  10050. * Sets the meshes not impacted by this light.
  10051. */
  10052. excludedMeshes: AbstractMesh[];
  10053. private _excludeWithLayerMask;
  10054. /**
  10055. * Gets the layer id use to find what meshes are not impacted by the light.
  10056. * Inactive if 0
  10057. */
  10058. /**
  10059. * Sets the layer id use to find what meshes are not impacted by the light.
  10060. * Inactive if 0
  10061. */
  10062. excludeWithLayerMask: number;
  10063. private _includeOnlyWithLayerMask;
  10064. /**
  10065. * Gets the layer id use to find what meshes are impacted by the light.
  10066. * Inactive if 0
  10067. */
  10068. /**
  10069. * Sets the layer id use to find what meshes are impacted by the light.
  10070. * Inactive if 0
  10071. */
  10072. includeOnlyWithLayerMask: number;
  10073. private _lightmapMode;
  10074. /**
  10075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10076. */
  10077. /**
  10078. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10079. */
  10080. lightmapMode: number;
  10081. /**
  10082. * Shadow generator associted to the light.
  10083. * @hidden Internal use only.
  10084. */
  10085. _shadowGenerator: Nullable<IShadowGenerator>;
  10086. /**
  10087. * @hidden Internal use only.
  10088. */
  10089. _excludedMeshesIds: string[];
  10090. /**
  10091. * @hidden Internal use only.
  10092. */
  10093. _includedOnlyMeshesIds: string[];
  10094. /**
  10095. * The current light unifom buffer.
  10096. * @hidden Internal use only.
  10097. */
  10098. _uniformBuffer: UniformBuffer;
  10099. /** @hidden */
  10100. _renderId: number;
  10101. /**
  10102. * Creates a Light object in the scene.
  10103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10104. * @param name The firendly name of the light
  10105. * @param scene The scene the light belongs too
  10106. */
  10107. constructor(name: string, scene: Scene);
  10108. protected abstract _buildUniformLayout(): void;
  10109. /**
  10110. * Sets the passed Effect "effect" with the Light information.
  10111. * @param effect The effect to update
  10112. * @param lightIndex The index of the light in the effect to update
  10113. * @returns The light
  10114. */
  10115. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10116. /**
  10117. * Sets the passed Effect "effect" with the Light information.
  10118. * @param effect The effect to update
  10119. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10120. * @returns The light
  10121. */
  10122. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10123. /**
  10124. * Returns the string "Light".
  10125. * @returns the class name
  10126. */
  10127. getClassName(): string;
  10128. /** @hidden */
  10129. readonly _isLight: boolean;
  10130. /**
  10131. * Converts the light information to a readable string for debug purpose.
  10132. * @param fullDetails Supports for multiple levels of logging within scene loading
  10133. * @returns the human readable light info
  10134. */
  10135. toString(fullDetails?: boolean): string;
  10136. /** @hidden */
  10137. protected _syncParentEnabledState(): void;
  10138. /**
  10139. * Set the enabled state of this node.
  10140. * @param value - the new enabled state
  10141. */
  10142. setEnabled(value: boolean): void;
  10143. /**
  10144. * Returns the Light associated shadow generator if any.
  10145. * @return the associated shadow generator.
  10146. */
  10147. getShadowGenerator(): Nullable<IShadowGenerator>;
  10148. /**
  10149. * Returns a Vector3, the absolute light position in the World.
  10150. * @returns the world space position of the light
  10151. */
  10152. getAbsolutePosition(): Vector3;
  10153. /**
  10154. * Specifies if the light will affect the passed mesh.
  10155. * @param mesh The mesh to test against the light
  10156. * @return true the mesh is affected otherwise, false.
  10157. */
  10158. canAffectMesh(mesh: AbstractMesh): boolean;
  10159. /**
  10160. * Sort function to order lights for rendering.
  10161. * @param a First Light object to compare to second.
  10162. * @param b Second Light object to compare first.
  10163. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10164. */
  10165. static CompareLightsPriority(a: Light, b: Light): number;
  10166. /**
  10167. * Releases resources associated with this node.
  10168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10170. */
  10171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10172. /**
  10173. * Returns the light type ID (integer).
  10174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10175. */
  10176. getTypeID(): number;
  10177. /**
  10178. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10179. * @returns the scaled intensity in intensity mode unit
  10180. */
  10181. getScaledIntensity(): number;
  10182. /**
  10183. * Returns a new Light object, named "name", from the current one.
  10184. * @param name The name of the cloned light
  10185. * @returns the new created light
  10186. */
  10187. clone(name: string): Nullable<Light>;
  10188. /**
  10189. * Serializes the current light into a Serialization object.
  10190. * @returns the serialized object.
  10191. */
  10192. serialize(): any;
  10193. /**
  10194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10195. * This new light is named "name" and added to the passed scene.
  10196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10197. * @param name The friendly name of the light
  10198. * @param scene The scene the new light will belong to
  10199. * @returns the constructor function
  10200. */
  10201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10202. /**
  10203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10204. * @param parsedLight The JSON representation of the light
  10205. * @param scene The scene to create the parsed light in
  10206. * @returns the created light after parsing
  10207. */
  10208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10209. private _hookArrayForExcluded;
  10210. private _hookArrayForIncludedOnly;
  10211. private _resyncMeshes;
  10212. /**
  10213. * Forces the meshes to update their light related information in their rendering used effects
  10214. * @hidden Internal Use Only
  10215. */
  10216. _markMeshesAsLightDirty(): void;
  10217. /**
  10218. * Recomputes the cached photometric scale if needed.
  10219. */
  10220. private _computePhotometricScale;
  10221. /**
  10222. * Returns the Photometric Scale according to the light type and intensity mode.
  10223. */
  10224. private _getPhotometricScale;
  10225. /**
  10226. * Reorder the light in the scene according to their defined priority.
  10227. * @hidden Internal Use Only
  10228. */
  10229. _reorderLightsInScene(): void;
  10230. /**
  10231. * Prepares the list of defines specific to the light type.
  10232. * @param defines the list of defines
  10233. * @param lightIndex defines the index of the light for the effect
  10234. */
  10235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10236. }
  10237. }
  10238. declare module "babylonjs/Actions/action" {
  10239. import { Observable } from "babylonjs/Misc/observable";
  10240. import { Condition } from "babylonjs/Actions/condition";
  10241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10242. import { ActionManager } from "babylonjs/Actions/actionManager";
  10243. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10244. /**
  10245. * Interface used to define Action
  10246. */
  10247. export interface IAction {
  10248. /**
  10249. * Trigger for the action
  10250. */
  10251. trigger: number;
  10252. /** Options of the trigger */
  10253. triggerOptions: any;
  10254. /**
  10255. * Gets the trigger parameters
  10256. * @returns the trigger parameters
  10257. */
  10258. getTriggerParameter(): any;
  10259. /**
  10260. * Internal only - executes current action event
  10261. * @hidden
  10262. */
  10263. _executeCurrent(evt?: ActionEvent): void;
  10264. /**
  10265. * Serialize placeholder for child classes
  10266. * @param parent of child
  10267. * @returns the serialized object
  10268. */
  10269. serialize(parent: any): any;
  10270. /**
  10271. * Internal only
  10272. * @hidden
  10273. */
  10274. _prepare(): void;
  10275. /**
  10276. * Internal only - manager for action
  10277. * @hidden
  10278. */
  10279. _actionManager: AbstractActionManager;
  10280. /**
  10281. * Adds action to chain of actions, may be a DoNothingAction
  10282. * @param action defines the next action to execute
  10283. * @returns The action passed in
  10284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10285. */
  10286. then(action: IAction): IAction;
  10287. }
  10288. /**
  10289. * The action to be carried out following a trigger
  10290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10291. */
  10292. export class Action implements IAction {
  10293. /** the trigger, with or without parameters, for the action */
  10294. triggerOptions: any;
  10295. /**
  10296. * Trigger for the action
  10297. */
  10298. trigger: number;
  10299. /**
  10300. * Internal only - manager for action
  10301. * @hidden
  10302. */
  10303. _actionManager: ActionManager;
  10304. private _nextActiveAction;
  10305. private _child;
  10306. private _condition?;
  10307. private _triggerParameter;
  10308. /**
  10309. * An event triggered prior to action being executed.
  10310. */
  10311. onBeforeExecuteObservable: Observable<Action>;
  10312. /**
  10313. * Creates a new Action
  10314. * @param triggerOptions the trigger, with or without parameters, for the action
  10315. * @param condition an optional determinant of action
  10316. */
  10317. constructor(
  10318. /** the trigger, with or without parameters, for the action */
  10319. triggerOptions: any, condition?: Condition);
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _prepare(): void;
  10325. /**
  10326. * Gets the trigger parameters
  10327. * @returns the trigger parameters
  10328. */
  10329. getTriggerParameter(): any;
  10330. /**
  10331. * Internal only - executes current action event
  10332. * @hidden
  10333. */
  10334. _executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getProperty(propertyPath: string): string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _getEffectiveTarget(target: any, propertyPath: string): any;
  10361. /**
  10362. * Serialize placeholder for child classes
  10363. * @param parent of child
  10364. * @returns the serialized object
  10365. */
  10366. serialize(parent: any): any;
  10367. /**
  10368. * Internal only called by serialize
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedAction: any, parent?: any): any;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. static _SerializeValueAsString: (value: any) => string;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10382. name: string;
  10383. targetType: string;
  10384. value: string;
  10385. };
  10386. }
  10387. }
  10388. declare module "babylonjs/Actions/condition" {
  10389. import { ActionManager } from "babylonjs/Actions/actionManager";
  10390. /**
  10391. * A Condition applied to an Action
  10392. */
  10393. export class Condition {
  10394. /**
  10395. * Internal only - manager for action
  10396. * @hidden
  10397. */
  10398. _actionManager: ActionManager;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _evaluationId: number;
  10404. /**
  10405. * Internal only
  10406. * @hidden
  10407. */
  10408. _currentResult: boolean;
  10409. /**
  10410. * Creates a new Condition
  10411. * @param actionManager the manager of the action the condition is applied to
  10412. */
  10413. constructor(actionManager: ActionManager);
  10414. /**
  10415. * Check if the current condition is valid
  10416. * @returns a boolean
  10417. */
  10418. isValid(): boolean;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @returns the serialized object
  10432. */
  10433. serialize(): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. protected _serialize(serializedCondition: any): any;
  10439. }
  10440. /**
  10441. * Defines specific conditional operators as extensions of Condition
  10442. */
  10443. export class ValueCondition extends Condition {
  10444. /** path to specify the property of the target the conditional operator uses */
  10445. propertyPath: string;
  10446. /** the value compared by the conditional operator against the current value of the property */
  10447. value: any;
  10448. /** the conditional operator, default ValueCondition.IsEqual */
  10449. operator: number;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsEqual;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsDifferent;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private static _IsGreater;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private static _IsLesser;
  10470. /**
  10471. * returns the number for IsEqual
  10472. */
  10473. static readonly IsEqual: number;
  10474. /**
  10475. * Returns the number for IsDifferent
  10476. */
  10477. static readonly IsDifferent: number;
  10478. /**
  10479. * Returns the number for IsGreater
  10480. */
  10481. static readonly IsGreater: number;
  10482. /**
  10483. * Returns the number for IsLesser
  10484. */
  10485. static readonly IsLesser: number;
  10486. /**
  10487. * Internal only The action manager for the condition
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private _target;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private _effectiveTarget;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private _property;
  10506. /**
  10507. * Creates a new ValueCondition
  10508. * @param actionManager manager for the action the condition applies to
  10509. * @param target for the action
  10510. * @param propertyPath path to specify the property of the target the conditional operator uses
  10511. * @param value the value compared by the conditional operator against the current value of the property
  10512. * @param operator the conditional operator, default ValueCondition.IsEqual
  10513. */
  10514. constructor(actionManager: ActionManager, target: any,
  10515. /** path to specify the property of the target the conditional operator uses */
  10516. propertyPath: string,
  10517. /** the value compared by the conditional operator against the current value of the property */
  10518. value: any,
  10519. /** the conditional operator, default ValueCondition.IsEqual */
  10520. operator?: number);
  10521. /**
  10522. * Compares the given value with the property value for the specified conditional operator
  10523. * @returns the result of the comparison
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Serialize the ValueCondition into a JSON compatible object
  10528. * @returns serialization object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Gets the name of the conditional operator for the ValueCondition
  10533. * @param operator the conditional operator
  10534. * @returns the name
  10535. */
  10536. static GetOperatorName(operator: number): string;
  10537. }
  10538. /**
  10539. * Defines a predicate condition as an extension of Condition
  10540. */
  10541. export class PredicateCondition extends Condition {
  10542. /** defines the predicate function used to validate the condition */
  10543. predicate: () => boolean;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Creates a new PredicateCondition
  10551. * @param actionManager manager for the action the condition applies to
  10552. * @param predicate defines the predicate function used to validate the condition
  10553. */
  10554. constructor(actionManager: ActionManager,
  10555. /** defines the predicate function used to validate the condition */
  10556. predicate: () => boolean);
  10557. /**
  10558. * @returns the validity of the predicate condition
  10559. */
  10560. isValid(): boolean;
  10561. }
  10562. /**
  10563. * Defines a state condition as an extension of Condition
  10564. */
  10565. export class StateCondition extends Condition {
  10566. /** Value to compare with target state */
  10567. value: string;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Creates a new StateCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target of the condition
  10582. * @param value to compare with target state
  10583. */
  10584. constructor(actionManager: ActionManager, target: any,
  10585. /** Value to compare with target state */
  10586. value: string);
  10587. /**
  10588. * Gets a boolean indicating if the current condition is met
  10589. * @returns the validity of the state
  10590. */
  10591. isValid(): boolean;
  10592. /**
  10593. * Serialize the StateCondition into a JSON compatible object
  10594. * @returns serialization object
  10595. */
  10596. serialize(): any;
  10597. }
  10598. }
  10599. declare module "babylonjs/Actions/directActions" {
  10600. import { Action } from "babylonjs/Actions/action";
  10601. import { Condition } from "babylonjs/Actions/condition";
  10602. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10603. /**
  10604. * This defines an action responsible to toggle a boolean once triggered.
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10606. */
  10607. export class SwitchBooleanAction extends Action {
  10608. /**
  10609. * The path to the boolean property in the target object
  10610. */
  10611. propertyPath: string;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the boolean
  10619. * @param propertyPath defines the path to the boolean property in the target object
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action toggle the boolean value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set a the state field of the target
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class SetStateAction extends Action {
  10642. /**
  10643. * The value to store in the state field.
  10644. */
  10645. value: string;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the state property
  10651. * @param value defines the value to store in the state field
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10655. /**
  10656. * Execute the action and store the value on the target state property.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to set a property of the target
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetValueAction extends Action {
  10672. /**
  10673. * The path of the property to set in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value to set in the property
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to set in the target
  10688. * @param value defines the value to set in the property
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and set the targetted property to the desired value.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to increment the target value
  10707. * to a desired value once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class IncrementValueAction extends Action {
  10711. /**
  10712. * The path of the property to increment in the target.
  10713. */
  10714. propertyPath: string;
  10715. /**
  10716. * The value we should increment the property by.
  10717. */
  10718. value: any;
  10719. private _target;
  10720. private _effectiveTarget;
  10721. private _property;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the object containing the property
  10726. * @param propertyPath defines the path of the property to increment in the target
  10727. * @param value defines the value value we should increment the property by
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and increment the target of the value amount.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to start an animation once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class PlayAnimationAction extends Action {
  10749. /**
  10750. * Where the animation should start (animation frame)
  10751. */
  10752. from: number;
  10753. /**
  10754. * Where the animation should stop (animation frame)
  10755. */
  10756. to: number;
  10757. /**
  10758. * Define if the animation should loop or stop after the first play.
  10759. */
  10760. loop?: boolean;
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param from defines from where the animation should start (animation frame)
  10767. * @param end defines where the animation should stop (animation frame)
  10768. * @param loop defines if the animation should loop or stop after the first play
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and play the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to stop an animation once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class StopAnimationAction extends Action {
  10790. private _target;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the target animation or animation name
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and stop the animation.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible that does nothing once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class DoNothingAction extends Action {
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param condition defines the trigger related conditions
  10820. */
  10821. constructor(triggerOptions?: any, condition?: Condition);
  10822. /**
  10823. * Execute the action and do nothing.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to trigger several actions once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class CombineAction extends Action {
  10838. /**
  10839. * The list of aggregated animations to run.
  10840. */
  10841. children: Action[];
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param children defines the list of aggregated animations to run
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and executes all the aggregated actions.
  10853. */
  10854. execute(evt: ActionEvent): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to run code (external event) once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class ExecuteCodeAction extends Action {
  10867. /**
  10868. * The callback function to run.
  10869. */
  10870. func: (evt: ActionEvent) => void;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param func defines the callback function to run
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10878. /**
  10879. * Execute the action and run the attached code.
  10880. */
  10881. execute(evt: ActionEvent): void;
  10882. }
  10883. /**
  10884. * This defines an action responsible to set the parent property of the target once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class SetParentAction extends Action {
  10888. private _parent;
  10889. private _target;
  10890. /**
  10891. * Instantiate the action
  10892. * @param triggerOptions defines the trigger options
  10893. * @param target defines the target containing the parent property
  10894. * @param parent defines from where the animation should start (animation frame)
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and set the parent property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. }
  10912. declare module "babylonjs/Actions/actionManager" {
  10913. import { Nullable } from "babylonjs/types";
  10914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10915. import { Scene } from "babylonjs/scene";
  10916. import { IAction } from "babylonjs/Actions/action";
  10917. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10918. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10919. /**
  10920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ActionManager extends AbstractActionManager {
  10925. /**
  10926. * Nothing
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly NothingTrigger: number;
  10930. /**
  10931. * On pick
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnPickTrigger: number;
  10935. /**
  10936. * On left pick
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnLeftPickTrigger: number;
  10940. /**
  10941. * On right pick
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnRightPickTrigger: number;
  10945. /**
  10946. * On center pick
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnCenterPickTrigger: number;
  10950. /**
  10951. * On pick down
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPickDownTrigger: number;
  10955. /**
  10956. * On double pick
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnDoublePickTrigger: number;
  10960. /**
  10961. * On pick up
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPickUpTrigger: number;
  10965. /**
  10966. * On pick out.
  10967. * This trigger will only be raised if you also declared a OnPickDown
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10969. */
  10970. static readonly OnPickOutTrigger: number;
  10971. /**
  10972. * On long press
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10974. */
  10975. static readonly OnLongPressTrigger: number;
  10976. /**
  10977. * On pointer over
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10979. */
  10980. static readonly OnPointerOverTrigger: number;
  10981. /**
  10982. * On pointer out
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly OnPointerOutTrigger: number;
  10986. /**
  10987. * On every frame
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnEveryFrameTrigger: number;
  10991. /**
  10992. * On intersection enter
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnIntersectionEnterTrigger: number;
  10996. /**
  10997. * On intersection exit
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnIntersectionExitTrigger: number;
  11001. /**
  11002. * On key down
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnKeyDownTrigger: number;
  11006. /**
  11007. * On key up
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnKeyUpTrigger: number;
  11011. private _scene;
  11012. /**
  11013. * Creates a new action manager
  11014. * @param scene defines the hosting scene
  11015. */
  11016. constructor(scene: Scene);
  11017. /**
  11018. * Releases all associated resources
  11019. */
  11020. dispose(): void;
  11021. /**
  11022. * Gets hosting scene
  11023. * @returns the hosting scene
  11024. */
  11025. getScene(): Scene;
  11026. /**
  11027. * Does this action manager handles actions of any of the given triggers
  11028. * @param triggers defines the triggers to be tested
  11029. * @return a boolean indicating whether one (or more) of the triggers is handled
  11030. */
  11031. hasSpecificTriggers(triggers: number[]): boolean;
  11032. /**
  11033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11034. * speed.
  11035. * @param triggerA defines the trigger to be tested
  11036. * @param triggerB defines the trigger to be tested
  11037. * @return a boolean indicating whether one (or more) of the triggers is handled
  11038. */
  11039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11040. /**
  11041. * Does this action manager handles actions of a given trigger
  11042. * @param trigger defines the trigger to be tested
  11043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11044. * @return whether the trigger is handled
  11045. */
  11046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11047. /**
  11048. * Does this action manager has pointer triggers
  11049. */
  11050. readonly hasPointerTriggers: boolean;
  11051. /**
  11052. * Does this action manager has pick triggers
  11053. */
  11054. readonly hasPickTriggers: boolean;
  11055. /**
  11056. * Registers an action to this action manager
  11057. * @param action defines the action to be registered
  11058. * @return the action amended (prepared) after registration
  11059. */
  11060. registerAction(action: IAction): Nullable<IAction>;
  11061. /**
  11062. * Unregisters an action to this action manager
  11063. * @param action defines the action to be unregistered
  11064. * @return a boolean indicating whether the action has been unregistered
  11065. */
  11066. unregisterAction(action: IAction): Boolean;
  11067. /**
  11068. * Process a specific trigger
  11069. * @param trigger defines the trigger to process
  11070. * @param evt defines the event details to be processed
  11071. */
  11072. processTrigger(trigger: number, evt?: IActionEvent): void;
  11073. /** @hidden */
  11074. _getEffectiveTarget(target: any, propertyPath: string): any;
  11075. /** @hidden */
  11076. _getProperty(propertyPath: string): string;
  11077. /**
  11078. * Serialize this manager to a JSON object
  11079. * @param name defines the property name to store this manager
  11080. * @returns a JSON representation of this manager
  11081. */
  11082. serialize(name: string): any;
  11083. /**
  11084. * Creates a new ActionManager from a JSON data
  11085. * @param parsedActions defines the JSON data to read from
  11086. * @param object defines the hosting mesh
  11087. * @param scene defines the hosting scene
  11088. */
  11089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11090. /**
  11091. * Get a trigger name by index
  11092. * @param trigger defines the trigger index
  11093. * @returns a trigger name
  11094. */
  11095. static GetTriggerName(trigger: number): string;
  11096. }
  11097. }
  11098. declare module "babylonjs/Culling/ray" {
  11099. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11100. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11104. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11105. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11106. import { Plane } from "babylonjs/Maths/math.plane";
  11107. /**
  11108. * Class representing a ray with position and direction
  11109. */
  11110. export class Ray {
  11111. /** origin point */
  11112. origin: Vector3;
  11113. /** direction */
  11114. direction: Vector3;
  11115. /** length of the ray */
  11116. length: number;
  11117. private static readonly TmpVector3;
  11118. private _tmpRay;
  11119. /**
  11120. * Creates a new ray
  11121. * @param origin origin point
  11122. * @param direction direction
  11123. * @param length length of the ray
  11124. */
  11125. constructor(
  11126. /** origin point */
  11127. origin: Vector3,
  11128. /** direction */
  11129. direction: Vector3,
  11130. /** length of the ray */
  11131. length?: number);
  11132. /**
  11133. * Checks if the ray intersects a box
  11134. * @param minimum bound of the box
  11135. * @param maximum bound of the box
  11136. * @param intersectionTreshold extra extend to be added to the box in all direction
  11137. * @returns if the box was hit
  11138. */
  11139. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11140. /**
  11141. * Checks if the ray intersects a box
  11142. * @param box the bounding box to check
  11143. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11144. * @returns if the box was hit
  11145. */
  11146. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11147. /**
  11148. * If the ray hits a sphere
  11149. * @param sphere the bounding sphere to check
  11150. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11151. * @returns true if it hits the sphere
  11152. */
  11153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * If the ray hits a triange
  11156. * @param vertex0 triangle vertex
  11157. * @param vertex1 triangle vertex
  11158. * @param vertex2 triangle vertex
  11159. * @returns intersection information if hit
  11160. */
  11161. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11162. /**
  11163. * Checks if ray intersects a plane
  11164. * @param plane the plane to check
  11165. * @returns the distance away it was hit
  11166. */
  11167. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11168. /**
  11169. * Calculate the intercept of a ray on a given axis
  11170. * @param axis to check 'x' | 'y' | 'z'
  11171. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11172. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11173. */
  11174. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11175. /**
  11176. * Checks if ray intersects a mesh
  11177. * @param mesh the mesh to check
  11178. * @param fastCheck if only the bounding box should checked
  11179. * @returns picking info of the intersecton
  11180. */
  11181. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11182. /**
  11183. * Checks if ray intersects a mesh
  11184. * @param meshes the meshes to check
  11185. * @param fastCheck if only the bounding box should checked
  11186. * @param results array to store result in
  11187. * @returns Array of picking infos
  11188. */
  11189. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11190. private _comparePickingInfo;
  11191. private static smallnum;
  11192. private static rayl;
  11193. /**
  11194. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11195. * @param sega the first point of the segment to test the intersection against
  11196. * @param segb the second point of the segment to test the intersection against
  11197. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11198. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11199. */
  11200. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11201. /**
  11202. * Update the ray from viewport position
  11203. * @param x position
  11204. * @param y y position
  11205. * @param viewportWidth viewport width
  11206. * @param viewportHeight viewport height
  11207. * @param world world matrix
  11208. * @param view view matrix
  11209. * @param projection projection matrix
  11210. * @returns this ray updated
  11211. */
  11212. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Creates a ray with origin and direction of 0,0,0
  11215. * @returns the new ray
  11216. */
  11217. static Zero(): Ray;
  11218. /**
  11219. * Creates a new ray from screen space and viewport
  11220. * @param x position
  11221. * @param y y position
  11222. * @param viewportWidth viewport width
  11223. * @param viewportHeight viewport height
  11224. * @param world world matrix
  11225. * @param view view matrix
  11226. * @param projection projection matrix
  11227. * @returns new ray
  11228. */
  11229. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11230. /**
  11231. * 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
  11232. * transformed to the given world matrix.
  11233. * @param origin The origin point
  11234. * @param end The end point
  11235. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11236. * @returns the new ray
  11237. */
  11238. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11239. /**
  11240. * Transforms a ray by a matrix
  11241. * @param ray ray to transform
  11242. * @param matrix matrix to apply
  11243. * @returns the resulting new ray
  11244. */
  11245. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * Transforms a ray by a matrix
  11248. * @param ray ray to transform
  11249. * @param matrix matrix to apply
  11250. * @param result ray to store result in
  11251. */
  11252. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11253. /**
  11254. * Unproject a ray from screen space to object space
  11255. * @param sourceX defines the screen space x coordinate to use
  11256. * @param sourceY defines the screen space y coordinate to use
  11257. * @param viewportWidth defines the current width of the viewport
  11258. * @param viewportHeight defines the current height of the viewport
  11259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11260. * @param view defines the view matrix to use
  11261. * @param projection defines the projection matrix to use
  11262. */
  11263. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11264. }
  11265. /**
  11266. * Type used to define predicate used to select faces when a mesh intersection is detected
  11267. */
  11268. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11269. module "babylonjs/scene" {
  11270. interface Scene {
  11271. /** @hidden */
  11272. _tempPickingRay: Nullable<Ray>;
  11273. /** @hidden */
  11274. _cachedRayForTransform: Ray;
  11275. /** @hidden */
  11276. _pickWithRayInverseMatrix: Matrix;
  11277. /** @hidden */
  11278. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11281. }
  11282. }
  11283. }
  11284. declare module "babylonjs/sceneComponent" {
  11285. import { Scene } from "babylonjs/scene";
  11286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11288. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11289. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Camera } from "babylonjs/Cameras/camera";
  11292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11293. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11294. import { AbstractScene } from "babylonjs/abstractScene";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. /**
  11297. * Groups all the scene component constants in one place to ease maintenance.
  11298. * @hidden
  11299. */
  11300. export class SceneComponentConstants {
  11301. static readonly NAME_EFFECTLAYER: string;
  11302. static readonly NAME_LAYER: string;
  11303. static readonly NAME_LENSFLARESYSTEM: string;
  11304. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11305. static readonly NAME_PARTICLESYSTEM: string;
  11306. static readonly NAME_GAMEPAD: string;
  11307. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11308. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11309. static readonly NAME_DEPTHRENDERER: string;
  11310. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11311. static readonly NAME_SPRITE: string;
  11312. static readonly NAME_OUTLINERENDERER: string;
  11313. static readonly NAME_PROCEDURALTEXTURE: string;
  11314. static readonly NAME_SHADOWGENERATOR: string;
  11315. static readonly NAME_OCTREE: string;
  11316. static readonly NAME_PHYSICSENGINE: string;
  11317. static readonly NAME_AUDIO: string;
  11318. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11319. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11320. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11321. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11322. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11323. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11324. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11325. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11326. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11327. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11328. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11329. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11330. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11331. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11332. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11333. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11334. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11336. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11337. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11338. static readonly STEP_AFTERRENDER_AUDIO: number;
  11339. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11341. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11344. static readonly STEP_POINTERMOVE_SPRITE: number;
  11345. static readonly STEP_POINTERDOWN_SPRITE: number;
  11346. static readonly STEP_POINTERUP_SPRITE: number;
  11347. }
  11348. /**
  11349. * This represents a scene component.
  11350. *
  11351. * This is used to decouple the dependency the scene is having on the different workloads like
  11352. * layers, post processes...
  11353. */
  11354. export interface ISceneComponent {
  11355. /**
  11356. * The name of the component. Each component must have a unique name.
  11357. */
  11358. name: string;
  11359. /**
  11360. * The scene the component belongs to.
  11361. */
  11362. scene: Scene;
  11363. /**
  11364. * Register the component to one instance of a scene.
  11365. */
  11366. register(): void;
  11367. /**
  11368. * Rebuilds the elements related to this component in case of
  11369. * context lost for instance.
  11370. */
  11371. rebuild(): void;
  11372. /**
  11373. * Disposes the component and the associated ressources.
  11374. */
  11375. dispose(): void;
  11376. }
  11377. /**
  11378. * This represents a SERIALIZABLE scene component.
  11379. *
  11380. * This extends Scene Component to add Serialization methods on top.
  11381. */
  11382. export interface ISceneSerializableComponent extends ISceneComponent {
  11383. /**
  11384. * Adds all the elements from the container to the scene
  11385. * @param container the container holding the elements
  11386. */
  11387. addFromContainer(container: AbstractScene): void;
  11388. /**
  11389. * Removes all the elements in the container from the scene
  11390. * @param container contains the elements to remove
  11391. * @param dispose if the removed element should be disposed (default: false)
  11392. */
  11393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11394. /**
  11395. * Serializes the component data to the specified json object
  11396. * @param serializationObject The object to serialize to
  11397. */
  11398. serialize(serializationObject: any): void;
  11399. }
  11400. /**
  11401. * Strong typing of a Mesh related stage step action
  11402. */
  11403. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11404. /**
  11405. * Strong typing of a Evaluate Sub Mesh related stage step action
  11406. */
  11407. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11408. /**
  11409. * Strong typing of a Active Mesh related stage step action
  11410. */
  11411. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11412. /**
  11413. * Strong typing of a Camera related stage step action
  11414. */
  11415. export type CameraStageAction = (camera: Camera) => void;
  11416. /**
  11417. * Strong typing of a Camera Frame buffer related stage step action
  11418. */
  11419. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11420. /**
  11421. * Strong typing of a Render Target related stage step action
  11422. */
  11423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11424. /**
  11425. * Strong typing of a RenderingGroup related stage step action
  11426. */
  11427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11428. /**
  11429. * Strong typing of a Mesh Render related stage step action
  11430. */
  11431. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11432. /**
  11433. * Strong typing of a simple stage step action
  11434. */
  11435. export type SimpleStageAction = () => void;
  11436. /**
  11437. * Strong typing of a render target action.
  11438. */
  11439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11440. /**
  11441. * Strong typing of a pointer move action.
  11442. */
  11443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11444. /**
  11445. * Strong typing of a pointer up/down action.
  11446. */
  11447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11448. /**
  11449. * Representation of a stage in the scene (Basically a list of ordered steps)
  11450. * @hidden
  11451. */
  11452. export class Stage<T extends Function> extends Array<{
  11453. index: number;
  11454. component: ISceneComponent;
  11455. action: T;
  11456. }> {
  11457. /**
  11458. * Hide ctor from the rest of the world.
  11459. * @param items The items to add.
  11460. */
  11461. private constructor();
  11462. /**
  11463. * Creates a new Stage.
  11464. * @returns A new instance of a Stage
  11465. */
  11466. static Create<T extends Function>(): Stage<T>;
  11467. /**
  11468. * Registers a step in an ordered way in the targeted stage.
  11469. * @param index Defines the position to register the step in
  11470. * @param component Defines the component attached to the step
  11471. * @param action Defines the action to launch during the step
  11472. */
  11473. registerStep(index: number, component: ISceneComponent, action: T): void;
  11474. /**
  11475. * Clears all the steps from the stage.
  11476. */
  11477. clear(): void;
  11478. }
  11479. }
  11480. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11481. import { Nullable } from "babylonjs/types";
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Scene } from "babylonjs/scene";
  11484. import { Sprite } from "babylonjs/Sprites/sprite";
  11485. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11486. import { Ray } from "babylonjs/Culling/ray";
  11487. import { Camera } from "babylonjs/Cameras/camera";
  11488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11489. import { ISceneComponent } from "babylonjs/sceneComponent";
  11490. module "babylonjs/scene" {
  11491. interface Scene {
  11492. /** @hidden */
  11493. _pointerOverSprite: Nullable<Sprite>;
  11494. /** @hidden */
  11495. _pickedDownSprite: Nullable<Sprite>;
  11496. /** @hidden */
  11497. _tempSpritePickingRay: Nullable<Ray>;
  11498. /**
  11499. * All of the sprite managers added to this scene
  11500. * @see http://doc.babylonjs.com/babylon101/sprites
  11501. */
  11502. spriteManagers: Array<ISpriteManager>;
  11503. /**
  11504. * An event triggered when sprites rendering is about to start
  11505. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11506. */
  11507. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11508. /**
  11509. * An event triggered when sprites rendering is done
  11510. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11511. */
  11512. onAfterSpritesRenderingObservable: Observable<Scene>;
  11513. /** @hidden */
  11514. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11515. /** Launch a ray to try to pick a sprite in the scene
  11516. * @param x position on screen
  11517. * @param y position on screen
  11518. * @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
  11519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11521. * @returns a PickingInfo
  11522. */
  11523. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11524. /** Use the given ray to pick a sprite in the scene
  11525. * @param ray The ray (in world space) to use to pick meshes
  11526. * @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
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** @hidden */
  11533. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11534. /** Launch a ray to try to pick sprites in the scene
  11535. * @param x position on screen
  11536. * @param y position on screen
  11537. * @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
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo array
  11540. */
  11541. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Use the given ray to pick sprites in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @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
  11545. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11546. * @returns a PickingInfo array
  11547. */
  11548. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Force the sprite under the pointer
  11551. * @param sprite defines the sprite to use
  11552. */
  11553. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11554. /**
  11555. * Gets the sprite under the pointer
  11556. * @returns a Sprite or null if no sprite is under the pointer
  11557. */
  11558. getPointerOverSprite(): Nullable<Sprite>;
  11559. }
  11560. }
  11561. /**
  11562. * Defines the sprite scene component responsible to manage sprites
  11563. * in a given scene.
  11564. */
  11565. export class SpriteSceneComponent implements ISceneComponent {
  11566. /**
  11567. * The component name helpfull to identify the component in the list of scene components.
  11568. */
  11569. readonly name: string;
  11570. /**
  11571. * The scene the component belongs to.
  11572. */
  11573. scene: Scene;
  11574. /** @hidden */
  11575. private _spritePredicate;
  11576. /**
  11577. * Creates a new instance of the component for the given scene
  11578. * @param scene Defines the scene to register the component in
  11579. */
  11580. constructor(scene: Scene);
  11581. /**
  11582. * Registers the component in a given scene
  11583. */
  11584. register(): void;
  11585. /**
  11586. * Rebuilds the elements related to this component in case of
  11587. * context lost for instance.
  11588. */
  11589. rebuild(): void;
  11590. /**
  11591. * Disposes the component and the associated ressources.
  11592. */
  11593. dispose(): void;
  11594. private _pickSpriteButKeepRay;
  11595. private _pointerMove;
  11596. private _pointerDown;
  11597. private _pointerUp;
  11598. }
  11599. }
  11600. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11601. /** @hidden */
  11602. export var fogFragmentDeclaration: {
  11603. name: string;
  11604. shader: string;
  11605. };
  11606. }
  11607. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11608. /** @hidden */
  11609. export var fogFragment: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module "babylonjs/Shaders/sprites.fragment" {
  11615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module "babylonjs/Shaders/sprites.vertex" {
  11631. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11632. /** @hidden */
  11633. export var spritesVertexShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module "babylonjs/Sprites/spriteManager" {
  11639. import { IDisposable, Scene } from "babylonjs/scene";
  11640. import { Nullable } from "babylonjs/types";
  11641. import { Observable } from "babylonjs/Misc/observable";
  11642. import { Sprite } from "babylonjs/Sprites/sprite";
  11643. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11644. import { Camera } from "babylonjs/Cameras/camera";
  11645. import { Texture } from "babylonjs/Materials/Textures/texture";
  11646. import "babylonjs/Shaders/sprites.fragment";
  11647. import "babylonjs/Shaders/sprites.vertex";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. /**
  11650. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11651. */
  11652. export interface ISpriteManager extends IDisposable {
  11653. /**
  11654. * Restricts the camera to viewing objects with the same layerMask.
  11655. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11656. */
  11657. layerMask: number;
  11658. /**
  11659. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11660. */
  11661. isPickable: boolean;
  11662. /**
  11663. * Specifies the rendering group id for this mesh (0 by default)
  11664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11665. */
  11666. renderingGroupId: number;
  11667. /**
  11668. * Defines the list of sprites managed by the manager.
  11669. */
  11670. sprites: Array<Sprite>;
  11671. /**
  11672. * Tests the intersection of a sprite with a specific ray.
  11673. * @param ray The ray we are sending to test the collision
  11674. * @param camera The camera space we are sending rays in
  11675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11676. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11677. * @returns picking info or null.
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Renders the list of sprites on screen.
  11690. */
  11691. render(): void;
  11692. }
  11693. /**
  11694. * Class used to manage multiple sprites on the same spritesheet
  11695. * @see http://doc.babylonjs.com/babylon101/sprites
  11696. */
  11697. export class SpriteManager implements ISpriteManager {
  11698. /** defines the manager's name */
  11699. name: string;
  11700. /** Gets the list of sprites */
  11701. sprites: Sprite[];
  11702. /** Gets or sets the rendering group id (0 by default) */
  11703. renderingGroupId: number;
  11704. /** Gets or sets camera layer mask */
  11705. layerMask: number;
  11706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11707. fogEnabled: boolean;
  11708. /** Gets or sets a boolean indicating if the sprites are pickable */
  11709. isPickable: boolean;
  11710. /** Defines the default width of a cell in the spritesheet */
  11711. cellWidth: number;
  11712. /** Defines the default height of a cell in the spritesheet */
  11713. cellHeight: number;
  11714. /** Associative array from JSON sprite data file */
  11715. private _cellData;
  11716. /** Array of sprite names from JSON sprite data file */
  11717. private _spriteMap;
  11718. /** True when packed cell data from JSON file is ready*/
  11719. private _packedAndReady;
  11720. /**
  11721. * An event triggered when the manager is disposed.
  11722. */
  11723. onDisposeObservable: Observable<SpriteManager>;
  11724. private _onDisposeObserver;
  11725. /**
  11726. * Callback called when the manager is disposed
  11727. */
  11728. onDispose: () => void;
  11729. private _capacity;
  11730. private _fromPacked;
  11731. private _spriteTexture;
  11732. private _epsilon;
  11733. private _scene;
  11734. private _vertexData;
  11735. private _buffer;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _effectBase;
  11739. private _effectFog;
  11740. /**
  11741. * Gets or sets the spritesheet texture
  11742. */
  11743. texture: Texture;
  11744. /**
  11745. * Creates a new sprite manager
  11746. * @param name defines the manager's name
  11747. * @param imgUrl defines the sprite sheet url
  11748. * @param capacity defines the maximum allowed number of sprites
  11749. * @param cellSize defines the size of a sprite cell
  11750. * @param scene defines the hosting scene
  11751. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11752. * @param samplingMode defines the smapling mode to use with spritesheet
  11753. * @param fromPacked set to false; do not alter
  11754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11755. */
  11756. constructor(
  11757. /** defines the manager's name */
  11758. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11759. private _makePacked;
  11760. private _appendSpriteVertex;
  11761. /**
  11762. * Intersects the sprites with a ray
  11763. * @param ray defines the ray to intersect with
  11764. * @param camera defines the current active camera
  11765. * @param predicate defines a predicate used to select candidate sprites
  11766. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11767. * @returns null if no hit or a PickingInfo
  11768. */
  11769. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11770. /**
  11771. * Intersects the sprites with a ray
  11772. * @param ray defines the ray to intersect with
  11773. * @param camera defines the current active camera
  11774. * @param predicate defines a predicate used to select candidate sprites
  11775. * @returns null if no hit or a PickingInfo array
  11776. */
  11777. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Render all child sprites
  11780. */
  11781. render(): void;
  11782. /**
  11783. * Release associated resources
  11784. */
  11785. dispose(): void;
  11786. }
  11787. }
  11788. declare module "babylonjs/Sprites/sprite" {
  11789. import { Vector3 } from "babylonjs/Maths/math.vector";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { ActionManager } from "babylonjs/Actions/actionManager";
  11792. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11793. import { Color4 } from "babylonjs/Maths/math.color";
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module "babylonjs/Collisions/pickingInfo" {
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11875. import { Sprite } from "babylonjs/Sprites/sprite";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Information about the result of picking within a scene
  11879. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11880. */
  11881. export class PickingInfo {
  11882. /** @hidden */
  11883. _pickingUnavailable: boolean;
  11884. /**
  11885. * If the pick collided with an object
  11886. */
  11887. hit: boolean;
  11888. /**
  11889. * Distance away where the pick collided
  11890. */
  11891. distance: number;
  11892. /**
  11893. * The location of pick collision
  11894. */
  11895. pickedPoint: Nullable<Vector3>;
  11896. /**
  11897. * The mesh corresponding the the pick collision
  11898. */
  11899. pickedMesh: Nullable<AbstractMesh>;
  11900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11901. bu: number;
  11902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bv: number;
  11904. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11905. faceId: number;
  11906. /** Id of the the submesh that was picked */
  11907. subMeshId: number;
  11908. /** If a sprite was picked, this will be the sprite the pick collided with */
  11909. pickedSprite: Nullable<Sprite>;
  11910. /**
  11911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11912. */
  11913. originMesh: Nullable<AbstractMesh>;
  11914. /**
  11915. * The ray that was used to perform the picking.
  11916. */
  11917. ray: Nullable<Ray>;
  11918. /**
  11919. * Gets the normal correspodning to the face the pick collided with
  11920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11922. * @returns The normal correspodning to the face the pick collided with
  11923. */
  11924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11925. /**
  11926. * Gets the texture coordinates of where the pick occured
  11927. * @returns the vector containing the coordnates of the texture
  11928. */
  11929. getTextureCoordinates(): Nullable<Vector2>;
  11930. }
  11931. }
  11932. declare module "babylonjs/Events/pointerEvents" {
  11933. import { Nullable } from "babylonjs/types";
  11934. import { Vector2 } from "babylonjs/Maths/math.vector";
  11935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11936. import { Ray } from "babylonjs/Culling/ray";
  11937. /**
  11938. * Gather the list of pointer event types as constants.
  11939. */
  11940. export class PointerEventTypes {
  11941. /**
  11942. * 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.
  11943. */
  11944. static readonly POINTERDOWN: number;
  11945. /**
  11946. * The pointerup event is fired when a pointer is no longer active.
  11947. */
  11948. static readonly POINTERUP: number;
  11949. /**
  11950. * The pointermove event is fired when a pointer changes coordinates.
  11951. */
  11952. static readonly POINTERMOVE: number;
  11953. /**
  11954. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11955. */
  11956. static readonly POINTERWHEEL: number;
  11957. /**
  11958. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11959. */
  11960. static readonly POINTERPICK: number;
  11961. /**
  11962. * The pointertap event is fired when a the object has been touched and released without drag.
  11963. */
  11964. static readonly POINTERTAP: number;
  11965. /**
  11966. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11967. */
  11968. static readonly POINTERDOUBLETAP: number;
  11969. }
  11970. /**
  11971. * Base class of pointer info types.
  11972. */
  11973. export class PointerInfoBase {
  11974. /**
  11975. * Defines the type of event (PointerEventTypes)
  11976. */
  11977. type: number;
  11978. /**
  11979. * Defines the related dom event
  11980. */
  11981. event: PointerEvent | MouseWheelEvent;
  11982. /**
  11983. * Instantiates the base class of pointers info.
  11984. * @param type Defines the type of event (PointerEventTypes)
  11985. * @param event Defines the related dom event
  11986. */
  11987. constructor(
  11988. /**
  11989. * Defines the type of event (PointerEventTypes)
  11990. */
  11991. type: number,
  11992. /**
  11993. * Defines the related dom event
  11994. */
  11995. event: PointerEvent | MouseWheelEvent);
  11996. }
  11997. /**
  11998. * This class is used to store pointer related info for the onPrePointerObservable event.
  11999. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12000. */
  12001. export class PointerInfoPre extends PointerInfoBase {
  12002. /**
  12003. * Ray from a pointer if availible (eg. 6dof controller)
  12004. */
  12005. ray: Nullable<Ray>;
  12006. /**
  12007. * Defines the local position of the pointer on the canvas.
  12008. */
  12009. localPosition: Vector2;
  12010. /**
  12011. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12012. */
  12013. skipOnPointerObservable: boolean;
  12014. /**
  12015. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param localX Defines the local x coordinates of the pointer when the event occured
  12019. * @param localY Defines the local y coordinates of the pointer when the event occured
  12020. */
  12021. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12022. }
  12023. /**
  12024. * This type contains all the data related to a pointer event in Babylon.js.
  12025. * 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.
  12026. */
  12027. export class PointerInfo extends PointerInfoBase {
  12028. /**
  12029. * Defines the picking info associated to the info (if any)\
  12030. */
  12031. pickInfo: Nullable<PickingInfo>;
  12032. /**
  12033. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param pickInfo Defines the picking info associated to the info (if any)\
  12037. */
  12038. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12039. /**
  12040. * Defines the picking info associated to the info (if any)\
  12041. */
  12042. pickInfo: Nullable<PickingInfo>);
  12043. }
  12044. /**
  12045. * Data relating to a touch event on the screen.
  12046. */
  12047. export interface PointerTouch {
  12048. /**
  12049. * X coordinate of touch.
  12050. */
  12051. x: number;
  12052. /**
  12053. * Y coordinate of touch.
  12054. */
  12055. y: number;
  12056. /**
  12057. * Id of touch. Unique for each finger.
  12058. */
  12059. pointerId: number;
  12060. /**
  12061. * Event type passed from DOM.
  12062. */
  12063. type: any;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12067. import { Observable } from "babylonjs/Misc/observable";
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */
  12107. _allowCameraRotation: boolean;
  12108. /**
  12109. * Manage the mouse inputs to control the movement of a free camera.
  12110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12111. * @param touchEnabled Defines if touch is enabled or not
  12112. */
  12113. constructor(
  12114. /**
  12115. * Define if touch is enabled in the mouse input
  12116. */
  12117. touchEnabled?: boolean);
  12118. /**
  12119. * Attach the input controls to a specific dom element to get the input from.
  12120. * @param element Defines the element the controls should be listened from
  12121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12122. */
  12123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12124. /**
  12125. * Called on JS contextmenu event.
  12126. * Override this method to provide functionality.
  12127. */
  12128. protected onContextMenu(evt: PointerEvent): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12207. import { Nullable } from "babylonjs/types";
  12208. /**
  12209. * Default Inputs manager for the FreeCamera.
  12210. * It groups all the default supported inputs for ease of use.
  12211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12212. */
  12213. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12214. /**
  12215. * @hidden
  12216. */
  12217. _mouseInput: Nullable<FreeCameraMouseInput>;
  12218. /**
  12219. * Instantiates a new FreeCameraInputsManager.
  12220. * @param camera Defines the camera the inputs belong to
  12221. */
  12222. constructor(camera: FreeCamera);
  12223. /**
  12224. * Add keyboard input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addKeyboard(): FreeCameraInputsManager;
  12228. /**
  12229. * Add mouse input support to the input manager.
  12230. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12231. * @returns the current input manager
  12232. */
  12233. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12234. /**
  12235. * Removes the mouse input support from the manager
  12236. * @returns the current input manager
  12237. */
  12238. removeMouse(): FreeCameraInputsManager;
  12239. /**
  12240. * Add touch input support to the input manager.
  12241. * @returns the current input manager
  12242. */
  12243. addTouch(): FreeCameraInputsManager;
  12244. /**
  12245. * Remove all attached input methods from a camera
  12246. */
  12247. clear(): void;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/freeCamera" {
  12251. import { Vector3 } from "babylonjs/Maths/math.vector";
  12252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12255. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12256. /**
  12257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12258. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12260. */
  12261. export class FreeCamera extends TargetCamera {
  12262. /**
  12263. * Define the collision ellipsoid of the camera.
  12264. * This is helpful to simulate a camera body like the player body around the camera
  12265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12266. */
  12267. ellipsoid: Vector3;
  12268. /**
  12269. * Define an offset for the position of the ellipsoid around the camera.
  12270. * This can be helpful to determine the center of the body near the gravity center of the body
  12271. * instead of its head.
  12272. */
  12273. ellipsoidOffset: Vector3;
  12274. /**
  12275. * Enable or disable collisions of the camera with the rest of the scene objects.
  12276. */
  12277. checkCollisions: boolean;
  12278. /**
  12279. * Enable or disable gravity on the camera.
  12280. */
  12281. applyGravity: boolean;
  12282. /**
  12283. * Define the input manager associated to the camera.
  12284. */
  12285. inputs: FreeCameraInputsManager;
  12286. /**
  12287. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12288. * Higher values reduce sensitivity.
  12289. */
  12290. /**
  12291. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. angularSensibility: number;
  12295. /**
  12296. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12297. */
  12298. keysUp: number[];
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12301. */
  12302. keysDown: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12305. */
  12306. keysLeft: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12309. */
  12310. keysRight: number[];
  12311. /**
  12312. * Event raised when the camera collide with a mesh in the scene.
  12313. */
  12314. onCollide: (collidedMesh: AbstractMesh) => void;
  12315. private _collider;
  12316. private _needMoveForGravity;
  12317. private _oldPosition;
  12318. private _diffPosition;
  12319. private _newPosition;
  12320. /** @hidden */
  12321. _localDirection: Vector3;
  12322. /** @hidden */
  12323. _transformedDirection: Vector3;
  12324. /**
  12325. * Instantiates a Free Camera.
  12326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12327. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12329. * @param name Define the name of the camera in the scene
  12330. * @param position Define the start position of the camera in the scene
  12331. * @param scene Define the scene the camera belongs to
  12332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12335. /**
  12336. * Attached controls to the current camera.
  12337. * @param element Defines the element the controls should be listened from
  12338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12339. */
  12340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12341. /**
  12342. * Detach the current controls from the camera.
  12343. * The camera will stop reacting to inputs.
  12344. * @param element Defines the element to stop listening the inputs from
  12345. */
  12346. detachControl(element: HTMLElement): void;
  12347. private _collisionMask;
  12348. /**
  12349. * Define a collision mask to limit the list of object the camera can collide with
  12350. */
  12351. collisionMask: number;
  12352. /** @hidden */
  12353. _collideWithWorld(displacement: Vector3): void;
  12354. private _onCollisionPositionChange;
  12355. /** @hidden */
  12356. _checkInputs(): void;
  12357. /** @hidden */
  12358. _decideIfNeedsToMove(): boolean;
  12359. /** @hidden */
  12360. _updatePosition(): void;
  12361. /**
  12362. * Destroy the camera and release the current resources hold by it.
  12363. */
  12364. dispose(): void;
  12365. /**
  12366. * Gets the current object class name.
  12367. * @return the class name
  12368. */
  12369. getClassName(): string;
  12370. }
  12371. }
  12372. declare module "babylonjs/Gamepads/gamepad" {
  12373. import { Observable } from "babylonjs/Misc/observable";
  12374. /**
  12375. * Represents a gamepad control stick position
  12376. */
  12377. export class StickValues {
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number;
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number;
  12386. /**
  12387. * Initializes the gamepad x and y control stick values
  12388. * @param x The x component of the gamepad control stick value
  12389. * @param y The y component of the gamepad control stick value
  12390. */
  12391. constructor(
  12392. /**
  12393. * The x component of the control stick
  12394. */
  12395. x: number,
  12396. /**
  12397. * The y component of the control stick
  12398. */
  12399. y: number);
  12400. }
  12401. /**
  12402. * An interface which manages callbacks for gamepad button changes
  12403. */
  12404. export interface GamepadButtonChanges {
  12405. /**
  12406. * Called when a gamepad has been changed
  12407. */
  12408. changed: boolean;
  12409. /**
  12410. * Called when a gamepad press event has been triggered
  12411. */
  12412. pressChanged: boolean;
  12413. /**
  12414. * Called when a touch event has been triggered
  12415. */
  12416. touchChanged: boolean;
  12417. /**
  12418. * Called when a value has changed
  12419. */
  12420. valueChanged: boolean;
  12421. }
  12422. /**
  12423. * Represents a gamepad
  12424. */
  12425. export class Gamepad {
  12426. /**
  12427. * The id of the gamepad
  12428. */
  12429. id: string;
  12430. /**
  12431. * The index of the gamepad
  12432. */
  12433. index: number;
  12434. /**
  12435. * The browser gamepad
  12436. */
  12437. browserGamepad: any;
  12438. /**
  12439. * Specifies what type of gamepad this represents
  12440. */
  12441. type: number;
  12442. private _leftStick;
  12443. private _rightStick;
  12444. /** @hidden */
  12445. _isConnected: boolean;
  12446. private _leftStickAxisX;
  12447. private _leftStickAxisY;
  12448. private _rightStickAxisX;
  12449. private _rightStickAxisY;
  12450. /**
  12451. * Triggered when the left control stick has been changed
  12452. */
  12453. private _onleftstickchanged;
  12454. /**
  12455. * Triggered when the right control stick has been changed
  12456. */
  12457. private _onrightstickchanged;
  12458. /**
  12459. * Represents a gamepad controller
  12460. */
  12461. static GAMEPAD: number;
  12462. /**
  12463. * Represents a generic controller
  12464. */
  12465. static GENERIC: number;
  12466. /**
  12467. * Represents an XBox controller
  12468. */
  12469. static XBOX: number;
  12470. /**
  12471. * Represents a pose-enabled controller
  12472. */
  12473. static POSE_ENABLED: number;
  12474. /**
  12475. * Represents an Dual Shock controller
  12476. */
  12477. static DUALSHOCK: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12586. import { Nullable } from "babylonjs/types";
  12587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12588. import { Scene } from "babylonjs/scene";
  12589. module "babylonjs/Engines/engine" {
  12590. interface Engine {
  12591. /**
  12592. * Creates a raw texture
  12593. * @param data defines the data to store in the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param format defines the format of the data
  12597. * @param generateMipMaps defines if the engine should generate the mip levels
  12598. * @param invertY defines if data must be stored with Y axis inverted
  12599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12600. * @param compression defines the compression used (null by default)
  12601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12602. * @returns the raw texture inside an InternalTexture
  12603. */
  12604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12605. /**
  12606. * Update a raw texture
  12607. * @param texture defines the texture to update
  12608. * @param data defines the data to store in the texture
  12609. * @param format defines the format of the data
  12610. * @param invertY defines if data must be stored with Y axis inverted
  12611. */
  12612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12613. /**
  12614. * Update a raw texture
  12615. * @param texture defines the texture to update
  12616. * @param data defines the data to store in the texture
  12617. * @param format defines the format of the data
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. */
  12622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12623. /**
  12624. * Creates a new raw cube texture
  12625. * @param data defines the array of data to use to create each face
  12626. * @param size defines the size of the textures
  12627. * @param format defines the format of the data
  12628. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12629. * @param generateMipMaps defines if the engine should generate the mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compression used (null by default)
  12633. * @returns the cube texture as an InternalTexture
  12634. */
  12635. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12636. /**
  12637. * Update a raw cube texture
  12638. * @param texture defines the texture to udpdate
  12639. * @param data defines the data to store
  12640. * @param format defines the data format
  12641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw cube texture
  12647. * @param texture defines the texture to udpdate
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @param compression defines the compression used (null by default)
  12653. */
  12654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12655. /**
  12656. * Update a raw cube texture
  12657. * @param texture defines the texture to udpdate
  12658. * @param data defines the data to store
  12659. * @param format defines the data format
  12660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12661. * @param invertY defines if data must be stored with Y axis inverted
  12662. * @param compression defines the compression used (null by default)
  12663. * @param level defines which level of the texture to update
  12664. */
  12665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @returns the cube texture as an InternalTexture
  12679. */
  12680. 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;
  12681. /**
  12682. * Creates a new raw cube texture from a specified url
  12683. * @param url defines the url where the data is located
  12684. * @param scene defines the current scene
  12685. * @param size defines the size of the textures
  12686. * @param format defines the format of the data
  12687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12688. * @param noMipmap defines if the engine should avoid generating the mip levels
  12689. * @param callback defines a callback used to extract texture data from loaded data
  12690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12691. * @param onLoad defines a callback called when texture is loaded
  12692. * @param onError defines a callback called if there is an error
  12693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12694. * @param invertY defines if data must be stored with Y axis inverted
  12695. * @returns the cube texture as an InternalTexture
  12696. */
  12697. 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;
  12698. /**
  12699. * Creates a new raw 3D texture
  12700. * @param data defines the data used to create the texture
  12701. * @param width defines the width of the texture
  12702. * @param height defines the height of the texture
  12703. * @param depth defines the depth of the texture
  12704. * @param format defines the format of the texture
  12705. * @param generateMipMaps defines if the engine must generate mip levels
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12708. * @param compression defines the compressed used (can be null)
  12709. * @param textureType defines the compressed used (can be null)
  12710. * @returns a new raw 3D texture (stored in an InternalTexture)
  12711. */
  12712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12713. /**
  12714. * Update a raw 3D texture
  12715. * @param texture defines the texture to update
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. */
  12720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12721. /**
  12722. * Update a raw 3D texture
  12723. * @param texture defines the texture to update
  12724. * @param data defines the data to store
  12725. * @param format defines the data format
  12726. * @param invertY defines if data must be stored with Y axis inverted
  12727. * @param compression defines the used compression (can be null)
  12728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12729. */
  12730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12731. }
  12732. }
  12733. }
  12734. declare module "babylonjs/Materials/Textures/rawTexture" {
  12735. import { Scene } from "babylonjs/scene";
  12736. import { Texture } from "babylonjs/Materials/Textures/texture";
  12737. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12738. /**
  12739. * Raw texture can help creating a texture directly from an array of data.
  12740. * This can be super useful if you either get the data from an uncompressed source or
  12741. * if you wish to create your texture pixel by pixel.
  12742. */
  12743. export class RawTexture extends Texture {
  12744. /**
  12745. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12746. */
  12747. format: number;
  12748. private _engine;
  12749. /**
  12750. * Instantiates a new RawTexture.
  12751. * Raw texture can help creating a texture directly from an array of data.
  12752. * This can be super useful if you either get the data from an uncompressed source or
  12753. * if you wish to create your texture pixel by pixel.
  12754. * @param data define the array of data to use to create the texture
  12755. * @param width define the width of the texture
  12756. * @param height define the height of the texture
  12757. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12758. * @param scene define the scene the texture belongs to
  12759. * @param generateMipMaps define whether mip maps should be generated or not
  12760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12762. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12763. */
  12764. constructor(data: ArrayBufferView, width: number, height: number,
  12765. /**
  12766. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12767. */
  12768. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12769. /**
  12770. * Updates the texture underlying data.
  12771. * @param data Define the new data of the texture
  12772. */
  12773. update(data: ArrayBufferView): void;
  12774. /**
  12775. * Creates a luminance texture from some data.
  12776. * @param data Define the texture data
  12777. * @param width Define the width of the texture
  12778. * @param height Define the height of the texture
  12779. * @param scene Define the scene the texture belongs to
  12780. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12781. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12782. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12783. * @returns the luminance texture
  12784. */
  12785. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12786. /**
  12787. * Creates a luminance alpha texture from some data.
  12788. * @param data Define the texture data
  12789. * @param width Define the width of the texture
  12790. * @param height Define the height of the texture
  12791. * @param scene Define the scene the texture belongs to
  12792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12795. * @returns the luminance alpha texture
  12796. */
  12797. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12798. /**
  12799. * Creates an alpha texture from some data.
  12800. * @param data Define the texture data
  12801. * @param width Define the width of the texture
  12802. * @param height Define the height of the texture
  12803. * @param scene Define the scene the texture belongs to
  12804. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12807. * @returns the alpha texture
  12808. */
  12809. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12810. /**
  12811. * Creates a RGB texture from some data.
  12812. * @param data Define the texture data
  12813. * @param width Define the width of the texture
  12814. * @param height Define the height of the texture
  12815. * @param scene Define the scene the texture belongs to
  12816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12819. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12820. * @returns the RGB alpha texture
  12821. */
  12822. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12823. /**
  12824. * Creates a RGBA texture from some data.
  12825. * @param data Define the texture data
  12826. * @param width Define the width of the texture
  12827. * @param height Define the height of the texture
  12828. * @param scene Define the scene the texture belongs to
  12829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12833. * @returns the RGBA texture
  12834. */
  12835. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12836. /**
  12837. * Creates a R texture from some data.
  12838. * @param data Define the texture data
  12839. * @param width Define the width of the texture
  12840. * @param height Define the height of the texture
  12841. * @param scene Define the scene the texture belongs to
  12842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12845. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12846. * @returns the R texture
  12847. */
  12848. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12849. }
  12850. }
  12851. declare module "babylonjs/Maths/math.size" {
  12852. /**
  12853. * Interface for the size containing width and height
  12854. */
  12855. export interface ISize {
  12856. /**
  12857. * Width
  12858. */
  12859. width: number;
  12860. /**
  12861. * Heighht
  12862. */
  12863. height: number;
  12864. }
  12865. /**
  12866. * Size containing widht and height
  12867. */
  12868. export class Size implements ISize {
  12869. /**
  12870. * Width
  12871. */
  12872. width: number;
  12873. /**
  12874. * Height
  12875. */
  12876. height: number;
  12877. /**
  12878. * Creates a Size object from the given width and height (floats).
  12879. * @param width width of the new size
  12880. * @param height height of the new size
  12881. */
  12882. constructor(width: number, height: number);
  12883. /**
  12884. * Returns a string with the Size width and height
  12885. * @returns a string with the Size width and height
  12886. */
  12887. toString(): string;
  12888. /**
  12889. * "Size"
  12890. * @returns the string "Size"
  12891. */
  12892. getClassName(): string;
  12893. /**
  12894. * Returns the Size hash code.
  12895. * @returns a hash code for a unique width and height
  12896. */
  12897. getHashCode(): number;
  12898. /**
  12899. * Updates the current size from the given one.
  12900. * @param src the given size
  12901. */
  12902. copyFrom(src: Size): void;
  12903. /**
  12904. * Updates in place the current Size from the given floats.
  12905. * @param width width of the new size
  12906. * @param height height of the new size
  12907. * @returns the updated Size.
  12908. */
  12909. copyFromFloats(width: number, height: number): Size;
  12910. /**
  12911. * Updates in place the current Size from the given floats.
  12912. * @param width width to set
  12913. * @param height height to set
  12914. * @returns the updated Size.
  12915. */
  12916. set(width: number, height: number): Size;
  12917. /**
  12918. * Multiplies the width and height by numbers
  12919. * @param w factor to multiple the width by
  12920. * @param h factor to multiple the height by
  12921. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12922. */
  12923. multiplyByFloats(w: number, h: number): Size;
  12924. /**
  12925. * Clones the size
  12926. * @returns a new Size copied from the given one.
  12927. */
  12928. clone(): Size;
  12929. /**
  12930. * True if the current Size and the given one width and height are strictly equal.
  12931. * @param other the other size to compare against
  12932. * @returns True if the current Size and the given one width and height are strictly equal.
  12933. */
  12934. equals(other: Size): boolean;
  12935. /**
  12936. * The surface of the Size : width * height (float).
  12937. */
  12938. readonly surface: number;
  12939. /**
  12940. * Create a new size of zero
  12941. * @returns a new Size set to (0.0, 0.0)
  12942. */
  12943. static Zero(): Size;
  12944. /**
  12945. * Sums the width and height of two sizes
  12946. * @param otherSize size to add to this size
  12947. * @returns a new Size set as the addition result of the current Size and the given one.
  12948. */
  12949. add(otherSize: Size): Size;
  12950. /**
  12951. * Subtracts the width and height of two
  12952. * @param otherSize size to subtract to this size
  12953. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12954. */
  12955. subtract(otherSize: Size): Size;
  12956. /**
  12957. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12958. * @param start starting size to lerp between
  12959. * @param end end size to lerp between
  12960. * @param amount amount to lerp between the start and end values
  12961. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12962. */
  12963. static Lerp(start: Size, end: Size, amount: number): Size;
  12964. }
  12965. }
  12966. declare module "babylonjs/Animations/runtimeAnimation" {
  12967. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12968. import { Animatable } from "babylonjs/Animations/animatable";
  12969. import { Scene } from "babylonjs/scene";
  12970. /**
  12971. * Defines a runtime animation
  12972. */
  12973. export class RuntimeAnimation {
  12974. private _events;
  12975. /**
  12976. * The current frame of the runtime animation
  12977. */
  12978. private _currentFrame;
  12979. /**
  12980. * The animation used by the runtime animation
  12981. */
  12982. private _animation;
  12983. /**
  12984. * The target of the runtime animation
  12985. */
  12986. private _target;
  12987. /**
  12988. * The initiating animatable
  12989. */
  12990. private _host;
  12991. /**
  12992. * The original value of the runtime animation
  12993. */
  12994. private _originalValue;
  12995. /**
  12996. * The original blend value of the runtime animation
  12997. */
  12998. private _originalBlendValue;
  12999. /**
  13000. * The offsets cache of the runtime animation
  13001. */
  13002. private _offsetsCache;
  13003. /**
  13004. * The high limits cache of the runtime animation
  13005. */
  13006. private _highLimitsCache;
  13007. /**
  13008. * Specifies if the runtime animation has been stopped
  13009. */
  13010. private _stopped;
  13011. /**
  13012. * The blending factor of the runtime animation
  13013. */
  13014. private _blendingFactor;
  13015. /**
  13016. * The BabylonJS scene
  13017. */
  13018. private _scene;
  13019. /**
  13020. * The current value of the runtime animation
  13021. */
  13022. private _currentValue;
  13023. /** @hidden */
  13024. _animationState: _IAnimationState;
  13025. /**
  13026. * The active target of the runtime animation
  13027. */
  13028. private _activeTargets;
  13029. private _currentActiveTarget;
  13030. private _directTarget;
  13031. /**
  13032. * The target path of the runtime animation
  13033. */
  13034. private _targetPath;
  13035. /**
  13036. * The weight of the runtime animation
  13037. */
  13038. private _weight;
  13039. /**
  13040. * The ratio offset of the runtime animation
  13041. */
  13042. private _ratioOffset;
  13043. /**
  13044. * The previous delay of the runtime animation
  13045. */
  13046. private _previousDelay;
  13047. /**
  13048. * The previous ratio of the runtime animation
  13049. */
  13050. private _previousRatio;
  13051. private _enableBlending;
  13052. private _keys;
  13053. private _minFrame;
  13054. private _maxFrame;
  13055. private _minValue;
  13056. private _maxValue;
  13057. private _targetIsArray;
  13058. /**
  13059. * Gets the current frame of the runtime animation
  13060. */
  13061. readonly currentFrame: number;
  13062. /**
  13063. * Gets the weight of the runtime animation
  13064. */
  13065. readonly weight: number;
  13066. /**
  13067. * Gets the current value of the runtime animation
  13068. */
  13069. readonly currentValue: any;
  13070. /**
  13071. * Gets the target path of the runtime animation
  13072. */
  13073. readonly targetPath: string;
  13074. /**
  13075. * Gets the actual target of the runtime animation
  13076. */
  13077. readonly target: any;
  13078. /** @hidden */
  13079. _onLoop: () => void;
  13080. /**
  13081. * Create a new RuntimeAnimation object
  13082. * @param target defines the target of the animation
  13083. * @param animation defines the source animation object
  13084. * @param scene defines the hosting scene
  13085. * @param host defines the initiating Animatable
  13086. */
  13087. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13088. private _preparePath;
  13089. /**
  13090. * Gets the animation from the runtime animation
  13091. */
  13092. readonly animation: Animation;
  13093. /**
  13094. * Resets the runtime animation to the beginning
  13095. * @param restoreOriginal defines whether to restore the target property to the original value
  13096. */
  13097. reset(restoreOriginal?: boolean): void;
  13098. /**
  13099. * Specifies if the runtime animation is stopped
  13100. * @returns Boolean specifying if the runtime animation is stopped
  13101. */
  13102. isStopped(): boolean;
  13103. /**
  13104. * Disposes of the runtime animation
  13105. */
  13106. dispose(): void;
  13107. /**
  13108. * Apply the interpolated value to the target
  13109. * @param currentValue defines the value computed by the animation
  13110. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13111. */
  13112. setValue(currentValue: any, weight: number): void;
  13113. private _getOriginalValues;
  13114. private _setValue;
  13115. /**
  13116. * Gets the loop pmode of the runtime animation
  13117. * @returns Loop Mode
  13118. */
  13119. private _getCorrectLoopMode;
  13120. /**
  13121. * Move the current animation to a given frame
  13122. * @param frame defines the frame to move to
  13123. */
  13124. goToFrame(frame: number): void;
  13125. /**
  13126. * @hidden Internal use only
  13127. */
  13128. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13129. /**
  13130. * Execute the current animation
  13131. * @param delay defines the delay to add to the current frame
  13132. * @param from defines the lower bound of the animation range
  13133. * @param to defines the upper bound of the animation range
  13134. * @param loop defines if the current animation must loop
  13135. * @param speedRatio defines the current speed ratio
  13136. * @param weight defines the weight of the animation (default is -1 so no weight)
  13137. * @param onLoop optional callback called when animation loops
  13138. * @returns a boolean indicating if the animation is running
  13139. */
  13140. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13141. }
  13142. }
  13143. declare module "babylonjs/Animations/animatable" {
  13144. import { Animation } from "babylonjs/Animations/animation";
  13145. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13146. import { Nullable } from "babylonjs/types";
  13147. import { Observable } from "babylonjs/Misc/observable";
  13148. import { Scene } from "babylonjs/scene";
  13149. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13150. import { Node } from "babylonjs/node";
  13151. /**
  13152. * Class used to store an actual running animation
  13153. */
  13154. export class Animatable {
  13155. /** defines the target object */
  13156. target: any;
  13157. /** defines the starting frame number (default is 0) */
  13158. fromFrame: number;
  13159. /** defines the ending frame number (default is 100) */
  13160. toFrame: number;
  13161. /** defines if the animation must loop (default is false) */
  13162. loopAnimation: boolean;
  13163. /** defines a callback to call when animation ends if it is not looping */
  13164. onAnimationEnd?: (() => void) | null | undefined;
  13165. /** defines a callback to call when animation loops */
  13166. onAnimationLoop?: (() => void) | null | undefined;
  13167. private _localDelayOffset;
  13168. private _pausedDelay;
  13169. private _runtimeAnimations;
  13170. private _paused;
  13171. private _scene;
  13172. private _speedRatio;
  13173. private _weight;
  13174. private _syncRoot;
  13175. /**
  13176. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13177. * This will only apply for non looping animation (default is true)
  13178. */
  13179. disposeOnEnd: boolean;
  13180. /**
  13181. * Gets a boolean indicating if the animation has started
  13182. */
  13183. animationStarted: boolean;
  13184. /**
  13185. * Observer raised when the animation ends
  13186. */
  13187. onAnimationEndObservable: Observable<Animatable>;
  13188. /**
  13189. * Observer raised when the animation loops
  13190. */
  13191. onAnimationLoopObservable: Observable<Animatable>;
  13192. /**
  13193. * Gets the root Animatable used to synchronize and normalize animations
  13194. */
  13195. readonly syncRoot: Nullable<Animatable>;
  13196. /**
  13197. * Gets the current frame of the first RuntimeAnimation
  13198. * Used to synchronize Animatables
  13199. */
  13200. readonly masterFrame: number;
  13201. /**
  13202. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13203. */
  13204. weight: number;
  13205. /**
  13206. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13207. */
  13208. speedRatio: number;
  13209. /**
  13210. * Creates a new Animatable
  13211. * @param scene defines the hosting scene
  13212. * @param target defines the target object
  13213. * @param fromFrame defines the starting frame number (default is 0)
  13214. * @param toFrame defines the ending frame number (default is 100)
  13215. * @param loopAnimation defines if the animation must loop (default is false)
  13216. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13217. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13218. * @param animations defines a group of animation to add to the new Animatable
  13219. * @param onAnimationLoop defines a callback to call when animation loops
  13220. */
  13221. constructor(scene: Scene,
  13222. /** defines the target object */
  13223. target: any,
  13224. /** defines the starting frame number (default is 0) */
  13225. fromFrame?: number,
  13226. /** defines the ending frame number (default is 100) */
  13227. toFrame?: number,
  13228. /** defines if the animation must loop (default is false) */
  13229. loopAnimation?: boolean, speedRatio?: number,
  13230. /** defines a callback to call when animation ends if it is not looping */
  13231. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13232. /** defines a callback to call when animation loops */
  13233. onAnimationLoop?: (() => void) | null | undefined);
  13234. /**
  13235. * Synchronize and normalize current Animatable with a source Animatable
  13236. * This is useful when using animation weights and when animations are not of the same length
  13237. * @param root defines the root Animatable to synchronize with
  13238. * @returns the current Animatable
  13239. */
  13240. syncWith(root: Animatable): Animatable;
  13241. /**
  13242. * Gets the list of runtime animations
  13243. * @returns an array of RuntimeAnimation
  13244. */
  13245. getAnimations(): RuntimeAnimation[];
  13246. /**
  13247. * Adds more animations to the current animatable
  13248. * @param target defines the target of the animations
  13249. * @param animations defines the new animations to add
  13250. */
  13251. appendAnimations(target: any, animations: Animation[]): void;
  13252. /**
  13253. * Gets the source animation for a specific property
  13254. * @param property defines the propertyu to look for
  13255. * @returns null or the source animation for the given property
  13256. */
  13257. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13258. /**
  13259. * Gets the runtime animation for a specific property
  13260. * @param property defines the propertyu to look for
  13261. * @returns null or the runtime animation for the given property
  13262. */
  13263. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13264. /**
  13265. * Resets the animatable to its original state
  13266. */
  13267. reset(): void;
  13268. /**
  13269. * Allows the animatable to blend with current running animations
  13270. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13271. * @param blendingSpeed defines the blending speed to use
  13272. */
  13273. enableBlending(blendingSpeed: number): void;
  13274. /**
  13275. * Disable animation blending
  13276. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13277. */
  13278. disableBlending(): void;
  13279. /**
  13280. * Jump directly to a given frame
  13281. * @param frame defines the frame to jump to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * Pause the animation
  13286. */
  13287. pause(): void;
  13288. /**
  13289. * Restart the animation
  13290. */
  13291. restart(): void;
  13292. private _raiseOnAnimationEnd;
  13293. /**
  13294. * Stop and delete the current animation
  13295. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13296. * @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)
  13297. */
  13298. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13299. /**
  13300. * Wait asynchronously for the animation to end
  13301. * @returns a promise which will be fullfilled when the animation ends
  13302. */
  13303. waitAsync(): Promise<Animatable>;
  13304. /** @hidden */
  13305. _animate(delay: number): boolean;
  13306. }
  13307. module "babylonjs/scene" {
  13308. interface Scene {
  13309. /** @hidden */
  13310. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13311. /** @hidden */
  13312. _processLateAnimationBindingsForMatrices(holder: {
  13313. totalWeight: number;
  13314. animations: RuntimeAnimation[];
  13315. originalValue: Matrix;
  13316. }): any;
  13317. /** @hidden */
  13318. _processLateAnimationBindingsForQuaternions(holder: {
  13319. totalWeight: number;
  13320. animations: RuntimeAnimation[];
  13321. originalValue: Quaternion;
  13322. }, refQuaternion: Quaternion): Quaternion;
  13323. /** @hidden */
  13324. _processLateAnimationBindings(): void;
  13325. /**
  13326. * Will start the animation sequence of a given target
  13327. * @param target defines the target
  13328. * @param from defines from which frame should animation start
  13329. * @param to defines until which frame should animation run.
  13330. * @param weight defines the weight to apply to the animation (1.0 by default)
  13331. * @param loop defines if the animation loops
  13332. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13333. * @param onAnimationEnd defines the function to be executed when the animation ends
  13334. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13335. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13336. * @param onAnimationLoop defines the callback to call when an animation loops
  13337. * @returns the animatable object created for this animation
  13338. */
  13339. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13340. /**
  13341. * Will start the animation sequence of a given target
  13342. * @param target defines the target
  13343. * @param from defines from which frame should animation start
  13344. * @param to defines until which frame should animation run.
  13345. * @param loop defines if the animation loops
  13346. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13347. * @param onAnimationEnd defines the function to be executed when the animation ends
  13348. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13349. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13350. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13351. * @param onAnimationLoop defines the callback to call when an animation loops
  13352. * @returns the animatable object created for this animation
  13353. */
  13354. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13355. /**
  13356. * Will start the animation sequence of a given target and its hierarchy
  13357. * @param target defines the target
  13358. * @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.
  13359. * @param from defines from which frame should animation start
  13360. * @param to defines until which frame should animation run.
  13361. * @param loop defines if the animation loops
  13362. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13363. * @param onAnimationEnd defines the function to be executed when the animation ends
  13364. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13365. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13366. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13367. * @param onAnimationLoop defines the callback to call when an animation loops
  13368. * @returns the list of created animatables
  13369. */
  13370. 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[];
  13371. /**
  13372. * Begin a new animation on a given node
  13373. * @param target defines the target where the animation will take place
  13374. * @param animations defines the list of animations to start
  13375. * @param from defines the initial value
  13376. * @param to defines the final value
  13377. * @param loop defines if you want animation to loop (off by default)
  13378. * @param speedRatio defines the speed ratio to apply to all animations
  13379. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13380. * @param onAnimationLoop defines the callback to call when an animation loops
  13381. * @returns the list of created animatables
  13382. */
  13383. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13384. /**
  13385. * Begin a new animation on a given node and its hierarchy
  13386. * @param target defines the root node where the animation will take place
  13387. * @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.
  13388. * @param animations defines the list of animations to start
  13389. * @param from defines the initial value
  13390. * @param to defines the final value
  13391. * @param loop defines if you want animation to loop (off by default)
  13392. * @param speedRatio defines the speed ratio to apply to all animations
  13393. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13394. * @param onAnimationLoop defines the callback to call when an animation loops
  13395. * @returns the list of animatables created for all nodes
  13396. */
  13397. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13398. /**
  13399. * Gets the animatable associated with a specific target
  13400. * @param target defines the target of the animatable
  13401. * @returns the required animatable if found
  13402. */
  13403. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13404. /**
  13405. * Gets all animatables associated with a given target
  13406. * @param target defines the target to look animatables for
  13407. * @returns an array of Animatables
  13408. */
  13409. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13410. /**
  13411. * Stops and removes all animations that have been applied to the scene
  13412. */
  13413. stopAllAnimations(): void;
  13414. /**
  13415. * Gets the current delta time used by animation engine
  13416. */
  13417. deltaTime: number;
  13418. }
  13419. }
  13420. module "babylonjs/Bones/bone" {
  13421. interface Bone {
  13422. /**
  13423. * Copy an animation range from another bone
  13424. * @param source defines the source bone
  13425. * @param rangeName defines the range name to copy
  13426. * @param frameOffset defines the frame offset
  13427. * @param rescaleAsRequired defines if rescaling must be applied if required
  13428. * @param skelDimensionsRatio defines the scaling ratio
  13429. * @returns true if operation was successful
  13430. */
  13431. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13432. }
  13433. }
  13434. }
  13435. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13436. /**
  13437. * Class used to override all child animations of a given target
  13438. */
  13439. export class AnimationPropertiesOverride {
  13440. /**
  13441. * Gets or sets a value indicating if animation blending must be used
  13442. */
  13443. enableBlending: boolean;
  13444. /**
  13445. * Gets or sets the blending speed to use when enableBlending is true
  13446. */
  13447. blendingSpeed: number;
  13448. /**
  13449. * Gets or sets the default loop mode to use
  13450. */
  13451. loopMode: number;
  13452. }
  13453. }
  13454. declare module "babylonjs/Bones/skeleton" {
  13455. import { Bone } from "babylonjs/Bones/bone";
  13456. import { Observable } from "babylonjs/Misc/observable";
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Scene } from "babylonjs/scene";
  13459. import { Nullable } from "babylonjs/types";
  13460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13461. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13462. import { Animatable } from "babylonjs/Animations/animatable";
  13463. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13464. import { Animation } from "babylonjs/Animations/animation";
  13465. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13466. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13468. /**
  13469. * Class used to handle skinning animations
  13470. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13471. */
  13472. export class Skeleton implements IAnimatable {
  13473. /** defines the skeleton name */
  13474. name: string;
  13475. /** defines the skeleton Id */
  13476. id: string;
  13477. /**
  13478. * Defines the list of child bones
  13479. */
  13480. bones: Bone[];
  13481. /**
  13482. * Defines an estimate of the dimension of the skeleton at rest
  13483. */
  13484. dimensionsAtRest: Vector3;
  13485. /**
  13486. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13487. */
  13488. needInitialSkinMatrix: boolean;
  13489. /**
  13490. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13491. */
  13492. overrideMesh: Nullable<AbstractMesh>;
  13493. /**
  13494. * Gets the list of animations attached to this skeleton
  13495. */
  13496. animations: Array<Animation>;
  13497. private _scene;
  13498. private _isDirty;
  13499. private _transformMatrices;
  13500. private _transformMatrixTexture;
  13501. private _meshesWithPoseMatrix;
  13502. private _animatables;
  13503. private _identity;
  13504. private _synchronizedWithMesh;
  13505. private _ranges;
  13506. private _lastAbsoluteTransformsUpdateId;
  13507. private _canUseTextureForBones;
  13508. private _uniqueId;
  13509. /** @hidden */
  13510. _numBonesWithLinkedTransformNode: number;
  13511. /** @hidden */
  13512. _hasWaitingData: Nullable<boolean>;
  13513. /**
  13514. * Specifies if the skeleton should be serialized
  13515. */
  13516. doNotSerialize: boolean;
  13517. private _useTextureToStoreBoneMatrices;
  13518. /**
  13519. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13520. * Please note that this option is not available if the hardware does not support it
  13521. */
  13522. useTextureToStoreBoneMatrices: boolean;
  13523. private _animationPropertiesOverride;
  13524. /**
  13525. * Gets or sets the animation properties override
  13526. */
  13527. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13528. /**
  13529. * List of inspectable custom properties (used by the Inspector)
  13530. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13531. */
  13532. inspectableCustomProperties: IInspectable[];
  13533. /**
  13534. * An observable triggered before computing the skeleton's matrices
  13535. */
  13536. onBeforeComputeObservable: Observable<Skeleton>;
  13537. /**
  13538. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13539. */
  13540. readonly isUsingTextureForMatrices: boolean;
  13541. /**
  13542. * Gets the unique ID of this skeleton
  13543. */
  13544. readonly uniqueId: number;
  13545. /**
  13546. * Creates a new skeleton
  13547. * @param name defines the skeleton name
  13548. * @param id defines the skeleton Id
  13549. * @param scene defines the hosting scene
  13550. */
  13551. constructor(
  13552. /** defines the skeleton name */
  13553. name: string,
  13554. /** defines the skeleton Id */
  13555. id: string, scene: Scene);
  13556. /**
  13557. * Gets the current object class name.
  13558. * @return the class name
  13559. */
  13560. getClassName(): string;
  13561. /**
  13562. * Returns an array containing the root bones
  13563. * @returns an array containing the root bones
  13564. */
  13565. getChildren(): Array<Bone>;
  13566. /**
  13567. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13568. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13569. * @returns a Float32Array containing matrices data
  13570. */
  13571. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13572. /**
  13573. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13574. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13575. * @returns a raw texture containing the data
  13576. */
  13577. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13578. /**
  13579. * Gets the current hosting scene
  13580. * @returns a scene object
  13581. */
  13582. getScene(): Scene;
  13583. /**
  13584. * Gets a string representing the current skeleton data
  13585. * @param fullDetails defines a boolean indicating if we want a verbose version
  13586. * @returns a string representing the current skeleton data
  13587. */
  13588. toString(fullDetails?: boolean): string;
  13589. /**
  13590. * Get bone's index searching by name
  13591. * @param name defines bone's name to search for
  13592. * @return the indice of the bone. Returns -1 if not found
  13593. */
  13594. getBoneIndexByName(name: string): number;
  13595. /**
  13596. * Creater a new animation range
  13597. * @param name defines the name of the range
  13598. * @param from defines the start key
  13599. * @param to defines the end key
  13600. */
  13601. createAnimationRange(name: string, from: number, to: number): void;
  13602. /**
  13603. * Delete a specific animation range
  13604. * @param name defines the name of the range
  13605. * @param deleteFrames defines if frames must be removed as well
  13606. */
  13607. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13608. /**
  13609. * Gets a specific animation range
  13610. * @param name defines the name of the range to look for
  13611. * @returns the requested animation range or null if not found
  13612. */
  13613. getAnimationRange(name: string): Nullable<AnimationRange>;
  13614. /**
  13615. * Gets the list of all animation ranges defined on this skeleton
  13616. * @returns an array
  13617. */
  13618. getAnimationRanges(): Nullable<AnimationRange>[];
  13619. /**
  13620. * Copy animation range from a source skeleton.
  13621. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13622. * @param source defines the source skeleton
  13623. * @param name defines the name of the range to copy
  13624. * @param rescaleAsRequired defines if rescaling must be applied if required
  13625. * @returns true if operation was successful
  13626. */
  13627. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13628. /**
  13629. * Forces the skeleton to go to rest pose
  13630. */
  13631. returnToRest(): void;
  13632. private _getHighestAnimationFrame;
  13633. /**
  13634. * Begin a specific animation range
  13635. * @param name defines the name of the range to start
  13636. * @param loop defines if looping must be turned on (false by default)
  13637. * @param speedRatio defines the speed ratio to apply (1 by default)
  13638. * @param onAnimationEnd defines a callback which will be called when animation will end
  13639. * @returns a new animatable
  13640. */
  13641. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13642. /** @hidden */
  13643. _markAsDirty(): void;
  13644. /** @hidden */
  13645. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13646. /** @hidden */
  13647. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13648. private _computeTransformMatrices;
  13649. /**
  13650. * Build all resources required to render a skeleton
  13651. */
  13652. prepare(): void;
  13653. /**
  13654. * Gets the list of animatables currently running for this skeleton
  13655. * @returns an array of animatables
  13656. */
  13657. getAnimatables(): IAnimatable[];
  13658. /**
  13659. * Clone the current skeleton
  13660. * @param name defines the name of the new skeleton
  13661. * @param id defines the id of the new skeleton
  13662. * @returns the new skeleton
  13663. */
  13664. clone(name: string, id: string): Skeleton;
  13665. /**
  13666. * Enable animation blending for this skeleton
  13667. * @param blendingSpeed defines the blending speed to apply
  13668. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13669. */
  13670. enableBlending(blendingSpeed?: number): void;
  13671. /**
  13672. * Releases all resources associated with the current skeleton
  13673. */
  13674. dispose(): void;
  13675. /**
  13676. * Serialize the skeleton in a JSON object
  13677. * @returns a JSON object
  13678. */
  13679. serialize(): any;
  13680. /**
  13681. * Creates a new skeleton from serialized data
  13682. * @param parsedSkeleton defines the serialized data
  13683. * @param scene defines the hosting scene
  13684. * @returns a new skeleton
  13685. */
  13686. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13687. /**
  13688. * Compute all node absolute transforms
  13689. * @param forceUpdate defines if computation must be done even if cache is up to date
  13690. */
  13691. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13692. /**
  13693. * Gets the root pose matrix
  13694. * @returns a matrix
  13695. */
  13696. getPoseMatrix(): Nullable<Matrix>;
  13697. /**
  13698. * Sorts bones per internal index
  13699. */
  13700. sortBones(): void;
  13701. private _sortBones;
  13702. }
  13703. }
  13704. declare module "babylonjs/Bones/bone" {
  13705. import { Skeleton } from "babylonjs/Bones/skeleton";
  13706. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13710. import { Node } from "babylonjs/node";
  13711. import { Space } from "babylonjs/Maths/math.axis";
  13712. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13713. /**
  13714. * Class used to store bone information
  13715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13716. */
  13717. export class Bone extends Node {
  13718. /**
  13719. * defines the bone name
  13720. */
  13721. name: string;
  13722. private static _tmpVecs;
  13723. private static _tmpQuat;
  13724. private static _tmpMats;
  13725. /**
  13726. * Gets the list of child bones
  13727. */
  13728. children: Bone[];
  13729. /** Gets the animations associated with this bone */
  13730. animations: import("babylonjs/Animations/animation").Animation[];
  13731. /**
  13732. * Gets or sets bone length
  13733. */
  13734. length: number;
  13735. /**
  13736. * @hidden Internal only
  13737. * Set this value to map this bone to a different index in the transform matrices
  13738. * Set this value to -1 to exclude the bone from the transform matrices
  13739. */
  13740. _index: Nullable<number>;
  13741. private _skeleton;
  13742. private _localMatrix;
  13743. private _restPose;
  13744. private _baseMatrix;
  13745. private _absoluteTransform;
  13746. private _invertedAbsoluteTransform;
  13747. private _parent;
  13748. private _scalingDeterminant;
  13749. private _worldTransform;
  13750. private _localScaling;
  13751. private _localRotation;
  13752. private _localPosition;
  13753. private _needToDecompose;
  13754. private _needToCompose;
  13755. /** @hidden */
  13756. _linkedTransformNode: Nullable<TransformNode>;
  13757. /** @hidden */
  13758. _waitingTransformNodeId: Nullable<string>;
  13759. /** @hidden */
  13760. /** @hidden */
  13761. _matrix: Matrix;
  13762. /**
  13763. * Create a new bone
  13764. * @param name defines the bone name
  13765. * @param skeleton defines the parent skeleton
  13766. * @param parentBone defines the parent (can be null if the bone is the root)
  13767. * @param localMatrix defines the local matrix
  13768. * @param restPose defines the rest pose matrix
  13769. * @param baseMatrix defines the base matrix
  13770. * @param index defines index of the bone in the hiearchy
  13771. */
  13772. constructor(
  13773. /**
  13774. * defines the bone name
  13775. */
  13776. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13777. /**
  13778. * Gets the current object class name.
  13779. * @return the class name
  13780. */
  13781. getClassName(): string;
  13782. /**
  13783. * Gets the parent skeleton
  13784. * @returns a skeleton
  13785. */
  13786. getSkeleton(): Skeleton;
  13787. /**
  13788. * Gets parent bone
  13789. * @returns a bone or null if the bone is the root of the bone hierarchy
  13790. */
  13791. getParent(): Nullable<Bone>;
  13792. /**
  13793. * Returns an array containing the root bones
  13794. * @returns an array containing the root bones
  13795. */
  13796. getChildren(): Array<Bone>;
  13797. /**
  13798. * Sets the parent bone
  13799. * @param parent defines the parent (can be null if the bone is the root)
  13800. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13801. */
  13802. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13803. /**
  13804. * Gets the local matrix
  13805. * @returns a matrix
  13806. */
  13807. getLocalMatrix(): Matrix;
  13808. /**
  13809. * Gets the base matrix (initial matrix which remains unchanged)
  13810. * @returns a matrix
  13811. */
  13812. getBaseMatrix(): Matrix;
  13813. /**
  13814. * Gets the rest pose matrix
  13815. * @returns a matrix
  13816. */
  13817. getRestPose(): Matrix;
  13818. /**
  13819. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13820. */
  13821. getWorldMatrix(): Matrix;
  13822. /**
  13823. * Sets the local matrix to rest pose matrix
  13824. */
  13825. returnToRest(): void;
  13826. /**
  13827. * Gets the inverse of the absolute transform matrix.
  13828. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13829. * @returns a matrix
  13830. */
  13831. getInvertedAbsoluteTransform(): Matrix;
  13832. /**
  13833. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13834. * @returns a matrix
  13835. */
  13836. getAbsoluteTransform(): Matrix;
  13837. /**
  13838. * Links with the given transform node.
  13839. * The local matrix of this bone is copied from the transform node every frame.
  13840. * @param transformNode defines the transform node to link to
  13841. */
  13842. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13843. /**
  13844. * Gets the node used to drive the bone's transformation
  13845. * @returns a transform node or null
  13846. */
  13847. getTransformNode(): Nullable<TransformNode>;
  13848. /** Gets or sets current position (in local space) */
  13849. position: Vector3;
  13850. /** Gets or sets current rotation (in local space) */
  13851. rotation: Vector3;
  13852. /** Gets or sets current rotation quaternion (in local space) */
  13853. rotationQuaternion: Quaternion;
  13854. /** Gets or sets current scaling (in local space) */
  13855. scaling: Vector3;
  13856. /**
  13857. * Gets the animation properties override
  13858. */
  13859. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13860. private _decompose;
  13861. private _compose;
  13862. /**
  13863. * Update the base and local matrices
  13864. * @param matrix defines the new base or local matrix
  13865. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13866. * @param updateLocalMatrix defines if the local matrix should be updated
  13867. */
  13868. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13869. /** @hidden */
  13870. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13871. /**
  13872. * Flag the bone as dirty (Forcing it to update everything)
  13873. */
  13874. markAsDirty(): void;
  13875. /** @hidden */
  13876. _markAsDirtyAndCompose(): void;
  13877. private _markAsDirtyAndDecompose;
  13878. /**
  13879. * Translate the bone in local or world space
  13880. * @param vec The amount to translate the bone
  13881. * @param space The space that the translation is in
  13882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13883. */
  13884. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13885. /**
  13886. * Set the postion of the bone in local or world space
  13887. * @param position The position to set the bone
  13888. * @param space The space that the position is in
  13889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13890. */
  13891. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13892. /**
  13893. * Set the absolute position of the bone (world space)
  13894. * @param position The position to set the bone
  13895. * @param mesh The mesh that this bone is attached to
  13896. */
  13897. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13898. /**
  13899. * Scale the bone on the x, y and z axes (in local space)
  13900. * @param x The amount to scale the bone on the x axis
  13901. * @param y The amount to scale the bone on the y axis
  13902. * @param z The amount to scale the bone on the z axis
  13903. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13904. */
  13905. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13906. /**
  13907. * Set the bone scaling in local space
  13908. * @param scale defines the scaling vector
  13909. */
  13910. setScale(scale: Vector3): void;
  13911. /**
  13912. * Gets the current scaling in local space
  13913. * @returns the current scaling vector
  13914. */
  13915. getScale(): Vector3;
  13916. /**
  13917. * Gets the current scaling in local space and stores it in a target vector
  13918. * @param result defines the target vector
  13919. */
  13920. getScaleToRef(result: Vector3): void;
  13921. /**
  13922. * Set the yaw, pitch, and roll of the bone in local or world space
  13923. * @param yaw The rotation of the bone on the y axis
  13924. * @param pitch The rotation of the bone on the x axis
  13925. * @param roll The rotation of the bone on the z axis
  13926. * @param space The space that the axes of rotation are in
  13927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13928. */
  13929. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13930. /**
  13931. * Add a rotation to the bone on an axis in local or world space
  13932. * @param axis The axis to rotate the bone on
  13933. * @param amount The amount to rotate the bone
  13934. * @param space The space that the axis is in
  13935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13936. */
  13937. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13938. /**
  13939. * Set the rotation of the bone to a particular axis angle in local or world space
  13940. * @param axis The axis to rotate the bone on
  13941. * @param angle The angle that the bone should be rotated to
  13942. * @param space The space that the axis is in
  13943. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13944. */
  13945. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13946. /**
  13947. * Set the euler rotation of the bone in local of world space
  13948. * @param rotation The euler rotation that the bone should be set to
  13949. * @param space The space that the rotation is in
  13950. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13951. */
  13952. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13953. /**
  13954. * Set the quaternion rotation of the bone in local of world space
  13955. * @param quat The quaternion rotation that the bone should be set to
  13956. * @param space The space that the rotation is in
  13957. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13958. */
  13959. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13960. /**
  13961. * Set the rotation matrix of the bone in local of world space
  13962. * @param rotMat The rotation matrix that the bone should be set to
  13963. * @param space The space that the rotation is in
  13964. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13965. */
  13966. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13967. private _rotateWithMatrix;
  13968. private _getNegativeRotationToRef;
  13969. /**
  13970. * Get the position of the bone in local or world space
  13971. * @param space The space that the returned position is in
  13972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13973. * @returns The position of the bone
  13974. */
  13975. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13976. /**
  13977. * Copy the position of the bone to a vector3 in local or world space
  13978. * @param space The space that the returned position is in
  13979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13980. * @param result The vector3 to copy the position to
  13981. */
  13982. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13983. /**
  13984. * Get the absolute position of the bone (world space)
  13985. * @param mesh The mesh that this bone is attached to
  13986. * @returns The absolute position of the bone
  13987. */
  13988. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13989. /**
  13990. * Copy the absolute position of the bone (world space) to the result param
  13991. * @param mesh The mesh that this bone is attached to
  13992. * @param result The vector3 to copy the absolute position to
  13993. */
  13994. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13995. /**
  13996. * Compute the absolute transforms of this bone and its children
  13997. */
  13998. computeAbsoluteTransforms(): void;
  13999. /**
  14000. * Get the world direction from an axis that is in the local space of the bone
  14001. * @param localAxis The local direction that is used to compute the world direction
  14002. * @param mesh The mesh that this bone is attached to
  14003. * @returns The world direction
  14004. */
  14005. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14006. /**
  14007. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14008. * @param localAxis The local direction that is used to compute the world direction
  14009. * @param mesh The mesh that this bone is attached to
  14010. * @param result The vector3 that the world direction will be copied to
  14011. */
  14012. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14013. /**
  14014. * Get the euler rotation of the bone in local or world space
  14015. * @param space The space that the rotation should be in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. * @returns The euler rotation
  14018. */
  14019. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14020. /**
  14021. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14022. * @param space The space that the rotation should be in
  14023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14024. * @param result The vector3 that the rotation should be copied to
  14025. */
  14026. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14027. /**
  14028. * Get the quaternion rotation of the bone in either local or world space
  14029. * @param space The space that the rotation should be in
  14030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14031. * @returns The quaternion rotation
  14032. */
  14033. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14034. /**
  14035. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14036. * @param space The space that the rotation should be in
  14037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14038. * @param result The quaternion that the rotation should be copied to
  14039. */
  14040. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14041. /**
  14042. * Get the rotation matrix of the bone in local or world space
  14043. * @param space The space that the rotation should be in
  14044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14045. * @returns The rotation matrix
  14046. */
  14047. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14048. /**
  14049. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14050. * @param space The space that the rotation should be in
  14051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14052. * @param result The quaternion that the rotation should be copied to
  14053. */
  14054. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14055. /**
  14056. * Get the world position of a point that is in the local space of the bone
  14057. * @param position The local position
  14058. * @param mesh The mesh that this bone is attached to
  14059. * @returns The world position
  14060. */
  14061. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14062. /**
  14063. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14064. * @param position The local position
  14065. * @param mesh The mesh that this bone is attached to
  14066. * @param result The vector3 that the world position should be copied to
  14067. */
  14068. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14069. /**
  14070. * Get the local position of a point that is in world space
  14071. * @param position The world position
  14072. * @param mesh The mesh that this bone is attached to
  14073. * @returns The local position
  14074. */
  14075. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14076. /**
  14077. * Get the local position of a point that is in world space and copy it to the result param
  14078. * @param position The world position
  14079. * @param mesh The mesh that this bone is attached to
  14080. * @param result The vector3 that the local position should be copied to
  14081. */
  14082. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14083. }
  14084. }
  14085. declare module "babylonjs/Meshes/transformNode" {
  14086. import { DeepImmutable } from "babylonjs/types";
  14087. import { Observable } from "babylonjs/Misc/observable";
  14088. import { Nullable } from "babylonjs/types";
  14089. import { Camera } from "babylonjs/Cameras/camera";
  14090. import { Scene } from "babylonjs/scene";
  14091. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14092. import { Node } from "babylonjs/node";
  14093. import { Bone } from "babylonjs/Bones/bone";
  14094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14095. import { Space } from "babylonjs/Maths/math.axis";
  14096. /**
  14097. * 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.
  14098. * @see https://doc.babylonjs.com/how_to/transformnode
  14099. */
  14100. export class TransformNode extends Node {
  14101. /**
  14102. * Object will not rotate to face the camera
  14103. */
  14104. static BILLBOARDMODE_NONE: number;
  14105. /**
  14106. * Object will rotate to face the camera but only on the x axis
  14107. */
  14108. static BILLBOARDMODE_X: number;
  14109. /**
  14110. * Object will rotate to face the camera but only on the y axis
  14111. */
  14112. static BILLBOARDMODE_Y: number;
  14113. /**
  14114. * Object will rotate to face the camera but only on the z axis
  14115. */
  14116. static BILLBOARDMODE_Z: number;
  14117. /**
  14118. * Object will rotate to face the camera
  14119. */
  14120. static BILLBOARDMODE_ALL: number;
  14121. /**
  14122. * Object will rotate to face the camera's position instead of orientation
  14123. */
  14124. static BILLBOARDMODE_USE_POSITION: number;
  14125. private _forward;
  14126. private _forwardInverted;
  14127. private _up;
  14128. private _right;
  14129. private _rightInverted;
  14130. private _position;
  14131. private _rotation;
  14132. private _rotationQuaternion;
  14133. protected _scaling: Vector3;
  14134. protected _isDirty: boolean;
  14135. private _transformToBoneReferal;
  14136. private _isAbsoluteSynced;
  14137. private _billboardMode;
  14138. /**
  14139. * Gets or sets the billboard mode. Default is 0.
  14140. *
  14141. * | Value | Type | Description |
  14142. * | --- | --- | --- |
  14143. * | 0 | BILLBOARDMODE_NONE | |
  14144. * | 1 | BILLBOARDMODE_X | |
  14145. * | 2 | BILLBOARDMODE_Y | |
  14146. * | 4 | BILLBOARDMODE_Z | |
  14147. * | 7 | BILLBOARDMODE_ALL | |
  14148. *
  14149. */
  14150. billboardMode: number;
  14151. private _preserveParentRotationForBillboard;
  14152. /**
  14153. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14154. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14155. */
  14156. preserveParentRotationForBillboard: boolean;
  14157. /**
  14158. * 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
  14159. */
  14160. scalingDeterminant: number;
  14161. private _infiniteDistance;
  14162. /**
  14163. * Gets or sets the distance of the object to max, often used by skybox
  14164. */
  14165. infiniteDistance: boolean;
  14166. /**
  14167. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14168. * By default the system will update normals to compensate
  14169. */
  14170. ignoreNonUniformScaling: boolean;
  14171. /**
  14172. * 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
  14173. */
  14174. reIntegrateRotationIntoRotationQuaternion: boolean;
  14175. /** @hidden */
  14176. _poseMatrix: Nullable<Matrix>;
  14177. /** @hidden */
  14178. _localMatrix: Matrix;
  14179. private _usePivotMatrix;
  14180. private _absolutePosition;
  14181. private _absoluteScaling;
  14182. private _absoluteRotationQuaternion;
  14183. private _pivotMatrix;
  14184. private _pivotMatrixInverse;
  14185. protected _postMultiplyPivotMatrix: boolean;
  14186. protected _isWorldMatrixFrozen: boolean;
  14187. /** @hidden */
  14188. _indexInSceneTransformNodesArray: number;
  14189. /**
  14190. * An event triggered after the world matrix is updated
  14191. */
  14192. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14193. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14194. /**
  14195. * Gets a string identifying the name of the class
  14196. * @returns "TransformNode" string
  14197. */
  14198. getClassName(): string;
  14199. /**
  14200. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14201. */
  14202. position: Vector3;
  14203. /**
  14204. * 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)).
  14205. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14206. */
  14207. rotation: Vector3;
  14208. /**
  14209. * 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)).
  14210. */
  14211. scaling: Vector3;
  14212. /**
  14213. * 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).
  14214. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14215. */
  14216. rotationQuaternion: Nullable<Quaternion>;
  14217. /**
  14218. * The forward direction of that transform in world space.
  14219. */
  14220. readonly forward: Vector3;
  14221. /**
  14222. * The up direction of that transform in world space.
  14223. */
  14224. readonly up: Vector3;
  14225. /**
  14226. * The right direction of that transform in world space.
  14227. */
  14228. readonly right: Vector3;
  14229. /**
  14230. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14231. * @param matrix the matrix to copy the pose from
  14232. * @returns this TransformNode.
  14233. */
  14234. updatePoseMatrix(matrix: Matrix): TransformNode;
  14235. /**
  14236. * Returns the mesh Pose matrix.
  14237. * @returns the pose matrix
  14238. */
  14239. getPoseMatrix(): Matrix;
  14240. /** @hidden */
  14241. _isSynchronized(): boolean;
  14242. /** @hidden */
  14243. _initCache(): void;
  14244. /**
  14245. * Flag the transform node as dirty (Forcing it to update everything)
  14246. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14247. * @returns this transform node
  14248. */
  14249. markAsDirty(property: string): TransformNode;
  14250. /**
  14251. * Returns the current mesh absolute position.
  14252. * Returns a Vector3.
  14253. */
  14254. readonly absolutePosition: Vector3;
  14255. /**
  14256. * Returns the current mesh absolute scaling.
  14257. * Returns a Vector3.
  14258. */
  14259. readonly absoluteScaling: Vector3;
  14260. /**
  14261. * Returns the current mesh absolute rotation.
  14262. * Returns a Quaternion.
  14263. */
  14264. readonly absoluteRotationQuaternion: Quaternion;
  14265. /**
  14266. * Sets a new matrix to apply before all other transformation
  14267. * @param matrix defines the transform matrix
  14268. * @returns the current TransformNode
  14269. */
  14270. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14271. /**
  14272. * Sets a new pivot matrix to the current node
  14273. * @param matrix defines the new pivot matrix to use
  14274. * @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
  14275. * @returns the current TransformNode
  14276. */
  14277. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14278. /**
  14279. * Returns the mesh pivot matrix.
  14280. * Default : Identity.
  14281. * @returns the matrix
  14282. */
  14283. getPivotMatrix(): Matrix;
  14284. /**
  14285. * Instantiate (when possible) or clone that node with its hierarchy
  14286. * @param newParent defines the new parent to use for the instance (or clone)
  14287. * @returns an instance (or a clone) of the current node with its hiearchy
  14288. */
  14289. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14290. /**
  14291. * Prevents the World matrix to be computed any longer
  14292. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14293. * @returns the TransformNode.
  14294. */
  14295. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14296. /**
  14297. * Allows back the World matrix computation.
  14298. * @returns the TransformNode.
  14299. */
  14300. unfreezeWorldMatrix(): this;
  14301. /**
  14302. * True if the World matrix has been frozen.
  14303. */
  14304. readonly isWorldMatrixFrozen: boolean;
  14305. /**
  14306. * Retuns the mesh absolute position in the World.
  14307. * @returns a Vector3.
  14308. */
  14309. getAbsolutePosition(): Vector3;
  14310. /**
  14311. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14312. * @param absolutePosition the absolute position to set
  14313. * @returns the TransformNode.
  14314. */
  14315. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14316. /**
  14317. * Sets the mesh position in its local space.
  14318. * @param vector3 the position to set in localspace
  14319. * @returns the TransformNode.
  14320. */
  14321. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14322. /**
  14323. * Returns the mesh position in the local space from the current World matrix values.
  14324. * @returns a new Vector3.
  14325. */
  14326. getPositionExpressedInLocalSpace(): Vector3;
  14327. /**
  14328. * Translates the mesh along the passed Vector3 in its local space.
  14329. * @param vector3 the distance to translate in localspace
  14330. * @returns the TransformNode.
  14331. */
  14332. locallyTranslate(vector3: Vector3): TransformNode;
  14333. private static _lookAtVectorCache;
  14334. /**
  14335. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14336. * @param targetPoint the position (must be in same space as current mesh) to look at
  14337. * @param yawCor optional yaw (y-axis) correction in radians
  14338. * @param pitchCor optional pitch (x-axis) correction in radians
  14339. * @param rollCor optional roll (z-axis) correction in radians
  14340. * @param space the choosen space of the target
  14341. * @returns the TransformNode.
  14342. */
  14343. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14344. /**
  14345. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14346. * This Vector3 is expressed in the World space.
  14347. * @param localAxis axis to rotate
  14348. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14349. */
  14350. getDirection(localAxis: Vector3): Vector3;
  14351. /**
  14352. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14353. * localAxis is expressed in the mesh local space.
  14354. * result is computed in the Wordl space from the mesh World matrix.
  14355. * @param localAxis axis to rotate
  14356. * @param result the resulting transformnode
  14357. * @returns this TransformNode.
  14358. */
  14359. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14360. /**
  14361. * Sets this transform node rotation to the given local axis.
  14362. * @param localAxis the axis in local space
  14363. * @param yawCor optional yaw (y-axis) correction in radians
  14364. * @param pitchCor optional pitch (x-axis) correction in radians
  14365. * @param rollCor optional roll (z-axis) correction in radians
  14366. * @returns this TransformNode
  14367. */
  14368. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14369. /**
  14370. * Sets a new pivot point to the current node
  14371. * @param point defines the new pivot point to use
  14372. * @param space defines if the point is in world or local space (local by default)
  14373. * @returns the current TransformNode
  14374. */
  14375. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14376. /**
  14377. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14378. * @returns the pivot point
  14379. */
  14380. getPivotPoint(): Vector3;
  14381. /**
  14382. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14383. * @param result the vector3 to store the result
  14384. * @returns this TransformNode.
  14385. */
  14386. getPivotPointToRef(result: Vector3): TransformNode;
  14387. /**
  14388. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14389. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14390. */
  14391. getAbsolutePivotPoint(): Vector3;
  14392. /**
  14393. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14394. * @param result vector3 to store the result
  14395. * @returns this TransformNode.
  14396. */
  14397. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14398. /**
  14399. * Defines the passed node as the parent of the current node.
  14400. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14401. * @see https://doc.babylonjs.com/how_to/parenting
  14402. * @param node the node ot set as the parent
  14403. * @returns this TransformNode.
  14404. */
  14405. setParent(node: Nullable<Node>): TransformNode;
  14406. private _nonUniformScaling;
  14407. /**
  14408. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14409. */
  14410. readonly nonUniformScaling: boolean;
  14411. /** @hidden */
  14412. _updateNonUniformScalingState(value: boolean): boolean;
  14413. /**
  14414. * Attach the current TransformNode to another TransformNode associated with a bone
  14415. * @param bone Bone affecting the TransformNode
  14416. * @param affectedTransformNode TransformNode associated with the bone
  14417. * @returns this object
  14418. */
  14419. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14420. /**
  14421. * Detach the transform node if its associated with a bone
  14422. * @returns this object
  14423. */
  14424. detachFromBone(): TransformNode;
  14425. private static _rotationAxisCache;
  14426. /**
  14427. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14428. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14429. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14430. * The passed axis is also normalized.
  14431. * @param axis the axis to rotate around
  14432. * @param amount the amount to rotate in radians
  14433. * @param space Space to rotate in (Default: local)
  14434. * @returns the TransformNode.
  14435. */
  14436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14437. /**
  14438. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14439. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14440. * The passed axis is also normalized. .
  14441. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14442. * @param point the point to rotate around
  14443. * @param axis the axis to rotate around
  14444. * @param amount the amount to rotate in radians
  14445. * @returns the TransformNode
  14446. */
  14447. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14448. /**
  14449. * Translates the mesh along the axis vector for the passed distance in the given space.
  14450. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14451. * @param axis the axis to translate in
  14452. * @param distance the distance to translate
  14453. * @param space Space to rotate in (Default: local)
  14454. * @returns the TransformNode.
  14455. */
  14456. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14457. /**
  14458. * Adds a rotation step to the mesh current rotation.
  14459. * x, y, z are Euler angles expressed in radians.
  14460. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14461. * This means this rotation is made in the mesh local space only.
  14462. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14463. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14464. * ```javascript
  14465. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14466. * ```
  14467. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14468. * 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.
  14469. * @param x Rotation to add
  14470. * @param y Rotation to add
  14471. * @param z Rotation to add
  14472. * @returns the TransformNode.
  14473. */
  14474. addRotation(x: number, y: number, z: number): TransformNode;
  14475. /**
  14476. * @hidden
  14477. */
  14478. protected _getEffectiveParent(): Nullable<Node>;
  14479. /**
  14480. * Computes the world matrix of the node
  14481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14482. * @returns the world matrix
  14483. */
  14484. computeWorldMatrix(force?: boolean): Matrix;
  14485. protected _afterComputeWorldMatrix(): void;
  14486. /**
  14487. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14488. * @param func callback function to add
  14489. *
  14490. * @returns the TransformNode.
  14491. */
  14492. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14493. /**
  14494. * Removes a registered callback function.
  14495. * @param func callback function to remove
  14496. * @returns the TransformNode.
  14497. */
  14498. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14499. /**
  14500. * Gets the position of the current mesh in camera space
  14501. * @param camera defines the camera to use
  14502. * @returns a position
  14503. */
  14504. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14505. /**
  14506. * Returns the distance from the mesh to the active camera
  14507. * @param camera defines the camera to use
  14508. * @returns the distance
  14509. */
  14510. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14511. /**
  14512. * Clone the current transform node
  14513. * @param name Name of the new clone
  14514. * @param newParent New parent for the clone
  14515. * @param doNotCloneChildren Do not clone children hierarchy
  14516. * @returns the new transform node
  14517. */
  14518. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14519. /**
  14520. * Serializes the objects information.
  14521. * @param currentSerializationObject defines the object to serialize in
  14522. * @returns the serialized object
  14523. */
  14524. serialize(currentSerializationObject?: any): any;
  14525. /**
  14526. * Returns a new TransformNode object parsed from the source provided.
  14527. * @param parsedTransformNode is the source.
  14528. * @param scene the scne the object belongs to
  14529. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14530. * @returns a new TransformNode object parsed from the source provided.
  14531. */
  14532. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14533. /**
  14534. * Get all child-transformNodes of this node
  14535. * @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
  14536. * @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
  14537. * @returns an array of TransformNode
  14538. */
  14539. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14540. /**
  14541. * Releases resources associated with this transform node.
  14542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14544. */
  14545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14546. /**
  14547. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14548. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14549. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14550. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14551. * @returns the current mesh
  14552. */
  14553. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14554. private _syncAbsoluteScalingAndRotation;
  14555. }
  14556. }
  14557. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14558. import { Observable } from "babylonjs/Misc/observable";
  14559. import { Nullable } from "babylonjs/types";
  14560. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14561. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14563. import { Ray } from "babylonjs/Culling/ray";
  14564. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14565. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14566. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14567. /**
  14568. * Defines the types of pose enabled controllers that are supported
  14569. */
  14570. export enum PoseEnabledControllerType {
  14571. /**
  14572. * HTC Vive
  14573. */
  14574. VIVE = 0,
  14575. /**
  14576. * Oculus Rift
  14577. */
  14578. OCULUS = 1,
  14579. /**
  14580. * Windows mixed reality
  14581. */
  14582. WINDOWS = 2,
  14583. /**
  14584. * Samsung gear VR
  14585. */
  14586. GEAR_VR = 3,
  14587. /**
  14588. * Google Daydream
  14589. */
  14590. DAYDREAM = 4,
  14591. /**
  14592. * Generic
  14593. */
  14594. GENERIC = 5
  14595. }
  14596. /**
  14597. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14598. */
  14599. export interface MutableGamepadButton {
  14600. /**
  14601. * Value of the button/trigger
  14602. */
  14603. value: number;
  14604. /**
  14605. * If the button/trigger is currently touched
  14606. */
  14607. touched: boolean;
  14608. /**
  14609. * If the button/trigger is currently pressed
  14610. */
  14611. pressed: boolean;
  14612. }
  14613. /**
  14614. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14615. * @hidden
  14616. */
  14617. export interface ExtendedGamepadButton extends GamepadButton {
  14618. /**
  14619. * If the button/trigger is currently pressed
  14620. */
  14621. readonly pressed: boolean;
  14622. /**
  14623. * If the button/trigger is currently touched
  14624. */
  14625. readonly touched: boolean;
  14626. /**
  14627. * Value of the button/trigger
  14628. */
  14629. readonly value: number;
  14630. }
  14631. /** @hidden */
  14632. export interface _GamePadFactory {
  14633. /**
  14634. * Returns wether or not the current gamepad can be created for this type of controller.
  14635. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14636. * @returns true if it can be created, otherwise false
  14637. */
  14638. canCreate(gamepadInfo: any): boolean;
  14639. /**
  14640. * Creates a new instance of the Gamepad.
  14641. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14642. * @returns the new gamepad instance
  14643. */
  14644. create(gamepadInfo: any): Gamepad;
  14645. }
  14646. /**
  14647. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14648. */
  14649. export class PoseEnabledControllerHelper {
  14650. /** @hidden */
  14651. static _ControllerFactories: _GamePadFactory[];
  14652. /** @hidden */
  14653. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14654. /**
  14655. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14656. * @param vrGamepad the gamepad to initialized
  14657. * @returns a vr controller of the type the gamepad identified as
  14658. */
  14659. static InitiateController(vrGamepad: any): Gamepad;
  14660. }
  14661. /**
  14662. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14663. */
  14664. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14665. /**
  14666. * If the controller is used in a webXR session
  14667. */
  14668. isXR: boolean;
  14669. private _deviceRoomPosition;
  14670. private _deviceRoomRotationQuaternion;
  14671. /**
  14672. * The device position in babylon space
  14673. */
  14674. devicePosition: Vector3;
  14675. /**
  14676. * The device rotation in babylon space
  14677. */
  14678. deviceRotationQuaternion: Quaternion;
  14679. /**
  14680. * The scale factor of the device in babylon space
  14681. */
  14682. deviceScaleFactor: number;
  14683. /**
  14684. * (Likely devicePosition should be used instead) The device position in its room space
  14685. */
  14686. position: Vector3;
  14687. /**
  14688. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14689. */
  14690. rotationQuaternion: Quaternion;
  14691. /**
  14692. * The type of controller (Eg. Windows mixed reality)
  14693. */
  14694. controllerType: PoseEnabledControllerType;
  14695. protected _calculatedPosition: Vector3;
  14696. private _calculatedRotation;
  14697. /**
  14698. * The raw pose from the device
  14699. */
  14700. rawPose: DevicePose;
  14701. private _trackPosition;
  14702. private _maxRotationDistFromHeadset;
  14703. private _draggedRoomRotation;
  14704. /**
  14705. * @hidden
  14706. */
  14707. _disableTrackPosition(fixedPosition: Vector3): void;
  14708. /**
  14709. * Internal, the mesh attached to the controller
  14710. * @hidden
  14711. */
  14712. _mesh: Nullable<AbstractMesh>;
  14713. private _poseControlledCamera;
  14714. private _leftHandSystemQuaternion;
  14715. /**
  14716. * Internal, matrix used to convert room space to babylon space
  14717. * @hidden
  14718. */
  14719. _deviceToWorld: Matrix;
  14720. /**
  14721. * Node to be used when casting a ray from the controller
  14722. * @hidden
  14723. */
  14724. _pointingPoseNode: Nullable<TransformNode>;
  14725. /**
  14726. * Name of the child mesh that can be used to cast a ray from the controller
  14727. */
  14728. static readonly POINTING_POSE: string;
  14729. /**
  14730. * Creates a new PoseEnabledController from a gamepad
  14731. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14732. */
  14733. constructor(browserGamepad: any);
  14734. private _workingMatrix;
  14735. /**
  14736. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14737. */
  14738. update(): void;
  14739. /**
  14740. * Updates only the pose device and mesh without doing any button event checking
  14741. */
  14742. protected _updatePoseAndMesh(): void;
  14743. /**
  14744. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14745. * @param poseData raw pose fromthe device
  14746. */
  14747. updateFromDevice(poseData: DevicePose): void;
  14748. /**
  14749. * @hidden
  14750. */
  14751. _meshAttachedObservable: Observable<AbstractMesh>;
  14752. /**
  14753. * Attaches a mesh to the controller
  14754. * @param mesh the mesh to be attached
  14755. */
  14756. attachToMesh(mesh: AbstractMesh): void;
  14757. /**
  14758. * Attaches the controllers mesh to a camera
  14759. * @param camera the camera the mesh should be attached to
  14760. */
  14761. attachToPoseControlledCamera(camera: TargetCamera): void;
  14762. /**
  14763. * Disposes of the controller
  14764. */
  14765. dispose(): void;
  14766. /**
  14767. * The mesh that is attached to the controller
  14768. */
  14769. readonly mesh: Nullable<AbstractMesh>;
  14770. /**
  14771. * Gets the ray of the controller in the direction the controller is pointing
  14772. * @param length the length the resulting ray should be
  14773. * @returns a ray in the direction the controller is pointing
  14774. */
  14775. getForwardRay(length?: number): Ray;
  14776. }
  14777. }
  14778. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14779. import { Observable } from "babylonjs/Misc/observable";
  14780. import { Scene } from "babylonjs/scene";
  14781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14782. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14783. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14784. import { Nullable } from "babylonjs/types";
  14785. /**
  14786. * Defines the WebVRController object that represents controllers tracked in 3D space
  14787. */
  14788. export abstract class WebVRController extends PoseEnabledController {
  14789. /**
  14790. * Internal, the default controller model for the controller
  14791. */
  14792. protected _defaultModel: Nullable<AbstractMesh>;
  14793. /**
  14794. * Fired when the trigger state has changed
  14795. */
  14796. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14797. /**
  14798. * Fired when the main button state has changed
  14799. */
  14800. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14801. /**
  14802. * Fired when the secondary button state has changed
  14803. */
  14804. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14805. /**
  14806. * Fired when the pad state has changed
  14807. */
  14808. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14809. /**
  14810. * Fired when controllers stick values have changed
  14811. */
  14812. onPadValuesChangedObservable: Observable<StickValues>;
  14813. /**
  14814. * Array of button availible on the controller
  14815. */
  14816. protected _buttons: Array<MutableGamepadButton>;
  14817. private _onButtonStateChange;
  14818. /**
  14819. * Fired when a controller button's state has changed
  14820. * @param callback the callback containing the button that was modified
  14821. */
  14822. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14823. /**
  14824. * X and Y axis corresponding to the controllers joystick
  14825. */
  14826. pad: StickValues;
  14827. /**
  14828. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14829. */
  14830. hand: string;
  14831. /**
  14832. * The default controller model for the controller
  14833. */
  14834. readonly defaultModel: Nullable<AbstractMesh>;
  14835. /**
  14836. * Creates a new WebVRController from a gamepad
  14837. * @param vrGamepad the gamepad that the WebVRController should be created from
  14838. */
  14839. constructor(vrGamepad: any);
  14840. /**
  14841. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14842. */
  14843. update(): void;
  14844. /**
  14845. * Function to be called when a button is modified
  14846. */
  14847. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14848. /**
  14849. * Loads a mesh and attaches it to the controller
  14850. * @param scene the scene the mesh should be added to
  14851. * @param meshLoaded callback for when the mesh has been loaded
  14852. */
  14853. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14854. private _setButtonValue;
  14855. private _changes;
  14856. private _checkChanges;
  14857. /**
  14858. * Disposes of th webVRCOntroller
  14859. */
  14860. dispose(): void;
  14861. }
  14862. }
  14863. declare module "babylonjs/Lights/hemisphericLight" {
  14864. import { Nullable } from "babylonjs/types";
  14865. import { Scene } from "babylonjs/scene";
  14866. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14867. import { Color3 } from "babylonjs/Maths/math.color";
  14868. import { Effect } from "babylonjs/Materials/effect";
  14869. import { Light } from "babylonjs/Lights/light";
  14870. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14871. /**
  14872. * The HemisphericLight simulates the ambient environment light,
  14873. * so the passed direction is the light reflection direction, not the incoming direction.
  14874. */
  14875. export class HemisphericLight extends Light {
  14876. /**
  14877. * The groundColor is the light in the opposite direction to the one specified during creation.
  14878. * 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.
  14879. */
  14880. groundColor: Color3;
  14881. /**
  14882. * The light reflection direction, not the incoming direction.
  14883. */
  14884. direction: Vector3;
  14885. /**
  14886. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14887. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14888. * The HemisphericLight can't cast shadows.
  14889. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14890. * @param name The friendly name of the light
  14891. * @param direction The direction of the light reflection
  14892. * @param scene The scene the light belongs to
  14893. */
  14894. constructor(name: string, direction: Vector3, scene: Scene);
  14895. protected _buildUniformLayout(): void;
  14896. /**
  14897. * Returns the string "HemisphericLight".
  14898. * @return The class name
  14899. */
  14900. getClassName(): string;
  14901. /**
  14902. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14903. * Returns the updated direction.
  14904. * @param target The target the direction should point to
  14905. * @return The computed direction
  14906. */
  14907. setDirectionToTarget(target: Vector3): Vector3;
  14908. /**
  14909. * Returns the shadow generator associated to the light.
  14910. * @returns Always null for hemispheric lights because it does not support shadows.
  14911. */
  14912. getShadowGenerator(): Nullable<IShadowGenerator>;
  14913. /**
  14914. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14915. * @param effect The effect to update
  14916. * @param lightIndex The index of the light in the effect to update
  14917. * @returns The hemispheric light
  14918. */
  14919. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14920. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14921. /**
  14922. * Computes the world matrix of the node
  14923. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14924. * @param useWasUpdatedFlag defines a reserved property
  14925. * @returns the world matrix
  14926. */
  14927. computeWorldMatrix(): Matrix;
  14928. /**
  14929. * Returns the integer 3.
  14930. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14931. */
  14932. getTypeID(): number;
  14933. /**
  14934. * Prepares the list of defines specific to the light type.
  14935. * @param defines the list of defines
  14936. * @param lightIndex defines the index of the light for the effect
  14937. */
  14938. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14939. }
  14940. }
  14941. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14942. /** @hidden */
  14943. export var vrMultiviewToSingleviewPixelShader: {
  14944. name: string;
  14945. shader: string;
  14946. };
  14947. }
  14948. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14949. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14950. import { Scene } from "babylonjs/scene";
  14951. /**
  14952. * Renders to multiple views with a single draw call
  14953. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14954. */
  14955. export class MultiviewRenderTarget extends RenderTargetTexture {
  14956. /**
  14957. * Creates a multiview render target
  14958. * @param scene scene used with the render target
  14959. * @param size the size of the render target (used for each view)
  14960. */
  14961. constructor(scene: Scene, size?: number | {
  14962. width: number;
  14963. height: number;
  14964. } | {
  14965. ratio: number;
  14966. });
  14967. /**
  14968. * @hidden
  14969. * @param faceIndex the face index, if its a cube texture
  14970. */
  14971. _bindFrameBuffer(faceIndex?: number): void;
  14972. /**
  14973. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14974. * @returns the view count
  14975. */
  14976. getViewCount(): number;
  14977. }
  14978. }
  14979. declare module "babylonjs/Maths/math.frustum" {
  14980. import { Matrix } from "babylonjs/Maths/math.vector";
  14981. import { DeepImmutable } from "babylonjs/types";
  14982. import { Plane } from "babylonjs/Maths/math.plane";
  14983. /**
  14984. * Represents a camera frustum
  14985. */
  14986. export class Frustum {
  14987. /**
  14988. * Gets the planes representing the frustum
  14989. * @param transform matrix to be applied to the returned planes
  14990. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14991. */
  14992. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14993. /**
  14994. * Gets the near frustum plane transformed by the transform matrix
  14995. * @param transform transformation matrix to be applied to the resulting frustum plane
  14996. * @param frustumPlane the resuling frustum plane
  14997. */
  14998. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14999. /**
  15000. * Gets the far frustum plane transformed by the transform matrix
  15001. * @param transform transformation matrix to be applied to the resulting frustum plane
  15002. * @param frustumPlane the resuling frustum plane
  15003. */
  15004. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15005. /**
  15006. * Gets the left frustum plane transformed by the transform matrix
  15007. * @param transform transformation matrix to be applied to the resulting frustum plane
  15008. * @param frustumPlane the resuling frustum plane
  15009. */
  15010. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15011. /**
  15012. * Gets the right frustum plane transformed by the transform matrix
  15013. * @param transform transformation matrix to be applied to the resulting frustum plane
  15014. * @param frustumPlane the resuling frustum plane
  15015. */
  15016. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15017. /**
  15018. * Gets the top frustum plane transformed by the transform matrix
  15019. * @param transform transformation matrix to be applied to the resulting frustum plane
  15020. * @param frustumPlane the resuling frustum plane
  15021. */
  15022. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15023. /**
  15024. * Gets the bottom frustum plane transformed by the transform matrix
  15025. * @param transform transformation matrix to be applied to the resulting frustum plane
  15026. * @param frustumPlane the resuling frustum plane
  15027. */
  15028. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15029. /**
  15030. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15031. * @param transform transformation matrix to be applied to the resulting frustum planes
  15032. * @param frustumPlanes the resuling frustum planes
  15033. */
  15034. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15035. }
  15036. }
  15037. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15038. import { Camera } from "babylonjs/Cameras/camera";
  15039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15040. import { Nullable } from "babylonjs/types";
  15041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15042. import { Matrix } from "babylonjs/Maths/math.vector";
  15043. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15044. module "babylonjs/Engines/engine" {
  15045. interface Engine {
  15046. /**
  15047. * Creates a new multiview render target
  15048. * @param width defines the width of the texture
  15049. * @param height defines the height of the texture
  15050. * @returns the created multiview texture
  15051. */
  15052. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15053. /**
  15054. * Binds a multiview framebuffer to be drawn to
  15055. * @param multiviewTexture texture to bind
  15056. */
  15057. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15058. }
  15059. }
  15060. module "babylonjs/Cameras/camera" {
  15061. interface Camera {
  15062. /**
  15063. * @hidden
  15064. * 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)
  15065. */
  15066. _useMultiviewToSingleView: boolean;
  15067. /**
  15068. * @hidden
  15069. * 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)
  15070. */
  15071. _multiviewTexture: Nullable<RenderTargetTexture>;
  15072. /**
  15073. * @hidden
  15074. * ensures the multiview texture of the camera exists and has the specified width/height
  15075. * @param width height to set on the multiview texture
  15076. * @param height width to set on the multiview texture
  15077. */
  15078. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15079. }
  15080. }
  15081. module "babylonjs/scene" {
  15082. interface Scene {
  15083. /** @hidden */
  15084. _transformMatrixR: Matrix;
  15085. /** @hidden */
  15086. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15087. /** @hidden */
  15088. _createMultiviewUbo(): void;
  15089. /** @hidden */
  15090. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15091. /** @hidden */
  15092. _renderMultiviewToSingleView(camera: Camera): void;
  15093. }
  15094. }
  15095. }
  15096. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15097. import { Camera } from "babylonjs/Cameras/camera";
  15098. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15099. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15100. import "babylonjs/Engines/Extensions/engine.multiview";
  15101. /**
  15102. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15103. * This will not be used for webXR as it supports displaying texture arrays directly
  15104. */
  15105. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15106. /**
  15107. * Initializes a VRMultiviewToSingleview
  15108. * @param name name of the post process
  15109. * @param camera camera to be applied to
  15110. * @param scaleFactor scaling factor to the size of the output texture
  15111. */
  15112. constructor(name: string, camera: Camera, scaleFactor: number);
  15113. }
  15114. }
  15115. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15116. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15117. import { Nullable } from "babylonjs/types";
  15118. import { Size } from "babylonjs/Maths/math.size";
  15119. import { Observable } from "babylonjs/Misc/observable";
  15120. module "babylonjs/Engines/engine" {
  15121. interface Engine {
  15122. /** @hidden */
  15123. _vrDisplay: any;
  15124. /** @hidden */
  15125. _vrSupported: boolean;
  15126. /** @hidden */
  15127. _oldSize: Size;
  15128. /** @hidden */
  15129. _oldHardwareScaleFactor: number;
  15130. /** @hidden */
  15131. _vrExclusivePointerMode: boolean;
  15132. /** @hidden */
  15133. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15134. /** @hidden */
  15135. _onVRDisplayPointerRestricted: () => void;
  15136. /** @hidden */
  15137. _onVRDisplayPointerUnrestricted: () => void;
  15138. /** @hidden */
  15139. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15140. /** @hidden */
  15141. _onVrDisplayDisconnect: Nullable<() => void>;
  15142. /** @hidden */
  15143. _onVrDisplayPresentChange: Nullable<() => void>;
  15144. /**
  15145. * Observable signaled when VR display mode changes
  15146. */
  15147. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15148. /**
  15149. * Observable signaled when VR request present is complete
  15150. */
  15151. onVRRequestPresentComplete: Observable<boolean>;
  15152. /**
  15153. * Observable signaled when VR request present starts
  15154. */
  15155. onVRRequestPresentStart: Observable<Engine>;
  15156. /**
  15157. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15158. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15159. */
  15160. isInVRExclusivePointerMode: boolean;
  15161. /**
  15162. * Gets a boolean indicating if a webVR device was detected
  15163. * @returns true if a webVR device was detected
  15164. */
  15165. isVRDevicePresent(): boolean;
  15166. /**
  15167. * Gets the current webVR device
  15168. * @returns the current webVR device (or null)
  15169. */
  15170. getVRDevice(): any;
  15171. /**
  15172. * Initializes a webVR display and starts listening to display change events
  15173. * The onVRDisplayChangedObservable will be notified upon these changes
  15174. * @returns A promise containing a VRDisplay and if vr is supported
  15175. */
  15176. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15177. /** @hidden */
  15178. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15179. /**
  15180. * Call this function to switch to webVR mode
  15181. * Will do nothing if webVR is not supported or if there is no webVR device
  15182. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15183. */
  15184. enableVR(): void;
  15185. /** @hidden */
  15186. _onVRFullScreenTriggered(): void;
  15187. }
  15188. }
  15189. }
  15190. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15191. import { Nullable } from "babylonjs/types";
  15192. import { Observable } from "babylonjs/Misc/observable";
  15193. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15194. import { Scene } from "babylonjs/scene";
  15195. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15196. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15197. import { Node } from "babylonjs/node";
  15198. import { Ray } from "babylonjs/Culling/ray";
  15199. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15200. import "babylonjs/Engines/Extensions/engine.webVR";
  15201. /**
  15202. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15203. * IMPORTANT!! The data is right-hand data.
  15204. * @export
  15205. * @interface DevicePose
  15206. */
  15207. export interface DevicePose {
  15208. /**
  15209. * The position of the device, values in array are [x,y,z].
  15210. */
  15211. readonly position: Nullable<Float32Array>;
  15212. /**
  15213. * The linearVelocity of the device, values in array are [x,y,z].
  15214. */
  15215. readonly linearVelocity: Nullable<Float32Array>;
  15216. /**
  15217. * The linearAcceleration of the device, values in array are [x,y,z].
  15218. */
  15219. readonly linearAcceleration: Nullable<Float32Array>;
  15220. /**
  15221. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15222. */
  15223. readonly orientation: Nullable<Float32Array>;
  15224. /**
  15225. * The angularVelocity of the device, values in array are [x,y,z].
  15226. */
  15227. readonly angularVelocity: Nullable<Float32Array>;
  15228. /**
  15229. * The angularAcceleration of the device, values in array are [x,y,z].
  15230. */
  15231. readonly angularAcceleration: Nullable<Float32Array>;
  15232. }
  15233. /**
  15234. * Interface representing a pose controlled object in Babylon.
  15235. * A pose controlled object has both regular pose values as well as pose values
  15236. * from an external device such as a VR head mounted display
  15237. */
  15238. export interface PoseControlled {
  15239. /**
  15240. * The position of the object in babylon space.
  15241. */
  15242. position: Vector3;
  15243. /**
  15244. * The rotation quaternion of the object in babylon space.
  15245. */
  15246. rotationQuaternion: Quaternion;
  15247. /**
  15248. * The position of the device in babylon space.
  15249. */
  15250. devicePosition?: Vector3;
  15251. /**
  15252. * The rotation quaternion of the device in babylon space.
  15253. */
  15254. deviceRotationQuaternion: Quaternion;
  15255. /**
  15256. * The raw pose coming from the device.
  15257. */
  15258. rawPose: Nullable<DevicePose>;
  15259. /**
  15260. * The scale of the device to be used when translating from device space to babylon space.
  15261. */
  15262. deviceScaleFactor: number;
  15263. /**
  15264. * Updates the poseControlled values based on the input device pose.
  15265. * @param poseData the pose data to update the object with
  15266. */
  15267. updateFromDevice(poseData: DevicePose): void;
  15268. }
  15269. /**
  15270. * Set of options to customize the webVRCamera
  15271. */
  15272. export interface WebVROptions {
  15273. /**
  15274. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15275. */
  15276. trackPosition?: boolean;
  15277. /**
  15278. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15279. */
  15280. positionScale?: number;
  15281. /**
  15282. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15283. */
  15284. displayName?: string;
  15285. /**
  15286. * Should the native controller meshes be initialized. (default: true)
  15287. */
  15288. controllerMeshes?: boolean;
  15289. /**
  15290. * Creating a default HemiLight only on controllers. (default: true)
  15291. */
  15292. defaultLightingOnControllers?: boolean;
  15293. /**
  15294. * If you don't want to use the default VR button of the helper. (default: false)
  15295. */
  15296. useCustomVRButton?: boolean;
  15297. /**
  15298. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15299. */
  15300. customVRButton?: HTMLButtonElement;
  15301. /**
  15302. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15303. */
  15304. rayLength?: number;
  15305. /**
  15306. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15307. */
  15308. defaultHeight?: number;
  15309. /**
  15310. * If multiview should be used if availible (default: false)
  15311. */
  15312. useMultiview?: boolean;
  15313. }
  15314. /**
  15315. * This represents a WebVR camera.
  15316. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15317. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15318. */
  15319. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15320. private webVROptions;
  15321. /**
  15322. * @hidden
  15323. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15324. */
  15325. _vrDevice: any;
  15326. /**
  15327. * The rawPose of the vrDevice.
  15328. */
  15329. rawPose: Nullable<DevicePose>;
  15330. private _onVREnabled;
  15331. private _specsVersion;
  15332. private _attached;
  15333. private _frameData;
  15334. protected _descendants: Array<Node>;
  15335. private _deviceRoomPosition;
  15336. /** @hidden */
  15337. _deviceRoomRotationQuaternion: Quaternion;
  15338. private _standingMatrix;
  15339. /**
  15340. * Represents device position in babylon space.
  15341. */
  15342. devicePosition: Vector3;
  15343. /**
  15344. * Represents device rotation in babylon space.
  15345. */
  15346. deviceRotationQuaternion: Quaternion;
  15347. /**
  15348. * The scale of the device to be used when translating from device space to babylon space.
  15349. */
  15350. deviceScaleFactor: number;
  15351. private _deviceToWorld;
  15352. private _worldToDevice;
  15353. /**
  15354. * References to the webVR controllers for the vrDevice.
  15355. */
  15356. controllers: Array<WebVRController>;
  15357. /**
  15358. * Emits an event when a controller is attached.
  15359. */
  15360. onControllersAttachedObservable: Observable<WebVRController[]>;
  15361. /**
  15362. * Emits an event when a controller's mesh has been loaded;
  15363. */
  15364. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15365. /**
  15366. * Emits an event when the HMD's pose has been updated.
  15367. */
  15368. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15369. private _poseSet;
  15370. /**
  15371. * If the rig cameras be used as parent instead of this camera.
  15372. */
  15373. rigParenting: boolean;
  15374. private _lightOnControllers;
  15375. private _defaultHeight?;
  15376. /**
  15377. * Instantiates a WebVRFreeCamera.
  15378. * @param name The name of the WebVRFreeCamera
  15379. * @param position The starting anchor position for the camera
  15380. * @param scene The scene the camera belongs to
  15381. * @param webVROptions a set of customizable options for the webVRCamera
  15382. */
  15383. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15384. /**
  15385. * Gets the device distance from the ground in meters.
  15386. * @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.
  15387. */
  15388. deviceDistanceToRoomGround(): number;
  15389. /**
  15390. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15391. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15392. */
  15393. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15394. /**
  15395. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15396. * @returns A promise with a boolean set to if the standing matrix is supported.
  15397. */
  15398. useStandingMatrixAsync(): Promise<boolean>;
  15399. /**
  15400. * Disposes the camera
  15401. */
  15402. dispose(): void;
  15403. /**
  15404. * Gets a vrController by name.
  15405. * @param name The name of the controller to retreive
  15406. * @returns the controller matching the name specified or null if not found
  15407. */
  15408. getControllerByName(name: string): Nullable<WebVRController>;
  15409. private _leftController;
  15410. /**
  15411. * The controller corresponding to the users left hand.
  15412. */
  15413. readonly leftController: Nullable<WebVRController>;
  15414. private _rightController;
  15415. /**
  15416. * The controller corresponding to the users right hand.
  15417. */
  15418. readonly rightController: Nullable<WebVRController>;
  15419. /**
  15420. * Casts a ray forward from the vrCamera's gaze.
  15421. * @param length Length of the ray (default: 100)
  15422. * @returns the ray corresponding to the gaze
  15423. */
  15424. getForwardRay(length?: number): Ray;
  15425. /**
  15426. * @hidden
  15427. * Updates the camera based on device's frame data
  15428. */
  15429. _checkInputs(): void;
  15430. /**
  15431. * Updates the poseControlled values based on the input device pose.
  15432. * @param poseData Pose coming from the device
  15433. */
  15434. updateFromDevice(poseData: DevicePose): void;
  15435. private _htmlElementAttached;
  15436. private _detachIfAttached;
  15437. /**
  15438. * WebVR's attach control will start broadcasting frames to the device.
  15439. * Note that in certain browsers (chrome for example) this function must be called
  15440. * within a user-interaction callback. Example:
  15441. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15442. *
  15443. * @param element html element to attach the vrDevice to
  15444. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15445. */
  15446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15447. /**
  15448. * Detaches the camera from the html element and disables VR
  15449. *
  15450. * @param element html element to detach from
  15451. */
  15452. detachControl(element: HTMLElement): void;
  15453. /**
  15454. * @returns the name of this class
  15455. */
  15456. getClassName(): string;
  15457. /**
  15458. * Calls resetPose on the vrDisplay
  15459. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15460. */
  15461. resetToCurrentRotation(): void;
  15462. /**
  15463. * @hidden
  15464. * Updates the rig cameras (left and right eye)
  15465. */
  15466. _updateRigCameras(): void;
  15467. private _workingVector;
  15468. private _oneVector;
  15469. private _workingMatrix;
  15470. private updateCacheCalled;
  15471. private _correctPositionIfNotTrackPosition;
  15472. /**
  15473. * @hidden
  15474. * Updates the cached values of the camera
  15475. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15476. */
  15477. _updateCache(ignoreParentClass?: boolean): void;
  15478. /**
  15479. * @hidden
  15480. * Get current device position in babylon world
  15481. */
  15482. _computeDevicePosition(): void;
  15483. /**
  15484. * Updates the current device position and rotation in the babylon world
  15485. */
  15486. update(): void;
  15487. /**
  15488. * @hidden
  15489. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15490. * @returns an identity matrix
  15491. */
  15492. _getViewMatrix(): Matrix;
  15493. private _tmpMatrix;
  15494. /**
  15495. * This function is called by the two RIG cameras.
  15496. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15497. * @hidden
  15498. */
  15499. _getWebVRViewMatrix(): Matrix;
  15500. /** @hidden */
  15501. _getWebVRProjectionMatrix(): Matrix;
  15502. private _onGamepadConnectedObserver;
  15503. private _onGamepadDisconnectedObserver;
  15504. private _updateCacheWhenTrackingDisabledObserver;
  15505. /**
  15506. * Initializes the controllers and their meshes
  15507. */
  15508. initControllers(): void;
  15509. }
  15510. }
  15511. declare module "babylonjs/PostProcesses/postProcess" {
  15512. import { Nullable } from "babylonjs/types";
  15513. import { SmartArray } from "babylonjs/Misc/smartArray";
  15514. import { Observable } from "babylonjs/Misc/observable";
  15515. import { Vector2 } from "babylonjs/Maths/math.vector";
  15516. import { Camera } from "babylonjs/Cameras/camera";
  15517. import { Effect } from "babylonjs/Materials/effect";
  15518. import "babylonjs/Shaders/postprocess.vertex";
  15519. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15520. import { Engine } from "babylonjs/Engines/engine";
  15521. import { Color4 } from "babylonjs/Maths/math.color";
  15522. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15524. /**
  15525. * Size options for a post process
  15526. */
  15527. export type PostProcessOptions = {
  15528. width: number;
  15529. height: number;
  15530. };
  15531. /**
  15532. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15533. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15534. */
  15535. export class PostProcess {
  15536. /** Name of the PostProcess. */
  15537. name: string;
  15538. /**
  15539. * Gets or sets the unique id of the post process
  15540. */
  15541. uniqueId: number;
  15542. /**
  15543. * Width of the texture to apply the post process on
  15544. */
  15545. width: number;
  15546. /**
  15547. * Height of the texture to apply the post process on
  15548. */
  15549. height: number;
  15550. /**
  15551. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15552. * @hidden
  15553. */
  15554. _outputTexture: Nullable<InternalTexture>;
  15555. /**
  15556. * Sampling mode used by the shader
  15557. * See https://doc.babylonjs.com/classes/3.1/texture
  15558. */
  15559. renderTargetSamplingMode: number;
  15560. /**
  15561. * Clear color to use when screen clearing
  15562. */
  15563. clearColor: Color4;
  15564. /**
  15565. * If the buffer needs to be cleared before applying the post process. (default: true)
  15566. * Should be set to false if shader will overwrite all previous pixels.
  15567. */
  15568. autoClear: boolean;
  15569. /**
  15570. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15571. */
  15572. alphaMode: number;
  15573. /**
  15574. * Sets the setAlphaBlendConstants of the babylon engine
  15575. */
  15576. alphaConstants: Color4;
  15577. /**
  15578. * Animations to be used for the post processing
  15579. */
  15580. animations: import("babylonjs/Animations/animation").Animation[];
  15581. /**
  15582. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15583. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15584. */
  15585. enablePixelPerfectMode: boolean;
  15586. /**
  15587. * Force the postprocess to be applied without taking in account viewport
  15588. */
  15589. forceFullscreenViewport: boolean;
  15590. /**
  15591. * List of inspectable custom properties (used by the Inspector)
  15592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15593. */
  15594. inspectableCustomProperties: IInspectable[];
  15595. /**
  15596. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15597. *
  15598. * | Value | Type | Description |
  15599. * | ----- | ----------------------------------- | ----------- |
  15600. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15601. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15602. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15603. *
  15604. */
  15605. scaleMode: number;
  15606. /**
  15607. * Force textures to be a power of two (default: false)
  15608. */
  15609. alwaysForcePOT: boolean;
  15610. private _samples;
  15611. /**
  15612. * Number of sample textures (default: 1)
  15613. */
  15614. samples: number;
  15615. /**
  15616. * Modify the scale of the post process to be the same as the viewport (default: false)
  15617. */
  15618. adaptScaleToCurrentViewport: boolean;
  15619. private _camera;
  15620. private _scene;
  15621. private _engine;
  15622. private _options;
  15623. private _reusable;
  15624. private _textureType;
  15625. /**
  15626. * Smart array of input and output textures for the post process.
  15627. * @hidden
  15628. */
  15629. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15630. /**
  15631. * The index in _textures that corresponds to the output texture.
  15632. * @hidden
  15633. */
  15634. _currentRenderTextureInd: number;
  15635. private _effect;
  15636. private _samplers;
  15637. private _fragmentUrl;
  15638. private _vertexUrl;
  15639. private _parameters;
  15640. private _scaleRatio;
  15641. protected _indexParameters: any;
  15642. private _shareOutputWithPostProcess;
  15643. private _texelSize;
  15644. private _forcedOutputTexture;
  15645. /**
  15646. * Returns the fragment url or shader name used in the post process.
  15647. * @returns the fragment url or name in the shader store.
  15648. */
  15649. getEffectName(): string;
  15650. /**
  15651. * An event triggered when the postprocess is activated.
  15652. */
  15653. onActivateObservable: Observable<Camera>;
  15654. private _onActivateObserver;
  15655. /**
  15656. * A function that is added to the onActivateObservable
  15657. */
  15658. onActivate: Nullable<(camera: Camera) => void>;
  15659. /**
  15660. * An event triggered when the postprocess changes its size.
  15661. */
  15662. onSizeChangedObservable: Observable<PostProcess>;
  15663. private _onSizeChangedObserver;
  15664. /**
  15665. * A function that is added to the onSizeChangedObservable
  15666. */
  15667. onSizeChanged: (postProcess: PostProcess) => void;
  15668. /**
  15669. * An event triggered when the postprocess applies its effect.
  15670. */
  15671. onApplyObservable: Observable<Effect>;
  15672. private _onApplyObserver;
  15673. /**
  15674. * A function that is added to the onApplyObservable
  15675. */
  15676. onApply: (effect: Effect) => void;
  15677. /**
  15678. * An event triggered before rendering the postprocess
  15679. */
  15680. onBeforeRenderObservable: Observable<Effect>;
  15681. private _onBeforeRenderObserver;
  15682. /**
  15683. * A function that is added to the onBeforeRenderObservable
  15684. */
  15685. onBeforeRender: (effect: Effect) => void;
  15686. /**
  15687. * An event triggered after rendering the postprocess
  15688. */
  15689. onAfterRenderObservable: Observable<Effect>;
  15690. private _onAfterRenderObserver;
  15691. /**
  15692. * A function that is added to the onAfterRenderObservable
  15693. */
  15694. onAfterRender: (efect: Effect) => void;
  15695. /**
  15696. * 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
  15697. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15698. */
  15699. inputTexture: InternalTexture;
  15700. /**
  15701. * Gets the camera which post process is applied to.
  15702. * @returns The camera the post process is applied to.
  15703. */
  15704. getCamera(): Camera;
  15705. /**
  15706. * Gets the texel size of the postprocess.
  15707. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15708. */
  15709. readonly texelSize: Vector2;
  15710. /**
  15711. * Creates a new instance PostProcess
  15712. * @param name The name of the PostProcess.
  15713. * @param fragmentUrl The url of the fragment shader to be used.
  15714. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15715. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15716. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15717. * @param camera The camera to apply the render pass to.
  15718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15719. * @param engine The engine which the post process will be applied. (default: current engine)
  15720. * @param reusable If the post process can be reused on the same frame. (default: false)
  15721. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15722. * @param textureType Type of textures used when performing the post process. (default: 0)
  15723. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15724. * @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
  15725. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15726. */
  15727. constructor(
  15728. /** Name of the PostProcess. */
  15729. 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);
  15730. /**
  15731. * Gets a string idenfifying the name of the class
  15732. * @returns "PostProcess" string
  15733. */
  15734. getClassName(): string;
  15735. /**
  15736. * Gets the engine which this post process belongs to.
  15737. * @returns The engine the post process was enabled with.
  15738. */
  15739. getEngine(): Engine;
  15740. /**
  15741. * The effect that is created when initializing the post process.
  15742. * @returns The created effect corresponding the the postprocess.
  15743. */
  15744. getEffect(): Effect;
  15745. /**
  15746. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15747. * @param postProcess The post process to share the output with.
  15748. * @returns This post process.
  15749. */
  15750. shareOutputWith(postProcess: PostProcess): PostProcess;
  15751. /**
  15752. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15753. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15754. */
  15755. useOwnOutput(): void;
  15756. /**
  15757. * Updates the effect with the current post process compile time values and recompiles the shader.
  15758. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15759. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15760. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15761. * @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
  15762. * @param onCompiled Called when the shader has been compiled.
  15763. * @param onError Called if there is an error when compiling a shader.
  15764. */
  15765. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15766. /**
  15767. * The post process is reusable if it can be used multiple times within one frame.
  15768. * @returns If the post process is reusable
  15769. */
  15770. isReusable(): boolean;
  15771. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15772. markTextureDirty(): void;
  15773. /**
  15774. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15775. * 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.
  15776. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15777. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15778. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15779. * @returns The target texture that was bound to be written to.
  15780. */
  15781. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15782. /**
  15783. * If the post process is supported.
  15784. */
  15785. readonly isSupported: boolean;
  15786. /**
  15787. * The aspect ratio of the output texture.
  15788. */
  15789. readonly aspectRatio: number;
  15790. /**
  15791. * Get a value indicating if the post-process is ready to be used
  15792. * @returns true if the post-process is ready (shader is compiled)
  15793. */
  15794. isReady(): boolean;
  15795. /**
  15796. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15797. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15798. */
  15799. apply(): Nullable<Effect>;
  15800. private _disposeTextures;
  15801. /**
  15802. * Disposes the post process.
  15803. * @param camera The camera to dispose the post process on.
  15804. */
  15805. dispose(camera?: Camera): void;
  15806. }
  15807. }
  15808. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15809. /** @hidden */
  15810. export var kernelBlurVaryingDeclaration: {
  15811. name: string;
  15812. shader: string;
  15813. };
  15814. }
  15815. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15816. /** @hidden */
  15817. export var kernelBlurFragment: {
  15818. name: string;
  15819. shader: string;
  15820. };
  15821. }
  15822. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15823. /** @hidden */
  15824. export var kernelBlurFragment2: {
  15825. name: string;
  15826. shader: string;
  15827. };
  15828. }
  15829. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15830. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15831. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15832. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15833. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15834. /** @hidden */
  15835. export var kernelBlurPixelShader: {
  15836. name: string;
  15837. shader: string;
  15838. };
  15839. }
  15840. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15841. /** @hidden */
  15842. export var kernelBlurVertex: {
  15843. name: string;
  15844. shader: string;
  15845. };
  15846. }
  15847. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15848. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15849. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15850. /** @hidden */
  15851. export var kernelBlurVertexShader: {
  15852. name: string;
  15853. shader: string;
  15854. };
  15855. }
  15856. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15857. import { Vector2 } from "babylonjs/Maths/math.vector";
  15858. import { Nullable } from "babylonjs/types";
  15859. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15860. import { Camera } from "babylonjs/Cameras/camera";
  15861. import { Effect } from "babylonjs/Materials/effect";
  15862. import { Engine } from "babylonjs/Engines/engine";
  15863. import "babylonjs/Shaders/kernelBlur.fragment";
  15864. import "babylonjs/Shaders/kernelBlur.vertex";
  15865. /**
  15866. * The Blur Post Process which blurs an image based on a kernel and direction.
  15867. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15868. */
  15869. export class BlurPostProcess extends PostProcess {
  15870. /** The direction in which to blur the image. */
  15871. direction: Vector2;
  15872. private blockCompilation;
  15873. protected _kernel: number;
  15874. protected _idealKernel: number;
  15875. protected _packedFloat: boolean;
  15876. private _staticDefines;
  15877. /**
  15878. * Sets the length in pixels of the blur sample region
  15879. */
  15880. /**
  15881. * Gets the length in pixels of the blur sample region
  15882. */
  15883. kernel: number;
  15884. /**
  15885. * Sets wether or not the blur needs to unpack/repack floats
  15886. */
  15887. /**
  15888. * Gets wether or not the blur is unpacking/repacking floats
  15889. */
  15890. packedFloat: boolean;
  15891. /**
  15892. * Creates a new instance BlurPostProcess
  15893. * @param name The name of the effect.
  15894. * @param direction The direction in which to blur the image.
  15895. * @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.
  15896. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15897. * @param camera The camera to apply the render pass to.
  15898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15899. * @param engine The engine which the post process will be applied. (default: current engine)
  15900. * @param reusable If the post process can be reused on the same frame. (default: false)
  15901. * @param textureType Type of textures used when performing the post process. (default: 0)
  15902. * @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)
  15903. */
  15904. constructor(name: string,
  15905. /** The direction in which to blur the image. */
  15906. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15907. /**
  15908. * Updates the effect with the current post process compile time values and recompiles the shader.
  15909. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15910. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15911. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15912. * @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
  15913. * @param onCompiled Called when the shader has been compiled.
  15914. * @param onError Called if there is an error when compiling a shader.
  15915. */
  15916. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15917. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15918. /**
  15919. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15920. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15921. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15922. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15923. * The gaps between physical kernels are compensated for in the weighting of the samples
  15924. * @param idealKernel Ideal blur kernel.
  15925. * @return Nearest best kernel.
  15926. */
  15927. protected _nearestBestKernel(idealKernel: number): number;
  15928. /**
  15929. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15930. * @param x The point on the Gaussian distribution to sample.
  15931. * @return the value of the Gaussian function at x.
  15932. */
  15933. protected _gaussianWeight(x: number): number;
  15934. /**
  15935. * Generates a string that can be used as a floating point number in GLSL.
  15936. * @param x Value to print.
  15937. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15938. * @return GLSL float string.
  15939. */
  15940. protected _glslFloat(x: number, decimalFigures?: number): string;
  15941. }
  15942. }
  15943. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15944. import { Scene } from "babylonjs/scene";
  15945. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15946. import { Plane } from "babylonjs/Maths/math.plane";
  15947. /**
  15948. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15949. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15950. * You can then easily use it as a reflectionTexture on a flat surface.
  15951. * In case the surface is not a plane, please consider relying on reflection probes.
  15952. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15953. */
  15954. export class MirrorTexture extends RenderTargetTexture {
  15955. private scene;
  15956. /**
  15957. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15958. * 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.
  15959. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15960. */
  15961. mirrorPlane: Plane;
  15962. /**
  15963. * Define the blur ratio used to blur the reflection if needed.
  15964. */
  15965. blurRatio: number;
  15966. /**
  15967. * Define the adaptive blur kernel used to blur the reflection if needed.
  15968. * This will autocompute the closest best match for the `blurKernel`
  15969. */
  15970. adaptiveBlurKernel: number;
  15971. /**
  15972. * Define the blur kernel used to blur the reflection if needed.
  15973. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15974. */
  15975. blurKernel: number;
  15976. /**
  15977. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15978. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15979. */
  15980. blurKernelX: number;
  15981. /**
  15982. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15983. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15984. */
  15985. blurKernelY: number;
  15986. private _autoComputeBlurKernel;
  15987. protected _onRatioRescale(): void;
  15988. private _updateGammaSpace;
  15989. private _imageProcessingConfigChangeObserver;
  15990. private _transformMatrix;
  15991. private _mirrorMatrix;
  15992. private _savedViewMatrix;
  15993. private _blurX;
  15994. private _blurY;
  15995. private _adaptiveBlurKernel;
  15996. private _blurKernelX;
  15997. private _blurKernelY;
  15998. private _blurRatio;
  15999. /**
  16000. * Instantiates a Mirror Texture.
  16001. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16002. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16003. * You can then easily use it as a reflectionTexture on a flat surface.
  16004. * In case the surface is not a plane, please consider relying on reflection probes.
  16005. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16006. * @param name
  16007. * @param size
  16008. * @param scene
  16009. * @param generateMipMaps
  16010. * @param type
  16011. * @param samplingMode
  16012. * @param generateDepthBuffer
  16013. */
  16014. constructor(name: string, size: number | {
  16015. width: number;
  16016. height: number;
  16017. } | {
  16018. ratio: number;
  16019. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16020. private _preparePostProcesses;
  16021. /**
  16022. * Clone the mirror texture.
  16023. * @returns the cloned texture
  16024. */
  16025. clone(): MirrorTexture;
  16026. /**
  16027. * Serialize the texture to a JSON representation you could use in Parse later on
  16028. * @returns the serialized JSON representation
  16029. */
  16030. serialize(): any;
  16031. /**
  16032. * Dispose the texture and release its associated resources.
  16033. */
  16034. dispose(): void;
  16035. }
  16036. }
  16037. declare module "babylonjs/Materials/Textures/texture" {
  16038. import { Observable } from "babylonjs/Misc/observable";
  16039. import { Nullable } from "babylonjs/types";
  16040. import { Matrix } from "babylonjs/Maths/math.vector";
  16041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16042. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16043. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16044. import { Scene } from "babylonjs/scene";
  16045. /**
  16046. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16047. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16048. */
  16049. export class Texture extends BaseTexture {
  16050. /**
  16051. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16052. */
  16053. static SerializeBuffers: boolean;
  16054. /** @hidden */
  16055. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16056. /** @hidden */
  16057. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16058. /** @hidden */
  16059. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16060. /** nearest is mag = nearest and min = nearest and mip = linear */
  16061. static readonly NEAREST_SAMPLINGMODE: number;
  16062. /** nearest is mag = nearest and min = nearest and mip = linear */
  16063. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16064. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16065. static readonly BILINEAR_SAMPLINGMODE: number;
  16066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16067. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16068. /** Trilinear is mag = linear and min = linear and mip = linear */
  16069. static readonly TRILINEAR_SAMPLINGMODE: number;
  16070. /** Trilinear is mag = linear and min = linear and mip = linear */
  16071. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16072. /** mag = nearest and min = nearest and mip = nearest */
  16073. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16074. /** mag = nearest and min = linear and mip = nearest */
  16075. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16076. /** mag = nearest and min = linear and mip = linear */
  16077. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16078. /** mag = nearest and min = linear and mip = none */
  16079. static readonly NEAREST_LINEAR: number;
  16080. /** mag = nearest and min = nearest and mip = none */
  16081. static readonly NEAREST_NEAREST: number;
  16082. /** mag = linear and min = nearest and mip = nearest */
  16083. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16084. /** mag = linear and min = nearest and mip = linear */
  16085. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16086. /** mag = linear and min = linear and mip = none */
  16087. static readonly LINEAR_LINEAR: number;
  16088. /** mag = linear and min = nearest and mip = none */
  16089. static readonly LINEAR_NEAREST: number;
  16090. /** Explicit coordinates mode */
  16091. static readonly EXPLICIT_MODE: number;
  16092. /** Spherical coordinates mode */
  16093. static readonly SPHERICAL_MODE: number;
  16094. /** Planar coordinates mode */
  16095. static readonly PLANAR_MODE: number;
  16096. /** Cubic coordinates mode */
  16097. static readonly CUBIC_MODE: number;
  16098. /** Projection coordinates mode */
  16099. static readonly PROJECTION_MODE: number;
  16100. /** Inverse Cubic coordinates mode */
  16101. static readonly SKYBOX_MODE: number;
  16102. /** Inverse Cubic coordinates mode */
  16103. static readonly INVCUBIC_MODE: number;
  16104. /** Equirectangular coordinates mode */
  16105. static readonly EQUIRECTANGULAR_MODE: number;
  16106. /** Equirectangular Fixed coordinates mode */
  16107. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16108. /** Equirectangular Fixed Mirrored coordinates mode */
  16109. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16110. /** Texture is not repeating outside of 0..1 UVs */
  16111. static readonly CLAMP_ADDRESSMODE: number;
  16112. /** Texture is repeating outside of 0..1 UVs */
  16113. static readonly WRAP_ADDRESSMODE: number;
  16114. /** Texture is repeating and mirrored */
  16115. static readonly MIRROR_ADDRESSMODE: number;
  16116. /**
  16117. * 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
  16118. */
  16119. static UseSerializedUrlIfAny: boolean;
  16120. /**
  16121. * Define the url of the texture.
  16122. */
  16123. url: Nullable<string>;
  16124. /**
  16125. * Define an offset on the texture to offset the u coordinates of the UVs
  16126. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16127. */
  16128. uOffset: number;
  16129. /**
  16130. * Define an offset on the texture to offset the v coordinates of the UVs
  16131. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16132. */
  16133. vOffset: number;
  16134. /**
  16135. * Define an offset on the texture to scale the u coordinates of the UVs
  16136. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16137. */
  16138. uScale: number;
  16139. /**
  16140. * Define an offset on the texture to scale the v coordinates of the UVs
  16141. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16142. */
  16143. vScale: number;
  16144. /**
  16145. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16146. * @see http://doc.babylonjs.com/how_to/more_materials
  16147. */
  16148. uAng: number;
  16149. /**
  16150. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16151. * @see http://doc.babylonjs.com/how_to/more_materials
  16152. */
  16153. vAng: number;
  16154. /**
  16155. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16156. * @see http://doc.babylonjs.com/how_to/more_materials
  16157. */
  16158. wAng: number;
  16159. /**
  16160. * Defines the center of rotation (U)
  16161. */
  16162. uRotationCenter: number;
  16163. /**
  16164. * Defines the center of rotation (V)
  16165. */
  16166. vRotationCenter: number;
  16167. /**
  16168. * Defines the center of rotation (W)
  16169. */
  16170. wRotationCenter: number;
  16171. /**
  16172. * Are mip maps generated for this texture or not.
  16173. */
  16174. readonly noMipmap: boolean;
  16175. /**
  16176. * List of inspectable custom properties (used by the Inspector)
  16177. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16178. */
  16179. inspectableCustomProperties: Nullable<IInspectable[]>;
  16180. private _noMipmap;
  16181. /** @hidden */
  16182. _invertY: boolean;
  16183. private _rowGenerationMatrix;
  16184. private _cachedTextureMatrix;
  16185. private _projectionModeMatrix;
  16186. private _t0;
  16187. private _t1;
  16188. private _t2;
  16189. private _cachedUOffset;
  16190. private _cachedVOffset;
  16191. private _cachedUScale;
  16192. private _cachedVScale;
  16193. private _cachedUAng;
  16194. private _cachedVAng;
  16195. private _cachedWAng;
  16196. private _cachedProjectionMatrixId;
  16197. private _cachedCoordinatesMode;
  16198. /** @hidden */
  16199. protected _initialSamplingMode: number;
  16200. /** @hidden */
  16201. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16202. private _deleteBuffer;
  16203. protected _format: Nullable<number>;
  16204. private _delayedOnLoad;
  16205. private _delayedOnError;
  16206. private _mimeType?;
  16207. /**
  16208. * Observable triggered once the texture has been loaded.
  16209. */
  16210. onLoadObservable: Observable<Texture>;
  16211. protected _isBlocking: boolean;
  16212. /**
  16213. * Is the texture preventing material to render while loading.
  16214. * If false, a default texture will be used instead of the loading one during the preparation step.
  16215. */
  16216. isBlocking: boolean;
  16217. /**
  16218. * Get the current sampling mode associated with the texture.
  16219. */
  16220. readonly samplingMode: number;
  16221. /**
  16222. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16223. */
  16224. readonly invertY: boolean;
  16225. /**
  16226. * Instantiates a new texture.
  16227. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16228. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16229. * @param url defines the url of the picture to load as a texture
  16230. * @param scene defines the scene or engine the texture will belong to
  16231. * @param noMipmap defines if the texture will require mip maps or not
  16232. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16233. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16234. * @param onLoad defines a callback triggered when the texture has been loaded
  16235. * @param onError defines a callback triggered when an error occurred during the loading session
  16236. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16237. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16238. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16239. * @param mimeType defines an optional mime type information
  16240. */
  16241. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16242. /**
  16243. * Update the url (and optional buffer) of this texture if url was null during construction.
  16244. * @param url the url of the texture
  16245. * @param buffer the buffer of the texture (defaults to null)
  16246. * @param onLoad callback called when the texture is loaded (defaults to null)
  16247. */
  16248. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16249. /**
  16250. * Finish the loading sequence of a texture flagged as delayed load.
  16251. * @hidden
  16252. */
  16253. delayLoad(): void;
  16254. private _prepareRowForTextureGeneration;
  16255. /**
  16256. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16257. * @returns the transform matrix of the texture.
  16258. */
  16259. getTextureMatrix(): Matrix;
  16260. /**
  16261. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16262. * @returns The reflection texture transform
  16263. */
  16264. getReflectionTextureMatrix(): Matrix;
  16265. /**
  16266. * Clones the texture.
  16267. * @returns the cloned texture
  16268. */
  16269. clone(): Texture;
  16270. /**
  16271. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16272. * @returns The JSON representation of the texture
  16273. */
  16274. serialize(): any;
  16275. /**
  16276. * Get the current class name of the texture useful for serialization or dynamic coding.
  16277. * @returns "Texture"
  16278. */
  16279. getClassName(): string;
  16280. /**
  16281. * Dispose the texture and release its associated resources.
  16282. */
  16283. dispose(): void;
  16284. /**
  16285. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16286. * @param parsedTexture Define the JSON representation of the texture
  16287. * @param scene Define the scene the parsed texture should be instantiated in
  16288. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16289. * @returns The parsed texture if successful
  16290. */
  16291. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16292. /**
  16293. * Creates a texture from its base 64 representation.
  16294. * @param data Define the base64 payload without the data: prefix
  16295. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16296. * @param scene Define the scene the texture should belong to
  16297. * @param noMipmap Forces the texture to not create mip map information if true
  16298. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16299. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16300. * @param onLoad define a callback triggered when the texture has been loaded
  16301. * @param onError define a callback triggered when an error occurred during the loading session
  16302. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16303. * @returns the created texture
  16304. */
  16305. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16306. /**
  16307. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16308. * @param data Define the base64 payload without the data: prefix
  16309. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16310. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16311. * @param scene Define the scene the texture should belong to
  16312. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16313. * @param noMipmap Forces the texture to not create mip map information if true
  16314. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16315. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16316. * @param onLoad define a callback triggered when the texture has been loaded
  16317. * @param onError define a callback triggered when an error occurred during the loading session
  16318. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16319. * @returns the created texture
  16320. */
  16321. 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;
  16322. }
  16323. }
  16324. declare module "babylonjs/PostProcesses/postProcessManager" {
  16325. import { Nullable } from "babylonjs/types";
  16326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16328. import { Scene } from "babylonjs/scene";
  16329. /**
  16330. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16331. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16332. */
  16333. export class PostProcessManager {
  16334. private _scene;
  16335. private _indexBuffer;
  16336. private _vertexBuffers;
  16337. /**
  16338. * Creates a new instance PostProcess
  16339. * @param scene The scene that the post process is associated with.
  16340. */
  16341. constructor(scene: Scene);
  16342. private _prepareBuffers;
  16343. private _buildIndexBuffer;
  16344. /**
  16345. * Rebuilds the vertex buffers of the manager.
  16346. * @hidden
  16347. */
  16348. _rebuild(): void;
  16349. /**
  16350. * Prepares a frame to be run through a post process.
  16351. * @param sourceTexture The input texture to the post procesess. (default: null)
  16352. * @param postProcesses An array of post processes to be run. (default: null)
  16353. * @returns True if the post processes were able to be run.
  16354. * @hidden
  16355. */
  16356. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16357. /**
  16358. * Manually render a set of post processes to a texture.
  16359. * @param postProcesses An array of post processes to be run.
  16360. * @param targetTexture The target texture to render to.
  16361. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16362. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16363. * @param lodLevel defines which lod of the texture to render to
  16364. */
  16365. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16366. /**
  16367. * Finalize the result of the output of the postprocesses.
  16368. * @param doNotPresent If true the result will not be displayed to the screen.
  16369. * @param targetTexture The target texture to render to.
  16370. * @param faceIndex The index of the face to bind the target texture to.
  16371. * @param postProcesses The array of post processes to render.
  16372. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16373. * @hidden
  16374. */
  16375. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16376. /**
  16377. * Disposes of the post process manager.
  16378. */
  16379. dispose(): void;
  16380. }
  16381. }
  16382. declare module "babylonjs/Misc/gradients" {
  16383. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16384. /** Interface used by value gradients (color, factor, ...) */
  16385. export interface IValueGradient {
  16386. /**
  16387. * Gets or sets the gradient value (between 0 and 1)
  16388. */
  16389. gradient: number;
  16390. }
  16391. /** Class used to store color4 gradient */
  16392. export class ColorGradient implements IValueGradient {
  16393. /**
  16394. * Gets or sets the gradient value (between 0 and 1)
  16395. */
  16396. gradient: number;
  16397. /**
  16398. * Gets or sets first associated color
  16399. */
  16400. color1: Color4;
  16401. /**
  16402. * Gets or sets second associated color
  16403. */
  16404. color2?: Color4;
  16405. /**
  16406. * Will get a color picked randomly between color1 and color2.
  16407. * If color2 is undefined then color1 will be used
  16408. * @param result defines the target Color4 to store the result in
  16409. */
  16410. getColorToRef(result: Color4): void;
  16411. }
  16412. /** Class used to store color 3 gradient */
  16413. export class Color3Gradient implements IValueGradient {
  16414. /**
  16415. * Gets or sets the gradient value (between 0 and 1)
  16416. */
  16417. gradient: number;
  16418. /**
  16419. * Gets or sets the associated color
  16420. */
  16421. color: Color3;
  16422. }
  16423. /** Class used to store factor gradient */
  16424. export class FactorGradient implements IValueGradient {
  16425. /**
  16426. * Gets or sets the gradient value (between 0 and 1)
  16427. */
  16428. gradient: number;
  16429. /**
  16430. * Gets or sets first associated factor
  16431. */
  16432. factor1: number;
  16433. /**
  16434. * Gets or sets second associated factor
  16435. */
  16436. factor2?: number;
  16437. /**
  16438. * Will get a number picked randomly between factor1 and factor2.
  16439. * If factor2 is undefined then factor1 will be used
  16440. * @returns the picked number
  16441. */
  16442. getFactor(): number;
  16443. }
  16444. /**
  16445. * Helper used to simplify some generic gradient tasks
  16446. */
  16447. export class GradientHelper {
  16448. /**
  16449. * Gets the current gradient from an array of IValueGradient
  16450. * @param ratio defines the current ratio to get
  16451. * @param gradients defines the array of IValueGradient
  16452. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16453. */
  16454. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16455. }
  16456. }
  16457. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16459. import { Nullable } from "babylonjs/types";
  16460. module "babylonjs/Engines/thinEngine" {
  16461. interface ThinEngine {
  16462. /**
  16463. * Creates a dynamic texture
  16464. * @param width defines the width of the texture
  16465. * @param height defines the height of the texture
  16466. * @param generateMipMaps defines if the engine should generate the mip levels
  16467. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16468. * @returns the dynamic texture inside an InternalTexture
  16469. */
  16470. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16471. /**
  16472. * Update the content of a dynamic texture
  16473. * @param texture defines the texture to update
  16474. * @param canvas defines the canvas containing the source
  16475. * @param invertY defines if data must be stored with Y axis inverted
  16476. * @param premulAlpha defines if alpha is stored as premultiplied
  16477. * @param format defines the format of the data
  16478. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16479. */
  16480. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16481. }
  16482. }
  16483. }
  16484. declare module "babylonjs/Misc/canvasGenerator" {
  16485. /**
  16486. * Helper class used to generate a canvas to manipulate images
  16487. */
  16488. export class CanvasGenerator {
  16489. /**
  16490. * Create a new canvas (or offscreen canvas depending on the context)
  16491. * @param width defines the expected width
  16492. * @param height defines the expected height
  16493. * @return a new canvas or offscreen canvas
  16494. */
  16495. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16496. }
  16497. }
  16498. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16499. import { Scene } from "babylonjs/scene";
  16500. import { Texture } from "babylonjs/Materials/Textures/texture";
  16501. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16502. /**
  16503. * A class extending Texture allowing drawing on a texture
  16504. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16505. */
  16506. export class DynamicTexture extends Texture {
  16507. private _generateMipMaps;
  16508. private _canvas;
  16509. private _context;
  16510. private _engine;
  16511. /**
  16512. * Creates a DynamicTexture
  16513. * @param name defines the name of the texture
  16514. * @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
  16515. * @param scene defines the scene where you want the texture
  16516. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16517. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16518. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16519. */
  16520. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16521. /**
  16522. * Get the current class name of the texture useful for serialization or dynamic coding.
  16523. * @returns "DynamicTexture"
  16524. */
  16525. getClassName(): string;
  16526. /**
  16527. * Gets the current state of canRescale
  16528. */
  16529. readonly canRescale: boolean;
  16530. private _recreate;
  16531. /**
  16532. * Scales the texture
  16533. * @param ratio the scale factor to apply to both width and height
  16534. */
  16535. scale(ratio: number): void;
  16536. /**
  16537. * Resizes the texture
  16538. * @param width the new width
  16539. * @param height the new height
  16540. */
  16541. scaleTo(width: number, height: number): void;
  16542. /**
  16543. * Gets the context of the canvas used by the texture
  16544. * @returns the canvas context of the dynamic texture
  16545. */
  16546. getContext(): CanvasRenderingContext2D;
  16547. /**
  16548. * Clears the texture
  16549. */
  16550. clear(): void;
  16551. /**
  16552. * Updates the texture
  16553. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16554. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16555. */
  16556. update(invertY?: boolean, premulAlpha?: boolean): void;
  16557. /**
  16558. * Draws text onto the texture
  16559. * @param text defines the text to be drawn
  16560. * @param x defines the placement of the text from the left
  16561. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16562. * @param font defines the font to be used with font-style, font-size, font-name
  16563. * @param color defines the color used for the text
  16564. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16565. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16566. * @param update defines whether texture is immediately update (default is true)
  16567. */
  16568. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16569. /**
  16570. * Clones the texture
  16571. * @returns the clone of the texture.
  16572. */
  16573. clone(): DynamicTexture;
  16574. /**
  16575. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16576. * @returns a serialized dynamic texture object
  16577. */
  16578. serialize(): any;
  16579. /** @hidden */
  16580. _rebuild(): void;
  16581. }
  16582. }
  16583. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16584. import { Scene } from "babylonjs/scene";
  16585. import { ISceneComponent } from "babylonjs/sceneComponent";
  16586. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16587. module "babylonjs/abstractScene" {
  16588. interface AbstractScene {
  16589. /**
  16590. * The list of procedural textures added to the scene
  16591. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16592. */
  16593. proceduralTextures: Array<ProceduralTexture>;
  16594. }
  16595. }
  16596. /**
  16597. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16598. * in a given scene.
  16599. */
  16600. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16601. /**
  16602. * The component name helpfull to identify the component in the list of scene components.
  16603. */
  16604. readonly name: string;
  16605. /**
  16606. * The scene the component belongs to.
  16607. */
  16608. scene: Scene;
  16609. /**
  16610. * Creates a new instance of the component for the given scene
  16611. * @param scene Defines the scene to register the component in
  16612. */
  16613. constructor(scene: Scene);
  16614. /**
  16615. * Registers the component in a given scene
  16616. */
  16617. register(): void;
  16618. /**
  16619. * Rebuilds the elements related to this component in case of
  16620. * context lost for instance.
  16621. */
  16622. rebuild(): void;
  16623. /**
  16624. * Disposes the component and the associated ressources.
  16625. */
  16626. dispose(): void;
  16627. private _beforeClear;
  16628. }
  16629. }
  16630. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16631. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16632. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16633. module "babylonjs/Engines/thinEngine" {
  16634. interface ThinEngine {
  16635. /**
  16636. * Creates a new render target cube texture
  16637. * @param size defines the size of the texture
  16638. * @param options defines the options used to create the texture
  16639. * @returns a new render target cube texture stored in an InternalTexture
  16640. */
  16641. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16642. }
  16643. }
  16644. }
  16645. declare module "babylonjs/Shaders/procedural.vertex" {
  16646. /** @hidden */
  16647. export var proceduralVertexShader: {
  16648. name: string;
  16649. shader: string;
  16650. };
  16651. }
  16652. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16653. import { Observable } from "babylonjs/Misc/observable";
  16654. import { Nullable } from "babylonjs/types";
  16655. import { Scene } from "babylonjs/scene";
  16656. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16657. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16658. import { Effect } from "babylonjs/Materials/effect";
  16659. import { Texture } from "babylonjs/Materials/Textures/texture";
  16660. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16661. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16662. import "babylonjs/Shaders/procedural.vertex";
  16663. /**
  16664. * 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.
  16665. * This is the base class of any Procedural texture and contains most of the shareable code.
  16666. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16667. */
  16668. export class ProceduralTexture extends Texture {
  16669. isCube: boolean;
  16670. /**
  16671. * Define if the texture is enabled or not (disabled texture will not render)
  16672. */
  16673. isEnabled: boolean;
  16674. /**
  16675. * Define if the texture must be cleared before rendering (default is true)
  16676. */
  16677. autoClear: boolean;
  16678. /**
  16679. * Callback called when the texture is generated
  16680. */
  16681. onGenerated: () => void;
  16682. /**
  16683. * Event raised when the texture is generated
  16684. */
  16685. onGeneratedObservable: Observable<ProceduralTexture>;
  16686. /** @hidden */
  16687. _generateMipMaps: boolean;
  16688. /** @hidden **/
  16689. _effect: Effect;
  16690. /** @hidden */
  16691. _textures: {
  16692. [key: string]: Texture;
  16693. };
  16694. private _size;
  16695. private _currentRefreshId;
  16696. private _refreshRate;
  16697. private _vertexBuffers;
  16698. private _indexBuffer;
  16699. private _uniforms;
  16700. private _samplers;
  16701. private _fragment;
  16702. private _floats;
  16703. private _ints;
  16704. private _floatsArrays;
  16705. private _colors3;
  16706. private _colors4;
  16707. private _vectors2;
  16708. private _vectors3;
  16709. private _matrices;
  16710. private _fallbackTexture;
  16711. private _fallbackTextureUsed;
  16712. private _engine;
  16713. private _cachedDefines;
  16714. private _contentUpdateId;
  16715. private _contentData;
  16716. /**
  16717. * Instantiates a new procedural texture.
  16718. * 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.
  16719. * This is the base class of any Procedural texture and contains most of the shareable code.
  16720. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16721. * @param name Define the name of the texture
  16722. * @param size Define the size of the texture to create
  16723. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16724. * @param scene Define the scene the texture belongs to
  16725. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16726. * @param generateMipMaps Define if the texture should creates mip maps or not
  16727. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16728. */
  16729. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16730. /**
  16731. * The effect that is created when initializing the post process.
  16732. * @returns The created effect corresponding the the postprocess.
  16733. */
  16734. getEffect(): Effect;
  16735. /**
  16736. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16737. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16738. */
  16739. getContent(): Nullable<ArrayBufferView>;
  16740. private _createIndexBuffer;
  16741. /** @hidden */
  16742. _rebuild(): void;
  16743. /**
  16744. * Resets the texture in order to recreate its associated resources.
  16745. * This can be called in case of context loss
  16746. */
  16747. reset(): void;
  16748. protected _getDefines(): string;
  16749. /**
  16750. * Is the texture ready to be used ? (rendered at least once)
  16751. * @returns true if ready, otherwise, false.
  16752. */
  16753. isReady(): boolean;
  16754. /**
  16755. * Resets the refresh counter of the texture and start bak from scratch.
  16756. * Could be useful to regenerate the texture if it is setup to render only once.
  16757. */
  16758. resetRefreshCounter(): void;
  16759. /**
  16760. * Set the fragment shader to use in order to render the texture.
  16761. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16762. */
  16763. setFragment(fragment: any): void;
  16764. /**
  16765. * Define the refresh rate of the texture or the rendering frequency.
  16766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16767. */
  16768. refreshRate: number;
  16769. /** @hidden */
  16770. _shouldRender(): boolean;
  16771. /**
  16772. * Get the size the texture is rendering at.
  16773. * @returns the size (texture is always squared)
  16774. */
  16775. getRenderSize(): number;
  16776. /**
  16777. * Resize the texture to new value.
  16778. * @param size Define the new size the texture should have
  16779. * @param generateMipMaps Define whether the new texture should create mip maps
  16780. */
  16781. resize(size: number, generateMipMaps: boolean): void;
  16782. private _checkUniform;
  16783. /**
  16784. * Set a texture in the shader program used to render.
  16785. * @param name Define the name of the uniform samplers as defined in the shader
  16786. * @param texture Define the texture to bind to this sampler
  16787. * @return the texture itself allowing "fluent" like uniform updates
  16788. */
  16789. setTexture(name: string, texture: Texture): ProceduralTexture;
  16790. /**
  16791. * Set a float in the shader.
  16792. * @param name Define the name of the uniform as defined in the shader
  16793. * @param value Define the value to give to the uniform
  16794. * @return the texture itself allowing "fluent" like uniform updates
  16795. */
  16796. setFloat(name: string, value: number): ProceduralTexture;
  16797. /**
  16798. * Set a int in the shader.
  16799. * @param name Define the name of the uniform as defined in the shader
  16800. * @param value Define the value to give to the uniform
  16801. * @return the texture itself allowing "fluent" like uniform updates
  16802. */
  16803. setInt(name: string, value: number): ProceduralTexture;
  16804. /**
  16805. * Set an array of floats in the shader.
  16806. * @param name Define the name of the uniform as defined in the shader
  16807. * @param value Define the value to give to the uniform
  16808. * @return the texture itself allowing "fluent" like uniform updates
  16809. */
  16810. setFloats(name: string, value: number[]): ProceduralTexture;
  16811. /**
  16812. * Set a vec3 in the shader from a Color3.
  16813. * @param name Define the name of the uniform as defined in the shader
  16814. * @param value Define the value to give to the uniform
  16815. * @return the texture itself allowing "fluent" like uniform updates
  16816. */
  16817. setColor3(name: string, value: Color3): ProceduralTexture;
  16818. /**
  16819. * Set a vec4 in the shader from a Color4.
  16820. * @param name Define the name of the uniform as defined in the shader
  16821. * @param value Define the value to give to the uniform
  16822. * @return the texture itself allowing "fluent" like uniform updates
  16823. */
  16824. setColor4(name: string, value: Color4): ProceduralTexture;
  16825. /**
  16826. * Set a vec2 in the shader from a Vector2.
  16827. * @param name Define the name of the uniform as defined in the shader
  16828. * @param value Define the value to give to the uniform
  16829. * @return the texture itself allowing "fluent" like uniform updates
  16830. */
  16831. setVector2(name: string, value: Vector2): ProceduralTexture;
  16832. /**
  16833. * Set a vec3 in the shader from a Vector3.
  16834. * @param name Define the name of the uniform as defined in the shader
  16835. * @param value Define the value to give to the uniform
  16836. * @return the texture itself allowing "fluent" like uniform updates
  16837. */
  16838. setVector3(name: string, value: Vector3): ProceduralTexture;
  16839. /**
  16840. * Set a mat4 in the shader from a MAtrix.
  16841. * @param name Define the name of the uniform as defined in the shader
  16842. * @param value Define the value to give to the uniform
  16843. * @return the texture itself allowing "fluent" like uniform updates
  16844. */
  16845. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16846. /**
  16847. * Render the texture to its associated render target.
  16848. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16849. */
  16850. render(useCameraPostProcess?: boolean): void;
  16851. /**
  16852. * Clone the texture.
  16853. * @returns the cloned texture
  16854. */
  16855. clone(): ProceduralTexture;
  16856. /**
  16857. * Dispose the texture and release its asoociated resources.
  16858. */
  16859. dispose(): void;
  16860. }
  16861. }
  16862. declare module "babylonjs/Particles/baseParticleSystem" {
  16863. import { Nullable } from "babylonjs/types";
  16864. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16866. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16867. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16868. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16869. import { Scene } from "babylonjs/scene";
  16870. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16871. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16872. import { Texture } from "babylonjs/Materials/Textures/texture";
  16873. import { Color4 } from "babylonjs/Maths/math.color";
  16874. import { Animation } from "babylonjs/Animations/animation";
  16875. /**
  16876. * This represents the base class for particle system in Babylon.
  16877. * 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.
  16878. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16879. * @example https://doc.babylonjs.com/babylon101/particles
  16880. */
  16881. export class BaseParticleSystem {
  16882. /**
  16883. * Source color is added to the destination color without alpha affecting the result
  16884. */
  16885. static BLENDMODE_ONEONE: number;
  16886. /**
  16887. * Blend current color and particle color using particle’s alpha
  16888. */
  16889. static BLENDMODE_STANDARD: number;
  16890. /**
  16891. * Add current color and particle color multiplied by particle’s alpha
  16892. */
  16893. static BLENDMODE_ADD: number;
  16894. /**
  16895. * Multiply current color with particle color
  16896. */
  16897. static BLENDMODE_MULTIPLY: number;
  16898. /**
  16899. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16900. */
  16901. static BLENDMODE_MULTIPLYADD: number;
  16902. /**
  16903. * List of animations used by the particle system.
  16904. */
  16905. animations: Animation[];
  16906. /**
  16907. * The id of the Particle system.
  16908. */
  16909. id: string;
  16910. /**
  16911. * The friendly name of the Particle system.
  16912. */
  16913. name: string;
  16914. /**
  16915. * The rendering group used by the Particle system to chose when to render.
  16916. */
  16917. renderingGroupId: number;
  16918. /**
  16919. * The emitter represents the Mesh or position we are attaching the particle system to.
  16920. */
  16921. emitter: Nullable<AbstractMesh | Vector3>;
  16922. /**
  16923. * The maximum number of particles to emit per frame
  16924. */
  16925. emitRate: number;
  16926. /**
  16927. * If you want to launch only a few particles at once, that can be done, as well.
  16928. */
  16929. manualEmitCount: number;
  16930. /**
  16931. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16932. */
  16933. updateSpeed: number;
  16934. /**
  16935. * The amount of time the particle system is running (depends of the overall update speed).
  16936. */
  16937. targetStopDuration: number;
  16938. /**
  16939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16940. */
  16941. disposeOnStop: boolean;
  16942. /**
  16943. * Minimum power of emitting particles.
  16944. */
  16945. minEmitPower: number;
  16946. /**
  16947. * Maximum power of emitting particles.
  16948. */
  16949. maxEmitPower: number;
  16950. /**
  16951. * Minimum life time of emitting particles.
  16952. */
  16953. minLifeTime: number;
  16954. /**
  16955. * Maximum life time of emitting particles.
  16956. */
  16957. maxLifeTime: number;
  16958. /**
  16959. * Minimum Size of emitting particles.
  16960. */
  16961. minSize: number;
  16962. /**
  16963. * Maximum Size of emitting particles.
  16964. */
  16965. maxSize: number;
  16966. /**
  16967. * Minimum scale of emitting particles on X axis.
  16968. */
  16969. minScaleX: number;
  16970. /**
  16971. * Maximum scale of emitting particles on X axis.
  16972. */
  16973. maxScaleX: number;
  16974. /**
  16975. * Minimum scale of emitting particles on Y axis.
  16976. */
  16977. minScaleY: number;
  16978. /**
  16979. * Maximum scale of emitting particles on Y axis.
  16980. */
  16981. maxScaleY: number;
  16982. /**
  16983. * Gets or sets the minimal initial rotation in radians.
  16984. */
  16985. minInitialRotation: number;
  16986. /**
  16987. * Gets or sets the maximal initial rotation in radians.
  16988. */
  16989. maxInitialRotation: number;
  16990. /**
  16991. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16992. */
  16993. minAngularSpeed: number;
  16994. /**
  16995. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16996. */
  16997. maxAngularSpeed: number;
  16998. /**
  16999. * The texture used to render each particle. (this can be a spritesheet)
  17000. */
  17001. particleTexture: Nullable<Texture>;
  17002. /**
  17003. * The layer mask we are rendering the particles through.
  17004. */
  17005. layerMask: number;
  17006. /**
  17007. * This can help using your own shader to render the particle system.
  17008. * The according effect will be created
  17009. */
  17010. customShader: any;
  17011. /**
  17012. * By default particle system starts as soon as they are created. This prevents the
  17013. * automatic start to happen and let you decide when to start emitting particles.
  17014. */
  17015. preventAutoStart: boolean;
  17016. private _noiseTexture;
  17017. /**
  17018. * Gets or sets a texture used to add random noise to particle positions
  17019. */
  17020. noiseTexture: Nullable<ProceduralTexture>;
  17021. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17022. noiseStrength: Vector3;
  17023. /**
  17024. * Callback triggered when the particle animation is ending.
  17025. */
  17026. onAnimationEnd: Nullable<() => void>;
  17027. /**
  17028. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17029. */
  17030. blendMode: number;
  17031. /**
  17032. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17033. * to override the particles.
  17034. */
  17035. forceDepthWrite: boolean;
  17036. /** 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 */
  17037. preWarmCycles: number;
  17038. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17039. preWarmStepOffset: number;
  17040. /**
  17041. * 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)
  17042. */
  17043. spriteCellChangeSpeed: number;
  17044. /**
  17045. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17046. */
  17047. startSpriteCellID: number;
  17048. /**
  17049. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17050. */
  17051. endSpriteCellID: number;
  17052. /**
  17053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17054. */
  17055. spriteCellWidth: number;
  17056. /**
  17057. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17058. */
  17059. spriteCellHeight: number;
  17060. /**
  17061. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17062. */
  17063. spriteRandomStartCell: boolean;
  17064. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17065. translationPivot: Vector2;
  17066. /** @hidden */
  17067. protected _isAnimationSheetEnabled: boolean;
  17068. /**
  17069. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17070. */
  17071. beginAnimationOnStart: boolean;
  17072. /**
  17073. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17074. */
  17075. beginAnimationFrom: number;
  17076. /**
  17077. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17078. */
  17079. beginAnimationTo: number;
  17080. /**
  17081. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17082. */
  17083. beginAnimationLoop: boolean;
  17084. /**
  17085. * Gets or sets a world offset applied to all particles
  17086. */
  17087. worldOffset: Vector3;
  17088. /**
  17089. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17090. */
  17091. isAnimationSheetEnabled: boolean;
  17092. /**
  17093. * Get hosting scene
  17094. * @returns the scene
  17095. */
  17096. getScene(): Scene;
  17097. /**
  17098. * You can use gravity if you want to give an orientation to your particles.
  17099. */
  17100. gravity: Vector3;
  17101. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17102. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17103. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17104. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17105. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17106. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17107. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17108. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17109. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17110. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17111. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17112. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17113. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17114. /**
  17115. * Defines the delay in milliseconds before starting the system (0 by default)
  17116. */
  17117. startDelay: number;
  17118. /**
  17119. * Gets the current list of drag gradients.
  17120. * You must use addDragGradient and removeDragGradient to udpate this list
  17121. * @returns the list of drag gradients
  17122. */
  17123. getDragGradients(): Nullable<Array<FactorGradient>>;
  17124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17125. limitVelocityDamping: number;
  17126. /**
  17127. * Gets the current list of limit velocity gradients.
  17128. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17129. * @returns the list of limit velocity gradients
  17130. */
  17131. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17132. /**
  17133. * Gets the current list of color gradients.
  17134. * You must use addColorGradient and removeColorGradient to udpate this list
  17135. * @returns the list of color gradients
  17136. */
  17137. getColorGradients(): Nullable<Array<ColorGradient>>;
  17138. /**
  17139. * Gets the current list of size gradients.
  17140. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17141. * @returns the list of size gradients
  17142. */
  17143. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17144. /**
  17145. * Gets the current list of color remap gradients.
  17146. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17147. * @returns the list of color remap gradients
  17148. */
  17149. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17150. /**
  17151. * Gets the current list of alpha remap gradients.
  17152. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17153. * @returns the list of alpha remap gradients
  17154. */
  17155. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17156. /**
  17157. * Gets the current list of life time gradients.
  17158. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17159. * @returns the list of life time gradients
  17160. */
  17161. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17162. /**
  17163. * Gets the current list of angular speed gradients.
  17164. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17165. * @returns the list of angular speed gradients
  17166. */
  17167. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17168. /**
  17169. * Gets the current list of velocity gradients.
  17170. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17171. * @returns the list of velocity gradients
  17172. */
  17173. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17174. /**
  17175. * Gets the current list of start size gradients.
  17176. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17177. * @returns the list of start size gradients
  17178. */
  17179. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17180. /**
  17181. * Gets the current list of emit rate gradients.
  17182. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17183. * @returns the list of emit rate gradients
  17184. */
  17185. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17186. /**
  17187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17188. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17189. */
  17190. direction1: Vector3;
  17191. /**
  17192. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17193. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17194. */
  17195. direction2: Vector3;
  17196. /**
  17197. * 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.
  17198. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17199. */
  17200. minEmitBox: Vector3;
  17201. /**
  17202. * 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.
  17203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17204. */
  17205. maxEmitBox: Vector3;
  17206. /**
  17207. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17208. */
  17209. color1: Color4;
  17210. /**
  17211. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17212. */
  17213. color2: Color4;
  17214. /**
  17215. * Color the particle will have at the end of its lifetime
  17216. */
  17217. colorDead: Color4;
  17218. /**
  17219. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17220. */
  17221. textureMask: Color4;
  17222. /**
  17223. * The particle emitter type defines the emitter used by the particle system.
  17224. * It can be for example box, sphere, or cone...
  17225. */
  17226. particleEmitterType: IParticleEmitterType;
  17227. /** @hidden */
  17228. _isSubEmitter: boolean;
  17229. /**
  17230. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17231. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17232. */
  17233. billboardMode: number;
  17234. protected _isBillboardBased: boolean;
  17235. /**
  17236. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17237. */
  17238. isBillboardBased: boolean;
  17239. /**
  17240. * The scene the particle system belongs to.
  17241. */
  17242. protected _scene: Scene;
  17243. /**
  17244. * Local cache of defines for image processing.
  17245. */
  17246. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17247. /**
  17248. * Default configuration related to image processing available in the standard Material.
  17249. */
  17250. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17251. /**
  17252. * Gets the image processing configuration used either in this material.
  17253. */
  17254. /**
  17255. * Sets the Default image processing configuration used either in the this material.
  17256. *
  17257. * If sets to null, the scene one is in use.
  17258. */
  17259. imageProcessingConfiguration: ImageProcessingConfiguration;
  17260. /**
  17261. * Attaches a new image processing configuration to the Standard Material.
  17262. * @param configuration
  17263. */
  17264. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17265. /** @hidden */
  17266. protected _reset(): void;
  17267. /** @hidden */
  17268. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17269. /**
  17270. * Instantiates a particle system.
  17271. * 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.
  17272. * @param name The name of the particle system
  17273. */
  17274. constructor(name: string);
  17275. /**
  17276. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17279. * @returns the emitter
  17280. */
  17281. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17282. /**
  17283. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17284. * @param radius The radius of the hemisphere to emit from
  17285. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17286. * @returns the emitter
  17287. */
  17288. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17289. /**
  17290. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17291. * @param radius The radius of the sphere to emit from
  17292. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17293. * @returns the emitter
  17294. */
  17295. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17296. /**
  17297. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17298. * @param radius The radius of the sphere to emit from
  17299. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17300. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17301. * @returns the emitter
  17302. */
  17303. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17304. /**
  17305. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17306. * @param radius The radius of the emission cylinder
  17307. * @param height The height of the emission cylinder
  17308. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17309. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17310. * @returns the emitter
  17311. */
  17312. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17313. /**
  17314. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17315. * @param radius The radius of the cylinder to emit from
  17316. * @param height The height of the emission cylinder
  17317. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17318. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17319. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17320. * @returns the emitter
  17321. */
  17322. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17323. /**
  17324. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17325. * @param radius The radius of the cone to emit from
  17326. * @param angle The base angle of the cone
  17327. * @returns the emitter
  17328. */
  17329. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17330. /**
  17331. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17334. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17335. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17336. * @returns the emitter
  17337. */
  17338. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17339. }
  17340. }
  17341. declare module "babylonjs/Particles/subEmitter" {
  17342. import { Scene } from "babylonjs/scene";
  17343. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17344. /**
  17345. * Type of sub emitter
  17346. */
  17347. export enum SubEmitterType {
  17348. /**
  17349. * Attached to the particle over it's lifetime
  17350. */
  17351. ATTACHED = 0,
  17352. /**
  17353. * Created when the particle dies
  17354. */
  17355. END = 1
  17356. }
  17357. /**
  17358. * Sub emitter class used to emit particles from an existing particle
  17359. */
  17360. export class SubEmitter {
  17361. /**
  17362. * the particle system to be used by the sub emitter
  17363. */
  17364. particleSystem: ParticleSystem;
  17365. /**
  17366. * Type of the submitter (Default: END)
  17367. */
  17368. type: SubEmitterType;
  17369. /**
  17370. * 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)
  17371. * Note: This only is supported when using an emitter of type Mesh
  17372. */
  17373. inheritDirection: boolean;
  17374. /**
  17375. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17376. */
  17377. inheritedVelocityAmount: number;
  17378. /**
  17379. * Creates a sub emitter
  17380. * @param particleSystem the particle system to be used by the sub emitter
  17381. */
  17382. constructor(
  17383. /**
  17384. * the particle system to be used by the sub emitter
  17385. */
  17386. particleSystem: ParticleSystem);
  17387. /**
  17388. * Clones the sub emitter
  17389. * @returns the cloned sub emitter
  17390. */
  17391. clone(): SubEmitter;
  17392. /**
  17393. * Serialize current object to a JSON object
  17394. * @returns the serialized object
  17395. */
  17396. serialize(): any;
  17397. /** @hidden */
  17398. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17399. /**
  17400. * Creates a new SubEmitter from a serialized JSON version
  17401. * @param serializationObject defines the JSON object to read from
  17402. * @param scene defines the hosting scene
  17403. * @param rootUrl defines the rootUrl for data loading
  17404. * @returns a new SubEmitter
  17405. */
  17406. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17407. /** Release associated resources */
  17408. dispose(): void;
  17409. }
  17410. }
  17411. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17412. /** @hidden */
  17413. export var clipPlaneFragmentDeclaration: {
  17414. name: string;
  17415. shader: string;
  17416. };
  17417. }
  17418. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17419. /** @hidden */
  17420. export var imageProcessingDeclaration: {
  17421. name: string;
  17422. shader: string;
  17423. };
  17424. }
  17425. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17426. /** @hidden */
  17427. export var imageProcessingFunctions: {
  17428. name: string;
  17429. shader: string;
  17430. };
  17431. }
  17432. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17433. /** @hidden */
  17434. export var clipPlaneFragment: {
  17435. name: string;
  17436. shader: string;
  17437. };
  17438. }
  17439. declare module "babylonjs/Shaders/particles.fragment" {
  17440. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17441. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17443. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17445. /** @hidden */
  17446. export var particlesPixelShader: {
  17447. name: string;
  17448. shader: string;
  17449. };
  17450. }
  17451. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17452. /** @hidden */
  17453. export var clipPlaneVertexDeclaration: {
  17454. name: string;
  17455. shader: string;
  17456. };
  17457. }
  17458. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17459. /** @hidden */
  17460. export var clipPlaneVertex: {
  17461. name: string;
  17462. shader: string;
  17463. };
  17464. }
  17465. declare module "babylonjs/Shaders/particles.vertex" {
  17466. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17467. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17468. /** @hidden */
  17469. export var particlesVertexShader: {
  17470. name: string;
  17471. shader: string;
  17472. };
  17473. }
  17474. declare module "babylonjs/Particles/particleSystem" {
  17475. import { Nullable } from "babylonjs/types";
  17476. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17477. import { Observable } from "babylonjs/Misc/observable";
  17478. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17479. import { Effect } from "babylonjs/Materials/effect";
  17480. import { Scene, IDisposable } from "babylonjs/scene";
  17481. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17482. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17483. import { Particle } from "babylonjs/Particles/particle";
  17484. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17485. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17486. import "babylonjs/Shaders/particles.fragment";
  17487. import "babylonjs/Shaders/particles.vertex";
  17488. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17489. /**
  17490. * This represents a particle system in Babylon.
  17491. * 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.
  17492. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17493. * @example https://doc.babylonjs.com/babylon101/particles
  17494. */
  17495. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17496. /**
  17497. * Billboard mode will only apply to Y axis
  17498. */
  17499. static readonly BILLBOARDMODE_Y: number;
  17500. /**
  17501. * Billboard mode will apply to all axes
  17502. */
  17503. static readonly BILLBOARDMODE_ALL: number;
  17504. /**
  17505. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17506. */
  17507. static readonly BILLBOARDMODE_STRETCHED: number;
  17508. /**
  17509. * This function can be defined to provide custom update for active particles.
  17510. * This function will be called instead of regular update (age, position, color, etc.).
  17511. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17512. */
  17513. updateFunction: (particles: Particle[]) => void;
  17514. private _emitterWorldMatrix;
  17515. /**
  17516. * This function can be defined to specify initial direction for every new particle.
  17517. * It by default use the emitterType defined function
  17518. */
  17519. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17520. /**
  17521. * This function can be defined to specify initial position for every new particle.
  17522. * It by default use the emitterType defined function
  17523. */
  17524. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17525. /**
  17526. * @hidden
  17527. */
  17528. _inheritedVelocityOffset: Vector3;
  17529. /**
  17530. * An event triggered when the system is disposed
  17531. */
  17532. onDisposeObservable: Observable<ParticleSystem>;
  17533. private _onDisposeObserver;
  17534. /**
  17535. * Sets a callback that will be triggered when the system is disposed
  17536. */
  17537. onDispose: () => void;
  17538. private _particles;
  17539. private _epsilon;
  17540. private _capacity;
  17541. private _stockParticles;
  17542. private _newPartsExcess;
  17543. private _vertexData;
  17544. private _vertexBuffer;
  17545. private _vertexBuffers;
  17546. private _spriteBuffer;
  17547. private _indexBuffer;
  17548. private _effect;
  17549. private _customEffect;
  17550. private _cachedDefines;
  17551. private _scaledColorStep;
  17552. private _colorDiff;
  17553. private _scaledDirection;
  17554. private _scaledGravity;
  17555. private _currentRenderId;
  17556. private _alive;
  17557. private _useInstancing;
  17558. private _started;
  17559. private _stopped;
  17560. private _actualFrame;
  17561. private _scaledUpdateSpeed;
  17562. private _vertexBufferSize;
  17563. /** @hidden */
  17564. _currentEmitRateGradient: Nullable<FactorGradient>;
  17565. /** @hidden */
  17566. _currentEmitRate1: number;
  17567. /** @hidden */
  17568. _currentEmitRate2: number;
  17569. /** @hidden */
  17570. _currentStartSizeGradient: Nullable<FactorGradient>;
  17571. /** @hidden */
  17572. _currentStartSize1: number;
  17573. /** @hidden */
  17574. _currentStartSize2: number;
  17575. private readonly _rawTextureWidth;
  17576. private _rampGradientsTexture;
  17577. private _useRampGradients;
  17578. /** Gets or sets a boolean indicating that ramp gradients must be used
  17579. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17580. */
  17581. useRampGradients: boolean;
  17582. /**
  17583. * 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.
  17584. * 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: [])
  17585. */
  17586. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17587. private _subEmitters;
  17588. /**
  17589. * @hidden
  17590. * If the particle systems emitter should be disposed when the particle system is disposed
  17591. */
  17592. _disposeEmitterOnDispose: boolean;
  17593. /**
  17594. * The current active Sub-systems, this property is used by the root particle system only.
  17595. */
  17596. activeSubSystems: Array<ParticleSystem>;
  17597. private _rootParticleSystem;
  17598. /**
  17599. * Gets the current list of active particles
  17600. */
  17601. readonly particles: Particle[];
  17602. /**
  17603. * Returns the string "ParticleSystem"
  17604. * @returns a string containing the class name
  17605. */
  17606. getClassName(): string;
  17607. /**
  17608. * Instantiates a particle system.
  17609. * 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.
  17610. * @param name The name of the particle system
  17611. * @param capacity The max number of particles alive at the same time
  17612. * @param scene The scene the particle system belongs to
  17613. * @param customEffect a custom effect used to change the way particles are rendered by default
  17614. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17615. * @param epsilon Offset used to render the particles
  17616. */
  17617. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17618. private _addFactorGradient;
  17619. private _removeFactorGradient;
  17620. /**
  17621. * Adds a new life time gradient
  17622. * @param gradient defines the gradient to use (between 0 and 1)
  17623. * @param factor defines the life time factor to affect to the specified gradient
  17624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17625. * @returns the current particle system
  17626. */
  17627. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17628. /**
  17629. * Remove a specific life time gradient
  17630. * @param gradient defines the gradient to remove
  17631. * @returns the current particle system
  17632. */
  17633. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17634. /**
  17635. * Adds a new size gradient
  17636. * @param gradient defines the gradient to use (between 0 and 1)
  17637. * @param factor defines the size factor to affect to the specified gradient
  17638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17639. * @returns the current particle system
  17640. */
  17641. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17642. /**
  17643. * Remove a specific size gradient
  17644. * @param gradient defines the gradient to remove
  17645. * @returns the current particle system
  17646. */
  17647. removeSizeGradient(gradient: number): IParticleSystem;
  17648. /**
  17649. * Adds a new color remap gradient
  17650. * @param gradient defines the gradient to use (between 0 and 1)
  17651. * @param min defines the color remap minimal range
  17652. * @param max defines the color remap maximal range
  17653. * @returns the current particle system
  17654. */
  17655. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17656. /**
  17657. * Remove a specific color remap gradient
  17658. * @param gradient defines the gradient to remove
  17659. * @returns the current particle system
  17660. */
  17661. removeColorRemapGradient(gradient: number): IParticleSystem;
  17662. /**
  17663. * Adds a new alpha remap gradient
  17664. * @param gradient defines the gradient to use (between 0 and 1)
  17665. * @param min defines the alpha remap minimal range
  17666. * @param max defines the alpha remap maximal range
  17667. * @returns the current particle system
  17668. */
  17669. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17670. /**
  17671. * Remove a specific alpha remap gradient
  17672. * @param gradient defines the gradient to remove
  17673. * @returns the current particle system
  17674. */
  17675. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17676. /**
  17677. * Adds a new angular speed gradient
  17678. * @param gradient defines the gradient to use (between 0 and 1)
  17679. * @param factor defines the angular speed to affect to the specified gradient
  17680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17681. * @returns the current particle system
  17682. */
  17683. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17684. /**
  17685. * Remove a specific angular speed gradient
  17686. * @param gradient defines the gradient to remove
  17687. * @returns the current particle system
  17688. */
  17689. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17690. /**
  17691. * Adds a new velocity gradient
  17692. * @param gradient defines the gradient to use (between 0 and 1)
  17693. * @param factor defines the velocity to affect to the specified gradient
  17694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17695. * @returns the current particle system
  17696. */
  17697. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17698. /**
  17699. * Remove a specific velocity gradient
  17700. * @param gradient defines the gradient to remove
  17701. * @returns the current particle system
  17702. */
  17703. removeVelocityGradient(gradient: number): IParticleSystem;
  17704. /**
  17705. * Adds a new limit velocity gradient
  17706. * @param gradient defines the gradient to use (between 0 and 1)
  17707. * @param factor defines the limit velocity value to affect to the specified gradient
  17708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17709. * @returns the current particle system
  17710. */
  17711. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17712. /**
  17713. * Remove a specific limit velocity gradient
  17714. * @param gradient defines the gradient to remove
  17715. * @returns the current particle system
  17716. */
  17717. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17718. /**
  17719. * Adds a new drag gradient
  17720. * @param gradient defines the gradient to use (between 0 and 1)
  17721. * @param factor defines the drag value to affect to the specified gradient
  17722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17723. * @returns the current particle system
  17724. */
  17725. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17726. /**
  17727. * Remove a specific drag gradient
  17728. * @param gradient defines the gradient to remove
  17729. * @returns the current particle system
  17730. */
  17731. removeDragGradient(gradient: number): IParticleSystem;
  17732. /**
  17733. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17734. * @param gradient defines the gradient to use (between 0 and 1)
  17735. * @param factor defines the emit rate value to affect to the specified gradient
  17736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17737. * @returns the current particle system
  17738. */
  17739. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17740. /**
  17741. * Remove a specific emit rate gradient
  17742. * @param gradient defines the gradient to remove
  17743. * @returns the current particle system
  17744. */
  17745. removeEmitRateGradient(gradient: number): IParticleSystem;
  17746. /**
  17747. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17748. * @param gradient defines the gradient to use (between 0 and 1)
  17749. * @param factor defines the start size value to affect to the specified gradient
  17750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17751. * @returns the current particle system
  17752. */
  17753. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17754. /**
  17755. * Remove a specific start size gradient
  17756. * @param gradient defines the gradient to remove
  17757. * @returns the current particle system
  17758. */
  17759. removeStartSizeGradient(gradient: number): IParticleSystem;
  17760. private _createRampGradientTexture;
  17761. /**
  17762. * Gets the current list of ramp gradients.
  17763. * You must use addRampGradient and removeRampGradient to udpate this list
  17764. * @returns the list of ramp gradients
  17765. */
  17766. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17767. /**
  17768. * Adds a new ramp gradient used to remap particle colors
  17769. * @param gradient defines the gradient to use (between 0 and 1)
  17770. * @param color defines the color to affect to the specified gradient
  17771. * @returns the current particle system
  17772. */
  17773. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17774. /**
  17775. * Remove a specific ramp gradient
  17776. * @param gradient defines the gradient to remove
  17777. * @returns the current particle system
  17778. */
  17779. removeRampGradient(gradient: number): ParticleSystem;
  17780. /**
  17781. * Adds a new color gradient
  17782. * @param gradient defines the gradient to use (between 0 and 1)
  17783. * @param color1 defines the color to affect to the specified gradient
  17784. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17785. * @returns this particle system
  17786. */
  17787. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17788. /**
  17789. * Remove a specific color gradient
  17790. * @param gradient defines the gradient to remove
  17791. * @returns this particle system
  17792. */
  17793. removeColorGradient(gradient: number): IParticleSystem;
  17794. private _fetchR;
  17795. protected _reset(): void;
  17796. private _resetEffect;
  17797. private _createVertexBuffers;
  17798. private _createIndexBuffer;
  17799. /**
  17800. * Gets the maximum number of particles active at the same time.
  17801. * @returns The max number of active particles.
  17802. */
  17803. getCapacity(): number;
  17804. /**
  17805. * Gets whether there are still active particles in the system.
  17806. * @returns True if it is alive, otherwise false.
  17807. */
  17808. isAlive(): boolean;
  17809. /**
  17810. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17811. * @returns True if it has been started, otherwise false.
  17812. */
  17813. isStarted(): boolean;
  17814. private _prepareSubEmitterInternalArray;
  17815. /**
  17816. * Starts the particle system and begins to emit
  17817. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17818. */
  17819. start(delay?: number): void;
  17820. /**
  17821. * Stops the particle system.
  17822. * @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.
  17823. */
  17824. stop(stopSubEmitters?: boolean): void;
  17825. /**
  17826. * Remove all active particles
  17827. */
  17828. reset(): void;
  17829. /**
  17830. * @hidden (for internal use only)
  17831. */
  17832. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17833. /**
  17834. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17835. * Its lifetime will start back at 0.
  17836. */
  17837. recycleParticle: (particle: Particle) => void;
  17838. private _stopSubEmitters;
  17839. private _createParticle;
  17840. private _removeFromRoot;
  17841. private _emitFromParticle;
  17842. private _update;
  17843. /** @hidden */
  17844. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17845. /** @hidden */
  17846. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17847. /** @hidden */
  17848. private _getEffect;
  17849. /**
  17850. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17851. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17852. */
  17853. animate(preWarmOnly?: boolean): void;
  17854. private _appendParticleVertices;
  17855. /**
  17856. * Rebuilds the particle system.
  17857. */
  17858. rebuild(): void;
  17859. /**
  17860. * Is this system ready to be used/rendered
  17861. * @return true if the system is ready
  17862. */
  17863. isReady(): boolean;
  17864. private _render;
  17865. /**
  17866. * Renders the particle system in its current state.
  17867. * @returns the current number of particles
  17868. */
  17869. render(): number;
  17870. /**
  17871. * Disposes the particle system and free the associated resources
  17872. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17873. */
  17874. dispose(disposeTexture?: boolean): void;
  17875. /**
  17876. * Clones the particle system.
  17877. * @param name The name of the cloned object
  17878. * @param newEmitter The new emitter to use
  17879. * @returns the cloned particle system
  17880. */
  17881. clone(name: string, newEmitter: any): ParticleSystem;
  17882. /**
  17883. * Serializes the particle system to a JSON object.
  17884. * @returns the JSON object
  17885. */
  17886. serialize(): any;
  17887. /** @hidden */
  17888. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17889. /** @hidden */
  17890. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17891. /**
  17892. * Parses a JSON object to create a particle system.
  17893. * @param parsedParticleSystem The JSON object to parse
  17894. * @param scene The scene to create the particle system in
  17895. * @param rootUrl The root url to use to load external dependencies like texture
  17896. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17897. * @returns the Parsed particle system
  17898. */
  17899. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17900. }
  17901. }
  17902. declare module "babylonjs/Particles/particle" {
  17903. import { Nullable } from "babylonjs/types";
  17904. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17905. import { Color4 } from "babylonjs/Maths/math.color";
  17906. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17907. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17908. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17909. /**
  17910. * A particle represents one of the element emitted by a particle system.
  17911. * This is mainly define by its coordinates, direction, velocity and age.
  17912. */
  17913. export class Particle {
  17914. /**
  17915. * The particle system the particle belongs to.
  17916. */
  17917. particleSystem: ParticleSystem;
  17918. private static _Count;
  17919. /**
  17920. * Unique ID of the particle
  17921. */
  17922. id: number;
  17923. /**
  17924. * The world position of the particle in the scene.
  17925. */
  17926. position: Vector3;
  17927. /**
  17928. * The world direction of the particle in the scene.
  17929. */
  17930. direction: Vector3;
  17931. /**
  17932. * The color of the particle.
  17933. */
  17934. color: Color4;
  17935. /**
  17936. * The color change of the particle per step.
  17937. */
  17938. colorStep: Color4;
  17939. /**
  17940. * Defines how long will the life of the particle be.
  17941. */
  17942. lifeTime: number;
  17943. /**
  17944. * The current age of the particle.
  17945. */
  17946. age: number;
  17947. /**
  17948. * The current size of the particle.
  17949. */
  17950. size: number;
  17951. /**
  17952. * The current scale of the particle.
  17953. */
  17954. scale: Vector2;
  17955. /**
  17956. * The current angle of the particle.
  17957. */
  17958. angle: number;
  17959. /**
  17960. * Defines how fast is the angle changing.
  17961. */
  17962. angularSpeed: number;
  17963. /**
  17964. * Defines the cell index used by the particle to be rendered from a sprite.
  17965. */
  17966. cellIndex: number;
  17967. /**
  17968. * The information required to support color remapping
  17969. */
  17970. remapData: Vector4;
  17971. /** @hidden */
  17972. _randomCellOffset?: number;
  17973. /** @hidden */
  17974. _initialDirection: Nullable<Vector3>;
  17975. /** @hidden */
  17976. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17977. /** @hidden */
  17978. _initialStartSpriteCellID: number;
  17979. /** @hidden */
  17980. _initialEndSpriteCellID: number;
  17981. /** @hidden */
  17982. _currentColorGradient: Nullable<ColorGradient>;
  17983. /** @hidden */
  17984. _currentColor1: Color4;
  17985. /** @hidden */
  17986. _currentColor2: Color4;
  17987. /** @hidden */
  17988. _currentSizeGradient: Nullable<FactorGradient>;
  17989. /** @hidden */
  17990. _currentSize1: number;
  17991. /** @hidden */
  17992. _currentSize2: number;
  17993. /** @hidden */
  17994. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17995. /** @hidden */
  17996. _currentAngularSpeed1: number;
  17997. /** @hidden */
  17998. _currentAngularSpeed2: number;
  17999. /** @hidden */
  18000. _currentVelocityGradient: Nullable<FactorGradient>;
  18001. /** @hidden */
  18002. _currentVelocity1: number;
  18003. /** @hidden */
  18004. _currentVelocity2: number;
  18005. /** @hidden */
  18006. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18007. /** @hidden */
  18008. _currentLimitVelocity1: number;
  18009. /** @hidden */
  18010. _currentLimitVelocity2: number;
  18011. /** @hidden */
  18012. _currentDragGradient: Nullable<FactorGradient>;
  18013. /** @hidden */
  18014. _currentDrag1: number;
  18015. /** @hidden */
  18016. _currentDrag2: number;
  18017. /** @hidden */
  18018. _randomNoiseCoordinates1: Vector3;
  18019. /** @hidden */
  18020. _randomNoiseCoordinates2: Vector3;
  18021. /**
  18022. * Creates a new instance Particle
  18023. * @param particleSystem the particle system the particle belongs to
  18024. */
  18025. constructor(
  18026. /**
  18027. * The particle system the particle belongs to.
  18028. */
  18029. particleSystem: ParticleSystem);
  18030. private updateCellInfoFromSystem;
  18031. /**
  18032. * Defines how the sprite cell index is updated for the particle
  18033. */
  18034. updateCellIndex(): void;
  18035. /** @hidden */
  18036. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18037. /** @hidden */
  18038. _inheritParticleInfoToSubEmitters(): void;
  18039. /** @hidden */
  18040. _reset(): void;
  18041. /**
  18042. * Copy the properties of particle to another one.
  18043. * @param other the particle to copy the information to.
  18044. */
  18045. copyTo(other: Particle): void;
  18046. }
  18047. }
  18048. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18049. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18050. import { Effect } from "babylonjs/Materials/effect";
  18051. import { Particle } from "babylonjs/Particles/particle";
  18052. /**
  18053. * Particle emitter represents a volume emitting particles.
  18054. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18055. */
  18056. export interface IParticleEmitterType {
  18057. /**
  18058. * Called by the particle System when the direction is computed for the created particle.
  18059. * @param worldMatrix is the world matrix of the particle system
  18060. * @param directionToUpdate is the direction vector to update with the result
  18061. * @param particle is the particle we are computed the direction for
  18062. */
  18063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18064. /**
  18065. * Called by the particle System when the position is computed for the created particle.
  18066. * @param worldMatrix is the world matrix of the particle system
  18067. * @param positionToUpdate is the position vector to update with the result
  18068. * @param particle is the particle we are computed the position for
  18069. */
  18070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18071. /**
  18072. * Clones the current emitter and returns a copy of it
  18073. * @returns the new emitter
  18074. */
  18075. clone(): IParticleEmitterType;
  18076. /**
  18077. * Called by the GPUParticleSystem to setup the update shader
  18078. * @param effect defines the update shader
  18079. */
  18080. applyToShader(effect: Effect): void;
  18081. /**
  18082. * Returns a string to use to update the GPU particles update shader
  18083. * @returns the effect defines string
  18084. */
  18085. getEffectDefines(): string;
  18086. /**
  18087. * Returns a string representing the class name
  18088. * @returns a string containing the class name
  18089. */
  18090. getClassName(): string;
  18091. /**
  18092. * Serializes the particle system to a JSON object.
  18093. * @returns the JSON object
  18094. */
  18095. serialize(): any;
  18096. /**
  18097. * Parse properties from a JSON object
  18098. * @param serializationObject defines the JSON object
  18099. */
  18100. parse(serializationObject: any): void;
  18101. }
  18102. }
  18103. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18104. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18105. import { Effect } from "babylonjs/Materials/effect";
  18106. import { Particle } from "babylonjs/Particles/particle";
  18107. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18108. /**
  18109. * Particle emitter emitting particles from the inside of a box.
  18110. * It emits the particles randomly between 2 given directions.
  18111. */
  18112. export class BoxParticleEmitter implements IParticleEmitterType {
  18113. /**
  18114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18115. */
  18116. direction1: Vector3;
  18117. /**
  18118. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18119. */
  18120. direction2: Vector3;
  18121. /**
  18122. * 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.
  18123. */
  18124. minEmitBox: Vector3;
  18125. /**
  18126. * 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.
  18127. */
  18128. maxEmitBox: Vector3;
  18129. /**
  18130. * Creates a new instance BoxParticleEmitter
  18131. */
  18132. constructor();
  18133. /**
  18134. * Called by the particle System when the direction is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param directionToUpdate is the direction vector to update with the result
  18137. * @param particle is the particle we are computed the direction for
  18138. */
  18139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Called by the particle System when the position is computed for the created particle.
  18142. * @param worldMatrix is the world matrix of the particle system
  18143. * @param positionToUpdate is the position vector to update with the result
  18144. * @param particle is the particle we are computed the position for
  18145. */
  18146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18147. /**
  18148. * Clones the current emitter and returns a copy of it
  18149. * @returns the new emitter
  18150. */
  18151. clone(): BoxParticleEmitter;
  18152. /**
  18153. * Called by the GPUParticleSystem to setup the update shader
  18154. * @param effect defines the update shader
  18155. */
  18156. applyToShader(effect: Effect): void;
  18157. /**
  18158. * Returns a string to use to update the GPU particles update shader
  18159. * @returns a string containng the defines string
  18160. */
  18161. getEffectDefines(): string;
  18162. /**
  18163. * Returns the string "BoxParticleEmitter"
  18164. * @returns a string containing the class name
  18165. */
  18166. getClassName(): string;
  18167. /**
  18168. * Serializes the particle system to a JSON object.
  18169. * @returns the JSON object
  18170. */
  18171. serialize(): any;
  18172. /**
  18173. * Parse properties from a JSON object
  18174. * @param serializationObject defines the JSON object
  18175. */
  18176. parse(serializationObject: any): void;
  18177. }
  18178. }
  18179. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18180. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18181. import { Effect } from "babylonjs/Materials/effect";
  18182. import { Particle } from "babylonjs/Particles/particle";
  18183. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18184. /**
  18185. * Particle emitter emitting particles from the inside of a cone.
  18186. * It emits the particles alongside the cone volume from the base to the particle.
  18187. * The emission direction might be randomized.
  18188. */
  18189. export class ConeParticleEmitter implements IParticleEmitterType {
  18190. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18191. directionRandomizer: number;
  18192. private _radius;
  18193. private _angle;
  18194. private _height;
  18195. /**
  18196. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18197. */
  18198. radiusRange: number;
  18199. /**
  18200. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18201. */
  18202. heightRange: number;
  18203. /**
  18204. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18205. */
  18206. emitFromSpawnPointOnly: boolean;
  18207. /**
  18208. * Gets or sets the radius of the emission cone
  18209. */
  18210. radius: number;
  18211. /**
  18212. * Gets or sets the angle of the emission cone
  18213. */
  18214. angle: number;
  18215. private _buildHeight;
  18216. /**
  18217. * Creates a new instance ConeParticleEmitter
  18218. * @param radius the radius of the emission cone (1 by default)
  18219. * @param angle the cone base angle (PI by default)
  18220. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18221. */
  18222. constructor(radius?: number, angle?: number,
  18223. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18224. directionRandomizer?: number);
  18225. /**
  18226. * Called by the particle System when the direction is computed for the created particle.
  18227. * @param worldMatrix is the world matrix of the particle system
  18228. * @param directionToUpdate is the direction vector to update with the result
  18229. * @param particle is the particle we are computed the direction for
  18230. */
  18231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18232. /**
  18233. * Called by the particle System when the position is computed for the created particle.
  18234. * @param worldMatrix is the world matrix of the particle system
  18235. * @param positionToUpdate is the position vector to update with the result
  18236. * @param particle is the particle we are computed the position for
  18237. */
  18238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18239. /**
  18240. * Clones the current emitter and returns a copy of it
  18241. * @returns the new emitter
  18242. */
  18243. clone(): ConeParticleEmitter;
  18244. /**
  18245. * Called by the GPUParticleSystem to setup the update shader
  18246. * @param effect defines the update shader
  18247. */
  18248. applyToShader(effect: Effect): void;
  18249. /**
  18250. * Returns a string to use to update the GPU particles update shader
  18251. * @returns a string containng the defines string
  18252. */
  18253. getEffectDefines(): string;
  18254. /**
  18255. * Returns the string "ConeParticleEmitter"
  18256. * @returns a string containing the class name
  18257. */
  18258. getClassName(): string;
  18259. /**
  18260. * Serializes the particle system to a JSON object.
  18261. * @returns the JSON object
  18262. */
  18263. serialize(): any;
  18264. /**
  18265. * Parse properties from a JSON object
  18266. * @param serializationObject defines the JSON object
  18267. */
  18268. parse(serializationObject: any): void;
  18269. }
  18270. }
  18271. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18272. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18273. import { Effect } from "babylonjs/Materials/effect";
  18274. import { Particle } from "babylonjs/Particles/particle";
  18275. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18276. /**
  18277. * Particle emitter emitting particles from the inside of a cylinder.
  18278. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18279. */
  18280. export class CylinderParticleEmitter implements IParticleEmitterType {
  18281. /**
  18282. * The radius of the emission cylinder.
  18283. */
  18284. radius: number;
  18285. /**
  18286. * The height of the emission cylinder.
  18287. */
  18288. height: number;
  18289. /**
  18290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18291. */
  18292. radiusRange: number;
  18293. /**
  18294. * How much to randomize the particle direction [0-1].
  18295. */
  18296. directionRandomizer: number;
  18297. /**
  18298. * Creates a new instance CylinderParticleEmitter
  18299. * @param radius the radius of the emission cylinder (1 by default)
  18300. * @param height the height of the emission cylinder (1 by default)
  18301. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18302. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18303. */
  18304. constructor(
  18305. /**
  18306. * The radius of the emission cylinder.
  18307. */
  18308. radius?: number,
  18309. /**
  18310. * The height of the emission cylinder.
  18311. */
  18312. height?: number,
  18313. /**
  18314. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18315. */
  18316. radiusRange?: number,
  18317. /**
  18318. * How much to randomize the particle direction [0-1].
  18319. */
  18320. directionRandomizer?: number);
  18321. /**
  18322. * Called by the particle System when the direction is computed for the created particle.
  18323. * @param worldMatrix is the world matrix of the particle system
  18324. * @param directionToUpdate is the direction vector to update with the result
  18325. * @param particle is the particle we are computed the direction for
  18326. */
  18327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18328. /**
  18329. * Called by the particle System when the position is computed for the created particle.
  18330. * @param worldMatrix is the world matrix of the particle system
  18331. * @param positionToUpdate is the position vector to update with the result
  18332. * @param particle is the particle we are computed the position for
  18333. */
  18334. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18335. /**
  18336. * Clones the current emitter and returns a copy of it
  18337. * @returns the new emitter
  18338. */
  18339. clone(): CylinderParticleEmitter;
  18340. /**
  18341. * Called by the GPUParticleSystem to setup the update shader
  18342. * @param effect defines the update shader
  18343. */
  18344. applyToShader(effect: Effect): void;
  18345. /**
  18346. * Returns a string to use to update the GPU particles update shader
  18347. * @returns a string containng the defines string
  18348. */
  18349. getEffectDefines(): string;
  18350. /**
  18351. * Returns the string "CylinderParticleEmitter"
  18352. * @returns a string containing the class name
  18353. */
  18354. getClassName(): string;
  18355. /**
  18356. * Serializes the particle system to a JSON object.
  18357. * @returns the JSON object
  18358. */
  18359. serialize(): any;
  18360. /**
  18361. * Parse properties from a JSON object
  18362. * @param serializationObject defines the JSON object
  18363. */
  18364. parse(serializationObject: any): void;
  18365. }
  18366. /**
  18367. * Particle emitter emitting particles from the inside of a cylinder.
  18368. * It emits the particles randomly between two vectors.
  18369. */
  18370. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18371. /**
  18372. * The min limit of the emission direction.
  18373. */
  18374. direction1: Vector3;
  18375. /**
  18376. * The max limit of the emission direction.
  18377. */
  18378. direction2: Vector3;
  18379. /**
  18380. * Creates a new instance CylinderDirectedParticleEmitter
  18381. * @param radius the radius of the emission cylinder (1 by default)
  18382. * @param height the height of the emission cylinder (1 by default)
  18383. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18384. * @param direction1 the min limit of the emission direction (up vector by default)
  18385. * @param direction2 the max limit of the emission direction (up vector by default)
  18386. */
  18387. constructor(radius?: number, height?: number, radiusRange?: number,
  18388. /**
  18389. * The min limit of the emission direction.
  18390. */
  18391. direction1?: Vector3,
  18392. /**
  18393. * The max limit of the emission direction.
  18394. */
  18395. direction2?: Vector3);
  18396. /**
  18397. * Called by the particle System when the direction is computed for the created particle.
  18398. * @param worldMatrix is the world matrix of the particle system
  18399. * @param directionToUpdate is the direction vector to update with the result
  18400. * @param particle is the particle we are computed the direction for
  18401. */
  18402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18403. /**
  18404. * Clones the current emitter and returns a copy of it
  18405. * @returns the new emitter
  18406. */
  18407. clone(): CylinderDirectedParticleEmitter;
  18408. /**
  18409. * Called by the GPUParticleSystem to setup the update shader
  18410. * @param effect defines the update shader
  18411. */
  18412. applyToShader(effect: Effect): void;
  18413. /**
  18414. * Returns a string to use to update the GPU particles update shader
  18415. * @returns a string containng the defines string
  18416. */
  18417. getEffectDefines(): string;
  18418. /**
  18419. * Returns the string "CylinderDirectedParticleEmitter"
  18420. * @returns a string containing the class name
  18421. */
  18422. getClassName(): string;
  18423. /**
  18424. * Serializes the particle system to a JSON object.
  18425. * @returns the JSON object
  18426. */
  18427. serialize(): any;
  18428. /**
  18429. * Parse properties from a JSON object
  18430. * @param serializationObject defines the JSON object
  18431. */
  18432. parse(serializationObject: any): void;
  18433. }
  18434. }
  18435. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18436. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18437. import { Effect } from "babylonjs/Materials/effect";
  18438. import { Particle } from "babylonjs/Particles/particle";
  18439. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18440. /**
  18441. * Particle emitter emitting particles from the inside of a hemisphere.
  18442. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18443. */
  18444. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18445. /**
  18446. * The radius of the emission hemisphere.
  18447. */
  18448. radius: number;
  18449. /**
  18450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18451. */
  18452. radiusRange: number;
  18453. /**
  18454. * How much to randomize the particle direction [0-1].
  18455. */
  18456. directionRandomizer: number;
  18457. /**
  18458. * Creates a new instance HemisphericParticleEmitter
  18459. * @param radius the radius of the emission hemisphere (1 by default)
  18460. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18461. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18462. */
  18463. constructor(
  18464. /**
  18465. * The radius of the emission hemisphere.
  18466. */
  18467. radius?: number,
  18468. /**
  18469. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18470. */
  18471. radiusRange?: number,
  18472. /**
  18473. * How much to randomize the particle direction [0-1].
  18474. */
  18475. directionRandomizer?: number);
  18476. /**
  18477. * Called by the particle System when the direction is computed for the created particle.
  18478. * @param worldMatrix is the world matrix of the particle system
  18479. * @param directionToUpdate is the direction vector to update with the result
  18480. * @param particle is the particle we are computed the direction for
  18481. */
  18482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18483. /**
  18484. * Called by the particle System when the position is computed for the created particle.
  18485. * @param worldMatrix is the world matrix of the particle system
  18486. * @param positionToUpdate is the position vector to update with the result
  18487. * @param particle is the particle we are computed the position for
  18488. */
  18489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18490. /**
  18491. * Clones the current emitter and returns a copy of it
  18492. * @returns the new emitter
  18493. */
  18494. clone(): HemisphericParticleEmitter;
  18495. /**
  18496. * Called by the GPUParticleSystem to setup the update shader
  18497. * @param effect defines the update shader
  18498. */
  18499. applyToShader(effect: Effect): void;
  18500. /**
  18501. * Returns a string to use to update the GPU particles update shader
  18502. * @returns a string containng the defines string
  18503. */
  18504. getEffectDefines(): string;
  18505. /**
  18506. * Returns the string "HemisphericParticleEmitter"
  18507. * @returns a string containing the class name
  18508. */
  18509. getClassName(): string;
  18510. /**
  18511. * Serializes the particle system to a JSON object.
  18512. * @returns the JSON object
  18513. */
  18514. serialize(): any;
  18515. /**
  18516. * Parse properties from a JSON object
  18517. * @param serializationObject defines the JSON object
  18518. */
  18519. parse(serializationObject: any): void;
  18520. }
  18521. }
  18522. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18523. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18524. import { Effect } from "babylonjs/Materials/effect";
  18525. import { Particle } from "babylonjs/Particles/particle";
  18526. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18527. /**
  18528. * Particle emitter emitting particles from a point.
  18529. * It emits the particles randomly between 2 given directions.
  18530. */
  18531. export class PointParticleEmitter implements IParticleEmitterType {
  18532. /**
  18533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18534. */
  18535. direction1: Vector3;
  18536. /**
  18537. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18538. */
  18539. direction2: Vector3;
  18540. /**
  18541. * Creates a new instance PointParticleEmitter
  18542. */
  18543. constructor();
  18544. /**
  18545. * Called by the particle System when the direction is computed for the created particle.
  18546. * @param worldMatrix is the world matrix of the particle system
  18547. * @param directionToUpdate is the direction vector to update with the result
  18548. * @param particle is the particle we are computed the direction for
  18549. */
  18550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18551. /**
  18552. * Called by the particle System when the position is computed for the created particle.
  18553. * @param worldMatrix is the world matrix of the particle system
  18554. * @param positionToUpdate is the position vector to update with the result
  18555. * @param particle is the particle we are computed the position for
  18556. */
  18557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18558. /**
  18559. * Clones the current emitter and returns a copy of it
  18560. * @returns the new emitter
  18561. */
  18562. clone(): PointParticleEmitter;
  18563. /**
  18564. * Called by the GPUParticleSystem to setup the update shader
  18565. * @param effect defines the update shader
  18566. */
  18567. applyToShader(effect: Effect): void;
  18568. /**
  18569. * Returns a string to use to update the GPU particles update shader
  18570. * @returns a string containng the defines string
  18571. */
  18572. getEffectDefines(): string;
  18573. /**
  18574. * Returns the string "PointParticleEmitter"
  18575. * @returns a string containing the class name
  18576. */
  18577. getClassName(): string;
  18578. /**
  18579. * Serializes the particle system to a JSON object.
  18580. * @returns the JSON object
  18581. */
  18582. serialize(): any;
  18583. /**
  18584. * Parse properties from a JSON object
  18585. * @param serializationObject defines the JSON object
  18586. */
  18587. parse(serializationObject: any): void;
  18588. }
  18589. }
  18590. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18591. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18592. import { Effect } from "babylonjs/Materials/effect";
  18593. import { Particle } from "babylonjs/Particles/particle";
  18594. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18595. /**
  18596. * Particle emitter emitting particles from the inside of a sphere.
  18597. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18598. */
  18599. export class SphereParticleEmitter implements IParticleEmitterType {
  18600. /**
  18601. * The radius of the emission sphere.
  18602. */
  18603. radius: number;
  18604. /**
  18605. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18606. */
  18607. radiusRange: number;
  18608. /**
  18609. * How much to randomize the particle direction [0-1].
  18610. */
  18611. directionRandomizer: number;
  18612. /**
  18613. * Creates a new instance SphereParticleEmitter
  18614. * @param radius the radius of the emission sphere (1 by default)
  18615. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18616. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18617. */
  18618. constructor(
  18619. /**
  18620. * The radius of the emission sphere.
  18621. */
  18622. radius?: number,
  18623. /**
  18624. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18625. */
  18626. radiusRange?: number,
  18627. /**
  18628. * How much to randomize the particle direction [0-1].
  18629. */
  18630. directionRandomizer?: number);
  18631. /**
  18632. * Called by the particle System when the direction is computed for the created particle.
  18633. * @param worldMatrix is the world matrix of the particle system
  18634. * @param directionToUpdate is the direction vector to update with the result
  18635. * @param particle is the particle we are computed the direction for
  18636. */
  18637. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18638. /**
  18639. * Called by the particle System when the position is computed for the created particle.
  18640. * @param worldMatrix is the world matrix of the particle system
  18641. * @param positionToUpdate is the position vector to update with the result
  18642. * @param particle is the particle we are computed the position for
  18643. */
  18644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18645. /**
  18646. * Clones the current emitter and returns a copy of it
  18647. * @returns the new emitter
  18648. */
  18649. clone(): SphereParticleEmitter;
  18650. /**
  18651. * Called by the GPUParticleSystem to setup the update shader
  18652. * @param effect defines the update shader
  18653. */
  18654. applyToShader(effect: Effect): void;
  18655. /**
  18656. * Returns a string to use to update the GPU particles update shader
  18657. * @returns a string containng the defines string
  18658. */
  18659. getEffectDefines(): string;
  18660. /**
  18661. * Returns the string "SphereParticleEmitter"
  18662. * @returns a string containing the class name
  18663. */
  18664. getClassName(): string;
  18665. /**
  18666. * Serializes the particle system to a JSON object.
  18667. * @returns the JSON object
  18668. */
  18669. serialize(): any;
  18670. /**
  18671. * Parse properties from a JSON object
  18672. * @param serializationObject defines the JSON object
  18673. */
  18674. parse(serializationObject: any): void;
  18675. }
  18676. /**
  18677. * Particle emitter emitting particles from the inside of a sphere.
  18678. * It emits the particles randomly between two vectors.
  18679. */
  18680. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18681. /**
  18682. * The min limit of the emission direction.
  18683. */
  18684. direction1: Vector3;
  18685. /**
  18686. * The max limit of the emission direction.
  18687. */
  18688. direction2: Vector3;
  18689. /**
  18690. * Creates a new instance SphereDirectedParticleEmitter
  18691. * @param radius the radius of the emission sphere (1 by default)
  18692. * @param direction1 the min limit of the emission direction (up vector by default)
  18693. * @param direction2 the max limit of the emission direction (up vector by default)
  18694. */
  18695. constructor(radius?: number,
  18696. /**
  18697. * The min limit of the emission direction.
  18698. */
  18699. direction1?: Vector3,
  18700. /**
  18701. * The max limit of the emission direction.
  18702. */
  18703. direction2?: Vector3);
  18704. /**
  18705. * Called by the particle System when the direction is computed for the created particle.
  18706. * @param worldMatrix is the world matrix of the particle system
  18707. * @param directionToUpdate is the direction vector to update with the result
  18708. * @param particle is the particle we are computed the direction for
  18709. */
  18710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18711. /**
  18712. * Clones the current emitter and returns a copy of it
  18713. * @returns the new emitter
  18714. */
  18715. clone(): SphereDirectedParticleEmitter;
  18716. /**
  18717. * Called by the GPUParticleSystem to setup the update shader
  18718. * @param effect defines the update shader
  18719. */
  18720. applyToShader(effect: Effect): void;
  18721. /**
  18722. * Returns a string to use to update the GPU particles update shader
  18723. * @returns a string containng the defines string
  18724. */
  18725. getEffectDefines(): string;
  18726. /**
  18727. * Returns the string "SphereDirectedParticleEmitter"
  18728. * @returns a string containing the class name
  18729. */
  18730. getClassName(): string;
  18731. /**
  18732. * Serializes the particle system to a JSON object.
  18733. * @returns the JSON object
  18734. */
  18735. serialize(): any;
  18736. /**
  18737. * Parse properties from a JSON object
  18738. * @param serializationObject defines the JSON object
  18739. */
  18740. parse(serializationObject: any): void;
  18741. }
  18742. }
  18743. declare module "babylonjs/Particles/EmitterTypes/index" {
  18744. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18745. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18746. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18747. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18748. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18749. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18750. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18751. }
  18752. declare module "babylonjs/Particles/IParticleSystem" {
  18753. import { Nullable } from "babylonjs/types";
  18754. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18755. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18758. import { Texture } from "babylonjs/Materials/Textures/texture";
  18759. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18760. import { Scene } from "babylonjs/scene";
  18761. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18762. import { Animation } from "babylonjs/Animations/animation";
  18763. /**
  18764. * Interface representing a particle system in Babylon.js.
  18765. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18766. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18767. */
  18768. export interface IParticleSystem {
  18769. /**
  18770. * List of animations used by the particle system.
  18771. */
  18772. animations: Animation[];
  18773. /**
  18774. * The id of the Particle system.
  18775. */
  18776. id: string;
  18777. /**
  18778. * The name of the Particle system.
  18779. */
  18780. name: string;
  18781. /**
  18782. * The emitter represents the Mesh or position we are attaching the particle system to.
  18783. */
  18784. emitter: Nullable<AbstractMesh | Vector3>;
  18785. /**
  18786. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18787. */
  18788. isBillboardBased: boolean;
  18789. /**
  18790. * The rendering group used by the Particle system to chose when to render.
  18791. */
  18792. renderingGroupId: number;
  18793. /**
  18794. * The layer mask we are rendering the particles through.
  18795. */
  18796. layerMask: number;
  18797. /**
  18798. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18799. */
  18800. updateSpeed: number;
  18801. /**
  18802. * The amount of time the particle system is running (depends of the overall update speed).
  18803. */
  18804. targetStopDuration: number;
  18805. /**
  18806. * The texture used to render each particle. (this can be a spritesheet)
  18807. */
  18808. particleTexture: Nullable<Texture>;
  18809. /**
  18810. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18811. */
  18812. blendMode: number;
  18813. /**
  18814. * Minimum life time of emitting particles.
  18815. */
  18816. minLifeTime: number;
  18817. /**
  18818. * Maximum life time of emitting particles.
  18819. */
  18820. maxLifeTime: number;
  18821. /**
  18822. * Minimum Size of emitting particles.
  18823. */
  18824. minSize: number;
  18825. /**
  18826. * Maximum Size of emitting particles.
  18827. */
  18828. maxSize: number;
  18829. /**
  18830. * Minimum scale of emitting particles on X axis.
  18831. */
  18832. minScaleX: number;
  18833. /**
  18834. * Maximum scale of emitting particles on X axis.
  18835. */
  18836. maxScaleX: number;
  18837. /**
  18838. * Minimum scale of emitting particles on Y axis.
  18839. */
  18840. minScaleY: number;
  18841. /**
  18842. * Maximum scale of emitting particles on Y axis.
  18843. */
  18844. maxScaleY: number;
  18845. /**
  18846. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18847. */
  18848. color1: Color4;
  18849. /**
  18850. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18851. */
  18852. color2: Color4;
  18853. /**
  18854. * Color the particle will have at the end of its lifetime.
  18855. */
  18856. colorDead: Color4;
  18857. /**
  18858. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18859. */
  18860. emitRate: number;
  18861. /**
  18862. * You can use gravity if you want to give an orientation to your particles.
  18863. */
  18864. gravity: Vector3;
  18865. /**
  18866. * Minimum power of emitting particles.
  18867. */
  18868. minEmitPower: number;
  18869. /**
  18870. * Maximum power of emitting particles.
  18871. */
  18872. maxEmitPower: number;
  18873. /**
  18874. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18875. */
  18876. minAngularSpeed: number;
  18877. /**
  18878. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18879. */
  18880. maxAngularSpeed: number;
  18881. /**
  18882. * Gets or sets the minimal initial rotation in radians.
  18883. */
  18884. minInitialRotation: number;
  18885. /**
  18886. * Gets or sets the maximal initial rotation in radians.
  18887. */
  18888. maxInitialRotation: number;
  18889. /**
  18890. * The particle emitter type defines the emitter used by the particle system.
  18891. * It can be for example box, sphere, or cone...
  18892. */
  18893. particleEmitterType: Nullable<IParticleEmitterType>;
  18894. /**
  18895. * Defines the delay in milliseconds before starting the system (0 by default)
  18896. */
  18897. startDelay: number;
  18898. /**
  18899. * 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
  18900. */
  18901. preWarmCycles: number;
  18902. /**
  18903. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18904. */
  18905. preWarmStepOffset: number;
  18906. /**
  18907. * 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)
  18908. */
  18909. spriteCellChangeSpeed: number;
  18910. /**
  18911. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18912. */
  18913. startSpriteCellID: number;
  18914. /**
  18915. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18916. */
  18917. endSpriteCellID: number;
  18918. /**
  18919. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18920. */
  18921. spriteCellWidth: number;
  18922. /**
  18923. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18924. */
  18925. spriteCellHeight: number;
  18926. /**
  18927. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18928. */
  18929. spriteRandomStartCell: boolean;
  18930. /**
  18931. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18932. */
  18933. isAnimationSheetEnabled: boolean;
  18934. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18935. translationPivot: Vector2;
  18936. /**
  18937. * Gets or sets a texture used to add random noise to particle positions
  18938. */
  18939. noiseTexture: Nullable<BaseTexture>;
  18940. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18941. noiseStrength: Vector3;
  18942. /**
  18943. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18944. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18945. */
  18946. billboardMode: number;
  18947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18948. limitVelocityDamping: number;
  18949. /**
  18950. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18951. */
  18952. beginAnimationOnStart: boolean;
  18953. /**
  18954. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18955. */
  18956. beginAnimationFrom: number;
  18957. /**
  18958. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18959. */
  18960. beginAnimationTo: number;
  18961. /**
  18962. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18963. */
  18964. beginAnimationLoop: boolean;
  18965. /**
  18966. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18967. */
  18968. disposeOnStop: boolean;
  18969. /**
  18970. * Gets the maximum number of particles active at the same time.
  18971. * @returns The max number of active particles.
  18972. */
  18973. getCapacity(): number;
  18974. /**
  18975. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18976. * @returns True if it has been started, otherwise false.
  18977. */
  18978. isStarted(): boolean;
  18979. /**
  18980. * Animates the particle system for this frame.
  18981. */
  18982. animate(): void;
  18983. /**
  18984. * Renders the particle system in its current state.
  18985. * @returns the current number of particles
  18986. */
  18987. render(): number;
  18988. /**
  18989. * Dispose the particle system and frees its associated resources.
  18990. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18991. */
  18992. dispose(disposeTexture?: boolean): void;
  18993. /**
  18994. * Clones the particle system.
  18995. * @param name The name of the cloned object
  18996. * @param newEmitter The new emitter to use
  18997. * @returns the cloned particle system
  18998. */
  18999. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19000. /**
  19001. * Serializes the particle system to a JSON object.
  19002. * @returns the JSON object
  19003. */
  19004. serialize(): any;
  19005. /**
  19006. * Rebuild the particle system
  19007. */
  19008. rebuild(): void;
  19009. /**
  19010. * Starts the particle system and begins to emit
  19011. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19012. */
  19013. start(delay?: number): void;
  19014. /**
  19015. * Stops the particle system.
  19016. */
  19017. stop(): void;
  19018. /**
  19019. * Remove all active particles
  19020. */
  19021. reset(): void;
  19022. /**
  19023. * Is this system ready to be used/rendered
  19024. * @return true if the system is ready
  19025. */
  19026. isReady(): boolean;
  19027. /**
  19028. * Adds a new color gradient
  19029. * @param gradient defines the gradient to use (between 0 and 1)
  19030. * @param color1 defines the color to affect to the specified gradient
  19031. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19032. * @returns the current particle system
  19033. */
  19034. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19035. /**
  19036. * Remove a specific color gradient
  19037. * @param gradient defines the gradient to remove
  19038. * @returns the current particle system
  19039. */
  19040. removeColorGradient(gradient: number): IParticleSystem;
  19041. /**
  19042. * Adds a new size gradient
  19043. * @param gradient defines the gradient to use (between 0 and 1)
  19044. * @param factor defines the size factor to affect to the specified gradient
  19045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19046. * @returns the current particle system
  19047. */
  19048. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19049. /**
  19050. * Remove a specific size gradient
  19051. * @param gradient defines the gradient to remove
  19052. * @returns the current particle system
  19053. */
  19054. removeSizeGradient(gradient: number): IParticleSystem;
  19055. /**
  19056. * Gets the current list of color gradients.
  19057. * You must use addColorGradient and removeColorGradient to udpate this list
  19058. * @returns the list of color gradients
  19059. */
  19060. getColorGradients(): Nullable<Array<ColorGradient>>;
  19061. /**
  19062. * Gets the current list of size gradients.
  19063. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19064. * @returns the list of size gradients
  19065. */
  19066. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19067. /**
  19068. * Gets the current list of angular speed gradients.
  19069. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19070. * @returns the list of angular speed gradients
  19071. */
  19072. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19073. /**
  19074. * Adds a new angular speed gradient
  19075. * @param gradient defines the gradient to use (between 0 and 1)
  19076. * @param factor defines the angular speed to affect to the specified gradient
  19077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19078. * @returns the current particle system
  19079. */
  19080. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19081. /**
  19082. * Remove a specific angular speed gradient
  19083. * @param gradient defines the gradient to remove
  19084. * @returns the current particle system
  19085. */
  19086. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19087. /**
  19088. * Gets the current list of velocity gradients.
  19089. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19090. * @returns the list of velocity gradients
  19091. */
  19092. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19093. /**
  19094. * Adds a new velocity gradient
  19095. * @param gradient defines the gradient to use (between 0 and 1)
  19096. * @param factor defines the velocity to affect to the specified gradient
  19097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19098. * @returns the current particle system
  19099. */
  19100. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19101. /**
  19102. * Remove a specific velocity gradient
  19103. * @param gradient defines the gradient to remove
  19104. * @returns the current particle system
  19105. */
  19106. removeVelocityGradient(gradient: number): IParticleSystem;
  19107. /**
  19108. * Gets the current list of limit velocity gradients.
  19109. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19110. * @returns the list of limit velocity gradients
  19111. */
  19112. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19113. /**
  19114. * Adds a new limit velocity gradient
  19115. * @param gradient defines the gradient to use (between 0 and 1)
  19116. * @param factor defines the limit velocity to affect to the specified gradient
  19117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19118. * @returns the current particle system
  19119. */
  19120. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19121. /**
  19122. * Remove a specific limit velocity gradient
  19123. * @param gradient defines the gradient to remove
  19124. * @returns the current particle system
  19125. */
  19126. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19127. /**
  19128. * Adds a new drag gradient
  19129. * @param gradient defines the gradient to use (between 0 and 1)
  19130. * @param factor defines the drag to affect to the specified gradient
  19131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19132. * @returns the current particle system
  19133. */
  19134. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19135. /**
  19136. * Remove a specific drag gradient
  19137. * @param gradient defines the gradient to remove
  19138. * @returns the current particle system
  19139. */
  19140. removeDragGradient(gradient: number): IParticleSystem;
  19141. /**
  19142. * Gets the current list of drag gradients.
  19143. * You must use addDragGradient and removeDragGradient to udpate this list
  19144. * @returns the list of drag gradients
  19145. */
  19146. getDragGradients(): Nullable<Array<FactorGradient>>;
  19147. /**
  19148. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19149. * @param gradient defines the gradient to use (between 0 and 1)
  19150. * @param factor defines the emit rate to affect to the specified gradient
  19151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19152. * @returns the current particle system
  19153. */
  19154. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19155. /**
  19156. * Remove a specific emit rate gradient
  19157. * @param gradient defines the gradient to remove
  19158. * @returns the current particle system
  19159. */
  19160. removeEmitRateGradient(gradient: number): IParticleSystem;
  19161. /**
  19162. * Gets the current list of emit rate gradients.
  19163. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19164. * @returns the list of emit rate gradients
  19165. */
  19166. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19167. /**
  19168. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19169. * @param gradient defines the gradient to use (between 0 and 1)
  19170. * @param factor defines the start size to affect to the specified gradient
  19171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19172. * @returns the current particle system
  19173. */
  19174. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19175. /**
  19176. * Remove a specific start size gradient
  19177. * @param gradient defines the gradient to remove
  19178. * @returns the current particle system
  19179. */
  19180. removeStartSizeGradient(gradient: number): IParticleSystem;
  19181. /**
  19182. * Gets the current list of start size gradients.
  19183. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19184. * @returns the list of start size gradients
  19185. */
  19186. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19187. /**
  19188. * Adds a new life time gradient
  19189. * @param gradient defines the gradient to use (between 0 and 1)
  19190. * @param factor defines the life time factor to affect to the specified gradient
  19191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19192. * @returns the current particle system
  19193. */
  19194. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19195. /**
  19196. * Remove a specific life time gradient
  19197. * @param gradient defines the gradient to remove
  19198. * @returns the current particle system
  19199. */
  19200. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19201. /**
  19202. * Gets the current list of life time gradients.
  19203. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19204. * @returns the list of life time gradients
  19205. */
  19206. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19207. /**
  19208. * Gets the current list of color gradients.
  19209. * You must use addColorGradient and removeColorGradient to udpate this list
  19210. * @returns the list of color gradients
  19211. */
  19212. getColorGradients(): Nullable<Array<ColorGradient>>;
  19213. /**
  19214. * Adds a new ramp gradient used to remap particle colors
  19215. * @param gradient defines the gradient to use (between 0 and 1)
  19216. * @param color defines the color to affect to the specified gradient
  19217. * @returns the current particle system
  19218. */
  19219. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19220. /**
  19221. * Gets the current list of ramp gradients.
  19222. * You must use addRampGradient and removeRampGradient to udpate this list
  19223. * @returns the list of ramp gradients
  19224. */
  19225. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19226. /** Gets or sets a boolean indicating that ramp gradients must be used
  19227. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19228. */
  19229. useRampGradients: boolean;
  19230. /**
  19231. * Adds a new color remap gradient
  19232. * @param gradient defines the gradient to use (between 0 and 1)
  19233. * @param min defines the color remap minimal range
  19234. * @param max defines the color remap maximal range
  19235. * @returns the current particle system
  19236. */
  19237. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19238. /**
  19239. * Gets the current list of color remap gradients.
  19240. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19241. * @returns the list of color remap gradients
  19242. */
  19243. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19244. /**
  19245. * Adds a new alpha remap gradient
  19246. * @param gradient defines the gradient to use (between 0 and 1)
  19247. * @param min defines the alpha remap minimal range
  19248. * @param max defines the alpha remap maximal range
  19249. * @returns the current particle system
  19250. */
  19251. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19252. /**
  19253. * Gets the current list of alpha remap gradients.
  19254. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19255. * @returns the list of alpha remap gradients
  19256. */
  19257. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19258. /**
  19259. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19260. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19261. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19262. * @returns the emitter
  19263. */
  19264. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19265. /**
  19266. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19267. * @param radius The radius of the hemisphere to emit from
  19268. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19269. * @returns the emitter
  19270. */
  19271. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19272. /**
  19273. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19274. * @param radius The radius of the sphere to emit from
  19275. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19276. * @returns the emitter
  19277. */
  19278. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19279. /**
  19280. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19281. * @param radius The radius of the sphere to emit from
  19282. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19283. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19284. * @returns the emitter
  19285. */
  19286. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19287. /**
  19288. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19289. * @param radius The radius of the emission cylinder
  19290. * @param height The height of the emission cylinder
  19291. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19292. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19293. * @returns the emitter
  19294. */
  19295. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19296. /**
  19297. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19298. * @param radius The radius of the cylinder to emit from
  19299. * @param height The height of the emission cylinder
  19300. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19301. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19302. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19303. * @returns the emitter
  19304. */
  19305. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19306. /**
  19307. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19308. * @param radius The radius of the cone to emit from
  19309. * @param angle The base angle of the cone
  19310. * @returns the emitter
  19311. */
  19312. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19313. /**
  19314. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19317. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19318. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19319. * @returns the emitter
  19320. */
  19321. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19322. /**
  19323. * Get hosting scene
  19324. * @returns the scene
  19325. */
  19326. getScene(): Scene;
  19327. }
  19328. }
  19329. declare module "babylonjs/Meshes/instancedMesh" {
  19330. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19332. import { Camera } from "babylonjs/Cameras/camera";
  19333. import { Node } from "babylonjs/node";
  19334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19335. import { Mesh } from "babylonjs/Meshes/mesh";
  19336. import { Material } from "babylonjs/Materials/material";
  19337. import { Skeleton } from "babylonjs/Bones/skeleton";
  19338. import { Light } from "babylonjs/Lights/light";
  19339. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19340. /**
  19341. * Creates an instance based on a source mesh.
  19342. */
  19343. export class InstancedMesh extends AbstractMesh {
  19344. private _sourceMesh;
  19345. private _currentLOD;
  19346. /** @hidden */
  19347. _indexInSourceMeshInstanceArray: number;
  19348. constructor(name: string, source: Mesh);
  19349. /**
  19350. * Returns the string "InstancedMesh".
  19351. */
  19352. getClassName(): string;
  19353. /** Gets the list of lights affecting that mesh */
  19354. readonly lightSources: Light[];
  19355. _resyncLightSources(): void;
  19356. _resyncLighSource(light: Light): void;
  19357. _removeLightSource(light: Light, dispose: boolean): void;
  19358. /**
  19359. * If the source mesh receives shadows
  19360. */
  19361. readonly receiveShadows: boolean;
  19362. /**
  19363. * The material of the source mesh
  19364. */
  19365. readonly material: Nullable<Material>;
  19366. /**
  19367. * Visibility of the source mesh
  19368. */
  19369. readonly visibility: number;
  19370. /**
  19371. * Skeleton of the source mesh
  19372. */
  19373. readonly skeleton: Nullable<Skeleton>;
  19374. /**
  19375. * Rendering ground id of the source mesh
  19376. */
  19377. renderingGroupId: number;
  19378. /**
  19379. * Returns the total number of vertices (integer).
  19380. */
  19381. getTotalVertices(): number;
  19382. /**
  19383. * Returns a positive integer : the total number of indices in this mesh geometry.
  19384. * @returns the numner of indices or zero if the mesh has no geometry.
  19385. */
  19386. getTotalIndices(): number;
  19387. /**
  19388. * The source mesh of the instance
  19389. */
  19390. readonly sourceMesh: Mesh;
  19391. /**
  19392. * Is this node ready to be used/rendered
  19393. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19394. * @return {boolean} is it ready
  19395. */
  19396. isReady(completeCheck?: boolean): boolean;
  19397. /**
  19398. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19399. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19400. * @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.
  19401. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19402. */
  19403. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19404. /**
  19405. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19406. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19407. * The `data` are either a numeric array either a Float32Array.
  19408. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19409. * 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).
  19410. * Note that a new underlying VertexBuffer object is created each call.
  19411. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19412. *
  19413. * Possible `kind` values :
  19414. * - VertexBuffer.PositionKind
  19415. * - VertexBuffer.UVKind
  19416. * - VertexBuffer.UV2Kind
  19417. * - VertexBuffer.UV3Kind
  19418. * - VertexBuffer.UV4Kind
  19419. * - VertexBuffer.UV5Kind
  19420. * - VertexBuffer.UV6Kind
  19421. * - VertexBuffer.ColorKind
  19422. * - VertexBuffer.MatricesIndicesKind
  19423. * - VertexBuffer.MatricesIndicesExtraKind
  19424. * - VertexBuffer.MatricesWeightsKind
  19425. * - VertexBuffer.MatricesWeightsExtraKind
  19426. *
  19427. * Returns the Mesh.
  19428. */
  19429. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19430. /**
  19431. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19432. * If the mesh has no geometry, it is simply returned as it is.
  19433. * The `data` are either a numeric array either a Float32Array.
  19434. * No new underlying VertexBuffer object is created.
  19435. * 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.
  19436. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19437. *
  19438. * Possible `kind` values :
  19439. * - VertexBuffer.PositionKind
  19440. * - VertexBuffer.UVKind
  19441. * - VertexBuffer.UV2Kind
  19442. * - VertexBuffer.UV3Kind
  19443. * - VertexBuffer.UV4Kind
  19444. * - VertexBuffer.UV5Kind
  19445. * - VertexBuffer.UV6Kind
  19446. * - VertexBuffer.ColorKind
  19447. * - VertexBuffer.MatricesIndicesKind
  19448. * - VertexBuffer.MatricesIndicesExtraKind
  19449. * - VertexBuffer.MatricesWeightsKind
  19450. * - VertexBuffer.MatricesWeightsExtraKind
  19451. *
  19452. * Returns the Mesh.
  19453. */
  19454. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19455. /**
  19456. * Sets the mesh indices.
  19457. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19458. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19459. * This method creates a new index buffer each call.
  19460. * Returns the Mesh.
  19461. */
  19462. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19463. /**
  19464. * Boolean : True if the mesh owns the requested kind of data.
  19465. */
  19466. isVerticesDataPresent(kind: string): boolean;
  19467. /**
  19468. * Returns an array of indices (IndicesArray).
  19469. */
  19470. getIndices(): Nullable<IndicesArray>;
  19471. readonly _positions: Nullable<Vector3[]>;
  19472. /**
  19473. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19474. * This means the mesh underlying bounding box and sphere are recomputed.
  19475. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19476. * @returns the current mesh
  19477. */
  19478. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19479. /** @hidden */
  19480. _preActivate(): InstancedMesh;
  19481. /** @hidden */
  19482. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19483. /** @hidden */
  19484. _postActivate(): void;
  19485. getWorldMatrix(): Matrix;
  19486. readonly isAnInstance: boolean;
  19487. /**
  19488. * Returns the current associated LOD AbstractMesh.
  19489. */
  19490. getLOD(camera: Camera): AbstractMesh;
  19491. /** @hidden */
  19492. _syncSubMeshes(): InstancedMesh;
  19493. /** @hidden */
  19494. _generatePointsArray(): boolean;
  19495. /**
  19496. * Creates a new InstancedMesh from the current mesh.
  19497. * - name (string) : the cloned mesh name
  19498. * - newParent (optional Node) : the optional Node to parent the clone to.
  19499. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19500. *
  19501. * Returns the clone.
  19502. */
  19503. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19504. /**
  19505. * Disposes the InstancedMesh.
  19506. * Returns nothing.
  19507. */
  19508. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19509. }
  19510. module "babylonjs/Meshes/mesh" {
  19511. interface Mesh {
  19512. /**
  19513. * Register a custom buffer that will be instanced
  19514. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19515. * @param kind defines the buffer kind
  19516. * @param stride defines the stride in floats
  19517. */
  19518. registerInstancedBuffer(kind: string, stride: number): void;
  19519. /** @hidden */
  19520. _userInstancedBuffersStorage: {
  19521. data: {
  19522. [key: string]: Float32Array;
  19523. };
  19524. sizes: {
  19525. [key: string]: number;
  19526. };
  19527. vertexBuffers: {
  19528. [key: string]: Nullable<VertexBuffer>;
  19529. };
  19530. strides: {
  19531. [key: string]: number;
  19532. };
  19533. };
  19534. }
  19535. }
  19536. module "babylonjs/Meshes/abstractMesh" {
  19537. interface AbstractMesh {
  19538. /**
  19539. * Object used to store instanced buffers defined by user
  19540. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19541. */
  19542. instancedBuffers: {
  19543. [key: string]: any;
  19544. };
  19545. }
  19546. }
  19547. }
  19548. declare module "babylonjs/Materials/shaderMaterial" {
  19549. import { Scene } from "babylonjs/scene";
  19550. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19552. import { Mesh } from "babylonjs/Meshes/mesh";
  19553. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19554. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19555. import { Texture } from "babylonjs/Materials/Textures/texture";
  19556. import { Material } from "babylonjs/Materials/material";
  19557. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19558. /**
  19559. * Defines the options associated with the creation of a shader material.
  19560. */
  19561. export interface IShaderMaterialOptions {
  19562. /**
  19563. * Does the material work in alpha blend mode
  19564. */
  19565. needAlphaBlending: boolean;
  19566. /**
  19567. * Does the material work in alpha test mode
  19568. */
  19569. needAlphaTesting: boolean;
  19570. /**
  19571. * The list of attribute names used in the shader
  19572. */
  19573. attributes: string[];
  19574. /**
  19575. * The list of unifrom names used in the shader
  19576. */
  19577. uniforms: string[];
  19578. /**
  19579. * The list of UBO names used in the shader
  19580. */
  19581. uniformBuffers: string[];
  19582. /**
  19583. * The list of sampler names used in the shader
  19584. */
  19585. samplers: string[];
  19586. /**
  19587. * The list of defines used in the shader
  19588. */
  19589. defines: string[];
  19590. }
  19591. /**
  19592. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19593. *
  19594. * This returned material effects how the mesh will look based on the code in the shaders.
  19595. *
  19596. * @see http://doc.babylonjs.com/how_to/shader_material
  19597. */
  19598. export class ShaderMaterial extends Material {
  19599. private _shaderPath;
  19600. private _options;
  19601. private _textures;
  19602. private _textureArrays;
  19603. private _floats;
  19604. private _ints;
  19605. private _floatsArrays;
  19606. private _colors3;
  19607. private _colors3Arrays;
  19608. private _colors4;
  19609. private _colors4Arrays;
  19610. private _vectors2;
  19611. private _vectors3;
  19612. private _vectors4;
  19613. private _matrices;
  19614. private _matrices3x3;
  19615. private _matrices2x2;
  19616. private _vectors2Arrays;
  19617. private _vectors3Arrays;
  19618. private _vectors4Arrays;
  19619. private _cachedWorldViewMatrix;
  19620. private _cachedWorldViewProjectionMatrix;
  19621. private _renderId;
  19622. /**
  19623. * Instantiate a new shader material.
  19624. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19625. * This returned material effects how the mesh will look based on the code in the shaders.
  19626. * @see http://doc.babylonjs.com/how_to/shader_material
  19627. * @param name Define the name of the material in the scene
  19628. * @param scene Define the scene the material belongs to
  19629. * @param shaderPath Defines the route to the shader code in one of three ways:
  19630. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19631. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19632. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19633. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19634. * @param options Define the options used to create the shader
  19635. */
  19636. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19637. /**
  19638. * Gets the options used to compile the shader.
  19639. * They can be modified to trigger a new compilation
  19640. */
  19641. readonly options: IShaderMaterialOptions;
  19642. /**
  19643. * Gets the current class name of the material e.g. "ShaderMaterial"
  19644. * Mainly use in serialization.
  19645. * @returns the class name
  19646. */
  19647. getClassName(): string;
  19648. /**
  19649. * Specifies if the material will require alpha blending
  19650. * @returns a boolean specifying if alpha blending is needed
  19651. */
  19652. needAlphaBlending(): boolean;
  19653. /**
  19654. * Specifies if this material should be rendered in alpha test mode
  19655. * @returns a boolean specifying if an alpha test is needed.
  19656. */
  19657. needAlphaTesting(): boolean;
  19658. private _checkUniform;
  19659. /**
  19660. * Set a texture in the shader.
  19661. * @param name Define the name of the uniform samplers as defined in the shader
  19662. * @param texture Define the texture to bind to this sampler
  19663. * @return the material itself allowing "fluent" like uniform updates
  19664. */
  19665. setTexture(name: string, texture: Texture): ShaderMaterial;
  19666. /**
  19667. * Set a texture array in the shader.
  19668. * @param name Define the name of the uniform sampler array as defined in the shader
  19669. * @param textures Define the list of textures to bind to this sampler
  19670. * @return the material itself allowing "fluent" like uniform updates
  19671. */
  19672. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19673. /**
  19674. * Set a float in the shader.
  19675. * @param name Define the name of the uniform as defined in the shader
  19676. * @param value Define the value to give to the uniform
  19677. * @return the material itself allowing "fluent" like uniform updates
  19678. */
  19679. setFloat(name: string, value: number): ShaderMaterial;
  19680. /**
  19681. * Set a int in the shader.
  19682. * @param name Define the name of the uniform as defined in the shader
  19683. * @param value Define the value to give to the uniform
  19684. * @return the material itself allowing "fluent" like uniform updates
  19685. */
  19686. setInt(name: string, value: number): ShaderMaterial;
  19687. /**
  19688. * Set an array of floats in the shader.
  19689. * @param name Define the name of the uniform as defined in the shader
  19690. * @param value Define the value to give to the uniform
  19691. * @return the material itself allowing "fluent" like uniform updates
  19692. */
  19693. setFloats(name: string, value: number[]): ShaderMaterial;
  19694. /**
  19695. * Set a vec3 in the shader from a Color3.
  19696. * @param name Define the name of the uniform as defined in the shader
  19697. * @param value Define the value to give to the uniform
  19698. * @return the material itself allowing "fluent" like uniform updates
  19699. */
  19700. setColor3(name: string, value: Color3): ShaderMaterial;
  19701. /**
  19702. * Set a vec3 array in the shader from a Color3 array.
  19703. * @param name Define the name of the uniform as defined in the shader
  19704. * @param value Define the value to give to the uniform
  19705. * @return the material itself allowing "fluent" like uniform updates
  19706. */
  19707. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19708. /**
  19709. * Set a vec4 in the shader from a Color4.
  19710. * @param name Define the name of the uniform as defined in the shader
  19711. * @param value Define the value to give to the uniform
  19712. * @return the material itself allowing "fluent" like uniform updates
  19713. */
  19714. setColor4(name: string, value: Color4): ShaderMaterial;
  19715. /**
  19716. * Set a vec4 array in the shader from a Color4 array.
  19717. * @param name Define the name of the uniform as defined in the shader
  19718. * @param value Define the value to give to the uniform
  19719. * @return the material itself allowing "fluent" like uniform updates
  19720. */
  19721. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19722. /**
  19723. * Set a vec2 in the shader from a Vector2.
  19724. * @param name Define the name of the uniform as defined in the shader
  19725. * @param value Define the value to give to the uniform
  19726. * @return the material itself allowing "fluent" like uniform updates
  19727. */
  19728. setVector2(name: string, value: Vector2): ShaderMaterial;
  19729. /**
  19730. * Set a vec3 in the shader from a Vector3.
  19731. * @param name Define the name of the uniform as defined in the shader
  19732. * @param value Define the value to give to the uniform
  19733. * @return the material itself allowing "fluent" like uniform updates
  19734. */
  19735. setVector3(name: string, value: Vector3): ShaderMaterial;
  19736. /**
  19737. * Set a vec4 in the shader from a Vector4.
  19738. * @param name Define the name of the uniform as defined in the shader
  19739. * @param value Define the value to give to the uniform
  19740. * @return the material itself allowing "fluent" like uniform updates
  19741. */
  19742. setVector4(name: string, value: Vector4): ShaderMaterial;
  19743. /**
  19744. * Set a mat4 in the shader from a Matrix.
  19745. * @param name Define the name of the uniform as defined in the shader
  19746. * @param value Define the value to give to the uniform
  19747. * @return the material itself allowing "fluent" like uniform updates
  19748. */
  19749. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19750. /**
  19751. * Set a mat3 in the shader from a Float32Array.
  19752. * @param name Define the name of the uniform as defined in the shader
  19753. * @param value Define the value to give to the uniform
  19754. * @return the material itself allowing "fluent" like uniform updates
  19755. */
  19756. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19757. /**
  19758. * Set a mat2 in the shader from a Float32Array.
  19759. * @param name Define the name of the uniform as defined in the shader
  19760. * @param value Define the value to give to the uniform
  19761. * @return the material itself allowing "fluent" like uniform updates
  19762. */
  19763. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19764. /**
  19765. * Set a vec2 array in the shader from a number array.
  19766. * @param name Define the name of the uniform as defined in the shader
  19767. * @param value Define the value to give to the uniform
  19768. * @return the material itself allowing "fluent" like uniform updates
  19769. */
  19770. setArray2(name: string, value: number[]): ShaderMaterial;
  19771. /**
  19772. * Set a vec3 array in the shader from a number array.
  19773. * @param name Define the name of the uniform as defined in the shader
  19774. * @param value Define the value to give to the uniform
  19775. * @return the material itself allowing "fluent" like uniform updates
  19776. */
  19777. setArray3(name: string, value: number[]): ShaderMaterial;
  19778. /**
  19779. * Set a vec4 array in the shader from a number array.
  19780. * @param name Define the name of the uniform as defined in the shader
  19781. * @param value Define the value to give to the uniform
  19782. * @return the material itself allowing "fluent" like uniform updates
  19783. */
  19784. setArray4(name: string, value: number[]): ShaderMaterial;
  19785. private _checkCache;
  19786. /**
  19787. * Specifies that the submesh is ready to be used
  19788. * @param mesh defines the mesh to check
  19789. * @param subMesh defines which submesh to check
  19790. * @param useInstances specifies that instances should be used
  19791. * @returns a boolean indicating that the submesh is ready or not
  19792. */
  19793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19794. /**
  19795. * Checks if the material is ready to render the requested mesh
  19796. * @param mesh Define the mesh to render
  19797. * @param useInstances Define whether or not the material is used with instances
  19798. * @returns true if ready, otherwise false
  19799. */
  19800. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19801. /**
  19802. * Binds the world matrix to the material
  19803. * @param world defines the world transformation matrix
  19804. */
  19805. bindOnlyWorldMatrix(world: Matrix): void;
  19806. /**
  19807. * Binds the material to the mesh
  19808. * @param world defines the world transformation matrix
  19809. * @param mesh defines the mesh to bind the material to
  19810. */
  19811. bind(world: Matrix, mesh?: Mesh): void;
  19812. /**
  19813. * Gets the active textures from the material
  19814. * @returns an array of textures
  19815. */
  19816. getActiveTextures(): BaseTexture[];
  19817. /**
  19818. * Specifies if the material uses a texture
  19819. * @param texture defines the texture to check against the material
  19820. * @returns a boolean specifying if the material uses the texture
  19821. */
  19822. hasTexture(texture: BaseTexture): boolean;
  19823. /**
  19824. * Makes a duplicate of the material, and gives it a new name
  19825. * @param name defines the new name for the duplicated material
  19826. * @returns the cloned material
  19827. */
  19828. clone(name: string): ShaderMaterial;
  19829. /**
  19830. * Disposes the material
  19831. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19832. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19833. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19834. */
  19835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19836. /**
  19837. * Serializes this material in a JSON representation
  19838. * @returns the serialized material object
  19839. */
  19840. serialize(): any;
  19841. /**
  19842. * Creates a shader material from parsed shader material data
  19843. * @param source defines the JSON represnetation of the material
  19844. * @param scene defines the hosting scene
  19845. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19846. * @returns a new material
  19847. */
  19848. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19849. }
  19850. }
  19851. declare module "babylonjs/Shaders/color.fragment" {
  19852. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19853. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19854. /** @hidden */
  19855. export var colorPixelShader: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module "babylonjs/Shaders/color.vertex" {
  19861. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19862. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19863. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19864. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19865. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19866. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19867. /** @hidden */
  19868. export var colorVertexShader: {
  19869. name: string;
  19870. shader: string;
  19871. };
  19872. }
  19873. declare module "babylonjs/Meshes/linesMesh" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Scene } from "babylonjs/scene";
  19876. import { Color3 } from "babylonjs/Maths/math.color";
  19877. import { Node } from "babylonjs/node";
  19878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19879. import { Mesh } from "babylonjs/Meshes/mesh";
  19880. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19881. import { Effect } from "babylonjs/Materials/effect";
  19882. import { Material } from "babylonjs/Materials/material";
  19883. import "babylonjs/Shaders/color.fragment";
  19884. import "babylonjs/Shaders/color.vertex";
  19885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19886. /**
  19887. * Line mesh
  19888. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19889. */
  19890. export class LinesMesh extends Mesh {
  19891. /**
  19892. * If vertex color should be applied to the mesh
  19893. */
  19894. readonly useVertexColor?: boolean | undefined;
  19895. /**
  19896. * If vertex alpha should be applied to the mesh
  19897. */
  19898. readonly useVertexAlpha?: boolean | undefined;
  19899. /**
  19900. * Color of the line (Default: White)
  19901. */
  19902. color: Color3;
  19903. /**
  19904. * Alpha of the line (Default: 1)
  19905. */
  19906. alpha: number;
  19907. /**
  19908. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19909. * This margin is expressed in world space coordinates, so its value may vary.
  19910. * Default value is 0.1
  19911. */
  19912. intersectionThreshold: number;
  19913. private _colorShader;
  19914. private color4;
  19915. /**
  19916. * Creates a new LinesMesh
  19917. * @param name defines the name
  19918. * @param scene defines the hosting scene
  19919. * @param parent defines the parent mesh if any
  19920. * @param source defines the optional source LinesMesh used to clone data from
  19921. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19922. * When false, achieved by calling a clone(), also passing False.
  19923. * This will make creation of children, recursive.
  19924. * @param useVertexColor defines if this LinesMesh supports vertex color
  19925. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19926. */
  19927. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19928. /**
  19929. * If vertex color should be applied to the mesh
  19930. */
  19931. useVertexColor?: boolean | undefined,
  19932. /**
  19933. * If vertex alpha should be applied to the mesh
  19934. */
  19935. useVertexAlpha?: boolean | undefined);
  19936. private _addClipPlaneDefine;
  19937. private _removeClipPlaneDefine;
  19938. isReady(): boolean;
  19939. /**
  19940. * Returns the string "LineMesh"
  19941. */
  19942. getClassName(): string;
  19943. /**
  19944. * @hidden
  19945. */
  19946. /**
  19947. * @hidden
  19948. */
  19949. material: Material;
  19950. /**
  19951. * @hidden
  19952. */
  19953. readonly checkCollisions: boolean;
  19954. /** @hidden */
  19955. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19956. /** @hidden */
  19957. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19958. /**
  19959. * Disposes of the line mesh
  19960. * @param doNotRecurse If children should be disposed
  19961. */
  19962. dispose(doNotRecurse?: boolean): void;
  19963. /**
  19964. * Returns a new LineMesh object cloned from the current one.
  19965. */
  19966. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19967. /**
  19968. * Creates a new InstancedLinesMesh object from the mesh model.
  19969. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19970. * @param name defines the name of the new instance
  19971. * @returns a new InstancedLinesMesh
  19972. */
  19973. createInstance(name: string): InstancedLinesMesh;
  19974. }
  19975. /**
  19976. * Creates an instance based on a source LinesMesh
  19977. */
  19978. export class InstancedLinesMesh extends InstancedMesh {
  19979. /**
  19980. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19981. * This margin is expressed in world space coordinates, so its value may vary.
  19982. * Initilized with the intersectionThreshold value of the source LinesMesh
  19983. */
  19984. intersectionThreshold: number;
  19985. constructor(name: string, source: LinesMesh);
  19986. /**
  19987. * Returns the string "InstancedLinesMesh".
  19988. */
  19989. getClassName(): string;
  19990. }
  19991. }
  19992. declare module "babylonjs/Shaders/line.fragment" {
  19993. /** @hidden */
  19994. export var linePixelShader: {
  19995. name: string;
  19996. shader: string;
  19997. };
  19998. }
  19999. declare module "babylonjs/Shaders/line.vertex" {
  20000. /** @hidden */
  20001. export var lineVertexShader: {
  20002. name: string;
  20003. shader: string;
  20004. };
  20005. }
  20006. declare module "babylonjs/Rendering/edgesRenderer" {
  20007. import { Nullable } from "babylonjs/types";
  20008. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20010. import { Vector3 } from "babylonjs/Maths/math.vector";
  20011. import { IDisposable } from "babylonjs/scene";
  20012. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20013. import "babylonjs/Shaders/line.fragment";
  20014. import "babylonjs/Shaders/line.vertex";
  20015. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20016. module "babylonjs/Meshes/abstractMesh" {
  20017. interface AbstractMesh {
  20018. /**
  20019. * Gets the edgesRenderer associated with the mesh
  20020. */
  20021. edgesRenderer: Nullable<EdgesRenderer>;
  20022. }
  20023. }
  20024. module "babylonjs/Meshes/linesMesh" {
  20025. interface LinesMesh {
  20026. /**
  20027. * Enables the edge rendering mode on the mesh.
  20028. * This mode makes the mesh edges visible
  20029. * @param epsilon defines the maximal distance between two angles to detect a face
  20030. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20031. * @returns the currentAbstractMesh
  20032. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20033. */
  20034. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20035. }
  20036. }
  20037. module "babylonjs/Meshes/linesMesh" {
  20038. interface InstancedLinesMesh {
  20039. /**
  20040. * Enables the edge rendering mode on the mesh.
  20041. * This mode makes the mesh edges visible
  20042. * @param epsilon defines the maximal distance between two angles to detect a face
  20043. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20044. * @returns the current InstancedLinesMesh
  20045. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20046. */
  20047. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20048. }
  20049. }
  20050. /**
  20051. * Defines the minimum contract an Edges renderer should follow.
  20052. */
  20053. export interface IEdgesRenderer extends IDisposable {
  20054. /**
  20055. * Gets or sets a boolean indicating if the edgesRenderer is active
  20056. */
  20057. isEnabled: boolean;
  20058. /**
  20059. * Renders the edges of the attached mesh,
  20060. */
  20061. render(): void;
  20062. /**
  20063. * Checks wether or not the edges renderer is ready to render.
  20064. * @return true if ready, otherwise false.
  20065. */
  20066. isReady(): boolean;
  20067. }
  20068. /**
  20069. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20070. */
  20071. export class EdgesRenderer implements IEdgesRenderer {
  20072. /**
  20073. * Define the size of the edges with an orthographic camera
  20074. */
  20075. edgesWidthScalerForOrthographic: number;
  20076. /**
  20077. * Define the size of the edges with a perspective camera
  20078. */
  20079. edgesWidthScalerForPerspective: number;
  20080. protected _source: AbstractMesh;
  20081. protected _linesPositions: number[];
  20082. protected _linesNormals: number[];
  20083. protected _linesIndices: number[];
  20084. protected _epsilon: number;
  20085. protected _indicesCount: number;
  20086. protected _lineShader: ShaderMaterial;
  20087. protected _ib: DataBuffer;
  20088. protected _buffers: {
  20089. [key: string]: Nullable<VertexBuffer>;
  20090. };
  20091. protected _checkVerticesInsteadOfIndices: boolean;
  20092. private _meshRebuildObserver;
  20093. private _meshDisposeObserver;
  20094. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20095. isEnabled: boolean;
  20096. /**
  20097. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20098. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20099. * @param source Mesh used to create edges
  20100. * @param epsilon sum of angles in adjacency to check for edge
  20101. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20102. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20103. */
  20104. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20105. protected _prepareRessources(): void;
  20106. /** @hidden */
  20107. _rebuild(): void;
  20108. /**
  20109. * Releases the required resources for the edges renderer
  20110. */
  20111. dispose(): void;
  20112. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20113. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20114. /**
  20115. * Checks if the pair of p0 and p1 is en edge
  20116. * @param faceIndex
  20117. * @param edge
  20118. * @param faceNormals
  20119. * @param p0
  20120. * @param p1
  20121. * @private
  20122. */
  20123. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20124. /**
  20125. * push line into the position, normal and index buffer
  20126. * @protected
  20127. */
  20128. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20129. /**
  20130. * Generates lines edges from adjacencjes
  20131. * @private
  20132. */
  20133. _generateEdgesLines(): void;
  20134. /**
  20135. * Checks wether or not the edges renderer is ready to render.
  20136. * @return true if ready, otherwise false.
  20137. */
  20138. isReady(): boolean;
  20139. /**
  20140. * Renders the edges of the attached mesh,
  20141. */
  20142. render(): void;
  20143. }
  20144. /**
  20145. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20146. */
  20147. export class LineEdgesRenderer extends EdgesRenderer {
  20148. /**
  20149. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20150. * @param source LineMesh used to generate edges
  20151. * @param epsilon not important (specified angle for edge detection)
  20152. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20153. */
  20154. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20155. /**
  20156. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20157. */
  20158. _generateEdgesLines(): void;
  20159. }
  20160. }
  20161. declare module "babylonjs/Rendering/renderingGroup" {
  20162. import { SmartArray } from "babylonjs/Misc/smartArray";
  20163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20165. import { Nullable } from "babylonjs/types";
  20166. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20167. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20168. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20169. import { Material } from "babylonjs/Materials/material";
  20170. import { Scene } from "babylonjs/scene";
  20171. /**
  20172. * This represents the object necessary to create a rendering group.
  20173. * This is exclusively used and created by the rendering manager.
  20174. * To modify the behavior, you use the available helpers in your scene or meshes.
  20175. * @hidden
  20176. */
  20177. export class RenderingGroup {
  20178. index: number;
  20179. private static _zeroVector;
  20180. private _scene;
  20181. private _opaqueSubMeshes;
  20182. private _transparentSubMeshes;
  20183. private _alphaTestSubMeshes;
  20184. private _depthOnlySubMeshes;
  20185. private _particleSystems;
  20186. private _spriteManagers;
  20187. private _opaqueSortCompareFn;
  20188. private _alphaTestSortCompareFn;
  20189. private _transparentSortCompareFn;
  20190. private _renderOpaque;
  20191. private _renderAlphaTest;
  20192. private _renderTransparent;
  20193. /** @hidden */
  20194. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20195. onBeforeTransparentRendering: () => void;
  20196. /**
  20197. * Set the opaque sort comparison function.
  20198. * If null the sub meshes will be render in the order they were created
  20199. */
  20200. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20201. /**
  20202. * Set the alpha test sort comparison function.
  20203. * If null the sub meshes will be render in the order they were created
  20204. */
  20205. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20206. /**
  20207. * Set the transparent sort comparison function.
  20208. * If null the sub meshes will be render in the order they were created
  20209. */
  20210. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20211. /**
  20212. * Creates a new rendering group.
  20213. * @param index The rendering group index
  20214. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20215. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20216. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20217. */
  20218. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20219. /**
  20220. * Render all the sub meshes contained in the group.
  20221. * @param customRenderFunction Used to override the default render behaviour of the group.
  20222. * @returns true if rendered some submeshes.
  20223. */
  20224. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20225. /**
  20226. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20227. * @param subMeshes The submeshes to render
  20228. */
  20229. private renderOpaqueSorted;
  20230. /**
  20231. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20232. * @param subMeshes The submeshes to render
  20233. */
  20234. private renderAlphaTestSorted;
  20235. /**
  20236. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20237. * @param subMeshes The submeshes to render
  20238. */
  20239. private renderTransparentSorted;
  20240. /**
  20241. * Renders the submeshes in a specified order.
  20242. * @param subMeshes The submeshes to sort before render
  20243. * @param sortCompareFn The comparison function use to sort
  20244. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20245. * @param transparent Specifies to activate blending if true
  20246. */
  20247. private static renderSorted;
  20248. /**
  20249. * Renders the submeshes in the order they were dispatched (no sort applied).
  20250. * @param subMeshes The submeshes to render
  20251. */
  20252. private static renderUnsorted;
  20253. /**
  20254. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20255. * are rendered back to front if in the same alpha index.
  20256. *
  20257. * @param a The first submesh
  20258. * @param b The second submesh
  20259. * @returns The result of the comparison
  20260. */
  20261. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20262. /**
  20263. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20264. * are rendered back to front.
  20265. *
  20266. * @param a The first submesh
  20267. * @param b The second submesh
  20268. * @returns The result of the comparison
  20269. */
  20270. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20271. /**
  20272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20273. * are rendered front to back (prevent overdraw).
  20274. *
  20275. * @param a The first submesh
  20276. * @param b The second submesh
  20277. * @returns The result of the comparison
  20278. */
  20279. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20280. /**
  20281. * Resets the different lists of submeshes to prepare a new frame.
  20282. */
  20283. prepare(): void;
  20284. dispose(): void;
  20285. /**
  20286. * Inserts the submesh in its correct queue depending on its material.
  20287. * @param subMesh The submesh to dispatch
  20288. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20289. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20290. */
  20291. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20292. dispatchSprites(spriteManager: ISpriteManager): void;
  20293. dispatchParticles(particleSystem: IParticleSystem): void;
  20294. private _renderParticles;
  20295. private _renderSprites;
  20296. }
  20297. }
  20298. declare module "babylonjs/Rendering/renderingManager" {
  20299. import { Nullable } from "babylonjs/types";
  20300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20301. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20302. import { SmartArray } from "babylonjs/Misc/smartArray";
  20303. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20305. import { Material } from "babylonjs/Materials/material";
  20306. import { Scene } from "babylonjs/scene";
  20307. import { Camera } from "babylonjs/Cameras/camera";
  20308. /**
  20309. * Interface describing the different options available in the rendering manager
  20310. * regarding Auto Clear between groups.
  20311. */
  20312. export interface IRenderingManagerAutoClearSetup {
  20313. /**
  20314. * Defines whether or not autoclear is enable.
  20315. */
  20316. autoClear: boolean;
  20317. /**
  20318. * Defines whether or not to autoclear the depth buffer.
  20319. */
  20320. depth: boolean;
  20321. /**
  20322. * Defines whether or not to autoclear the stencil buffer.
  20323. */
  20324. stencil: boolean;
  20325. }
  20326. /**
  20327. * This class is used by the onRenderingGroupObservable
  20328. */
  20329. export class RenderingGroupInfo {
  20330. /**
  20331. * The Scene that being rendered
  20332. */
  20333. scene: Scene;
  20334. /**
  20335. * The camera currently used for the rendering pass
  20336. */
  20337. camera: Nullable<Camera>;
  20338. /**
  20339. * The ID of the renderingGroup being processed
  20340. */
  20341. renderingGroupId: number;
  20342. }
  20343. /**
  20344. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20345. * It is enable to manage the different groups as well as the different necessary sort functions.
  20346. * This should not be used directly aside of the few static configurations
  20347. */
  20348. export class RenderingManager {
  20349. /**
  20350. * The max id used for rendering groups (not included)
  20351. */
  20352. static MAX_RENDERINGGROUPS: number;
  20353. /**
  20354. * The min id used for rendering groups (included)
  20355. */
  20356. static MIN_RENDERINGGROUPS: number;
  20357. /**
  20358. * Used to globally prevent autoclearing scenes.
  20359. */
  20360. static AUTOCLEAR: boolean;
  20361. /**
  20362. * @hidden
  20363. */
  20364. _useSceneAutoClearSetup: boolean;
  20365. private _scene;
  20366. private _renderingGroups;
  20367. private _depthStencilBufferAlreadyCleaned;
  20368. private _autoClearDepthStencil;
  20369. private _customOpaqueSortCompareFn;
  20370. private _customAlphaTestSortCompareFn;
  20371. private _customTransparentSortCompareFn;
  20372. private _renderingGroupInfo;
  20373. /**
  20374. * Instantiates a new rendering group for a particular scene
  20375. * @param scene Defines the scene the groups belongs to
  20376. */
  20377. constructor(scene: Scene);
  20378. private _clearDepthStencilBuffer;
  20379. /**
  20380. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20381. * @hidden
  20382. */
  20383. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20384. /**
  20385. * Resets the different information of the group to prepare a new frame
  20386. * @hidden
  20387. */
  20388. reset(): void;
  20389. /**
  20390. * Dispose and release the group and its associated resources.
  20391. * @hidden
  20392. */
  20393. dispose(): void;
  20394. /**
  20395. * Clear the info related to rendering groups preventing retention points during dispose.
  20396. */
  20397. freeRenderingGroups(): void;
  20398. private _prepareRenderingGroup;
  20399. /**
  20400. * Add a sprite manager to the rendering manager in order to render it this frame.
  20401. * @param spriteManager Define the sprite manager to render
  20402. */
  20403. dispatchSprites(spriteManager: ISpriteManager): void;
  20404. /**
  20405. * Add a particle system to the rendering manager in order to render it this frame.
  20406. * @param particleSystem Define the particle system to render
  20407. */
  20408. dispatchParticles(particleSystem: IParticleSystem): void;
  20409. /**
  20410. * Add a submesh to the manager in order to render it this frame
  20411. * @param subMesh The submesh to dispatch
  20412. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20413. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20414. */
  20415. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20416. /**
  20417. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20418. * This allowed control for front to back rendering or reversly depending of the special needs.
  20419. *
  20420. * @param renderingGroupId The rendering group id corresponding to its index
  20421. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20422. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20423. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20424. */
  20425. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20426. /**
  20427. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20428. *
  20429. * @param renderingGroupId The rendering group id corresponding to its index
  20430. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20431. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20432. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20433. */
  20434. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20435. /**
  20436. * Gets the current auto clear configuration for one rendering group of the rendering
  20437. * manager.
  20438. * @param index the rendering group index to get the information for
  20439. * @returns The auto clear setup for the requested rendering group
  20440. */
  20441. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20442. }
  20443. }
  20444. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20445. import { Observable } from "babylonjs/Misc/observable";
  20446. import { SmartArray } from "babylonjs/Misc/smartArray";
  20447. import { Nullable } from "babylonjs/types";
  20448. import { Camera } from "babylonjs/Cameras/camera";
  20449. import { Scene } from "babylonjs/scene";
  20450. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20451. import { Color4 } from "babylonjs/Maths/math.color";
  20452. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20454. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20456. import { Texture } from "babylonjs/Materials/Textures/texture";
  20457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20458. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20459. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20460. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20461. import { Engine } from "babylonjs/Engines/engine";
  20462. /**
  20463. * This Helps creating a texture that will be created from a camera in your scene.
  20464. * It is basically a dynamic texture that could be used to create special effects for instance.
  20465. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20466. */
  20467. export class RenderTargetTexture extends Texture {
  20468. isCube: boolean;
  20469. /**
  20470. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20471. */
  20472. static readonly REFRESHRATE_RENDER_ONCE: number;
  20473. /**
  20474. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20475. */
  20476. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20477. /**
  20478. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20479. * the central point of your effect and can save a lot of performances.
  20480. */
  20481. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20482. /**
  20483. * Use this predicate to dynamically define the list of mesh you want to render.
  20484. * If set, the renderList property will be overwritten.
  20485. */
  20486. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20487. private _renderList;
  20488. /**
  20489. * Use this list to define the list of mesh you want to render.
  20490. */
  20491. renderList: Nullable<Array<AbstractMesh>>;
  20492. private _hookArray;
  20493. /**
  20494. * Define if particles should be rendered in your texture.
  20495. */
  20496. renderParticles: boolean;
  20497. /**
  20498. * Define if sprites should be rendered in your texture.
  20499. */
  20500. renderSprites: boolean;
  20501. /**
  20502. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20503. */
  20504. coordinatesMode: number;
  20505. /**
  20506. * Define the camera used to render the texture.
  20507. */
  20508. activeCamera: Nullable<Camera>;
  20509. /**
  20510. * Override the render function of the texture with your own one.
  20511. */
  20512. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20513. /**
  20514. * Define if camera post processes should be use while rendering the texture.
  20515. */
  20516. useCameraPostProcesses: boolean;
  20517. /**
  20518. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20519. */
  20520. ignoreCameraViewport: boolean;
  20521. private _postProcessManager;
  20522. private _postProcesses;
  20523. private _resizeObserver;
  20524. /**
  20525. * An event triggered when the texture is unbind.
  20526. */
  20527. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20528. /**
  20529. * An event triggered when the texture is unbind.
  20530. */
  20531. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20532. private _onAfterUnbindObserver;
  20533. /**
  20534. * Set a after unbind callback in the texture.
  20535. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20536. */
  20537. onAfterUnbind: () => void;
  20538. /**
  20539. * An event triggered before rendering the texture
  20540. */
  20541. onBeforeRenderObservable: Observable<number>;
  20542. private _onBeforeRenderObserver;
  20543. /**
  20544. * Set a before render callback in the texture.
  20545. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20546. */
  20547. onBeforeRender: (faceIndex: number) => void;
  20548. /**
  20549. * An event triggered after rendering the texture
  20550. */
  20551. onAfterRenderObservable: Observable<number>;
  20552. private _onAfterRenderObserver;
  20553. /**
  20554. * Set a after render callback in the texture.
  20555. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20556. */
  20557. onAfterRender: (faceIndex: number) => void;
  20558. /**
  20559. * An event triggered after the texture clear
  20560. */
  20561. onClearObservable: Observable<Engine>;
  20562. private _onClearObserver;
  20563. /**
  20564. * Set a clear callback in the texture.
  20565. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20566. */
  20567. onClear: (Engine: Engine) => void;
  20568. /**
  20569. * An event triggered when the texture is resized.
  20570. */
  20571. onResizeObservable: Observable<RenderTargetTexture>;
  20572. /**
  20573. * Define the clear color of the Render Target if it should be different from the scene.
  20574. */
  20575. clearColor: Color4;
  20576. protected _size: number | {
  20577. width: number;
  20578. height: number;
  20579. };
  20580. protected _initialSizeParameter: number | {
  20581. width: number;
  20582. height: number;
  20583. } | {
  20584. ratio: number;
  20585. };
  20586. protected _sizeRatio: Nullable<number>;
  20587. /** @hidden */
  20588. _generateMipMaps: boolean;
  20589. protected _renderingManager: RenderingManager;
  20590. /** @hidden */
  20591. _waitingRenderList: string[];
  20592. protected _doNotChangeAspectRatio: boolean;
  20593. protected _currentRefreshId: number;
  20594. protected _refreshRate: number;
  20595. protected _textureMatrix: Matrix;
  20596. protected _samples: number;
  20597. protected _renderTargetOptions: RenderTargetCreationOptions;
  20598. /**
  20599. * Gets render target creation options that were used.
  20600. */
  20601. readonly renderTargetOptions: RenderTargetCreationOptions;
  20602. protected _engine: Engine;
  20603. protected _onRatioRescale(): void;
  20604. /**
  20605. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20606. * It must define where the camera used to render the texture is set
  20607. */
  20608. boundingBoxPosition: Vector3;
  20609. private _boundingBoxSize;
  20610. /**
  20611. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20612. * When defined, the cubemap will switch to local mode
  20613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20614. * @example https://www.babylonjs-playground.com/#RNASML
  20615. */
  20616. boundingBoxSize: Vector3;
  20617. /**
  20618. * In case the RTT has been created with a depth texture, get the associated
  20619. * depth texture.
  20620. * Otherwise, return null.
  20621. */
  20622. depthStencilTexture: Nullable<InternalTexture>;
  20623. /**
  20624. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20625. * or used a shadow, depth texture...
  20626. * @param name The friendly name of the texture
  20627. * @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)
  20628. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20629. * @param generateMipMaps True if mip maps need to be generated after render.
  20630. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20631. * @param type The type of the buffer in the RTT (int, half float, float...)
  20632. * @param isCube True if a cube texture needs to be created
  20633. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20634. * @param generateDepthBuffer True to generate a depth buffer
  20635. * @param generateStencilBuffer True to generate a stencil buffer
  20636. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20637. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20638. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20639. */
  20640. constructor(name: string, size: number | {
  20641. width: number;
  20642. height: number;
  20643. } | {
  20644. ratio: number;
  20645. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20646. /**
  20647. * Creates a depth stencil texture.
  20648. * This is only available in WebGL 2 or with the depth texture extension available.
  20649. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20650. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20651. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20652. */
  20653. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20654. private _processSizeParameter;
  20655. /**
  20656. * Define the number of samples to use in case of MSAA.
  20657. * It defaults to one meaning no MSAA has been enabled.
  20658. */
  20659. samples: number;
  20660. /**
  20661. * Resets the refresh counter of the texture and start bak from scratch.
  20662. * Could be useful to regenerate the texture if it is setup to render only once.
  20663. */
  20664. resetRefreshCounter(): void;
  20665. /**
  20666. * Define the refresh rate of the texture or the rendering frequency.
  20667. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20668. */
  20669. refreshRate: number;
  20670. /**
  20671. * Adds a post process to the render target rendering passes.
  20672. * @param postProcess define the post process to add
  20673. */
  20674. addPostProcess(postProcess: PostProcess): void;
  20675. /**
  20676. * Clear all the post processes attached to the render target
  20677. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20678. */
  20679. clearPostProcesses(dispose?: boolean): void;
  20680. /**
  20681. * Remove one of the post process from the list of attached post processes to the texture
  20682. * @param postProcess define the post process to remove from the list
  20683. */
  20684. removePostProcess(postProcess: PostProcess): void;
  20685. /** @hidden */
  20686. _shouldRender(): boolean;
  20687. /**
  20688. * Gets the actual render size of the texture.
  20689. * @returns the width of the render size
  20690. */
  20691. getRenderSize(): number;
  20692. /**
  20693. * Gets the actual render width of the texture.
  20694. * @returns the width of the render size
  20695. */
  20696. getRenderWidth(): number;
  20697. /**
  20698. * Gets the actual render height of the texture.
  20699. * @returns the height of the render size
  20700. */
  20701. getRenderHeight(): number;
  20702. /**
  20703. * Get if the texture can be rescaled or not.
  20704. */
  20705. readonly canRescale: boolean;
  20706. /**
  20707. * Resize the texture using a ratio.
  20708. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20709. */
  20710. scale(ratio: number): void;
  20711. /**
  20712. * Get the texture reflection matrix used to rotate/transform the reflection.
  20713. * @returns the reflection matrix
  20714. */
  20715. getReflectionTextureMatrix(): Matrix;
  20716. /**
  20717. * Resize the texture to a new desired size.
  20718. * Be carrefull as it will recreate all the data in the new texture.
  20719. * @param size Define the new size. It can be:
  20720. * - a number for squared texture,
  20721. * - an object containing { width: number, height: number }
  20722. * - or an object containing a ratio { ratio: number }
  20723. */
  20724. resize(size: number | {
  20725. width: number;
  20726. height: number;
  20727. } | {
  20728. ratio: number;
  20729. }): void;
  20730. /**
  20731. * Renders all the objects from the render list into the texture.
  20732. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20733. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20734. */
  20735. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20736. private _bestReflectionRenderTargetDimension;
  20737. /**
  20738. * @hidden
  20739. * @param faceIndex face index to bind to if this is a cubetexture
  20740. */
  20741. _bindFrameBuffer(faceIndex?: number): void;
  20742. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20743. private renderToTarget;
  20744. /**
  20745. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20746. * This allowed control for front to back rendering or reversly depending of the special needs.
  20747. *
  20748. * @param renderingGroupId The rendering group id corresponding to its index
  20749. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20750. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20751. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20752. */
  20753. 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;
  20754. /**
  20755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20756. *
  20757. * @param renderingGroupId The rendering group id corresponding to its index
  20758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20759. */
  20760. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20761. /**
  20762. * Clones the texture.
  20763. * @returns the cloned texture
  20764. */
  20765. clone(): RenderTargetTexture;
  20766. /**
  20767. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20768. * @returns The JSON representation of the texture
  20769. */
  20770. serialize(): any;
  20771. /**
  20772. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20773. */
  20774. disposeFramebufferObjects(): void;
  20775. /**
  20776. * Dispose the texture and release its associated resources.
  20777. */
  20778. dispose(): void;
  20779. /** @hidden */
  20780. _rebuild(): void;
  20781. /**
  20782. * Clear the info related to rendering groups preventing retention point in material dispose.
  20783. */
  20784. freeRenderingGroups(): void;
  20785. /**
  20786. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20787. * @returns the view count
  20788. */
  20789. getViewCount(): number;
  20790. }
  20791. }
  20792. declare module "babylonjs/Materials/material" {
  20793. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20794. import { SmartArray } from "babylonjs/Misc/smartArray";
  20795. import { Observable } from "babylonjs/Misc/observable";
  20796. import { Nullable } from "babylonjs/types";
  20797. import { Scene } from "babylonjs/scene";
  20798. import { Matrix } from "babylonjs/Maths/math.vector";
  20799. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20801. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20802. import { Effect } from "babylonjs/Materials/effect";
  20803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20805. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20806. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20807. import { Mesh } from "babylonjs/Meshes/mesh";
  20808. import { Animation } from "babylonjs/Animations/animation";
  20809. /**
  20810. * Options for compiling materials.
  20811. */
  20812. export interface IMaterialCompilationOptions {
  20813. /**
  20814. * Defines whether clip planes are enabled.
  20815. */
  20816. clipPlane: boolean;
  20817. /**
  20818. * Defines whether instances are enabled.
  20819. */
  20820. useInstances: boolean;
  20821. }
  20822. /**
  20823. * Base class for the main features of a material in Babylon.js
  20824. */
  20825. export class Material implements IAnimatable {
  20826. /**
  20827. * Returns the triangle fill mode
  20828. */
  20829. static readonly TriangleFillMode: number;
  20830. /**
  20831. * Returns the wireframe mode
  20832. */
  20833. static readonly WireFrameFillMode: number;
  20834. /**
  20835. * Returns the point fill mode
  20836. */
  20837. static readonly PointFillMode: number;
  20838. /**
  20839. * Returns the point list draw mode
  20840. */
  20841. static readonly PointListDrawMode: number;
  20842. /**
  20843. * Returns the line list draw mode
  20844. */
  20845. static readonly LineListDrawMode: number;
  20846. /**
  20847. * Returns the line loop draw mode
  20848. */
  20849. static readonly LineLoopDrawMode: number;
  20850. /**
  20851. * Returns the line strip draw mode
  20852. */
  20853. static readonly LineStripDrawMode: number;
  20854. /**
  20855. * Returns the triangle strip draw mode
  20856. */
  20857. static readonly TriangleStripDrawMode: number;
  20858. /**
  20859. * Returns the triangle fan draw mode
  20860. */
  20861. static readonly TriangleFanDrawMode: number;
  20862. /**
  20863. * Stores the clock-wise side orientation
  20864. */
  20865. static readonly ClockWiseSideOrientation: number;
  20866. /**
  20867. * Stores the counter clock-wise side orientation
  20868. */
  20869. static readonly CounterClockWiseSideOrientation: number;
  20870. /**
  20871. * The dirty texture flag value
  20872. */
  20873. static readonly TextureDirtyFlag: number;
  20874. /**
  20875. * The dirty light flag value
  20876. */
  20877. static readonly LightDirtyFlag: number;
  20878. /**
  20879. * The dirty fresnel flag value
  20880. */
  20881. static readonly FresnelDirtyFlag: number;
  20882. /**
  20883. * The dirty attribute flag value
  20884. */
  20885. static readonly AttributesDirtyFlag: number;
  20886. /**
  20887. * The dirty misc flag value
  20888. */
  20889. static readonly MiscDirtyFlag: number;
  20890. /**
  20891. * The all dirty flag value
  20892. */
  20893. static readonly AllDirtyFlag: number;
  20894. /**
  20895. * The ID of the material
  20896. */
  20897. id: string;
  20898. /**
  20899. * Gets or sets the unique id of the material
  20900. */
  20901. uniqueId: number;
  20902. /**
  20903. * The name of the material
  20904. */
  20905. name: string;
  20906. /**
  20907. * Gets or sets user defined metadata
  20908. */
  20909. metadata: any;
  20910. /**
  20911. * For internal use only. Please do not use.
  20912. */
  20913. reservedDataStore: any;
  20914. /**
  20915. * Specifies if the ready state should be checked on each call
  20916. */
  20917. checkReadyOnEveryCall: boolean;
  20918. /**
  20919. * Specifies if the ready state should be checked once
  20920. */
  20921. checkReadyOnlyOnce: boolean;
  20922. /**
  20923. * The state of the material
  20924. */
  20925. state: string;
  20926. /**
  20927. * The alpha value of the material
  20928. */
  20929. protected _alpha: number;
  20930. /**
  20931. * List of inspectable custom properties (used by the Inspector)
  20932. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20933. */
  20934. inspectableCustomProperties: IInspectable[];
  20935. /**
  20936. * Sets the alpha value of the material
  20937. */
  20938. /**
  20939. * Gets the alpha value of the material
  20940. */
  20941. alpha: number;
  20942. /**
  20943. * Specifies if back face culling is enabled
  20944. */
  20945. protected _backFaceCulling: boolean;
  20946. /**
  20947. * Sets the back-face culling state
  20948. */
  20949. /**
  20950. * Gets the back-face culling state
  20951. */
  20952. backFaceCulling: boolean;
  20953. /**
  20954. * Stores the value for side orientation
  20955. */
  20956. sideOrientation: number;
  20957. /**
  20958. * Callback triggered when the material is compiled
  20959. */
  20960. onCompiled: Nullable<(effect: Effect) => void>;
  20961. /**
  20962. * Callback triggered when an error occurs
  20963. */
  20964. onError: Nullable<(effect: Effect, errors: string) => void>;
  20965. /**
  20966. * Callback triggered to get the render target textures
  20967. */
  20968. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20969. /**
  20970. * Gets a boolean indicating that current material needs to register RTT
  20971. */
  20972. readonly hasRenderTargetTextures: boolean;
  20973. /**
  20974. * Specifies if the material should be serialized
  20975. */
  20976. doNotSerialize: boolean;
  20977. /**
  20978. * @hidden
  20979. */
  20980. _storeEffectOnSubMeshes: boolean;
  20981. /**
  20982. * Stores the animations for the material
  20983. */
  20984. animations: Nullable<Array<Animation>>;
  20985. /**
  20986. * An event triggered when the material is disposed
  20987. */
  20988. onDisposeObservable: Observable<Material>;
  20989. /**
  20990. * An observer which watches for dispose events
  20991. */
  20992. private _onDisposeObserver;
  20993. private _onUnBindObservable;
  20994. /**
  20995. * Called during a dispose event
  20996. */
  20997. onDispose: () => void;
  20998. private _onBindObservable;
  20999. /**
  21000. * An event triggered when the material is bound
  21001. */
  21002. readonly onBindObservable: Observable<AbstractMesh>;
  21003. /**
  21004. * An observer which watches for bind events
  21005. */
  21006. private _onBindObserver;
  21007. /**
  21008. * Called during a bind event
  21009. */
  21010. onBind: (Mesh: AbstractMesh) => void;
  21011. /**
  21012. * An event triggered when the material is unbound
  21013. */
  21014. readonly onUnBindObservable: Observable<Material>;
  21015. /**
  21016. * Stores the value of the alpha mode
  21017. */
  21018. private _alphaMode;
  21019. /**
  21020. * Sets the value of the alpha mode.
  21021. *
  21022. * | Value | Type | Description |
  21023. * | --- | --- | --- |
  21024. * | 0 | ALPHA_DISABLE | |
  21025. * | 1 | ALPHA_ADD | |
  21026. * | 2 | ALPHA_COMBINE | |
  21027. * | 3 | ALPHA_SUBTRACT | |
  21028. * | 4 | ALPHA_MULTIPLY | |
  21029. * | 5 | ALPHA_MAXIMIZED | |
  21030. * | 6 | ALPHA_ONEONE | |
  21031. * | 7 | ALPHA_PREMULTIPLIED | |
  21032. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21033. * | 9 | ALPHA_INTERPOLATE | |
  21034. * | 10 | ALPHA_SCREENMODE | |
  21035. *
  21036. */
  21037. /**
  21038. * Gets the value of the alpha mode
  21039. */
  21040. alphaMode: number;
  21041. /**
  21042. * Stores the state of the need depth pre-pass value
  21043. */
  21044. private _needDepthPrePass;
  21045. /**
  21046. * Sets the need depth pre-pass value
  21047. */
  21048. /**
  21049. * Gets the depth pre-pass value
  21050. */
  21051. needDepthPrePass: boolean;
  21052. /**
  21053. * Specifies if depth writing should be disabled
  21054. */
  21055. disableDepthWrite: boolean;
  21056. /**
  21057. * Specifies if depth writing should be forced
  21058. */
  21059. forceDepthWrite: boolean;
  21060. /**
  21061. * Specifies if there should be a separate pass for culling
  21062. */
  21063. separateCullingPass: boolean;
  21064. /**
  21065. * Stores the state specifing if fog should be enabled
  21066. */
  21067. private _fogEnabled;
  21068. /**
  21069. * Sets the state for enabling fog
  21070. */
  21071. /**
  21072. * Gets the value of the fog enabled state
  21073. */
  21074. fogEnabled: boolean;
  21075. /**
  21076. * Stores the size of points
  21077. */
  21078. pointSize: number;
  21079. /**
  21080. * Stores the z offset value
  21081. */
  21082. zOffset: number;
  21083. /**
  21084. * Gets a value specifying if wireframe mode is enabled
  21085. */
  21086. /**
  21087. * Sets the state of wireframe mode
  21088. */
  21089. wireframe: boolean;
  21090. /**
  21091. * Gets the value specifying if point clouds are enabled
  21092. */
  21093. /**
  21094. * Sets the state of point cloud mode
  21095. */
  21096. pointsCloud: boolean;
  21097. /**
  21098. * Gets the material fill mode
  21099. */
  21100. /**
  21101. * Sets the material fill mode
  21102. */
  21103. fillMode: number;
  21104. /**
  21105. * @hidden
  21106. * Stores the effects for the material
  21107. */
  21108. _effect: Nullable<Effect>;
  21109. /**
  21110. * @hidden
  21111. * Specifies if the material was previously ready
  21112. */
  21113. _wasPreviouslyReady: boolean;
  21114. /**
  21115. * Specifies if uniform buffers should be used
  21116. */
  21117. private _useUBO;
  21118. /**
  21119. * Stores a reference to the scene
  21120. */
  21121. private _scene;
  21122. /**
  21123. * Stores the fill mode state
  21124. */
  21125. private _fillMode;
  21126. /**
  21127. * Specifies if the depth write state should be cached
  21128. */
  21129. private _cachedDepthWriteState;
  21130. /**
  21131. * Stores the uniform buffer
  21132. */
  21133. protected _uniformBuffer: UniformBuffer;
  21134. /** @hidden */
  21135. _indexInSceneMaterialArray: number;
  21136. /** @hidden */
  21137. meshMap: Nullable<{
  21138. [id: string]: AbstractMesh | undefined;
  21139. }>;
  21140. /**
  21141. * Creates a material instance
  21142. * @param name defines the name of the material
  21143. * @param scene defines the scene to reference
  21144. * @param doNotAdd specifies if the material should be added to the scene
  21145. */
  21146. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21147. /**
  21148. * Returns a string representation of the current material
  21149. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21150. * @returns a string with material information
  21151. */
  21152. toString(fullDetails?: boolean): string;
  21153. /**
  21154. * Gets the class name of the material
  21155. * @returns a string with the class name of the material
  21156. */
  21157. getClassName(): string;
  21158. /**
  21159. * Specifies if updates for the material been locked
  21160. */
  21161. readonly isFrozen: boolean;
  21162. /**
  21163. * Locks updates for the material
  21164. */
  21165. freeze(): void;
  21166. /**
  21167. * Unlocks updates for the material
  21168. */
  21169. unfreeze(): void;
  21170. /**
  21171. * Specifies if the material is ready to be used
  21172. * @param mesh defines the mesh to check
  21173. * @param useInstances specifies if instances should be used
  21174. * @returns a boolean indicating if the material is ready to be used
  21175. */
  21176. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21177. /**
  21178. * Specifies that the submesh is ready to be used
  21179. * @param mesh defines the mesh to check
  21180. * @param subMesh defines which submesh to check
  21181. * @param useInstances specifies that instances should be used
  21182. * @returns a boolean indicating that the submesh is ready or not
  21183. */
  21184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21185. /**
  21186. * Returns the material effect
  21187. * @returns the effect associated with the material
  21188. */
  21189. getEffect(): Nullable<Effect>;
  21190. /**
  21191. * Returns the current scene
  21192. * @returns a Scene
  21193. */
  21194. getScene(): Scene;
  21195. /**
  21196. * Specifies if the material will require alpha blending
  21197. * @returns a boolean specifying if alpha blending is needed
  21198. */
  21199. needAlphaBlending(): boolean;
  21200. /**
  21201. * Specifies if the mesh will require alpha blending
  21202. * @param mesh defines the mesh to check
  21203. * @returns a boolean specifying if alpha blending is needed for the mesh
  21204. */
  21205. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21206. /**
  21207. * Specifies if this material should be rendered in alpha test mode
  21208. * @returns a boolean specifying if an alpha test is needed.
  21209. */
  21210. needAlphaTesting(): boolean;
  21211. /**
  21212. * Gets the texture used for the alpha test
  21213. * @returns the texture to use for alpha testing
  21214. */
  21215. getAlphaTestTexture(): Nullable<BaseTexture>;
  21216. /**
  21217. * Marks the material to indicate that it needs to be re-calculated
  21218. */
  21219. markDirty(): void;
  21220. /** @hidden */
  21221. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21222. /**
  21223. * Binds the material to the mesh
  21224. * @param world defines the world transformation matrix
  21225. * @param mesh defines the mesh to bind the material to
  21226. */
  21227. bind(world: Matrix, mesh?: Mesh): void;
  21228. /**
  21229. * Binds the submesh to the material
  21230. * @param world defines the world transformation matrix
  21231. * @param mesh defines the mesh containing the submesh
  21232. * @param subMesh defines the submesh to bind the material to
  21233. */
  21234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21235. /**
  21236. * Binds the world matrix to the material
  21237. * @param world defines the world transformation matrix
  21238. */
  21239. bindOnlyWorldMatrix(world: Matrix): void;
  21240. /**
  21241. * Binds the scene's uniform buffer to the effect.
  21242. * @param effect defines the effect to bind to the scene uniform buffer
  21243. * @param sceneUbo defines the uniform buffer storing scene data
  21244. */
  21245. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21246. /**
  21247. * Binds the view matrix to the effect
  21248. * @param effect defines the effect to bind the view matrix to
  21249. */
  21250. bindView(effect: Effect): void;
  21251. /**
  21252. * Binds the view projection matrix to the effect
  21253. * @param effect defines the effect to bind the view projection matrix to
  21254. */
  21255. bindViewProjection(effect: Effect): void;
  21256. /**
  21257. * Specifies if material alpha testing should be turned on for the mesh
  21258. * @param mesh defines the mesh to check
  21259. */
  21260. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21261. /**
  21262. * Processes to execute after binding the material to a mesh
  21263. * @param mesh defines the rendered mesh
  21264. */
  21265. protected _afterBind(mesh?: Mesh): void;
  21266. /**
  21267. * Unbinds the material from the mesh
  21268. */
  21269. unbind(): void;
  21270. /**
  21271. * Gets the active textures from the material
  21272. * @returns an array of textures
  21273. */
  21274. getActiveTextures(): BaseTexture[];
  21275. /**
  21276. * Specifies if the material uses a texture
  21277. * @param texture defines the texture to check against the material
  21278. * @returns a boolean specifying if the material uses the texture
  21279. */
  21280. hasTexture(texture: BaseTexture): boolean;
  21281. /**
  21282. * Makes a duplicate of the material, and gives it a new name
  21283. * @param name defines the new name for the duplicated material
  21284. * @returns the cloned material
  21285. */
  21286. clone(name: string): Nullable<Material>;
  21287. /**
  21288. * Gets the meshes bound to the material
  21289. * @returns an array of meshes bound to the material
  21290. */
  21291. getBindedMeshes(): AbstractMesh[];
  21292. /**
  21293. * Force shader compilation
  21294. * @param mesh defines the mesh associated with this material
  21295. * @param onCompiled defines a function to execute once the material is compiled
  21296. * @param options defines the options to configure the compilation
  21297. * @param onError defines a function to execute if the material fails compiling
  21298. */
  21299. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21300. /**
  21301. * Force shader compilation
  21302. * @param mesh defines the mesh that will use this material
  21303. * @param options defines additional options for compiling the shaders
  21304. * @returns a promise that resolves when the compilation completes
  21305. */
  21306. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21307. private static readonly _AllDirtyCallBack;
  21308. private static readonly _ImageProcessingDirtyCallBack;
  21309. private static readonly _TextureDirtyCallBack;
  21310. private static readonly _FresnelDirtyCallBack;
  21311. private static readonly _MiscDirtyCallBack;
  21312. private static readonly _LightsDirtyCallBack;
  21313. private static readonly _AttributeDirtyCallBack;
  21314. private static _FresnelAndMiscDirtyCallBack;
  21315. private static _TextureAndMiscDirtyCallBack;
  21316. private static readonly _DirtyCallbackArray;
  21317. private static readonly _RunDirtyCallBacks;
  21318. /**
  21319. * Marks a define in the material to indicate that it needs to be re-computed
  21320. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21321. */
  21322. markAsDirty(flag: number): void;
  21323. /**
  21324. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21325. * @param func defines a function which checks material defines against the submeshes
  21326. */
  21327. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21328. /**
  21329. * Indicates that we need to re-calculated for all submeshes
  21330. */
  21331. protected _markAllSubMeshesAsAllDirty(): void;
  21332. /**
  21333. * Indicates that image processing needs to be re-calculated for all submeshes
  21334. */
  21335. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21336. /**
  21337. * Indicates that textures need to be re-calculated for all submeshes
  21338. */
  21339. protected _markAllSubMeshesAsTexturesDirty(): void;
  21340. /**
  21341. * Indicates that fresnel needs to be re-calculated for all submeshes
  21342. */
  21343. protected _markAllSubMeshesAsFresnelDirty(): void;
  21344. /**
  21345. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21346. */
  21347. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21348. /**
  21349. * Indicates that lights need to be re-calculated for all submeshes
  21350. */
  21351. protected _markAllSubMeshesAsLightsDirty(): void;
  21352. /**
  21353. * Indicates that attributes need to be re-calculated for all submeshes
  21354. */
  21355. protected _markAllSubMeshesAsAttributesDirty(): void;
  21356. /**
  21357. * Indicates that misc needs to be re-calculated for all submeshes
  21358. */
  21359. protected _markAllSubMeshesAsMiscDirty(): void;
  21360. /**
  21361. * Indicates that textures and misc need to be re-calculated for all submeshes
  21362. */
  21363. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21364. /**
  21365. * Disposes the material
  21366. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21367. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21368. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21369. */
  21370. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21371. /** @hidden */
  21372. private releaseVertexArrayObject;
  21373. /**
  21374. * Serializes this material
  21375. * @returns the serialized material object
  21376. */
  21377. serialize(): any;
  21378. /**
  21379. * Creates a material from parsed material data
  21380. * @param parsedMaterial defines parsed material data
  21381. * @param scene defines the hosting scene
  21382. * @param rootUrl defines the root URL to use to load textures
  21383. * @returns a new material
  21384. */
  21385. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21386. }
  21387. }
  21388. declare module "babylonjs/Materials/multiMaterial" {
  21389. import { Nullable } from "babylonjs/types";
  21390. import { Scene } from "babylonjs/scene";
  21391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21392. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21394. import { Material } from "babylonjs/Materials/material";
  21395. /**
  21396. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21397. * separate meshes. This can be use to improve performances.
  21398. * @see http://doc.babylonjs.com/how_to/multi_materials
  21399. */
  21400. export class MultiMaterial extends Material {
  21401. private _subMaterials;
  21402. /**
  21403. * Gets or Sets the list of Materials used within the multi material.
  21404. * They need to be ordered according to the submeshes order in the associated mesh
  21405. */
  21406. subMaterials: Nullable<Material>[];
  21407. /**
  21408. * Function used to align with Node.getChildren()
  21409. * @returns the list of Materials used within the multi material
  21410. */
  21411. getChildren(): Nullable<Material>[];
  21412. /**
  21413. * Instantiates a new Multi Material
  21414. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21415. * separate meshes. This can be use to improve performances.
  21416. * @see http://doc.babylonjs.com/how_to/multi_materials
  21417. * @param name Define the name in the scene
  21418. * @param scene Define the scene the material belongs to
  21419. */
  21420. constructor(name: string, scene: Scene);
  21421. private _hookArray;
  21422. /**
  21423. * Get one of the submaterial by its index in the submaterials array
  21424. * @param index The index to look the sub material at
  21425. * @returns The Material if the index has been defined
  21426. */
  21427. getSubMaterial(index: number): Nullable<Material>;
  21428. /**
  21429. * Get the list of active textures for the whole sub materials list.
  21430. * @returns All the textures that will be used during the rendering
  21431. */
  21432. getActiveTextures(): BaseTexture[];
  21433. /**
  21434. * Gets the current class name of the material e.g. "MultiMaterial"
  21435. * Mainly use in serialization.
  21436. * @returns the class name
  21437. */
  21438. getClassName(): string;
  21439. /**
  21440. * Checks if the material is ready to render the requested sub mesh
  21441. * @param mesh Define the mesh the submesh belongs to
  21442. * @param subMesh Define the sub mesh to look readyness for
  21443. * @param useInstances Define whether or not the material is used with instances
  21444. * @returns true if ready, otherwise false
  21445. */
  21446. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21447. /**
  21448. * Clones the current material and its related sub materials
  21449. * @param name Define the name of the newly cloned material
  21450. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21451. * @returns the cloned material
  21452. */
  21453. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21454. /**
  21455. * Serializes the materials into a JSON representation.
  21456. * @returns the JSON representation
  21457. */
  21458. serialize(): any;
  21459. /**
  21460. * Dispose the material and release its associated resources
  21461. * @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)
  21462. * @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)
  21463. * @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)
  21464. */
  21465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21466. /**
  21467. * Creates a MultiMaterial from parsed MultiMaterial data.
  21468. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21469. * @param scene defines the hosting scene
  21470. * @returns a new MultiMaterial
  21471. */
  21472. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21473. }
  21474. }
  21475. declare module "babylonjs/Meshes/subMesh" {
  21476. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21477. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21478. import { Engine } from "babylonjs/Engines/engine";
  21479. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21480. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21481. import { Effect } from "babylonjs/Materials/effect";
  21482. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21483. import { Plane } from "babylonjs/Maths/math.plane";
  21484. import { Collider } from "babylonjs/Collisions/collider";
  21485. import { Material } from "babylonjs/Materials/material";
  21486. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21488. import { Mesh } from "babylonjs/Meshes/mesh";
  21489. import { Ray } from "babylonjs/Culling/ray";
  21490. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21491. /**
  21492. * Base class for submeshes
  21493. */
  21494. export class BaseSubMesh {
  21495. /** @hidden */
  21496. _materialDefines: Nullable<MaterialDefines>;
  21497. /** @hidden */
  21498. _materialEffect: Nullable<Effect>;
  21499. /**
  21500. * Gets associated effect
  21501. */
  21502. readonly effect: Nullable<Effect>;
  21503. /**
  21504. * Sets associated effect (effect used to render this submesh)
  21505. * @param effect defines the effect to associate with
  21506. * @param defines defines the set of defines used to compile this effect
  21507. */
  21508. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21509. }
  21510. /**
  21511. * Defines a subdivision inside a mesh
  21512. */
  21513. export class SubMesh extends BaseSubMesh implements ICullable {
  21514. /** the material index to use */
  21515. materialIndex: number;
  21516. /** vertex index start */
  21517. verticesStart: number;
  21518. /** vertices count */
  21519. verticesCount: number;
  21520. /** index start */
  21521. indexStart: number;
  21522. /** indices count */
  21523. indexCount: number;
  21524. /** @hidden */
  21525. _linesIndexCount: number;
  21526. private _mesh;
  21527. private _renderingMesh;
  21528. private _boundingInfo;
  21529. private _linesIndexBuffer;
  21530. /** @hidden */
  21531. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21532. /** @hidden */
  21533. _trianglePlanes: Plane[];
  21534. /** @hidden */
  21535. _lastColliderTransformMatrix: Nullable<Matrix>;
  21536. /** @hidden */
  21537. _renderId: number;
  21538. /** @hidden */
  21539. _alphaIndex: number;
  21540. /** @hidden */
  21541. _distanceToCamera: number;
  21542. /** @hidden */
  21543. _id: number;
  21544. private _currentMaterial;
  21545. /**
  21546. * Add a new submesh to a mesh
  21547. * @param materialIndex defines the material index to use
  21548. * @param verticesStart defines vertex index start
  21549. * @param verticesCount defines vertices count
  21550. * @param indexStart defines index start
  21551. * @param indexCount defines indices count
  21552. * @param mesh defines the parent mesh
  21553. * @param renderingMesh defines an optional rendering mesh
  21554. * @param createBoundingBox defines if bounding box should be created for this submesh
  21555. * @returns the new submesh
  21556. */
  21557. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21558. /**
  21559. * Creates a new submesh
  21560. * @param materialIndex defines the material index to use
  21561. * @param verticesStart defines vertex index start
  21562. * @param verticesCount defines vertices count
  21563. * @param indexStart defines index start
  21564. * @param indexCount defines indices count
  21565. * @param mesh defines the parent mesh
  21566. * @param renderingMesh defines an optional rendering mesh
  21567. * @param createBoundingBox defines if bounding box should be created for this submesh
  21568. */
  21569. constructor(
  21570. /** the material index to use */
  21571. materialIndex: number,
  21572. /** vertex index start */
  21573. verticesStart: number,
  21574. /** vertices count */
  21575. verticesCount: number,
  21576. /** index start */
  21577. indexStart: number,
  21578. /** indices count */
  21579. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21580. /**
  21581. * Returns true if this submesh covers the entire parent mesh
  21582. * @ignorenaming
  21583. */
  21584. readonly IsGlobal: boolean;
  21585. /**
  21586. * Returns the submesh BoudingInfo object
  21587. * @returns current bounding info (or mesh's one if the submesh is global)
  21588. */
  21589. getBoundingInfo(): BoundingInfo;
  21590. /**
  21591. * Sets the submesh BoundingInfo
  21592. * @param boundingInfo defines the new bounding info to use
  21593. * @returns the SubMesh
  21594. */
  21595. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21596. /**
  21597. * Returns the mesh of the current submesh
  21598. * @return the parent mesh
  21599. */
  21600. getMesh(): AbstractMesh;
  21601. /**
  21602. * Returns the rendering mesh of the submesh
  21603. * @returns the rendering mesh (could be different from parent mesh)
  21604. */
  21605. getRenderingMesh(): Mesh;
  21606. /**
  21607. * Returns the submesh material
  21608. * @returns null or the current material
  21609. */
  21610. getMaterial(): Nullable<Material>;
  21611. /**
  21612. * Sets a new updated BoundingInfo object to the submesh
  21613. * @param data defines an optional position array to use to determine the bounding info
  21614. * @returns the SubMesh
  21615. */
  21616. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21617. /** @hidden */
  21618. _checkCollision(collider: Collider): boolean;
  21619. /**
  21620. * Updates the submesh BoundingInfo
  21621. * @param world defines the world matrix to use to update the bounding info
  21622. * @returns the submesh
  21623. */
  21624. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21625. /**
  21626. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21627. * @param frustumPlanes defines the frustum planes
  21628. * @returns true if the submesh is intersecting with the frustum
  21629. */
  21630. isInFrustum(frustumPlanes: Plane[]): boolean;
  21631. /**
  21632. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21633. * @param frustumPlanes defines the frustum planes
  21634. * @returns true if the submesh is inside the frustum
  21635. */
  21636. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21637. /**
  21638. * Renders the submesh
  21639. * @param enableAlphaMode defines if alpha needs to be used
  21640. * @returns the submesh
  21641. */
  21642. render(enableAlphaMode: boolean): SubMesh;
  21643. /**
  21644. * @hidden
  21645. */
  21646. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21647. /**
  21648. * Checks if the submesh intersects with a ray
  21649. * @param ray defines the ray to test
  21650. * @returns true is the passed ray intersects the submesh bounding box
  21651. */
  21652. canIntersects(ray: Ray): boolean;
  21653. /**
  21654. * Intersects current submesh with a ray
  21655. * @param ray defines the ray to test
  21656. * @param positions defines mesh's positions array
  21657. * @param indices defines mesh's indices array
  21658. * @param fastCheck defines if only bounding info should be used
  21659. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21660. * @returns intersection info or null if no intersection
  21661. */
  21662. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21663. /** @hidden */
  21664. private _intersectLines;
  21665. /** @hidden */
  21666. private _intersectUnIndexedLines;
  21667. /** @hidden */
  21668. private _intersectTriangles;
  21669. /** @hidden */
  21670. private _intersectUnIndexedTriangles;
  21671. /** @hidden */
  21672. _rebuild(): void;
  21673. /**
  21674. * Creates a new submesh from the passed mesh
  21675. * @param newMesh defines the new hosting mesh
  21676. * @param newRenderingMesh defines an optional rendering mesh
  21677. * @returns the new submesh
  21678. */
  21679. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21680. /**
  21681. * Release associated resources
  21682. */
  21683. dispose(): void;
  21684. /**
  21685. * Gets the class name
  21686. * @returns the string "SubMesh".
  21687. */
  21688. getClassName(): string;
  21689. /**
  21690. * Creates a new submesh from indices data
  21691. * @param materialIndex the index of the main mesh material
  21692. * @param startIndex the index where to start the copy in the mesh indices array
  21693. * @param indexCount the number of indices to copy then from the startIndex
  21694. * @param mesh the main mesh to create the submesh from
  21695. * @param renderingMesh the optional rendering mesh
  21696. * @returns a new submesh
  21697. */
  21698. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21699. }
  21700. }
  21701. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21702. /**
  21703. * Class used to represent data loading progression
  21704. */
  21705. export class SceneLoaderFlags {
  21706. private static _ForceFullSceneLoadingForIncremental;
  21707. private static _ShowLoadingScreen;
  21708. private static _CleanBoneMatrixWeights;
  21709. private static _loggingLevel;
  21710. /**
  21711. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21712. */
  21713. static ForceFullSceneLoadingForIncremental: boolean;
  21714. /**
  21715. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21716. */
  21717. static ShowLoadingScreen: boolean;
  21718. /**
  21719. * Defines the current logging level (while loading the scene)
  21720. * @ignorenaming
  21721. */
  21722. static loggingLevel: number;
  21723. /**
  21724. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21725. */
  21726. static CleanBoneMatrixWeights: boolean;
  21727. }
  21728. }
  21729. declare module "babylonjs/Meshes/geometry" {
  21730. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21731. import { Scene } from "babylonjs/scene";
  21732. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21733. import { Engine } from "babylonjs/Engines/engine";
  21734. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21735. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21736. import { Effect } from "babylonjs/Materials/effect";
  21737. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21738. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21739. import { Mesh } from "babylonjs/Meshes/mesh";
  21740. /**
  21741. * Class used to store geometry data (vertex buffers + index buffer)
  21742. */
  21743. export class Geometry implements IGetSetVerticesData {
  21744. /**
  21745. * Gets or sets the ID of the geometry
  21746. */
  21747. id: string;
  21748. /**
  21749. * Gets or sets the unique ID of the geometry
  21750. */
  21751. uniqueId: number;
  21752. /**
  21753. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21754. */
  21755. delayLoadState: number;
  21756. /**
  21757. * Gets the file containing the data to load when running in delay load state
  21758. */
  21759. delayLoadingFile: Nullable<string>;
  21760. /**
  21761. * Callback called when the geometry is updated
  21762. */
  21763. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21764. private _scene;
  21765. private _engine;
  21766. private _meshes;
  21767. private _totalVertices;
  21768. /** @hidden */
  21769. _indices: IndicesArray;
  21770. /** @hidden */
  21771. _vertexBuffers: {
  21772. [key: string]: VertexBuffer;
  21773. };
  21774. private _isDisposed;
  21775. private _extend;
  21776. private _boundingBias;
  21777. /** @hidden */
  21778. _delayInfo: Array<string>;
  21779. private _indexBuffer;
  21780. private _indexBufferIsUpdatable;
  21781. /** @hidden */
  21782. _boundingInfo: Nullable<BoundingInfo>;
  21783. /** @hidden */
  21784. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21785. /** @hidden */
  21786. _softwareSkinningFrameId: number;
  21787. private _vertexArrayObjects;
  21788. private _updatable;
  21789. /** @hidden */
  21790. _positions: Nullable<Vector3[]>;
  21791. /**
  21792. * 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
  21793. */
  21794. /**
  21795. * 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
  21796. */
  21797. boundingBias: Vector2;
  21798. /**
  21799. * Static function used to attach a new empty geometry to a mesh
  21800. * @param mesh defines the mesh to attach the geometry to
  21801. * @returns the new Geometry
  21802. */
  21803. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21804. /**
  21805. * Creates a new geometry
  21806. * @param id defines the unique ID
  21807. * @param scene defines the hosting scene
  21808. * @param vertexData defines the VertexData used to get geometry data
  21809. * @param updatable defines if geometry must be updatable (false by default)
  21810. * @param mesh defines the mesh that will be associated with the geometry
  21811. */
  21812. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21813. /**
  21814. * Gets the current extend of the geometry
  21815. */
  21816. readonly extend: {
  21817. minimum: Vector3;
  21818. maximum: Vector3;
  21819. };
  21820. /**
  21821. * Gets the hosting scene
  21822. * @returns the hosting Scene
  21823. */
  21824. getScene(): Scene;
  21825. /**
  21826. * Gets the hosting engine
  21827. * @returns the hosting Engine
  21828. */
  21829. getEngine(): Engine;
  21830. /**
  21831. * Defines if the geometry is ready to use
  21832. * @returns true if the geometry is ready to be used
  21833. */
  21834. isReady(): boolean;
  21835. /**
  21836. * Gets a value indicating that the geometry should not be serialized
  21837. */
  21838. readonly doNotSerialize: boolean;
  21839. /** @hidden */
  21840. _rebuild(): void;
  21841. /**
  21842. * Affects all geometry data in one call
  21843. * @param vertexData defines the geometry data
  21844. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21845. */
  21846. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21847. /**
  21848. * Set specific vertex data
  21849. * @param kind defines the data kind (Position, normal, etc...)
  21850. * @param data defines the vertex data to use
  21851. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21852. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21853. */
  21854. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21855. /**
  21856. * Removes a specific vertex data
  21857. * @param kind defines the data kind (Position, normal, etc...)
  21858. */
  21859. removeVerticesData(kind: string): void;
  21860. /**
  21861. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21862. * @param buffer defines the vertex buffer to use
  21863. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21864. */
  21865. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21866. /**
  21867. * Update a specific vertex buffer
  21868. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21869. * It will do nothing if the buffer is not updatable
  21870. * @param kind defines the data kind (Position, normal, etc...)
  21871. * @param data defines the data to use
  21872. * @param offset defines the offset in the target buffer where to store the data
  21873. * @param useBytes set to true if the offset is in bytes
  21874. */
  21875. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21876. /**
  21877. * Update a specific vertex buffer
  21878. * This function will create a new buffer if the current one is not updatable
  21879. * @param kind defines the data kind (Position, normal, etc...)
  21880. * @param data defines the data to use
  21881. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21882. */
  21883. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21884. private _updateBoundingInfo;
  21885. /** @hidden */
  21886. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21887. /**
  21888. * Gets total number of vertices
  21889. * @returns the total number of vertices
  21890. */
  21891. getTotalVertices(): number;
  21892. /**
  21893. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21894. * @param kind defines the data kind (Position, normal, etc...)
  21895. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21896. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21897. * @returns a float array containing vertex data
  21898. */
  21899. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21900. /**
  21901. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21902. * @param kind defines the data kind (Position, normal, etc...)
  21903. * @returns true if the vertex buffer with the specified kind is updatable
  21904. */
  21905. isVertexBufferUpdatable(kind: string): boolean;
  21906. /**
  21907. * Gets a specific vertex buffer
  21908. * @param kind defines the data kind (Position, normal, etc...)
  21909. * @returns a VertexBuffer
  21910. */
  21911. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21912. /**
  21913. * Returns all vertex buffers
  21914. * @return an object holding all vertex buffers indexed by kind
  21915. */
  21916. getVertexBuffers(): Nullable<{
  21917. [key: string]: VertexBuffer;
  21918. }>;
  21919. /**
  21920. * Gets a boolean indicating if specific vertex buffer is present
  21921. * @param kind defines the data kind (Position, normal, etc...)
  21922. * @returns true if data is present
  21923. */
  21924. isVerticesDataPresent(kind: string): boolean;
  21925. /**
  21926. * Gets a list of all attached data kinds (Position, normal, etc...)
  21927. * @returns a list of string containing all kinds
  21928. */
  21929. getVerticesDataKinds(): string[];
  21930. /**
  21931. * Update index buffer
  21932. * @param indices defines the indices to store in the index buffer
  21933. * @param offset defines the offset in the target buffer where to store the data
  21934. * @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)
  21935. */
  21936. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21937. /**
  21938. * Creates a new index buffer
  21939. * @param indices defines the indices to store in the index buffer
  21940. * @param totalVertices defines the total number of vertices (could be null)
  21941. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21942. */
  21943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21944. /**
  21945. * Return the total number of indices
  21946. * @returns the total number of indices
  21947. */
  21948. getTotalIndices(): number;
  21949. /**
  21950. * Gets the index buffer array
  21951. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21952. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21953. * @returns the index buffer array
  21954. */
  21955. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21956. /**
  21957. * Gets the index buffer
  21958. * @return the index buffer
  21959. */
  21960. getIndexBuffer(): Nullable<DataBuffer>;
  21961. /** @hidden */
  21962. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21963. /**
  21964. * Release the associated resources for a specific mesh
  21965. * @param mesh defines the source mesh
  21966. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21967. */
  21968. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21969. /**
  21970. * Apply current geometry to a given mesh
  21971. * @param mesh defines the mesh to apply geometry to
  21972. */
  21973. applyToMesh(mesh: Mesh): void;
  21974. private _updateExtend;
  21975. private _applyToMesh;
  21976. private notifyUpdate;
  21977. /**
  21978. * Load the geometry if it was flagged as delay loaded
  21979. * @param scene defines the hosting scene
  21980. * @param onLoaded defines a callback called when the geometry is loaded
  21981. */
  21982. load(scene: Scene, onLoaded?: () => void): void;
  21983. private _queueLoad;
  21984. /**
  21985. * Invert the geometry to move from a right handed system to a left handed one.
  21986. */
  21987. toLeftHanded(): void;
  21988. /** @hidden */
  21989. _resetPointsArrayCache(): void;
  21990. /** @hidden */
  21991. _generatePointsArray(): boolean;
  21992. /**
  21993. * Gets a value indicating if the geometry is disposed
  21994. * @returns true if the geometry was disposed
  21995. */
  21996. isDisposed(): boolean;
  21997. private _disposeVertexArrayObjects;
  21998. /**
  21999. * Free all associated resources
  22000. */
  22001. dispose(): void;
  22002. /**
  22003. * Clone the current geometry into a new geometry
  22004. * @param id defines the unique ID of the new geometry
  22005. * @returns a new geometry object
  22006. */
  22007. copy(id: string): Geometry;
  22008. /**
  22009. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22010. * @return a JSON representation of the current geometry data (without the vertices data)
  22011. */
  22012. serialize(): any;
  22013. private toNumberArray;
  22014. /**
  22015. * Serialize all vertices data into a JSON oject
  22016. * @returns a JSON representation of the current geometry data
  22017. */
  22018. serializeVerticeData(): any;
  22019. /**
  22020. * Extracts a clone of a mesh geometry
  22021. * @param mesh defines the source mesh
  22022. * @param id defines the unique ID of the new geometry object
  22023. * @returns the new geometry object
  22024. */
  22025. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22026. /**
  22027. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22028. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22029. * Be aware Math.random() could cause collisions, but:
  22030. * "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"
  22031. * @returns a string containing a new GUID
  22032. */
  22033. static RandomId(): string;
  22034. /** @hidden */
  22035. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22036. private static _CleanMatricesWeights;
  22037. /**
  22038. * Create a new geometry from persisted data (Using .babylon file format)
  22039. * @param parsedVertexData defines the persisted data
  22040. * @param scene defines the hosting scene
  22041. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22042. * @returns the new geometry object
  22043. */
  22044. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22045. }
  22046. }
  22047. declare module "babylonjs/Meshes/mesh.vertexData" {
  22048. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22049. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22050. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22051. import { Geometry } from "babylonjs/Meshes/geometry";
  22052. import { Mesh } from "babylonjs/Meshes/mesh";
  22053. /**
  22054. * Define an interface for all classes that will get and set the data on vertices
  22055. */
  22056. export interface IGetSetVerticesData {
  22057. /**
  22058. * Gets a boolean indicating if specific vertex data is present
  22059. * @param kind defines the vertex data kind to use
  22060. * @returns true is data kind is present
  22061. */
  22062. isVerticesDataPresent(kind: string): boolean;
  22063. /**
  22064. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22065. * @param kind defines the data kind (Position, normal, etc...)
  22066. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22067. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22068. * @returns a float array containing vertex data
  22069. */
  22070. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22071. /**
  22072. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22073. * @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.
  22074. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22075. * @returns the indices array or an empty array if the mesh has no geometry
  22076. */
  22077. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22078. /**
  22079. * Set specific vertex data
  22080. * @param kind defines the data kind (Position, normal, etc...)
  22081. * @param data defines the vertex data to use
  22082. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22083. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22084. */
  22085. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22086. /**
  22087. * Update a specific associated vertex buffer
  22088. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22089. * - VertexBuffer.PositionKind
  22090. * - VertexBuffer.UVKind
  22091. * - VertexBuffer.UV2Kind
  22092. * - VertexBuffer.UV3Kind
  22093. * - VertexBuffer.UV4Kind
  22094. * - VertexBuffer.UV5Kind
  22095. * - VertexBuffer.UV6Kind
  22096. * - VertexBuffer.ColorKind
  22097. * - VertexBuffer.MatricesIndicesKind
  22098. * - VertexBuffer.MatricesIndicesExtraKind
  22099. * - VertexBuffer.MatricesWeightsKind
  22100. * - VertexBuffer.MatricesWeightsExtraKind
  22101. * @param data defines the data source
  22102. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22103. * @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)
  22104. */
  22105. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22106. /**
  22107. * Creates a new index buffer
  22108. * @param indices defines the indices to store in the index buffer
  22109. * @param totalVertices defines the total number of vertices (could be null)
  22110. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22111. */
  22112. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22113. }
  22114. /**
  22115. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22116. */
  22117. export class VertexData {
  22118. /**
  22119. * Mesh side orientation : usually the external or front surface
  22120. */
  22121. static readonly FRONTSIDE: number;
  22122. /**
  22123. * Mesh side orientation : usually the internal or back surface
  22124. */
  22125. static readonly BACKSIDE: number;
  22126. /**
  22127. * Mesh side orientation : both internal and external or front and back surfaces
  22128. */
  22129. static readonly DOUBLESIDE: number;
  22130. /**
  22131. * Mesh side orientation : by default, `FRONTSIDE`
  22132. */
  22133. static readonly DEFAULTSIDE: number;
  22134. /**
  22135. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22136. */
  22137. positions: Nullable<FloatArray>;
  22138. /**
  22139. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22140. */
  22141. normals: Nullable<FloatArray>;
  22142. /**
  22143. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22144. */
  22145. tangents: Nullable<FloatArray>;
  22146. /**
  22147. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22148. */
  22149. uvs: Nullable<FloatArray>;
  22150. /**
  22151. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22152. */
  22153. uvs2: Nullable<FloatArray>;
  22154. /**
  22155. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22156. */
  22157. uvs3: Nullable<FloatArray>;
  22158. /**
  22159. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22160. */
  22161. uvs4: Nullable<FloatArray>;
  22162. /**
  22163. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22164. */
  22165. uvs5: Nullable<FloatArray>;
  22166. /**
  22167. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22168. */
  22169. uvs6: Nullable<FloatArray>;
  22170. /**
  22171. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22172. */
  22173. colors: Nullable<FloatArray>;
  22174. /**
  22175. * 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).
  22176. */
  22177. matricesIndices: Nullable<FloatArray>;
  22178. /**
  22179. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22180. */
  22181. matricesWeights: Nullable<FloatArray>;
  22182. /**
  22183. * An array extending the number of possible indices
  22184. */
  22185. matricesIndicesExtra: Nullable<FloatArray>;
  22186. /**
  22187. * An array extending the number of possible weights when the number of indices is extended
  22188. */
  22189. matricesWeightsExtra: Nullable<FloatArray>;
  22190. /**
  22191. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22192. */
  22193. indices: Nullable<IndicesArray>;
  22194. /**
  22195. * Uses the passed data array to set the set the values for the specified kind of data
  22196. * @param data a linear array of floating numbers
  22197. * @param kind the type of data that is being set, eg positions, colors etc
  22198. */
  22199. set(data: FloatArray, kind: string): void;
  22200. /**
  22201. * Associates the vertexData to the passed Mesh.
  22202. * Sets it as updatable or not (default `false`)
  22203. * @param mesh the mesh the vertexData is applied to
  22204. * @param updatable when used and having the value true allows new data to update the vertexData
  22205. * @returns the VertexData
  22206. */
  22207. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22208. /**
  22209. * Associates the vertexData to the passed Geometry.
  22210. * Sets it as updatable or not (default `false`)
  22211. * @param geometry the geometry the vertexData is applied to
  22212. * @param updatable when used and having the value true allows new data to update the vertexData
  22213. * @returns VertexData
  22214. */
  22215. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22216. /**
  22217. * Updates the associated mesh
  22218. * @param mesh the mesh to be updated
  22219. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22220. * @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
  22221. * @returns VertexData
  22222. */
  22223. updateMesh(mesh: Mesh): VertexData;
  22224. /**
  22225. * Updates the associated geometry
  22226. * @param geometry the geometry to be updated
  22227. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22228. * @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
  22229. * @returns VertexData.
  22230. */
  22231. updateGeometry(geometry: Geometry): VertexData;
  22232. private _applyTo;
  22233. private _update;
  22234. /**
  22235. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22236. * @param matrix the transforming matrix
  22237. * @returns the VertexData
  22238. */
  22239. transform(matrix: Matrix): VertexData;
  22240. /**
  22241. * Merges the passed VertexData into the current one
  22242. * @param other the VertexData to be merged into the current one
  22243. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22244. * @returns the modified VertexData
  22245. */
  22246. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22247. private _mergeElement;
  22248. private _validate;
  22249. /**
  22250. * Serializes the VertexData
  22251. * @returns a serialized object
  22252. */
  22253. serialize(): any;
  22254. /**
  22255. * Extracts the vertexData from a mesh
  22256. * @param mesh the mesh from which to extract the VertexData
  22257. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22258. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22259. * @returns the object VertexData associated to the passed mesh
  22260. */
  22261. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22262. /**
  22263. * Extracts the vertexData from the geometry
  22264. * @param geometry the geometry from which to extract the VertexData
  22265. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22266. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22267. * @returns the object VertexData associated to the passed mesh
  22268. */
  22269. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22270. private static _ExtractFrom;
  22271. /**
  22272. * Creates the VertexData for a Ribbon
  22273. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22274. * * pathArray array of paths, each of which an array of successive Vector3
  22275. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22276. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22277. * * 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
  22278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22279. * * 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)
  22280. * * 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)
  22281. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22282. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22283. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22284. * @returns the VertexData of the ribbon
  22285. */
  22286. static CreateRibbon(options: {
  22287. pathArray: Vector3[][];
  22288. closeArray?: boolean;
  22289. closePath?: boolean;
  22290. offset?: number;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. invertUV?: boolean;
  22295. uvs?: Vector2[];
  22296. colors?: Color4[];
  22297. }): VertexData;
  22298. /**
  22299. * Creates the VertexData for a box
  22300. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22301. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22302. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22303. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22304. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22305. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22306. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22308. * * 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)
  22309. * * 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)
  22310. * @returns the VertexData of the box
  22311. */
  22312. static CreateBox(options: {
  22313. size?: number;
  22314. width?: number;
  22315. height?: number;
  22316. depth?: number;
  22317. faceUV?: Vector4[];
  22318. faceColors?: Color4[];
  22319. sideOrientation?: number;
  22320. frontUVs?: Vector4;
  22321. backUVs?: Vector4;
  22322. }): VertexData;
  22323. /**
  22324. * Creates the VertexData for a tiled box
  22325. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22326. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22327. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22328. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22329. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22330. * @returns the VertexData of the box
  22331. */
  22332. static CreateTiledBox(options: {
  22333. pattern?: number;
  22334. width?: number;
  22335. height?: number;
  22336. depth?: number;
  22337. tileSize?: number;
  22338. tileWidth?: number;
  22339. tileHeight?: number;
  22340. alignHorizontal?: number;
  22341. alignVertical?: number;
  22342. faceUV?: Vector4[];
  22343. faceColors?: Color4[];
  22344. sideOrientation?: number;
  22345. }): VertexData;
  22346. /**
  22347. * Creates the VertexData for a tiled plane
  22348. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22349. * * pattern a limited pattern arrangement depending on the number
  22350. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22351. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22352. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22354. * * 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)
  22355. * * 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)
  22356. * @returns the VertexData of the tiled plane
  22357. */
  22358. static CreateTiledPlane(options: {
  22359. pattern?: number;
  22360. tileSize?: number;
  22361. tileWidth?: number;
  22362. tileHeight?: number;
  22363. size?: number;
  22364. width?: number;
  22365. height?: number;
  22366. alignHorizontal?: number;
  22367. alignVertical?: number;
  22368. sideOrientation?: number;
  22369. frontUVs?: Vector4;
  22370. backUVs?: Vector4;
  22371. }): VertexData;
  22372. /**
  22373. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22374. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22375. * * segments sets the number of horizontal strips optional, default 32
  22376. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22377. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22378. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22379. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22380. * * 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
  22381. * * 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
  22382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22383. * * 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)
  22384. * * 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)
  22385. * @returns the VertexData of the ellipsoid
  22386. */
  22387. static CreateSphere(options: {
  22388. segments?: number;
  22389. diameter?: number;
  22390. diameterX?: number;
  22391. diameterY?: number;
  22392. diameterZ?: number;
  22393. arc?: number;
  22394. slice?: number;
  22395. sideOrientation?: number;
  22396. frontUVs?: Vector4;
  22397. backUVs?: Vector4;
  22398. }): VertexData;
  22399. /**
  22400. * Creates the VertexData for a cylinder, cone or prism
  22401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22402. * * height sets the height (y direction) of the cylinder, optional, default 2
  22403. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22404. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22405. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22406. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22407. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22408. * * 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
  22409. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22410. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22411. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22412. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22414. * * 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)
  22415. * * 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)
  22416. * @returns the VertexData of the cylinder, cone or prism
  22417. */
  22418. static CreateCylinder(options: {
  22419. height?: number;
  22420. diameterTop?: number;
  22421. diameterBottom?: number;
  22422. diameter?: number;
  22423. tessellation?: number;
  22424. subdivisions?: number;
  22425. arc?: number;
  22426. faceColors?: Color4[];
  22427. faceUV?: Vector4[];
  22428. hasRings?: boolean;
  22429. enclose?: boolean;
  22430. sideOrientation?: number;
  22431. frontUVs?: Vector4;
  22432. backUVs?: Vector4;
  22433. }): VertexData;
  22434. /**
  22435. * Creates the VertexData for a torus
  22436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22437. * * diameter the diameter of the torus, optional default 1
  22438. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22439. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22441. * * 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)
  22442. * * 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)
  22443. * @returns the VertexData of the torus
  22444. */
  22445. static CreateTorus(options: {
  22446. diameter?: number;
  22447. thickness?: number;
  22448. tessellation?: number;
  22449. sideOrientation?: number;
  22450. frontUVs?: Vector4;
  22451. backUVs?: Vector4;
  22452. }): VertexData;
  22453. /**
  22454. * Creates the VertexData of the LineSystem
  22455. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22456. * - lines an array of lines, each line being an array of successive Vector3
  22457. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22458. * @returns the VertexData of the LineSystem
  22459. */
  22460. static CreateLineSystem(options: {
  22461. lines: Vector3[][];
  22462. colors?: Nullable<Color4[][]>;
  22463. }): VertexData;
  22464. /**
  22465. * Create the VertexData for a DashedLines
  22466. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22467. * - points an array successive Vector3
  22468. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22469. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22470. * - dashNb the intended total number of dashes, optional, default 200
  22471. * @returns the VertexData for the DashedLines
  22472. */
  22473. static CreateDashedLines(options: {
  22474. points: Vector3[];
  22475. dashSize?: number;
  22476. gapSize?: number;
  22477. dashNb?: number;
  22478. }): VertexData;
  22479. /**
  22480. * Creates the VertexData for a Ground
  22481. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22482. * - width the width (x direction) of the ground, optional, default 1
  22483. * - height the height (z direction) of the ground, optional, default 1
  22484. * - subdivisions the number of subdivisions per side, optional, default 1
  22485. * @returns the VertexData of the Ground
  22486. */
  22487. static CreateGround(options: {
  22488. width?: number;
  22489. height?: number;
  22490. subdivisions?: number;
  22491. subdivisionsX?: number;
  22492. subdivisionsY?: number;
  22493. }): VertexData;
  22494. /**
  22495. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22496. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22497. * * xmin the ground minimum X coordinate, optional, default -1
  22498. * * zmin the ground minimum Z coordinate, optional, default -1
  22499. * * xmax the ground maximum X coordinate, optional, default 1
  22500. * * zmax the ground maximum Z coordinate, optional, default 1
  22501. * * 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}
  22502. * * 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}
  22503. * @returns the VertexData of the TiledGround
  22504. */
  22505. static CreateTiledGround(options: {
  22506. xmin: number;
  22507. zmin: number;
  22508. xmax: number;
  22509. zmax: number;
  22510. subdivisions?: {
  22511. w: number;
  22512. h: number;
  22513. };
  22514. precision?: {
  22515. w: number;
  22516. h: number;
  22517. };
  22518. }): VertexData;
  22519. /**
  22520. * Creates the VertexData of the Ground designed from a heightmap
  22521. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22522. * * width the width (x direction) of the ground
  22523. * * height the height (z direction) of the ground
  22524. * * subdivisions the number of subdivisions per side
  22525. * * minHeight the minimum altitude on the ground, optional, default 0
  22526. * * maxHeight the maximum altitude on the ground, optional default 1
  22527. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22528. * * buffer the array holding the image color data
  22529. * * bufferWidth the width of image
  22530. * * bufferHeight the height of image
  22531. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22532. * @returns the VertexData of the Ground designed from a heightmap
  22533. */
  22534. static CreateGroundFromHeightMap(options: {
  22535. width: number;
  22536. height: number;
  22537. subdivisions: number;
  22538. minHeight: number;
  22539. maxHeight: number;
  22540. colorFilter: Color3;
  22541. buffer: Uint8Array;
  22542. bufferWidth: number;
  22543. bufferHeight: number;
  22544. alphaFilter: number;
  22545. }): VertexData;
  22546. /**
  22547. * Creates the VertexData for a Plane
  22548. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22549. * * size sets the width and height of the plane to the value of size, optional default 1
  22550. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22551. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22553. * * 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)
  22554. * * 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)
  22555. * @returns the VertexData of the box
  22556. */
  22557. static CreatePlane(options: {
  22558. size?: number;
  22559. width?: number;
  22560. height?: number;
  22561. sideOrientation?: number;
  22562. frontUVs?: Vector4;
  22563. backUVs?: Vector4;
  22564. }): VertexData;
  22565. /**
  22566. * Creates the VertexData of the Disc or regular Polygon
  22567. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22568. * * radius the radius of the disc, optional default 0.5
  22569. * * tessellation the number of polygon sides, optional, default 64
  22570. * * 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
  22571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22572. * * 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)
  22573. * * 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)
  22574. * @returns the VertexData of the box
  22575. */
  22576. static CreateDisc(options: {
  22577. radius?: number;
  22578. tessellation?: number;
  22579. arc?: number;
  22580. sideOrientation?: number;
  22581. frontUVs?: Vector4;
  22582. backUVs?: Vector4;
  22583. }): VertexData;
  22584. /**
  22585. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22586. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22587. * @param polygon a mesh built from polygonTriangulation.build()
  22588. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22589. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22590. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22591. * @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)
  22592. * @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)
  22593. * @returns the VertexData of the Polygon
  22594. */
  22595. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22596. /**
  22597. * Creates the VertexData of the IcoSphere
  22598. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22599. * * radius the radius of the IcoSphere, optional default 1
  22600. * * radiusX allows stretching in the x direction, optional, default radius
  22601. * * radiusY allows stretching in the y direction, optional, default radius
  22602. * * radiusZ allows stretching in the z direction, optional, default radius
  22603. * * flat when true creates a flat shaded mesh, optional, default true
  22604. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22606. * * 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)
  22607. * * 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)
  22608. * @returns the VertexData of the IcoSphere
  22609. */
  22610. static CreateIcoSphere(options: {
  22611. radius?: number;
  22612. radiusX?: number;
  22613. radiusY?: number;
  22614. radiusZ?: number;
  22615. flat?: boolean;
  22616. subdivisions?: number;
  22617. sideOrientation?: number;
  22618. frontUVs?: Vector4;
  22619. backUVs?: Vector4;
  22620. }): VertexData;
  22621. /**
  22622. * Creates the VertexData for a Polyhedron
  22623. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22624. * * type provided types are:
  22625. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22626. * * 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)
  22627. * * size the size of the IcoSphere, optional default 1
  22628. * * sizeX allows stretching in the x direction, optional, default size
  22629. * * sizeY allows stretching in the y direction, optional, default size
  22630. * * sizeZ allows stretching in the z direction, optional, default size
  22631. * * 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
  22632. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22633. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22634. * * flat when true creates a flat shaded mesh, optional, default true
  22635. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22637. * * 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)
  22638. * * 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)
  22639. * @returns the VertexData of the Polyhedron
  22640. */
  22641. static CreatePolyhedron(options: {
  22642. type?: number;
  22643. size?: number;
  22644. sizeX?: number;
  22645. sizeY?: number;
  22646. sizeZ?: number;
  22647. custom?: any;
  22648. faceUV?: Vector4[];
  22649. faceColors?: Color4[];
  22650. flat?: boolean;
  22651. sideOrientation?: number;
  22652. frontUVs?: Vector4;
  22653. backUVs?: Vector4;
  22654. }): VertexData;
  22655. /**
  22656. * Creates the VertexData for a TorusKnot
  22657. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22658. * * radius the radius of the torus knot, optional, default 2
  22659. * * tube the thickness of the tube, optional, default 0.5
  22660. * * radialSegments the number of sides on each tube segments, optional, default 32
  22661. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22662. * * p the number of windings around the z axis, optional, default 2
  22663. * * q the number of windings around the x axis, optional, default 3
  22664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22665. * * 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)
  22666. * * 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)
  22667. * @returns the VertexData of the Torus Knot
  22668. */
  22669. static CreateTorusKnot(options: {
  22670. radius?: number;
  22671. tube?: number;
  22672. radialSegments?: number;
  22673. tubularSegments?: number;
  22674. p?: number;
  22675. q?: number;
  22676. sideOrientation?: number;
  22677. frontUVs?: Vector4;
  22678. backUVs?: Vector4;
  22679. }): VertexData;
  22680. /**
  22681. * Compute normals for given positions and indices
  22682. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22683. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22684. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22685. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22686. * * facetNormals : optional array of facet normals (vector3)
  22687. * * facetPositions : optional array of facet positions (vector3)
  22688. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22689. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22690. * * bInfo : optional bounding info, required for facetPartitioning computation
  22691. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22692. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22693. * * useRightHandedSystem: optional boolean to for right handed system computation
  22694. * * depthSort : optional boolean to enable the facet depth sort computation
  22695. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22696. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22697. */
  22698. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22699. facetNormals?: any;
  22700. facetPositions?: any;
  22701. facetPartitioning?: any;
  22702. ratio?: number;
  22703. bInfo?: any;
  22704. bbSize?: Vector3;
  22705. subDiv?: any;
  22706. useRightHandedSystem?: boolean;
  22707. depthSort?: boolean;
  22708. distanceTo?: Vector3;
  22709. depthSortedFacets?: any;
  22710. }): void;
  22711. /** @hidden */
  22712. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22713. /**
  22714. * Applies VertexData created from the imported parameters to the geometry
  22715. * @param parsedVertexData the parsed data from an imported file
  22716. * @param geometry the geometry to apply the VertexData to
  22717. */
  22718. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22719. }
  22720. }
  22721. declare module "babylonjs/Morph/morphTarget" {
  22722. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22723. import { Observable } from "babylonjs/Misc/observable";
  22724. import { Nullable, FloatArray } from "babylonjs/types";
  22725. import { Scene } from "babylonjs/scene";
  22726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22727. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22728. /**
  22729. * Defines a target to use with MorphTargetManager
  22730. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22731. */
  22732. export class MorphTarget implements IAnimatable {
  22733. /** defines the name of the target */
  22734. name: string;
  22735. /**
  22736. * Gets or sets the list of animations
  22737. */
  22738. animations: import("babylonjs/Animations/animation").Animation[];
  22739. private _scene;
  22740. private _positions;
  22741. private _normals;
  22742. private _tangents;
  22743. private _uvs;
  22744. private _influence;
  22745. /**
  22746. * Observable raised when the influence changes
  22747. */
  22748. onInfluenceChanged: Observable<boolean>;
  22749. /** @hidden */
  22750. _onDataLayoutChanged: Observable<void>;
  22751. /**
  22752. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22753. */
  22754. influence: number;
  22755. /**
  22756. * Gets or sets the id of the morph Target
  22757. */
  22758. id: string;
  22759. private _animationPropertiesOverride;
  22760. /**
  22761. * Gets or sets the animation properties override
  22762. */
  22763. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22764. /**
  22765. * Creates a new MorphTarget
  22766. * @param name defines the name of the target
  22767. * @param influence defines the influence to use
  22768. * @param scene defines the scene the morphtarget belongs to
  22769. */
  22770. constructor(
  22771. /** defines the name of the target */
  22772. name: string, influence?: number, scene?: Nullable<Scene>);
  22773. /**
  22774. * Gets a boolean defining if the target contains position data
  22775. */
  22776. readonly hasPositions: boolean;
  22777. /**
  22778. * Gets a boolean defining if the target contains normal data
  22779. */
  22780. readonly hasNormals: boolean;
  22781. /**
  22782. * Gets a boolean defining if the target contains tangent data
  22783. */
  22784. readonly hasTangents: boolean;
  22785. /**
  22786. * Gets a boolean defining if the target contains texture coordinates data
  22787. */
  22788. readonly hasUVs: boolean;
  22789. /**
  22790. * Affects position data to this target
  22791. * @param data defines the position data to use
  22792. */
  22793. setPositions(data: Nullable<FloatArray>): void;
  22794. /**
  22795. * Gets the position data stored in this target
  22796. * @returns a FloatArray containing the position data (or null if not present)
  22797. */
  22798. getPositions(): Nullable<FloatArray>;
  22799. /**
  22800. * Affects normal data to this target
  22801. * @param data defines the normal data to use
  22802. */
  22803. setNormals(data: Nullable<FloatArray>): void;
  22804. /**
  22805. * Gets the normal data stored in this target
  22806. * @returns a FloatArray containing the normal data (or null if not present)
  22807. */
  22808. getNormals(): Nullable<FloatArray>;
  22809. /**
  22810. * Affects tangent data to this target
  22811. * @param data defines the tangent data to use
  22812. */
  22813. setTangents(data: Nullable<FloatArray>): void;
  22814. /**
  22815. * Gets the tangent data stored in this target
  22816. * @returns a FloatArray containing the tangent data (or null if not present)
  22817. */
  22818. getTangents(): Nullable<FloatArray>;
  22819. /**
  22820. * Affects texture coordinates data to this target
  22821. * @param data defines the texture coordinates data to use
  22822. */
  22823. setUVs(data: Nullable<FloatArray>): void;
  22824. /**
  22825. * Gets the texture coordinates data stored in this target
  22826. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22827. */
  22828. getUVs(): Nullable<FloatArray>;
  22829. /**
  22830. * Serializes the current target into a Serialization object
  22831. * @returns the serialized object
  22832. */
  22833. serialize(): any;
  22834. /**
  22835. * Returns the string "MorphTarget"
  22836. * @returns "MorphTarget"
  22837. */
  22838. getClassName(): string;
  22839. /**
  22840. * Creates a new target from serialized data
  22841. * @param serializationObject defines the serialized data to use
  22842. * @returns a new MorphTarget
  22843. */
  22844. static Parse(serializationObject: any): MorphTarget;
  22845. /**
  22846. * Creates a MorphTarget from mesh data
  22847. * @param mesh defines the source mesh
  22848. * @param name defines the name to use for the new target
  22849. * @param influence defines the influence to attach to the target
  22850. * @returns a new MorphTarget
  22851. */
  22852. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22853. }
  22854. }
  22855. declare module "babylonjs/Morph/morphTargetManager" {
  22856. import { Nullable } from "babylonjs/types";
  22857. import { Scene } from "babylonjs/scene";
  22858. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22859. /**
  22860. * This class is used to deform meshes using morphing between different targets
  22861. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22862. */
  22863. export class MorphTargetManager {
  22864. private _targets;
  22865. private _targetInfluenceChangedObservers;
  22866. private _targetDataLayoutChangedObservers;
  22867. private _activeTargets;
  22868. private _scene;
  22869. private _influences;
  22870. private _supportsNormals;
  22871. private _supportsTangents;
  22872. private _supportsUVs;
  22873. private _vertexCount;
  22874. private _uniqueId;
  22875. private _tempInfluences;
  22876. /**
  22877. * Gets or sets a boolean indicating if normals must be morphed
  22878. */
  22879. enableNormalMorphing: boolean;
  22880. /**
  22881. * Gets or sets a boolean indicating if tangents must be morphed
  22882. */
  22883. enableTangentMorphing: boolean;
  22884. /**
  22885. * Gets or sets a boolean indicating if UV must be morphed
  22886. */
  22887. enableUVMorphing: boolean;
  22888. /**
  22889. * Creates a new MorphTargetManager
  22890. * @param scene defines the current scene
  22891. */
  22892. constructor(scene?: Nullable<Scene>);
  22893. /**
  22894. * Gets the unique ID of this manager
  22895. */
  22896. readonly uniqueId: number;
  22897. /**
  22898. * Gets the number of vertices handled by this manager
  22899. */
  22900. readonly vertexCount: number;
  22901. /**
  22902. * Gets a boolean indicating if this manager supports morphing of normals
  22903. */
  22904. readonly supportsNormals: boolean;
  22905. /**
  22906. * Gets a boolean indicating if this manager supports morphing of tangents
  22907. */
  22908. readonly supportsTangents: boolean;
  22909. /**
  22910. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22911. */
  22912. readonly supportsUVs: boolean;
  22913. /**
  22914. * Gets the number of targets stored in this manager
  22915. */
  22916. readonly numTargets: number;
  22917. /**
  22918. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22919. */
  22920. readonly numInfluencers: number;
  22921. /**
  22922. * Gets the list of influences (one per target)
  22923. */
  22924. readonly influences: Float32Array;
  22925. /**
  22926. * Gets the active target at specified index. An active target is a target with an influence > 0
  22927. * @param index defines the index to check
  22928. * @returns the requested target
  22929. */
  22930. getActiveTarget(index: number): MorphTarget;
  22931. /**
  22932. * Gets the target at specified index
  22933. * @param index defines the index to check
  22934. * @returns the requested target
  22935. */
  22936. getTarget(index: number): MorphTarget;
  22937. /**
  22938. * Add a new target to this manager
  22939. * @param target defines the target to add
  22940. */
  22941. addTarget(target: MorphTarget): void;
  22942. /**
  22943. * Removes a target from the manager
  22944. * @param target defines the target to remove
  22945. */
  22946. removeTarget(target: MorphTarget): void;
  22947. /**
  22948. * Serializes the current manager into a Serialization object
  22949. * @returns the serialized object
  22950. */
  22951. serialize(): any;
  22952. private _syncActiveTargets;
  22953. /**
  22954. * Syncrhonize the targets with all the meshes using this morph target manager
  22955. */
  22956. synchronize(): void;
  22957. /**
  22958. * Creates a new MorphTargetManager from serialized data
  22959. * @param serializationObject defines the serialized data
  22960. * @param scene defines the hosting scene
  22961. * @returns the new MorphTargetManager
  22962. */
  22963. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22964. }
  22965. }
  22966. declare module "babylonjs/Meshes/meshLODLevel" {
  22967. import { Mesh } from "babylonjs/Meshes/mesh";
  22968. import { Nullable } from "babylonjs/types";
  22969. /**
  22970. * Class used to represent a specific level of detail of a mesh
  22971. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22972. */
  22973. export class MeshLODLevel {
  22974. /** Defines the distance where this level should start being displayed */
  22975. distance: number;
  22976. /** Defines the mesh to use to render this level */
  22977. mesh: Nullable<Mesh>;
  22978. /**
  22979. * Creates a new LOD level
  22980. * @param distance defines the distance where this level should star being displayed
  22981. * @param mesh defines the mesh to use to render this level
  22982. */
  22983. constructor(
  22984. /** Defines the distance where this level should start being displayed */
  22985. distance: number,
  22986. /** Defines the mesh to use to render this level */
  22987. mesh: Nullable<Mesh>);
  22988. }
  22989. }
  22990. declare module "babylonjs/Meshes/groundMesh" {
  22991. import { Scene } from "babylonjs/scene";
  22992. import { Vector3 } from "babylonjs/Maths/math.vector";
  22993. import { Mesh } from "babylonjs/Meshes/mesh";
  22994. /**
  22995. * Mesh representing the gorund
  22996. */
  22997. export class GroundMesh extends Mesh {
  22998. /** If octree should be generated */
  22999. generateOctree: boolean;
  23000. private _heightQuads;
  23001. /** @hidden */
  23002. _subdivisionsX: number;
  23003. /** @hidden */
  23004. _subdivisionsY: number;
  23005. /** @hidden */
  23006. _width: number;
  23007. /** @hidden */
  23008. _height: number;
  23009. /** @hidden */
  23010. _minX: number;
  23011. /** @hidden */
  23012. _maxX: number;
  23013. /** @hidden */
  23014. _minZ: number;
  23015. /** @hidden */
  23016. _maxZ: number;
  23017. constructor(name: string, scene: Scene);
  23018. /**
  23019. * "GroundMesh"
  23020. * @returns "GroundMesh"
  23021. */
  23022. getClassName(): string;
  23023. /**
  23024. * The minimum of x and y subdivisions
  23025. */
  23026. readonly subdivisions: number;
  23027. /**
  23028. * X subdivisions
  23029. */
  23030. readonly subdivisionsX: number;
  23031. /**
  23032. * Y subdivisions
  23033. */
  23034. readonly subdivisionsY: number;
  23035. /**
  23036. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23037. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23038. * @param chunksCount the number of subdivisions for x and y
  23039. * @param octreeBlocksSize (Default: 32)
  23040. */
  23041. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23042. /**
  23043. * Returns a height (y) value in the Worl system :
  23044. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23045. * @param x x coordinate
  23046. * @param z z coordinate
  23047. * @returns the ground y position if (x, z) are outside the ground surface.
  23048. */
  23049. getHeightAtCoordinates(x: number, z: number): number;
  23050. /**
  23051. * Returns a normalized vector (Vector3) orthogonal to the ground
  23052. * at the ground coordinates (x, z) expressed in the World system.
  23053. * @param x x coordinate
  23054. * @param z z coordinate
  23055. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23056. */
  23057. getNormalAtCoordinates(x: number, z: number): Vector3;
  23058. /**
  23059. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23060. * at the ground coordinates (x, z) expressed in the World system.
  23061. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23062. * @param x x coordinate
  23063. * @param z z coordinate
  23064. * @param ref vector to store the result
  23065. * @returns the GroundMesh.
  23066. */
  23067. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23068. /**
  23069. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23070. * if the ground has been updated.
  23071. * This can be used in the render loop.
  23072. * @returns the GroundMesh.
  23073. */
  23074. updateCoordinateHeights(): GroundMesh;
  23075. private _getFacetAt;
  23076. private _initHeightQuads;
  23077. private _computeHeightQuads;
  23078. /**
  23079. * Serializes this ground mesh
  23080. * @param serializationObject object to write serialization to
  23081. */
  23082. serialize(serializationObject: any): void;
  23083. /**
  23084. * Parses a serialized ground mesh
  23085. * @param parsedMesh the serialized mesh
  23086. * @param scene the scene to create the ground mesh in
  23087. * @returns the created ground mesh
  23088. */
  23089. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23090. }
  23091. }
  23092. declare module "babylonjs/Physics/physicsJoint" {
  23093. import { Vector3 } from "babylonjs/Maths/math.vector";
  23094. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23095. /**
  23096. * Interface for Physics-Joint data
  23097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23098. */
  23099. export interface PhysicsJointData {
  23100. /**
  23101. * The main pivot of the joint
  23102. */
  23103. mainPivot?: Vector3;
  23104. /**
  23105. * The connected pivot of the joint
  23106. */
  23107. connectedPivot?: Vector3;
  23108. /**
  23109. * The main axis of the joint
  23110. */
  23111. mainAxis?: Vector3;
  23112. /**
  23113. * The connected axis of the joint
  23114. */
  23115. connectedAxis?: Vector3;
  23116. /**
  23117. * The collision of the joint
  23118. */
  23119. collision?: boolean;
  23120. /**
  23121. * Native Oimo/Cannon/Energy data
  23122. */
  23123. nativeParams?: any;
  23124. }
  23125. /**
  23126. * This is a holder class for the physics joint created by the physics plugin
  23127. * It holds a set of functions to control the underlying joint
  23128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23129. */
  23130. export class PhysicsJoint {
  23131. /**
  23132. * The type of the physics joint
  23133. */
  23134. type: number;
  23135. /**
  23136. * The data for the physics joint
  23137. */
  23138. jointData: PhysicsJointData;
  23139. private _physicsJoint;
  23140. protected _physicsPlugin: IPhysicsEnginePlugin;
  23141. /**
  23142. * Initializes the physics joint
  23143. * @param type The type of the physics joint
  23144. * @param jointData The data for the physics joint
  23145. */
  23146. constructor(
  23147. /**
  23148. * The type of the physics joint
  23149. */
  23150. type: number,
  23151. /**
  23152. * The data for the physics joint
  23153. */
  23154. jointData: PhysicsJointData);
  23155. /**
  23156. * Gets the physics joint
  23157. */
  23158. /**
  23159. * Sets the physics joint
  23160. */
  23161. physicsJoint: any;
  23162. /**
  23163. * Sets the physics plugin
  23164. */
  23165. physicsPlugin: IPhysicsEnginePlugin;
  23166. /**
  23167. * Execute a function that is physics-plugin specific.
  23168. * @param {Function} func the function that will be executed.
  23169. * It accepts two parameters: the physics world and the physics joint
  23170. */
  23171. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23172. /**
  23173. * Distance-Joint type
  23174. */
  23175. static DistanceJoint: number;
  23176. /**
  23177. * Hinge-Joint type
  23178. */
  23179. static HingeJoint: number;
  23180. /**
  23181. * Ball-and-Socket joint type
  23182. */
  23183. static BallAndSocketJoint: number;
  23184. /**
  23185. * Wheel-Joint type
  23186. */
  23187. static WheelJoint: number;
  23188. /**
  23189. * Slider-Joint type
  23190. */
  23191. static SliderJoint: number;
  23192. /**
  23193. * Prismatic-Joint type
  23194. */
  23195. static PrismaticJoint: number;
  23196. /**
  23197. * Universal-Joint type
  23198. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23199. */
  23200. static UniversalJoint: number;
  23201. /**
  23202. * Hinge-Joint 2 type
  23203. */
  23204. static Hinge2Joint: number;
  23205. /**
  23206. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23207. */
  23208. static PointToPointJoint: number;
  23209. /**
  23210. * Spring-Joint type
  23211. */
  23212. static SpringJoint: number;
  23213. /**
  23214. * Lock-Joint type
  23215. */
  23216. static LockJoint: number;
  23217. }
  23218. /**
  23219. * A class representing a physics distance joint
  23220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23221. */
  23222. export class DistanceJoint extends PhysicsJoint {
  23223. /**
  23224. *
  23225. * @param jointData The data for the Distance-Joint
  23226. */
  23227. constructor(jointData: DistanceJointData);
  23228. /**
  23229. * Update the predefined distance.
  23230. * @param maxDistance The maximum preferred distance
  23231. * @param minDistance The minimum preferred distance
  23232. */
  23233. updateDistance(maxDistance: number, minDistance?: number): void;
  23234. }
  23235. /**
  23236. * Represents a Motor-Enabled Joint
  23237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23238. */
  23239. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23240. /**
  23241. * Initializes the Motor-Enabled Joint
  23242. * @param type The type of the joint
  23243. * @param jointData The physica joint data for the joint
  23244. */
  23245. constructor(type: number, jointData: PhysicsJointData);
  23246. /**
  23247. * Set the motor values.
  23248. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23249. * @param force the force to apply
  23250. * @param maxForce max force for this motor.
  23251. */
  23252. setMotor(force?: number, maxForce?: number): void;
  23253. /**
  23254. * Set the motor's limits.
  23255. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23256. * @param upperLimit The upper limit of the motor
  23257. * @param lowerLimit The lower limit of the motor
  23258. */
  23259. setLimit(upperLimit: number, lowerLimit?: number): void;
  23260. }
  23261. /**
  23262. * This class represents a single physics Hinge-Joint
  23263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23264. */
  23265. export class HingeJoint extends MotorEnabledJoint {
  23266. /**
  23267. * Initializes the Hinge-Joint
  23268. * @param jointData The joint data for the Hinge-Joint
  23269. */
  23270. constructor(jointData: PhysicsJointData);
  23271. /**
  23272. * Set the motor values.
  23273. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23274. * @param {number} force the force to apply
  23275. * @param {number} maxForce max force for this motor.
  23276. */
  23277. setMotor(force?: number, maxForce?: number): void;
  23278. /**
  23279. * Set the motor's limits.
  23280. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23281. * @param upperLimit The upper limit of the motor
  23282. * @param lowerLimit The lower limit of the motor
  23283. */
  23284. setLimit(upperLimit: number, lowerLimit?: number): void;
  23285. }
  23286. /**
  23287. * This class represents a dual hinge physics joint (same as wheel joint)
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export class Hinge2Joint extends MotorEnabledJoint {
  23291. /**
  23292. * Initializes the Hinge2-Joint
  23293. * @param jointData The joint data for the Hinge2-Joint
  23294. */
  23295. constructor(jointData: PhysicsJointData);
  23296. /**
  23297. * Set the motor values.
  23298. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23299. * @param {number} targetSpeed the speed the motor is to reach
  23300. * @param {number} maxForce max force for this motor.
  23301. * @param {motorIndex} the motor's index, 0 or 1.
  23302. */
  23303. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23304. /**
  23305. * Set the motor limits.
  23306. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23307. * @param {number} upperLimit the upper limit
  23308. * @param {number} lowerLimit lower limit
  23309. * @param {motorIndex} the motor's index, 0 or 1.
  23310. */
  23311. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23312. }
  23313. /**
  23314. * Interface for a motor enabled joint
  23315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23316. */
  23317. export interface IMotorEnabledJoint {
  23318. /**
  23319. * Physics joint
  23320. */
  23321. physicsJoint: any;
  23322. /**
  23323. * Sets the motor of the motor-enabled joint
  23324. * @param force The force of the motor
  23325. * @param maxForce The maximum force of the motor
  23326. * @param motorIndex The index of the motor
  23327. */
  23328. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23329. /**
  23330. * Sets the limit of the motor
  23331. * @param upperLimit The upper limit of the motor
  23332. * @param lowerLimit The lower limit of the motor
  23333. * @param motorIndex The index of the motor
  23334. */
  23335. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23336. }
  23337. /**
  23338. * Joint data for a Distance-Joint
  23339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23340. */
  23341. export interface DistanceJointData extends PhysicsJointData {
  23342. /**
  23343. * Max distance the 2 joint objects can be apart
  23344. */
  23345. maxDistance: number;
  23346. }
  23347. /**
  23348. * Joint data from a spring joint
  23349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23350. */
  23351. export interface SpringJointData extends PhysicsJointData {
  23352. /**
  23353. * Length of the spring
  23354. */
  23355. length: number;
  23356. /**
  23357. * Stiffness of the spring
  23358. */
  23359. stiffness: number;
  23360. /**
  23361. * Damping of the spring
  23362. */
  23363. damping: number;
  23364. /** this callback will be called when applying the force to the impostors. */
  23365. forceApplicationCallback: () => void;
  23366. }
  23367. }
  23368. declare module "babylonjs/Physics/physicsRaycastResult" {
  23369. import { Vector3 } from "babylonjs/Maths/math.vector";
  23370. /**
  23371. * Holds the data for the raycast result
  23372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23373. */
  23374. export class PhysicsRaycastResult {
  23375. private _hasHit;
  23376. private _hitDistance;
  23377. private _hitNormalWorld;
  23378. private _hitPointWorld;
  23379. private _rayFromWorld;
  23380. private _rayToWorld;
  23381. /**
  23382. * Gets if there was a hit
  23383. */
  23384. readonly hasHit: boolean;
  23385. /**
  23386. * Gets the distance from the hit
  23387. */
  23388. readonly hitDistance: number;
  23389. /**
  23390. * Gets the hit normal/direction in the world
  23391. */
  23392. readonly hitNormalWorld: Vector3;
  23393. /**
  23394. * Gets the hit point in the world
  23395. */
  23396. readonly hitPointWorld: Vector3;
  23397. /**
  23398. * Gets the ray "start point" of the ray in the world
  23399. */
  23400. readonly rayFromWorld: Vector3;
  23401. /**
  23402. * Gets the ray "end point" of the ray in the world
  23403. */
  23404. readonly rayToWorld: Vector3;
  23405. /**
  23406. * Sets the hit data (normal & point in world space)
  23407. * @param hitNormalWorld defines the normal in world space
  23408. * @param hitPointWorld defines the point in world space
  23409. */
  23410. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23411. /**
  23412. * Sets the distance from the start point to the hit point
  23413. * @param distance
  23414. */
  23415. setHitDistance(distance: number): void;
  23416. /**
  23417. * Calculates the distance manually
  23418. */
  23419. calculateHitDistance(): void;
  23420. /**
  23421. * Resets all the values to default
  23422. * @param from The from point on world space
  23423. * @param to The to point on world space
  23424. */
  23425. reset(from?: Vector3, to?: Vector3): void;
  23426. }
  23427. /**
  23428. * Interface for the size containing width and height
  23429. */
  23430. interface IXYZ {
  23431. /**
  23432. * X
  23433. */
  23434. x: number;
  23435. /**
  23436. * Y
  23437. */
  23438. y: number;
  23439. /**
  23440. * Z
  23441. */
  23442. z: number;
  23443. }
  23444. }
  23445. declare module "babylonjs/Physics/IPhysicsEngine" {
  23446. import { Nullable } from "babylonjs/types";
  23447. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23449. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23450. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23451. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23452. /**
  23453. * Interface used to describe a physics joint
  23454. */
  23455. export interface PhysicsImpostorJoint {
  23456. /** Defines the main impostor to which the joint is linked */
  23457. mainImpostor: PhysicsImpostor;
  23458. /** Defines the impostor that is connected to the main impostor using this joint */
  23459. connectedImpostor: PhysicsImpostor;
  23460. /** Defines the joint itself */
  23461. joint: PhysicsJoint;
  23462. }
  23463. /** @hidden */
  23464. export interface IPhysicsEnginePlugin {
  23465. world: any;
  23466. name: string;
  23467. setGravity(gravity: Vector3): void;
  23468. setTimeStep(timeStep: number): void;
  23469. getTimeStep(): number;
  23470. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23471. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23472. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23473. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23474. removePhysicsBody(impostor: PhysicsImpostor): void;
  23475. generateJoint(joint: PhysicsImpostorJoint): void;
  23476. removeJoint(joint: PhysicsImpostorJoint): void;
  23477. isSupported(): boolean;
  23478. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23480. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23481. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23482. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23483. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23484. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23485. getBodyMass(impostor: PhysicsImpostor): number;
  23486. getBodyFriction(impostor: PhysicsImpostor): number;
  23487. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23488. getBodyRestitution(impostor: PhysicsImpostor): number;
  23489. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23490. getBodyPressure?(impostor: PhysicsImpostor): number;
  23491. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23492. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23493. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23494. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23495. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23496. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23497. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23498. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23499. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23500. sleepBody(impostor: PhysicsImpostor): void;
  23501. wakeUpBody(impostor: PhysicsImpostor): void;
  23502. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23503. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23504. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23505. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23506. getRadius(impostor: PhysicsImpostor): number;
  23507. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23508. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23509. dispose(): void;
  23510. }
  23511. /**
  23512. * Interface used to define a physics engine
  23513. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23514. */
  23515. export interface IPhysicsEngine {
  23516. /**
  23517. * Gets the gravity vector used by the simulation
  23518. */
  23519. gravity: Vector3;
  23520. /**
  23521. * Sets the gravity vector used by the simulation
  23522. * @param gravity defines the gravity vector to use
  23523. */
  23524. setGravity(gravity: Vector3): void;
  23525. /**
  23526. * Set the time step of the physics engine.
  23527. * Default is 1/60.
  23528. * To slow it down, enter 1/600 for example.
  23529. * To speed it up, 1/30
  23530. * @param newTimeStep the new timestep to apply to this world.
  23531. */
  23532. setTimeStep(newTimeStep: number): void;
  23533. /**
  23534. * Get the time step of the physics engine.
  23535. * @returns the current time step
  23536. */
  23537. getTimeStep(): number;
  23538. /**
  23539. * Release all resources
  23540. */
  23541. dispose(): void;
  23542. /**
  23543. * Gets the name of the current physics plugin
  23544. * @returns the name of the plugin
  23545. */
  23546. getPhysicsPluginName(): string;
  23547. /**
  23548. * Adding a new impostor for the impostor tracking.
  23549. * This will be done by the impostor itself.
  23550. * @param impostor the impostor to add
  23551. */
  23552. addImpostor(impostor: PhysicsImpostor): void;
  23553. /**
  23554. * Remove an impostor from the engine.
  23555. * This impostor and its mesh will not longer be updated by the physics engine.
  23556. * @param impostor the impostor to remove
  23557. */
  23558. removeImpostor(impostor: PhysicsImpostor): void;
  23559. /**
  23560. * Add a joint to the physics engine
  23561. * @param mainImpostor defines the main impostor to which the joint is added.
  23562. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23563. * @param joint defines the joint that will connect both impostors.
  23564. */
  23565. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23566. /**
  23567. * Removes a joint from the simulation
  23568. * @param mainImpostor defines the impostor used with the joint
  23569. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23570. * @param joint defines the joint to remove
  23571. */
  23572. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23573. /**
  23574. * Gets the current plugin used to run the simulation
  23575. * @returns current plugin
  23576. */
  23577. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23578. /**
  23579. * Gets the list of physic impostors
  23580. * @returns an array of PhysicsImpostor
  23581. */
  23582. getImpostors(): Array<PhysicsImpostor>;
  23583. /**
  23584. * Gets the impostor for a physics enabled object
  23585. * @param object defines the object impersonated by the impostor
  23586. * @returns the PhysicsImpostor or null if not found
  23587. */
  23588. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23589. /**
  23590. * Gets the impostor for a physics body object
  23591. * @param body defines physics body used by the impostor
  23592. * @returns the PhysicsImpostor or null if not found
  23593. */
  23594. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23595. /**
  23596. * Does a raycast in the physics world
  23597. * @param from when should the ray start?
  23598. * @param to when should the ray end?
  23599. * @returns PhysicsRaycastResult
  23600. */
  23601. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23602. /**
  23603. * Called by the scene. No need to call it.
  23604. * @param delta defines the timespam between frames
  23605. */
  23606. _step(delta: number): void;
  23607. }
  23608. }
  23609. declare module "babylonjs/Physics/physicsImpostor" {
  23610. import { Nullable, IndicesArray } from "babylonjs/types";
  23611. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23612. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23614. import { Scene } from "babylonjs/scene";
  23615. import { Bone } from "babylonjs/Bones/bone";
  23616. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23617. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23618. import { Space } from "babylonjs/Maths/math.axis";
  23619. /**
  23620. * The interface for the physics imposter parameters
  23621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23622. */
  23623. export interface PhysicsImpostorParameters {
  23624. /**
  23625. * The mass of the physics imposter
  23626. */
  23627. mass: number;
  23628. /**
  23629. * The friction of the physics imposter
  23630. */
  23631. friction?: number;
  23632. /**
  23633. * The coefficient of restitution of the physics imposter
  23634. */
  23635. restitution?: number;
  23636. /**
  23637. * The native options of the physics imposter
  23638. */
  23639. nativeOptions?: any;
  23640. /**
  23641. * Specifies if the parent should be ignored
  23642. */
  23643. ignoreParent?: boolean;
  23644. /**
  23645. * Specifies if bi-directional transformations should be disabled
  23646. */
  23647. disableBidirectionalTransformation?: boolean;
  23648. /**
  23649. * The pressure inside the physics imposter, soft object only
  23650. */
  23651. pressure?: number;
  23652. /**
  23653. * The stiffness the physics imposter, soft object only
  23654. */
  23655. stiffness?: number;
  23656. /**
  23657. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23658. */
  23659. velocityIterations?: number;
  23660. /**
  23661. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23662. */
  23663. positionIterations?: number;
  23664. /**
  23665. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23666. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23667. * Add to fix multiple points
  23668. */
  23669. fixedPoints?: number;
  23670. /**
  23671. * The collision margin around a soft object
  23672. */
  23673. margin?: number;
  23674. /**
  23675. * The collision margin around a soft object
  23676. */
  23677. damping?: number;
  23678. /**
  23679. * The path for a rope based on an extrusion
  23680. */
  23681. path?: any;
  23682. /**
  23683. * The shape of an extrusion used for a rope based on an extrusion
  23684. */
  23685. shape?: any;
  23686. }
  23687. /**
  23688. * Interface for a physics-enabled object
  23689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23690. */
  23691. export interface IPhysicsEnabledObject {
  23692. /**
  23693. * The position of the physics-enabled object
  23694. */
  23695. position: Vector3;
  23696. /**
  23697. * The rotation of the physics-enabled object
  23698. */
  23699. rotationQuaternion: Nullable<Quaternion>;
  23700. /**
  23701. * The scale of the physics-enabled object
  23702. */
  23703. scaling: Vector3;
  23704. /**
  23705. * The rotation of the physics-enabled object
  23706. */
  23707. rotation?: Vector3;
  23708. /**
  23709. * The parent of the physics-enabled object
  23710. */
  23711. parent?: any;
  23712. /**
  23713. * The bounding info of the physics-enabled object
  23714. * @returns The bounding info of the physics-enabled object
  23715. */
  23716. getBoundingInfo(): BoundingInfo;
  23717. /**
  23718. * Computes the world matrix
  23719. * @param force Specifies if the world matrix should be computed by force
  23720. * @returns A world matrix
  23721. */
  23722. computeWorldMatrix(force: boolean): Matrix;
  23723. /**
  23724. * Gets the world matrix
  23725. * @returns A world matrix
  23726. */
  23727. getWorldMatrix?(): Matrix;
  23728. /**
  23729. * Gets the child meshes
  23730. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23731. * @returns An array of abstract meshes
  23732. */
  23733. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23734. /**
  23735. * Gets the vertex data
  23736. * @param kind The type of vertex data
  23737. * @returns A nullable array of numbers, or a float32 array
  23738. */
  23739. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23740. /**
  23741. * Gets the indices from the mesh
  23742. * @returns A nullable array of index arrays
  23743. */
  23744. getIndices?(): Nullable<IndicesArray>;
  23745. /**
  23746. * Gets the scene from the mesh
  23747. * @returns the indices array or null
  23748. */
  23749. getScene?(): Scene;
  23750. /**
  23751. * Gets the absolute position from the mesh
  23752. * @returns the absolute position
  23753. */
  23754. getAbsolutePosition(): Vector3;
  23755. /**
  23756. * Gets the absolute pivot point from the mesh
  23757. * @returns the absolute pivot point
  23758. */
  23759. getAbsolutePivotPoint(): Vector3;
  23760. /**
  23761. * Rotates the mesh
  23762. * @param axis The axis of rotation
  23763. * @param amount The amount of rotation
  23764. * @param space The space of the rotation
  23765. * @returns The rotation transform node
  23766. */
  23767. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23768. /**
  23769. * Translates the mesh
  23770. * @param axis The axis of translation
  23771. * @param distance The distance of translation
  23772. * @param space The space of the translation
  23773. * @returns The transform node
  23774. */
  23775. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23776. /**
  23777. * Sets the absolute position of the mesh
  23778. * @param absolutePosition The absolute position of the mesh
  23779. * @returns The transform node
  23780. */
  23781. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23782. /**
  23783. * Gets the class name of the mesh
  23784. * @returns The class name
  23785. */
  23786. getClassName(): string;
  23787. }
  23788. /**
  23789. * Represents a physics imposter
  23790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23791. */
  23792. export class PhysicsImpostor {
  23793. /**
  23794. * The physics-enabled object used as the physics imposter
  23795. */
  23796. object: IPhysicsEnabledObject;
  23797. /**
  23798. * The type of the physics imposter
  23799. */
  23800. type: number;
  23801. private _options;
  23802. private _scene?;
  23803. /**
  23804. * The default object size of the imposter
  23805. */
  23806. static DEFAULT_OBJECT_SIZE: Vector3;
  23807. /**
  23808. * The identity quaternion of the imposter
  23809. */
  23810. static IDENTITY_QUATERNION: Quaternion;
  23811. /** @hidden */
  23812. _pluginData: any;
  23813. private _physicsEngine;
  23814. private _physicsBody;
  23815. private _bodyUpdateRequired;
  23816. private _onBeforePhysicsStepCallbacks;
  23817. private _onAfterPhysicsStepCallbacks;
  23818. /** @hidden */
  23819. _onPhysicsCollideCallbacks: Array<{
  23820. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23821. otherImpostors: Array<PhysicsImpostor>;
  23822. }>;
  23823. private _deltaPosition;
  23824. private _deltaRotation;
  23825. private _deltaRotationConjugated;
  23826. /** @hidden */
  23827. _isFromLine: boolean;
  23828. private _parent;
  23829. private _isDisposed;
  23830. private static _tmpVecs;
  23831. private static _tmpQuat;
  23832. /**
  23833. * Specifies if the physics imposter is disposed
  23834. */
  23835. readonly isDisposed: boolean;
  23836. /**
  23837. * Gets the mass of the physics imposter
  23838. */
  23839. mass: number;
  23840. /**
  23841. * Gets the coefficient of friction
  23842. */
  23843. /**
  23844. * Sets the coefficient of friction
  23845. */
  23846. friction: number;
  23847. /**
  23848. * Gets the coefficient of restitution
  23849. */
  23850. /**
  23851. * Sets the coefficient of restitution
  23852. */
  23853. restitution: number;
  23854. /**
  23855. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23856. */
  23857. /**
  23858. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23859. */
  23860. pressure: number;
  23861. /**
  23862. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23863. */
  23864. /**
  23865. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23866. */
  23867. stiffness: number;
  23868. /**
  23869. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23870. */
  23871. /**
  23872. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23873. */
  23874. velocityIterations: number;
  23875. /**
  23876. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23877. */
  23878. /**
  23879. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23880. */
  23881. positionIterations: number;
  23882. /**
  23883. * The unique id of the physics imposter
  23884. * set by the physics engine when adding this impostor to the array
  23885. */
  23886. uniqueId: number;
  23887. /**
  23888. * @hidden
  23889. */
  23890. soft: boolean;
  23891. /**
  23892. * @hidden
  23893. */
  23894. segments: number;
  23895. private _joints;
  23896. /**
  23897. * Initializes the physics imposter
  23898. * @param object The physics-enabled object used as the physics imposter
  23899. * @param type The type of the physics imposter
  23900. * @param _options The options for the physics imposter
  23901. * @param _scene The Babylon scene
  23902. */
  23903. constructor(
  23904. /**
  23905. * The physics-enabled object used as the physics imposter
  23906. */
  23907. object: IPhysicsEnabledObject,
  23908. /**
  23909. * The type of the physics imposter
  23910. */
  23911. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23912. /**
  23913. * This function will completly initialize this impostor.
  23914. * It will create a new body - but only if this mesh has no parent.
  23915. * If it has, this impostor will not be used other than to define the impostor
  23916. * of the child mesh.
  23917. * @hidden
  23918. */
  23919. _init(): void;
  23920. private _getPhysicsParent;
  23921. /**
  23922. * Should a new body be generated.
  23923. * @returns boolean specifying if body initialization is required
  23924. */
  23925. isBodyInitRequired(): boolean;
  23926. /**
  23927. * Sets the updated scaling
  23928. * @param updated Specifies if the scaling is updated
  23929. */
  23930. setScalingUpdated(): void;
  23931. /**
  23932. * Force a regeneration of this or the parent's impostor's body.
  23933. * Use under cautious - This will remove all joints already implemented.
  23934. */
  23935. forceUpdate(): void;
  23936. /**
  23937. * Gets the body that holds this impostor. Either its own, or its parent.
  23938. */
  23939. /**
  23940. * Set the physics body. Used mainly by the physics engine/plugin
  23941. */
  23942. physicsBody: any;
  23943. /**
  23944. * Get the parent of the physics imposter
  23945. * @returns Physics imposter or null
  23946. */
  23947. /**
  23948. * Sets the parent of the physics imposter
  23949. */
  23950. parent: Nullable<PhysicsImpostor>;
  23951. /**
  23952. * Resets the update flags
  23953. */
  23954. resetUpdateFlags(): void;
  23955. /**
  23956. * Gets the object extend size
  23957. * @returns the object extend size
  23958. */
  23959. getObjectExtendSize(): Vector3;
  23960. /**
  23961. * Gets the object center
  23962. * @returns The object center
  23963. */
  23964. getObjectCenter(): Vector3;
  23965. /**
  23966. * Get a specific parametes from the options parameter
  23967. * @param paramName The object parameter name
  23968. * @returns The object parameter
  23969. */
  23970. getParam(paramName: string): any;
  23971. /**
  23972. * Sets a specific parameter in the options given to the physics plugin
  23973. * @param paramName The parameter name
  23974. * @param value The value of the parameter
  23975. */
  23976. setParam(paramName: string, value: number): void;
  23977. /**
  23978. * Specifically change the body's mass option. Won't recreate the physics body object
  23979. * @param mass The mass of the physics imposter
  23980. */
  23981. setMass(mass: number): void;
  23982. /**
  23983. * Gets the linear velocity
  23984. * @returns linear velocity or null
  23985. */
  23986. getLinearVelocity(): Nullable<Vector3>;
  23987. /**
  23988. * Sets the linear velocity
  23989. * @param velocity linear velocity or null
  23990. */
  23991. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23992. /**
  23993. * Gets the angular velocity
  23994. * @returns angular velocity or null
  23995. */
  23996. getAngularVelocity(): Nullable<Vector3>;
  23997. /**
  23998. * Sets the angular velocity
  23999. * @param velocity The velocity or null
  24000. */
  24001. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24002. /**
  24003. * Execute a function with the physics plugin native code
  24004. * Provide a function the will have two variables - the world object and the physics body object
  24005. * @param func The function to execute with the physics plugin native code
  24006. */
  24007. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24008. /**
  24009. * Register a function that will be executed before the physics world is stepping forward
  24010. * @param func The function to execute before the physics world is stepped forward
  24011. */
  24012. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24013. /**
  24014. * Unregister a function that will be executed before the physics world is stepping forward
  24015. * @param func The function to execute before the physics world is stepped forward
  24016. */
  24017. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24018. /**
  24019. * Register a function that will be executed after the physics step
  24020. * @param func The function to execute after physics step
  24021. */
  24022. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24023. /**
  24024. * Unregisters a function that will be executed after the physics step
  24025. * @param func The function to execute after physics step
  24026. */
  24027. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24028. /**
  24029. * register a function that will be executed when this impostor collides against a different body
  24030. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24031. * @param func Callback that is executed on collision
  24032. */
  24033. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24034. /**
  24035. * Unregisters the physics imposter on contact
  24036. * @param collideAgainst The physics object to collide against
  24037. * @param func Callback to execute on collision
  24038. */
  24039. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24040. private _tmpQuat;
  24041. private _tmpQuat2;
  24042. /**
  24043. * Get the parent rotation
  24044. * @returns The parent rotation
  24045. */
  24046. getParentsRotation(): Quaternion;
  24047. /**
  24048. * this function is executed by the physics engine.
  24049. */
  24050. beforeStep: () => void;
  24051. /**
  24052. * this function is executed by the physics engine
  24053. */
  24054. afterStep: () => void;
  24055. /**
  24056. * Legacy collision detection event support
  24057. */
  24058. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24059. /**
  24060. * event and body object due to cannon's event-based architecture.
  24061. */
  24062. onCollide: (e: {
  24063. body: any;
  24064. }) => void;
  24065. /**
  24066. * Apply a force
  24067. * @param force The force to apply
  24068. * @param contactPoint The contact point for the force
  24069. * @returns The physics imposter
  24070. */
  24071. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24072. /**
  24073. * Apply an impulse
  24074. * @param force The impulse force
  24075. * @param contactPoint The contact point for the impulse force
  24076. * @returns The physics imposter
  24077. */
  24078. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24079. /**
  24080. * A help function to create a joint
  24081. * @param otherImpostor A physics imposter used to create a joint
  24082. * @param jointType The type of joint
  24083. * @param jointData The data for the joint
  24084. * @returns The physics imposter
  24085. */
  24086. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24087. /**
  24088. * Add a joint to this impostor with a different impostor
  24089. * @param otherImpostor A physics imposter used to add a joint
  24090. * @param joint The joint to add
  24091. * @returns The physics imposter
  24092. */
  24093. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24094. /**
  24095. * Add an anchor to a cloth impostor
  24096. * @param otherImpostor rigid impostor to anchor to
  24097. * @param width ratio across width from 0 to 1
  24098. * @param height ratio up height from 0 to 1
  24099. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24100. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24101. * @returns impostor the soft imposter
  24102. */
  24103. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24104. /**
  24105. * Add a hook to a rope impostor
  24106. * @param otherImpostor rigid impostor to anchor to
  24107. * @param length ratio across rope from 0 to 1
  24108. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24109. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24110. * @returns impostor the rope imposter
  24111. */
  24112. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24113. /**
  24114. * Will keep this body still, in a sleep mode.
  24115. * @returns the physics imposter
  24116. */
  24117. sleep(): PhysicsImpostor;
  24118. /**
  24119. * Wake the body up.
  24120. * @returns The physics imposter
  24121. */
  24122. wakeUp(): PhysicsImpostor;
  24123. /**
  24124. * Clones the physics imposter
  24125. * @param newObject The physics imposter clones to this physics-enabled object
  24126. * @returns A nullable physics imposter
  24127. */
  24128. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24129. /**
  24130. * Disposes the physics imposter
  24131. */
  24132. dispose(): void;
  24133. /**
  24134. * Sets the delta position
  24135. * @param position The delta position amount
  24136. */
  24137. setDeltaPosition(position: Vector3): void;
  24138. /**
  24139. * Sets the delta rotation
  24140. * @param rotation The delta rotation amount
  24141. */
  24142. setDeltaRotation(rotation: Quaternion): void;
  24143. /**
  24144. * Gets the box size of the physics imposter and stores the result in the input parameter
  24145. * @param result Stores the box size
  24146. * @returns The physics imposter
  24147. */
  24148. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24149. /**
  24150. * Gets the radius of the physics imposter
  24151. * @returns Radius of the physics imposter
  24152. */
  24153. getRadius(): number;
  24154. /**
  24155. * Sync a bone with this impostor
  24156. * @param bone The bone to sync to the impostor.
  24157. * @param boneMesh The mesh that the bone is influencing.
  24158. * @param jointPivot The pivot of the joint / bone in local space.
  24159. * @param distToJoint Optional distance from the impostor to the joint.
  24160. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24161. */
  24162. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24163. /**
  24164. * Sync impostor to a bone
  24165. * @param bone The bone that the impostor will be synced to.
  24166. * @param boneMesh The mesh that the bone is influencing.
  24167. * @param jointPivot The pivot of the joint / bone in local space.
  24168. * @param distToJoint Optional distance from the impostor to the joint.
  24169. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24170. * @param boneAxis Optional vector3 axis the bone is aligned with
  24171. */
  24172. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24173. /**
  24174. * No-Imposter type
  24175. */
  24176. static NoImpostor: number;
  24177. /**
  24178. * Sphere-Imposter type
  24179. */
  24180. static SphereImpostor: number;
  24181. /**
  24182. * Box-Imposter type
  24183. */
  24184. static BoxImpostor: number;
  24185. /**
  24186. * Plane-Imposter type
  24187. */
  24188. static PlaneImpostor: number;
  24189. /**
  24190. * Mesh-imposter type
  24191. */
  24192. static MeshImpostor: number;
  24193. /**
  24194. * Capsule-Impostor type (Ammo.js plugin only)
  24195. */
  24196. static CapsuleImpostor: number;
  24197. /**
  24198. * Cylinder-Imposter type
  24199. */
  24200. static CylinderImpostor: number;
  24201. /**
  24202. * Particle-Imposter type
  24203. */
  24204. static ParticleImpostor: number;
  24205. /**
  24206. * Heightmap-Imposter type
  24207. */
  24208. static HeightmapImpostor: number;
  24209. /**
  24210. * ConvexHull-Impostor type (Ammo.js plugin only)
  24211. */
  24212. static ConvexHullImpostor: number;
  24213. /**
  24214. * Rope-Imposter type
  24215. */
  24216. static RopeImpostor: number;
  24217. /**
  24218. * Cloth-Imposter type
  24219. */
  24220. static ClothImpostor: number;
  24221. /**
  24222. * Softbody-Imposter type
  24223. */
  24224. static SoftbodyImpostor: number;
  24225. }
  24226. }
  24227. declare module "babylonjs/Meshes/mesh" {
  24228. import { Observable } from "babylonjs/Misc/observable";
  24229. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24230. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24231. import { Camera } from "babylonjs/Cameras/camera";
  24232. import { Scene } from "babylonjs/scene";
  24233. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24234. import { Color4 } from "babylonjs/Maths/math.color";
  24235. import { Engine } from "babylonjs/Engines/engine";
  24236. import { Node } from "babylonjs/node";
  24237. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24238. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24239. import { Buffer } from "babylonjs/Meshes/buffer";
  24240. import { Geometry } from "babylonjs/Meshes/geometry";
  24241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24243. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24244. import { Effect } from "babylonjs/Materials/effect";
  24245. import { Material } from "babylonjs/Materials/material";
  24246. import { Skeleton } from "babylonjs/Bones/skeleton";
  24247. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24248. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24249. import { Path3D } from "babylonjs/Maths/math.path";
  24250. import { Plane } from "babylonjs/Maths/math.plane";
  24251. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24252. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24253. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24254. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24255. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24256. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24257. /**
  24258. * @hidden
  24259. **/
  24260. export class _CreationDataStorage {
  24261. closePath?: boolean;
  24262. closeArray?: boolean;
  24263. idx: number[];
  24264. dashSize: number;
  24265. gapSize: number;
  24266. path3D: Path3D;
  24267. pathArray: Vector3[][];
  24268. arc: number;
  24269. radius: number;
  24270. cap: number;
  24271. tessellation: number;
  24272. }
  24273. /**
  24274. * @hidden
  24275. **/
  24276. class _InstanceDataStorage {
  24277. visibleInstances: any;
  24278. batchCache: _InstancesBatch;
  24279. instancesBufferSize: number;
  24280. instancesBuffer: Nullable<Buffer>;
  24281. instancesData: Float32Array;
  24282. overridenInstanceCount: number;
  24283. isFrozen: boolean;
  24284. previousBatch: Nullable<_InstancesBatch>;
  24285. hardwareInstancedRendering: boolean;
  24286. sideOrientation: number;
  24287. }
  24288. /**
  24289. * @hidden
  24290. **/
  24291. export class _InstancesBatch {
  24292. mustReturn: boolean;
  24293. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24294. renderSelf: boolean[];
  24295. hardwareInstancedRendering: boolean[];
  24296. }
  24297. /**
  24298. * Class used to represent renderable models
  24299. */
  24300. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24301. /**
  24302. * Mesh side orientation : usually the external or front surface
  24303. */
  24304. static readonly FRONTSIDE: number;
  24305. /**
  24306. * Mesh side orientation : usually the internal or back surface
  24307. */
  24308. static readonly BACKSIDE: number;
  24309. /**
  24310. * Mesh side orientation : both internal and external or front and back surfaces
  24311. */
  24312. static readonly DOUBLESIDE: number;
  24313. /**
  24314. * Mesh side orientation : by default, `FRONTSIDE`
  24315. */
  24316. static readonly DEFAULTSIDE: number;
  24317. /**
  24318. * Mesh cap setting : no cap
  24319. */
  24320. static readonly NO_CAP: number;
  24321. /**
  24322. * Mesh cap setting : one cap at the beginning of the mesh
  24323. */
  24324. static readonly CAP_START: number;
  24325. /**
  24326. * Mesh cap setting : one cap at the end of the mesh
  24327. */
  24328. static readonly CAP_END: number;
  24329. /**
  24330. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24331. */
  24332. static readonly CAP_ALL: number;
  24333. /**
  24334. * Mesh pattern setting : no flip or rotate
  24335. */
  24336. static readonly NO_FLIP: number;
  24337. /**
  24338. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24339. */
  24340. static readonly FLIP_TILE: number;
  24341. /**
  24342. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24343. */
  24344. static readonly ROTATE_TILE: number;
  24345. /**
  24346. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24347. */
  24348. static readonly FLIP_ROW: number;
  24349. /**
  24350. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24351. */
  24352. static readonly ROTATE_ROW: number;
  24353. /**
  24354. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24355. */
  24356. static readonly FLIP_N_ROTATE_TILE: number;
  24357. /**
  24358. * Mesh pattern setting : rotate pattern and rotate
  24359. */
  24360. static readonly FLIP_N_ROTATE_ROW: number;
  24361. /**
  24362. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24363. */
  24364. static readonly CENTER: number;
  24365. /**
  24366. * Mesh tile positioning : part tiles on left
  24367. */
  24368. static readonly LEFT: number;
  24369. /**
  24370. * Mesh tile positioning : part tiles on right
  24371. */
  24372. static readonly RIGHT: number;
  24373. /**
  24374. * Mesh tile positioning : part tiles on top
  24375. */
  24376. static readonly TOP: number;
  24377. /**
  24378. * Mesh tile positioning : part tiles on bottom
  24379. */
  24380. static readonly BOTTOM: number;
  24381. /**
  24382. * Gets the default side orientation.
  24383. * @param orientation the orientation to value to attempt to get
  24384. * @returns the default orientation
  24385. * @hidden
  24386. */
  24387. static _GetDefaultSideOrientation(orientation?: number): number;
  24388. private _internalMeshDataInfo;
  24389. /**
  24390. * An event triggered before rendering the mesh
  24391. */
  24392. readonly onBeforeRenderObservable: Observable<Mesh>;
  24393. /**
  24394. * An event triggered before binding the mesh
  24395. */
  24396. readonly onBeforeBindObservable: Observable<Mesh>;
  24397. /**
  24398. * An event triggered after rendering the mesh
  24399. */
  24400. readonly onAfterRenderObservable: Observable<Mesh>;
  24401. /**
  24402. * An event triggered before drawing the mesh
  24403. */
  24404. readonly onBeforeDrawObservable: Observable<Mesh>;
  24405. private _onBeforeDrawObserver;
  24406. /**
  24407. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24408. */
  24409. onBeforeDraw: () => void;
  24410. readonly hasInstances: boolean;
  24411. /**
  24412. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24413. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24414. */
  24415. delayLoadState: number;
  24416. /**
  24417. * Gets the list of instances created from this mesh
  24418. * it is not supposed to be modified manually.
  24419. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24420. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24421. */
  24422. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24423. /**
  24424. * Gets the file containing delay loading data for this mesh
  24425. */
  24426. delayLoadingFile: string;
  24427. /** @hidden */
  24428. _binaryInfo: any;
  24429. /**
  24430. * User defined function used to change how LOD level selection is done
  24431. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24432. */
  24433. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24434. /**
  24435. * Gets or sets the morph target manager
  24436. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24437. */
  24438. morphTargetManager: Nullable<MorphTargetManager>;
  24439. /** @hidden */
  24440. _creationDataStorage: Nullable<_CreationDataStorage>;
  24441. /** @hidden */
  24442. _geometry: Nullable<Geometry>;
  24443. /** @hidden */
  24444. _delayInfo: Array<string>;
  24445. /** @hidden */
  24446. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24447. /** @hidden */
  24448. _instanceDataStorage: _InstanceDataStorage;
  24449. private _effectiveMaterial;
  24450. /** @hidden */
  24451. _shouldGenerateFlatShading: boolean;
  24452. /** @hidden */
  24453. _originalBuilderSideOrientation: number;
  24454. /**
  24455. * Use this property to change the original side orientation defined at construction time
  24456. */
  24457. overrideMaterialSideOrientation: Nullable<number>;
  24458. /**
  24459. * Gets the source mesh (the one used to clone this one from)
  24460. */
  24461. readonly source: Nullable<Mesh>;
  24462. /**
  24463. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24464. */
  24465. isUnIndexed: boolean;
  24466. /**
  24467. * @constructor
  24468. * @param name The value used by scene.getMeshByName() to do a lookup.
  24469. * @param scene The scene to add this mesh to.
  24470. * @param parent The parent of this mesh, if it has one
  24471. * @param source An optional Mesh from which geometry is shared, cloned.
  24472. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24473. * When false, achieved by calling a clone(), also passing False.
  24474. * This will make creation of children, recursive.
  24475. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24476. */
  24477. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24478. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24479. /**
  24480. * Gets the class name
  24481. * @returns the string "Mesh".
  24482. */
  24483. getClassName(): string;
  24484. /** @hidden */
  24485. readonly _isMesh: boolean;
  24486. /**
  24487. * Returns a description of this mesh
  24488. * @param fullDetails define if full details about this mesh must be used
  24489. * @returns a descriptive string representing this mesh
  24490. */
  24491. toString(fullDetails?: boolean): string;
  24492. /** @hidden */
  24493. _unBindEffect(): void;
  24494. /**
  24495. * Gets a boolean indicating if this mesh has LOD
  24496. */
  24497. readonly hasLODLevels: boolean;
  24498. /**
  24499. * Gets the list of MeshLODLevel associated with the current mesh
  24500. * @returns an array of MeshLODLevel
  24501. */
  24502. getLODLevels(): MeshLODLevel[];
  24503. private _sortLODLevels;
  24504. /**
  24505. * Add a mesh as LOD level triggered at the given distance.
  24506. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24507. * @param distance The distance from the center of the object to show this level
  24508. * @param mesh The mesh to be added as LOD level (can be null)
  24509. * @return This mesh (for chaining)
  24510. */
  24511. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24512. /**
  24513. * Returns the LOD level mesh at the passed distance or null if not found.
  24514. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24515. * @param distance The distance from the center of the object to show this level
  24516. * @returns a Mesh or `null`
  24517. */
  24518. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24519. /**
  24520. * Remove a mesh from the LOD array
  24521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24522. * @param mesh defines the mesh to be removed
  24523. * @return This mesh (for chaining)
  24524. */
  24525. removeLODLevel(mesh: Mesh): Mesh;
  24526. /**
  24527. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24528. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24529. * @param camera defines the camera to use to compute distance
  24530. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24531. * @return This mesh (for chaining)
  24532. */
  24533. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24534. /**
  24535. * Gets the mesh internal Geometry object
  24536. */
  24537. readonly geometry: Nullable<Geometry>;
  24538. /**
  24539. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24540. * @returns the total number of vertices
  24541. */
  24542. getTotalVertices(): number;
  24543. /**
  24544. * Returns the content of an associated vertex buffer
  24545. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24546. * - VertexBuffer.PositionKind
  24547. * - VertexBuffer.UVKind
  24548. * - VertexBuffer.UV2Kind
  24549. * - VertexBuffer.UV3Kind
  24550. * - VertexBuffer.UV4Kind
  24551. * - VertexBuffer.UV5Kind
  24552. * - VertexBuffer.UV6Kind
  24553. * - VertexBuffer.ColorKind
  24554. * - VertexBuffer.MatricesIndicesKind
  24555. * - VertexBuffer.MatricesIndicesExtraKind
  24556. * - VertexBuffer.MatricesWeightsKind
  24557. * - VertexBuffer.MatricesWeightsExtraKind
  24558. * @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
  24559. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24560. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24561. */
  24562. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24563. /**
  24564. * Returns the mesh VertexBuffer object from the requested `kind`
  24565. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24566. * - VertexBuffer.PositionKind
  24567. * - VertexBuffer.NormalKind
  24568. * - VertexBuffer.UVKind
  24569. * - VertexBuffer.UV2Kind
  24570. * - VertexBuffer.UV3Kind
  24571. * - VertexBuffer.UV4Kind
  24572. * - VertexBuffer.UV5Kind
  24573. * - VertexBuffer.UV6Kind
  24574. * - VertexBuffer.ColorKind
  24575. * - VertexBuffer.MatricesIndicesKind
  24576. * - VertexBuffer.MatricesIndicesExtraKind
  24577. * - VertexBuffer.MatricesWeightsKind
  24578. * - VertexBuffer.MatricesWeightsExtraKind
  24579. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24580. */
  24581. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24582. /**
  24583. * Tests if a specific vertex buffer is associated with this mesh
  24584. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24585. * - VertexBuffer.PositionKind
  24586. * - VertexBuffer.NormalKind
  24587. * - VertexBuffer.UVKind
  24588. * - VertexBuffer.UV2Kind
  24589. * - VertexBuffer.UV3Kind
  24590. * - VertexBuffer.UV4Kind
  24591. * - VertexBuffer.UV5Kind
  24592. * - VertexBuffer.UV6Kind
  24593. * - VertexBuffer.ColorKind
  24594. * - VertexBuffer.MatricesIndicesKind
  24595. * - VertexBuffer.MatricesIndicesExtraKind
  24596. * - VertexBuffer.MatricesWeightsKind
  24597. * - VertexBuffer.MatricesWeightsExtraKind
  24598. * @returns a boolean
  24599. */
  24600. isVerticesDataPresent(kind: string): boolean;
  24601. /**
  24602. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24603. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24604. * - VertexBuffer.PositionKind
  24605. * - VertexBuffer.UVKind
  24606. * - VertexBuffer.UV2Kind
  24607. * - VertexBuffer.UV3Kind
  24608. * - VertexBuffer.UV4Kind
  24609. * - VertexBuffer.UV5Kind
  24610. * - VertexBuffer.UV6Kind
  24611. * - VertexBuffer.ColorKind
  24612. * - VertexBuffer.MatricesIndicesKind
  24613. * - VertexBuffer.MatricesIndicesExtraKind
  24614. * - VertexBuffer.MatricesWeightsKind
  24615. * - VertexBuffer.MatricesWeightsExtraKind
  24616. * @returns a boolean
  24617. */
  24618. isVertexBufferUpdatable(kind: string): boolean;
  24619. /**
  24620. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24621. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24622. * - VertexBuffer.PositionKind
  24623. * - VertexBuffer.NormalKind
  24624. * - VertexBuffer.UVKind
  24625. * - VertexBuffer.UV2Kind
  24626. * - VertexBuffer.UV3Kind
  24627. * - VertexBuffer.UV4Kind
  24628. * - VertexBuffer.UV5Kind
  24629. * - VertexBuffer.UV6Kind
  24630. * - VertexBuffer.ColorKind
  24631. * - VertexBuffer.MatricesIndicesKind
  24632. * - VertexBuffer.MatricesIndicesExtraKind
  24633. * - VertexBuffer.MatricesWeightsKind
  24634. * - VertexBuffer.MatricesWeightsExtraKind
  24635. * @returns an array of strings
  24636. */
  24637. getVerticesDataKinds(): string[];
  24638. /**
  24639. * Returns a positive integer : the total number of indices in this mesh geometry.
  24640. * @returns the numner of indices or zero if the mesh has no geometry.
  24641. */
  24642. getTotalIndices(): number;
  24643. /**
  24644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24645. * @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.
  24646. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24647. * @returns the indices array or an empty array if the mesh has no geometry
  24648. */
  24649. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24650. readonly isBlocked: boolean;
  24651. /**
  24652. * Determine if the current mesh is ready to be rendered
  24653. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24654. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24655. * @returns true if all associated assets are ready (material, textures, shaders)
  24656. */
  24657. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24658. /**
  24659. * 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.
  24660. */
  24661. readonly areNormalsFrozen: boolean;
  24662. /**
  24663. * 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.
  24664. * @returns the current mesh
  24665. */
  24666. freezeNormals(): Mesh;
  24667. /**
  24668. * 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
  24669. * @returns the current mesh
  24670. */
  24671. unfreezeNormals(): Mesh;
  24672. /**
  24673. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24674. */
  24675. overridenInstanceCount: number;
  24676. /** @hidden */
  24677. _preActivate(): Mesh;
  24678. /** @hidden */
  24679. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24680. /** @hidden */
  24681. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24682. /**
  24683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24684. * This means the mesh underlying bounding box and sphere are recomputed.
  24685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24686. * @returns the current mesh
  24687. */
  24688. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24689. /** @hidden */
  24690. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24691. /**
  24692. * This function will subdivide the mesh into multiple submeshes
  24693. * @param count defines the expected number of submeshes
  24694. */
  24695. subdivide(count: number): void;
  24696. /**
  24697. * Copy a FloatArray into a specific associated vertex buffer
  24698. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24699. * - VertexBuffer.PositionKind
  24700. * - VertexBuffer.UVKind
  24701. * - VertexBuffer.UV2Kind
  24702. * - VertexBuffer.UV3Kind
  24703. * - VertexBuffer.UV4Kind
  24704. * - VertexBuffer.UV5Kind
  24705. * - VertexBuffer.UV6Kind
  24706. * - VertexBuffer.ColorKind
  24707. * - VertexBuffer.MatricesIndicesKind
  24708. * - VertexBuffer.MatricesIndicesExtraKind
  24709. * - VertexBuffer.MatricesWeightsKind
  24710. * - VertexBuffer.MatricesWeightsExtraKind
  24711. * @param data defines the data source
  24712. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24713. * @param stride defines the data stride size (can be null)
  24714. * @returns the current mesh
  24715. */
  24716. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24717. /**
  24718. * Delete a vertex buffer associated with this mesh
  24719. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24720. * - VertexBuffer.PositionKind
  24721. * - VertexBuffer.UVKind
  24722. * - VertexBuffer.UV2Kind
  24723. * - VertexBuffer.UV3Kind
  24724. * - VertexBuffer.UV4Kind
  24725. * - VertexBuffer.UV5Kind
  24726. * - VertexBuffer.UV6Kind
  24727. * - VertexBuffer.ColorKind
  24728. * - VertexBuffer.MatricesIndicesKind
  24729. * - VertexBuffer.MatricesIndicesExtraKind
  24730. * - VertexBuffer.MatricesWeightsKind
  24731. * - VertexBuffer.MatricesWeightsExtraKind
  24732. */
  24733. removeVerticesData(kind: string): void;
  24734. /**
  24735. * Flags an associated vertex buffer as updatable
  24736. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24737. * - VertexBuffer.PositionKind
  24738. * - VertexBuffer.UVKind
  24739. * - VertexBuffer.UV2Kind
  24740. * - VertexBuffer.UV3Kind
  24741. * - VertexBuffer.UV4Kind
  24742. * - VertexBuffer.UV5Kind
  24743. * - VertexBuffer.UV6Kind
  24744. * - VertexBuffer.ColorKind
  24745. * - VertexBuffer.MatricesIndicesKind
  24746. * - VertexBuffer.MatricesIndicesExtraKind
  24747. * - VertexBuffer.MatricesWeightsKind
  24748. * - VertexBuffer.MatricesWeightsExtraKind
  24749. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24750. */
  24751. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24752. /**
  24753. * Sets the mesh global Vertex Buffer
  24754. * @param buffer defines the buffer to use
  24755. * @returns the current mesh
  24756. */
  24757. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24758. /**
  24759. * Update a specific associated vertex buffer
  24760. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24761. * - VertexBuffer.PositionKind
  24762. * - VertexBuffer.UVKind
  24763. * - VertexBuffer.UV2Kind
  24764. * - VertexBuffer.UV3Kind
  24765. * - VertexBuffer.UV4Kind
  24766. * - VertexBuffer.UV5Kind
  24767. * - VertexBuffer.UV6Kind
  24768. * - VertexBuffer.ColorKind
  24769. * - VertexBuffer.MatricesIndicesKind
  24770. * - VertexBuffer.MatricesIndicesExtraKind
  24771. * - VertexBuffer.MatricesWeightsKind
  24772. * - VertexBuffer.MatricesWeightsExtraKind
  24773. * @param data defines the data source
  24774. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24775. * @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)
  24776. * @returns the current mesh
  24777. */
  24778. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24779. /**
  24780. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24781. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24782. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24783. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24784. * @returns the current mesh
  24785. */
  24786. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24787. /**
  24788. * Creates a un-shared specific occurence of the geometry for the mesh.
  24789. * @returns the current mesh
  24790. */
  24791. makeGeometryUnique(): Mesh;
  24792. /**
  24793. * Set the index buffer of this mesh
  24794. * @param indices defines the source data
  24795. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24796. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24797. * @returns the current mesh
  24798. */
  24799. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24800. /**
  24801. * Update the current index buffer
  24802. * @param indices defines the source data
  24803. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24804. * @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)
  24805. * @returns the current mesh
  24806. */
  24807. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24808. /**
  24809. * Invert the geometry to move from a right handed system to a left handed one.
  24810. * @returns the current mesh
  24811. */
  24812. toLeftHanded(): Mesh;
  24813. /** @hidden */
  24814. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24815. /** @hidden */
  24816. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24817. /**
  24818. * Registers for this mesh a javascript function called just before the rendering process
  24819. * @param func defines the function to call before rendering this mesh
  24820. * @returns the current mesh
  24821. */
  24822. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24823. /**
  24824. * Disposes a previously registered javascript function called before the rendering
  24825. * @param func defines the function to remove
  24826. * @returns the current mesh
  24827. */
  24828. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24829. /**
  24830. * Registers for this mesh a javascript function called just after the rendering is complete
  24831. * @param func defines the function to call after rendering this mesh
  24832. * @returns the current mesh
  24833. */
  24834. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24835. /**
  24836. * Disposes a previously registered javascript function called after the rendering.
  24837. * @param func defines the function to remove
  24838. * @returns the current mesh
  24839. */
  24840. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24841. /** @hidden */
  24842. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24843. /** @hidden */
  24844. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24845. /** @hidden */
  24846. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24847. /** @hidden */
  24848. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24849. /** @hidden */
  24850. _rebuild(): void;
  24851. /** @hidden */
  24852. _freeze(): void;
  24853. /** @hidden */
  24854. _unFreeze(): void;
  24855. /**
  24856. * 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
  24857. * @param subMesh defines the subMesh to render
  24858. * @param enableAlphaMode defines if alpha mode can be changed
  24859. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24860. * @returns the current mesh
  24861. */
  24862. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24863. private _onBeforeDraw;
  24864. /**
  24865. * Renormalize the mesh and patch it up if there are no weights
  24866. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24867. * However in the case of zero weights then we set just a single influence to 1.
  24868. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24869. */
  24870. cleanMatrixWeights(): void;
  24871. private normalizeSkinFourWeights;
  24872. private normalizeSkinWeightsAndExtra;
  24873. /**
  24874. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24875. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24876. * the user know there was an issue with importing the mesh
  24877. * @returns a validation object with skinned, valid and report string
  24878. */
  24879. validateSkinning(): {
  24880. skinned: boolean;
  24881. valid: boolean;
  24882. report: string;
  24883. };
  24884. /** @hidden */
  24885. _checkDelayState(): Mesh;
  24886. private _queueLoad;
  24887. /**
  24888. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24889. * A mesh is in the frustum if its bounding box intersects the frustum
  24890. * @param frustumPlanes defines the frustum to test
  24891. * @returns true if the mesh is in the frustum planes
  24892. */
  24893. isInFrustum(frustumPlanes: Plane[]): boolean;
  24894. /**
  24895. * Sets the mesh material by the material or multiMaterial `id` property
  24896. * @param id is a string identifying the material or the multiMaterial
  24897. * @returns the current mesh
  24898. */
  24899. setMaterialByID(id: string): Mesh;
  24900. /**
  24901. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24902. * @returns an array of IAnimatable
  24903. */
  24904. getAnimatables(): IAnimatable[];
  24905. /**
  24906. * Modifies the mesh geometry according to the passed transformation matrix.
  24907. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24908. * The mesh normals are modified using the same transformation.
  24909. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24910. * @param transform defines the transform matrix to use
  24911. * @see http://doc.babylonjs.com/resources/baking_transformations
  24912. * @returns the current mesh
  24913. */
  24914. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24915. /**
  24916. * Modifies the mesh geometry according to its own current World Matrix.
  24917. * The mesh World Matrix is then reset.
  24918. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24919. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24920. * @see http://doc.babylonjs.com/resources/baking_transformations
  24921. * @returns the current mesh
  24922. */
  24923. bakeCurrentTransformIntoVertices(): Mesh;
  24924. /** @hidden */
  24925. readonly _positions: Nullable<Vector3[]>;
  24926. /** @hidden */
  24927. _resetPointsArrayCache(): Mesh;
  24928. /** @hidden */
  24929. _generatePointsArray(): boolean;
  24930. /**
  24931. * Returns a new Mesh object generated from the current mesh properties.
  24932. * This method must not get confused with createInstance()
  24933. * @param name is a string, the name given to the new mesh
  24934. * @param newParent can be any Node object (default `null`)
  24935. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24936. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24937. * @returns a new mesh
  24938. */
  24939. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24940. /**
  24941. * Releases resources associated with this mesh.
  24942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24944. */
  24945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24946. /** @hidden */
  24947. _disposeInstanceSpecificData(): void;
  24948. /**
  24949. * Modifies the mesh geometry according to a displacement map.
  24950. * 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.
  24951. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24952. * @param url is a string, the URL from the image file is to be downloaded.
  24953. * @param minHeight is the lower limit of the displacement.
  24954. * @param maxHeight is the upper limit of the displacement.
  24955. * @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.
  24956. * @param uvOffset is an optional vector2 used to offset UV.
  24957. * @param uvScale is an optional vector2 used to scale UV.
  24958. * @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.
  24959. * @returns the Mesh.
  24960. */
  24961. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24962. /**
  24963. * Modifies the mesh geometry according to a displacementMap buffer.
  24964. * 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.
  24965. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24966. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24967. * @param heightMapWidth is the width of the buffer image.
  24968. * @param heightMapHeight is the height of the buffer image.
  24969. * @param minHeight is the lower limit of the displacement.
  24970. * @param maxHeight is the upper limit of the displacement.
  24971. * @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.
  24972. * @param uvOffset is an optional vector2 used to offset UV.
  24973. * @param uvScale is an optional vector2 used to scale UV.
  24974. * @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.
  24975. * @returns the Mesh.
  24976. */
  24977. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24978. /**
  24979. * Modify the mesh to get a flat shading rendering.
  24980. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24981. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24982. * @returns current mesh
  24983. */
  24984. convertToFlatShadedMesh(): Mesh;
  24985. /**
  24986. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24987. * In other words, more vertices, no more indices and a single bigger VBO.
  24988. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24989. * @returns current mesh
  24990. */
  24991. convertToUnIndexedMesh(): Mesh;
  24992. /**
  24993. * Inverses facet orientations.
  24994. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24995. * @param flipNormals will also inverts the normals
  24996. * @returns current mesh
  24997. */
  24998. flipFaces(flipNormals?: boolean): Mesh;
  24999. /**
  25000. * Increase the number of facets and hence vertices in a mesh
  25001. * Vertex normals are interpolated from existing vertex normals
  25002. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25003. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25004. */
  25005. increaseVertices(numberPerEdge: number): void;
  25006. /**
  25007. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25008. * This will undo any application of covertToFlatShadedMesh
  25009. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25010. */
  25011. forceSharedVertices(): void;
  25012. /** @hidden */
  25013. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25014. /** @hidden */
  25015. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25016. /**
  25017. * Creates a new InstancedMesh object from the mesh model.
  25018. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25019. * @param name defines the name of the new instance
  25020. * @returns a new InstancedMesh
  25021. */
  25022. createInstance(name: string): InstancedMesh;
  25023. /**
  25024. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25025. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25026. * @returns the current mesh
  25027. */
  25028. synchronizeInstances(): Mesh;
  25029. /**
  25030. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25031. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25032. * This should be used together with the simplification to avoid disappearing triangles.
  25033. * @param successCallback an optional success callback to be called after the optimization finished.
  25034. * @returns the current mesh
  25035. */
  25036. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25037. /**
  25038. * Serialize current mesh
  25039. * @param serializationObject defines the object which will receive the serialization data
  25040. */
  25041. serialize(serializationObject: any): void;
  25042. /** @hidden */
  25043. _syncGeometryWithMorphTargetManager(): void;
  25044. /** @hidden */
  25045. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25046. /**
  25047. * Returns a new Mesh object parsed from the source provided.
  25048. * @param parsedMesh is the source
  25049. * @param scene defines the hosting scene
  25050. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25051. * @returns a new Mesh
  25052. */
  25053. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25054. /**
  25055. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25056. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25057. * @param name defines the name of the mesh to create
  25058. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25059. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25060. * @param closePath creates a seam between the first and the last points of each path of the path array
  25061. * @param offset is taken in account only if the `pathArray` is containing a single path
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25065. * @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)
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25069. /**
  25070. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25073. * @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
  25074. * @param scene defines the hosting scene
  25075. * @param updatable defines if the mesh must be flagged as updatable
  25076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25077. * @returns a new Mesh
  25078. */
  25079. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25080. /**
  25081. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25082. * @param name defines the name of the mesh to create
  25083. * @param size sets the size (float) of each box side (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 CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25090. /**
  25091. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25094. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25095. * @param scene defines the hosting scene
  25096. * @param updatable defines if the mesh must be flagged as updatable
  25097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25098. * @returns a new Mesh
  25099. */
  25100. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25101. /**
  25102. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25103. * @param name defines the name of the mesh to create
  25104. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25105. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25106. * @param scene defines the hosting scene
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25110. /**
  25111. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25112. * @param name defines the name of the mesh to create
  25113. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25114. * @param diameterTop set the top cap diameter (floats, default 1)
  25115. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25116. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25117. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25118. * @param scene defines the hosting scene
  25119. * @param updatable defines if the mesh must be flagged as updatable
  25120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25121. * @returns a new Mesh
  25122. */
  25123. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25124. /**
  25125. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25126. * @param name defines the name of the mesh to create
  25127. * @param diameter sets the diameter size (float) of the torus (default 1)
  25128. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25129. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25130. * @param scene defines the hosting scene
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25133. * @returns a new Mesh
  25134. */
  25135. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25136. /**
  25137. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25138. * @param name defines the name of the mesh to create
  25139. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25140. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25141. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25142. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25143. * @param p the number of windings on X axis (positive integers, default 2)
  25144. * @param q the number of windings on Y axis (positive integers, default 3)
  25145. * @param scene defines the hosting scene
  25146. * @param updatable defines if the mesh must be flagged as updatable
  25147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25148. * @returns a new Mesh
  25149. */
  25150. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25151. /**
  25152. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25153. * @param name defines the name of the mesh to create
  25154. * @param points is an array successive Vector3
  25155. * @param scene defines the hosting scene
  25156. * @param updatable defines if the mesh must be flagged as updatable
  25157. * @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).
  25158. * @returns a new Mesh
  25159. */
  25160. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25161. /**
  25162. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25163. * @param name defines the name of the mesh to create
  25164. * @param points is an array successive Vector3
  25165. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25166. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25167. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25168. * @param scene defines the hosting scene
  25169. * @param updatable defines if the mesh must be flagged as updatable
  25170. * @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)
  25171. * @returns a new Mesh
  25172. */
  25173. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25174. /**
  25175. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25176. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25177. * 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.
  25178. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25179. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25180. * Remember you can only change the shape positions, not their number when updating a polygon.
  25181. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25182. * @param name defines the name of the mesh to create
  25183. * @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
  25184. * @param scene defines the hosting scene
  25185. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25186. * @param updatable defines if the mesh must be flagged as updatable
  25187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25188. * @param earcutInjection can be used to inject your own earcut reference
  25189. * @returns a new Mesh
  25190. */
  25191. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25192. /**
  25193. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25195. * @param name defines the name of the mesh to create
  25196. * @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
  25197. * @param depth defines the height of extrusion
  25198. * @param scene defines the hosting scene
  25199. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25200. * @param updatable defines if the mesh must be flagged as updatable
  25201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25202. * @param earcutInjection can be used to inject your own earcut reference
  25203. * @returns a new Mesh
  25204. */
  25205. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25206. /**
  25207. * Creates an extruded shape mesh.
  25208. * 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
  25209. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25210. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25211. * @param name defines the name of the mesh to create
  25212. * @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
  25213. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25214. * @param scale is the value to scale the shape
  25215. * @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
  25216. * @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
  25217. * @param scene defines the hosting scene
  25218. * @param updatable defines if the mesh must be flagged as updatable
  25219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25220. * @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)
  25221. * @returns a new Mesh
  25222. */
  25223. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25224. /**
  25225. * Creates an custom extruded shape mesh.
  25226. * The custom extrusion is a parametric shape.
  25227. * It has no predefined shape. Its final shape will depend on the input parameters.
  25228. * Please consider using the same method from the MeshBuilder class instead
  25229. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25230. * @param name defines the name of the mesh to create
  25231. * @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
  25232. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25233. * @param scaleFunction is a custom Javascript function called on each path point
  25234. * @param rotationFunction is a custom Javascript function called on each path point
  25235. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25236. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25237. * @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
  25238. * @param scene defines the hosting scene
  25239. * @param updatable defines if the mesh must be flagged as updatable
  25240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25241. * @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)
  25242. * @returns a new Mesh
  25243. */
  25244. 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;
  25245. /**
  25246. * Creates lathe mesh.
  25247. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25248. * Please consider using the same method from the MeshBuilder class instead
  25249. * @param name defines the name of the mesh to create
  25250. * @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
  25251. * @param radius is the radius value of the lathe
  25252. * @param tessellation is the side number of the lathe.
  25253. * @param scene defines the hosting scene
  25254. * @param updatable defines if the mesh must be flagged as updatable
  25255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25256. * @returns a new Mesh
  25257. */
  25258. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25259. /**
  25260. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25261. * @param name defines the name of the mesh to create
  25262. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25263. * @param scene defines the hosting scene
  25264. * @param updatable defines if the mesh must be flagged as updatable
  25265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25266. * @returns a new Mesh
  25267. */
  25268. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25269. /**
  25270. * Creates a ground mesh.
  25271. * Please consider using the same method from the MeshBuilder class instead
  25272. * @param name defines the name of the mesh to create
  25273. * @param width set the width of the ground
  25274. * @param height set the height of the ground
  25275. * @param subdivisions sets the number of subdivisions per side
  25276. * @param scene defines the hosting scene
  25277. * @param updatable defines if the mesh must be flagged as updatable
  25278. * @returns a new Mesh
  25279. */
  25280. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25281. /**
  25282. * Creates a tiled ground mesh.
  25283. * Please consider using the same method from the MeshBuilder class instead
  25284. * @param name defines the name of the mesh to create
  25285. * @param xmin set the ground minimum X coordinate
  25286. * @param zmin set the ground minimum Y coordinate
  25287. * @param xmax set the ground maximum X coordinate
  25288. * @param zmax set the ground maximum Z coordinate
  25289. * @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
  25290. * @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
  25291. * @param scene defines the hosting scene
  25292. * @param updatable defines if the mesh must be flagged as updatable
  25293. * @returns a new Mesh
  25294. */
  25295. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25296. w: number;
  25297. h: number;
  25298. }, precision: {
  25299. w: number;
  25300. h: number;
  25301. }, scene: Scene, updatable?: boolean): Mesh;
  25302. /**
  25303. * Creates a ground mesh from a height map.
  25304. * Please consider using the same method from the MeshBuilder class instead
  25305. * @see http://doc.babylonjs.com/babylon101/height_map
  25306. * @param name defines the name of the mesh to create
  25307. * @param url sets the URL of the height map image resource
  25308. * @param width set the ground width size
  25309. * @param height set the ground height size
  25310. * @param subdivisions sets the number of subdivision per side
  25311. * @param minHeight is the minimum altitude on the ground
  25312. * @param maxHeight is the maximum altitude on the ground
  25313. * @param scene defines the hosting scene
  25314. * @param updatable defines if the mesh must be flagged as updatable
  25315. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25316. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25317. * @returns a new Mesh
  25318. */
  25319. 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;
  25320. /**
  25321. * Creates a tube mesh.
  25322. * The tube is a parametric shape.
  25323. * It has no predefined shape. Its final shape will depend on the input parameters.
  25324. * Please consider using the same method from the MeshBuilder class instead
  25325. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25326. * @param name defines the name of the mesh to create
  25327. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25328. * @param radius sets the tube radius size
  25329. * @param tessellation is the number of sides on the tubular surface
  25330. * @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
  25331. * @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
  25332. * @param scene defines the hosting scene
  25333. * @param updatable defines if the mesh must be flagged as updatable
  25334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25335. * @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)
  25336. * @returns a new Mesh
  25337. */
  25338. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25339. (i: number, distance: number): number;
  25340. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25341. /**
  25342. * Creates a polyhedron mesh.
  25343. * Please consider using the same method from the MeshBuilder class instead.
  25344. * * 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
  25345. * * The parameter `size` (positive float, default 1) sets the polygon size
  25346. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25347. * * 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`
  25348. * * 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
  25349. * * 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)`)
  25350. * * 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
  25351. * * 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
  25352. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25353. * * If you create a double-sided mesh, you can choose what parts of 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
  25354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25355. * @param name defines the name of the mesh to create
  25356. * @param options defines the options used to create the mesh
  25357. * @param scene defines the hosting scene
  25358. * @returns a new Mesh
  25359. */
  25360. static CreatePolyhedron(name: string, options: {
  25361. type?: number;
  25362. size?: number;
  25363. sizeX?: number;
  25364. sizeY?: number;
  25365. sizeZ?: number;
  25366. custom?: any;
  25367. faceUV?: Vector4[];
  25368. faceColors?: Color4[];
  25369. updatable?: boolean;
  25370. sideOrientation?: number;
  25371. }, scene: Scene): Mesh;
  25372. /**
  25373. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25374. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25375. * * 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`)
  25376. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25377. * * 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
  25378. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25379. * * If you create a double-sided mesh, you can choose what parts of 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
  25380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25381. * @param name defines the name of the mesh
  25382. * @param options defines the options used to create the mesh
  25383. * @param scene defines the hosting scene
  25384. * @returns a new Mesh
  25385. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25386. */
  25387. static CreateIcoSphere(name: string, options: {
  25388. radius?: number;
  25389. flat?: boolean;
  25390. subdivisions?: number;
  25391. sideOrientation?: number;
  25392. updatable?: boolean;
  25393. }, scene: Scene): Mesh;
  25394. /**
  25395. * Creates a decal mesh.
  25396. * Please consider using the same method from the MeshBuilder class instead.
  25397. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25398. * @param name defines the name of the mesh
  25399. * @param sourceMesh defines the mesh receiving the decal
  25400. * @param position sets the position of the decal in world coordinates
  25401. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25402. * @param size sets the decal scaling
  25403. * @param angle sets the angle to rotate the decal
  25404. * @returns a new Mesh
  25405. */
  25406. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25407. /**
  25408. * Prepare internal position array for software CPU skinning
  25409. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25410. */
  25411. setPositionsForCPUSkinning(): Float32Array;
  25412. /**
  25413. * Prepare internal normal array for software CPU skinning
  25414. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25415. */
  25416. setNormalsForCPUSkinning(): Float32Array;
  25417. /**
  25418. * Updates the vertex buffer by applying transformation from the bones
  25419. * @param skeleton defines the skeleton to apply to current mesh
  25420. * @returns the current mesh
  25421. */
  25422. applySkeleton(skeleton: Skeleton): Mesh;
  25423. /**
  25424. * 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
  25425. * @param meshes defines the list of meshes to scan
  25426. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25427. */
  25428. static MinMax(meshes: AbstractMesh[]): {
  25429. min: Vector3;
  25430. max: Vector3;
  25431. };
  25432. /**
  25433. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25434. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25435. * @returns a vector3
  25436. */
  25437. static Center(meshesOrMinMaxVector: {
  25438. min: Vector3;
  25439. max: Vector3;
  25440. } | AbstractMesh[]): Vector3;
  25441. /**
  25442. * Merge the array of meshes into a single mesh for performance reasons.
  25443. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25444. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25445. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25446. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25447. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25448. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25449. * @returns a new mesh
  25450. */
  25451. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25452. /** @hidden */
  25453. addInstance(instance: InstancedMesh): void;
  25454. /** @hidden */
  25455. removeInstance(instance: InstancedMesh): void;
  25456. }
  25457. }
  25458. declare module "babylonjs/Cameras/camera" {
  25459. import { SmartArray } from "babylonjs/Misc/smartArray";
  25460. import { Observable } from "babylonjs/Misc/observable";
  25461. import { Nullable } from "babylonjs/types";
  25462. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25463. import { Scene } from "babylonjs/scene";
  25464. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25465. import { Node } from "babylonjs/node";
  25466. import { Mesh } from "babylonjs/Meshes/mesh";
  25467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25468. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25469. import { Viewport } from "babylonjs/Maths/math.viewport";
  25470. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25472. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25473. import { Ray } from "babylonjs/Culling/ray";
  25474. /**
  25475. * This is the base class of all the camera used in the application.
  25476. * @see http://doc.babylonjs.com/features/cameras
  25477. */
  25478. export class Camera extends Node {
  25479. /** @hidden */
  25480. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25481. /**
  25482. * This is the default projection mode used by the cameras.
  25483. * It helps recreating a feeling of perspective and better appreciate depth.
  25484. * This is the best way to simulate real life cameras.
  25485. */
  25486. static readonly PERSPECTIVE_CAMERA: number;
  25487. /**
  25488. * This helps creating camera with an orthographic mode.
  25489. * 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.
  25490. */
  25491. static readonly ORTHOGRAPHIC_CAMERA: number;
  25492. /**
  25493. * This is the default FOV mode for perspective cameras.
  25494. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25495. */
  25496. static readonly FOVMODE_VERTICAL_FIXED: number;
  25497. /**
  25498. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25499. */
  25500. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25501. /**
  25502. * This specifies ther is no need for a camera rig.
  25503. * Basically only one eye is rendered corresponding to the camera.
  25504. */
  25505. static readonly RIG_MODE_NONE: number;
  25506. /**
  25507. * Simulates a camera Rig with one blue eye and one red eye.
  25508. * This can be use with 3d blue and red glasses.
  25509. */
  25510. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25511. /**
  25512. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25513. */
  25514. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25515. /**
  25516. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25517. */
  25518. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25519. /**
  25520. * Defines that both eyes of the camera will be rendered over under each other.
  25521. */
  25522. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25523. /**
  25524. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25525. */
  25526. static readonly RIG_MODE_VR: number;
  25527. /**
  25528. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25529. */
  25530. static readonly RIG_MODE_WEBVR: number;
  25531. /**
  25532. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25533. */
  25534. static readonly RIG_MODE_CUSTOM: number;
  25535. /**
  25536. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25537. */
  25538. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25539. /**
  25540. * Define the input manager associated with the camera.
  25541. */
  25542. inputs: CameraInputsManager<Camera>;
  25543. /** @hidden */
  25544. _position: Vector3;
  25545. /**
  25546. * Define the current local position of the camera in the scene
  25547. */
  25548. position: Vector3;
  25549. /**
  25550. * The vector the camera should consider as up.
  25551. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25552. */
  25553. upVector: Vector3;
  25554. /**
  25555. * Define the current limit on the left side for an orthographic camera
  25556. * In scene unit
  25557. */
  25558. orthoLeft: Nullable<number>;
  25559. /**
  25560. * Define the current limit on the right side for an orthographic camera
  25561. * In scene unit
  25562. */
  25563. orthoRight: Nullable<number>;
  25564. /**
  25565. * Define the current limit on the bottom side for an orthographic camera
  25566. * In scene unit
  25567. */
  25568. orthoBottom: Nullable<number>;
  25569. /**
  25570. * Define the current limit on the top side for an orthographic camera
  25571. * In scene unit
  25572. */
  25573. orthoTop: Nullable<number>;
  25574. /**
  25575. * Field Of View is set in Radians. (default is 0.8)
  25576. */
  25577. fov: number;
  25578. /**
  25579. * Define the minimum distance the camera can see from.
  25580. * This is important to note that the depth buffer are not infinite and the closer it starts
  25581. * the more your scene might encounter depth fighting issue.
  25582. */
  25583. minZ: number;
  25584. /**
  25585. * Define the maximum distance the camera can see to.
  25586. * This is important to note that the depth buffer are not infinite and the further it end
  25587. * the more your scene might encounter depth fighting issue.
  25588. */
  25589. maxZ: number;
  25590. /**
  25591. * Define the default inertia of the camera.
  25592. * This helps giving a smooth feeling to the camera movement.
  25593. */
  25594. inertia: number;
  25595. /**
  25596. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25597. */
  25598. mode: number;
  25599. /**
  25600. * Define wether the camera is intermediate.
  25601. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25602. */
  25603. isIntermediate: boolean;
  25604. /**
  25605. * Define the viewport of the camera.
  25606. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25607. */
  25608. viewport: Viewport;
  25609. /**
  25610. * Restricts the camera to viewing objects with the same layerMask.
  25611. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25612. */
  25613. layerMask: number;
  25614. /**
  25615. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25616. */
  25617. fovMode: number;
  25618. /**
  25619. * Rig mode of the camera.
  25620. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25621. * This is normally controlled byt the camera themselves as internal use.
  25622. */
  25623. cameraRigMode: number;
  25624. /**
  25625. * Defines the distance between both "eyes" in case of a RIG
  25626. */
  25627. interaxialDistance: number;
  25628. /**
  25629. * Defines if stereoscopic rendering is done side by side or over under.
  25630. */
  25631. isStereoscopicSideBySide: boolean;
  25632. /**
  25633. * 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
  25634. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25635. * else in the scene. (Eg. security camera)
  25636. *
  25637. * 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)
  25638. */
  25639. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25640. /**
  25641. * When set, the camera will render to this render target instead of the default canvas
  25642. *
  25643. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25644. */
  25645. outputRenderTarget: Nullable<RenderTargetTexture>;
  25646. /**
  25647. * Observable triggered when the camera view matrix has changed.
  25648. */
  25649. onViewMatrixChangedObservable: Observable<Camera>;
  25650. /**
  25651. * Observable triggered when the camera Projection matrix has changed.
  25652. */
  25653. onProjectionMatrixChangedObservable: Observable<Camera>;
  25654. /**
  25655. * Observable triggered when the inputs have been processed.
  25656. */
  25657. onAfterCheckInputsObservable: Observable<Camera>;
  25658. /**
  25659. * Observable triggered when reset has been called and applied to the camera.
  25660. */
  25661. onRestoreStateObservable: Observable<Camera>;
  25662. /** @hidden */
  25663. _cameraRigParams: any;
  25664. /** @hidden */
  25665. _rigCameras: Camera[];
  25666. /** @hidden */
  25667. _rigPostProcess: Nullable<PostProcess>;
  25668. protected _webvrViewMatrix: Matrix;
  25669. /** @hidden */
  25670. _skipRendering: boolean;
  25671. /** @hidden */
  25672. _projectionMatrix: Matrix;
  25673. /** @hidden */
  25674. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25675. /** @hidden */
  25676. _activeMeshes: SmartArray<AbstractMesh>;
  25677. protected _globalPosition: Vector3;
  25678. /** @hidden */
  25679. _computedViewMatrix: Matrix;
  25680. private _doNotComputeProjectionMatrix;
  25681. private _transformMatrix;
  25682. private _frustumPlanes;
  25683. private _refreshFrustumPlanes;
  25684. private _storedFov;
  25685. private _stateStored;
  25686. /**
  25687. * Instantiates a new camera object.
  25688. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25689. * @see http://doc.babylonjs.com/features/cameras
  25690. * @param name Defines the name of the camera in the scene
  25691. * @param position Defines the position of the camera
  25692. * @param scene Defines the scene the camera belongs too
  25693. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25694. */
  25695. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25696. /**
  25697. * Store current camera state (fov, position, etc..)
  25698. * @returns the camera
  25699. */
  25700. storeState(): Camera;
  25701. /**
  25702. * Restores the camera state values if it has been stored. You must call storeState() first
  25703. */
  25704. protected _restoreStateValues(): boolean;
  25705. /**
  25706. * Restored camera state. You must call storeState() first.
  25707. * @returns true if restored and false otherwise
  25708. */
  25709. restoreState(): boolean;
  25710. /**
  25711. * Gets the class name of the camera.
  25712. * @returns the class name
  25713. */
  25714. getClassName(): string;
  25715. /** @hidden */
  25716. readonly _isCamera: boolean;
  25717. /**
  25718. * Gets a string representation of the camera useful for debug purpose.
  25719. * @param fullDetails Defines that a more verboe level of logging is required
  25720. * @returns the string representation
  25721. */
  25722. toString(fullDetails?: boolean): string;
  25723. /**
  25724. * Gets the current world space position of the camera.
  25725. */
  25726. readonly globalPosition: Vector3;
  25727. /**
  25728. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25729. * @returns the active meshe list
  25730. */
  25731. getActiveMeshes(): SmartArray<AbstractMesh>;
  25732. /**
  25733. * Check wether a mesh is part of the current active mesh list of the camera
  25734. * @param mesh Defines the mesh to check
  25735. * @returns true if active, false otherwise
  25736. */
  25737. isActiveMesh(mesh: Mesh): boolean;
  25738. /**
  25739. * Is this camera ready to be used/rendered
  25740. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25741. * @return true if the camera is ready
  25742. */
  25743. isReady(completeCheck?: boolean): boolean;
  25744. /** @hidden */
  25745. _initCache(): void;
  25746. /** @hidden */
  25747. _updateCache(ignoreParentClass?: boolean): void;
  25748. /** @hidden */
  25749. _isSynchronized(): boolean;
  25750. /** @hidden */
  25751. _isSynchronizedViewMatrix(): boolean;
  25752. /** @hidden */
  25753. _isSynchronizedProjectionMatrix(): boolean;
  25754. /**
  25755. * Attach the input controls to a specific dom element to get the input from.
  25756. * @param element Defines the element the controls should be listened from
  25757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25758. */
  25759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25760. /**
  25761. * Detach the current controls from the specified dom element.
  25762. * @param element Defines the element to stop listening the inputs from
  25763. */
  25764. detachControl(element: HTMLElement): void;
  25765. /**
  25766. * Update the camera state according to the different inputs gathered during the frame.
  25767. */
  25768. update(): void;
  25769. /** @hidden */
  25770. _checkInputs(): void;
  25771. /** @hidden */
  25772. readonly rigCameras: Camera[];
  25773. /**
  25774. * Gets the post process used by the rig cameras
  25775. */
  25776. readonly rigPostProcess: Nullable<PostProcess>;
  25777. /**
  25778. * Internal, gets the first post proces.
  25779. * @returns the first post process to be run on this camera.
  25780. */
  25781. _getFirstPostProcess(): Nullable<PostProcess>;
  25782. private _cascadePostProcessesToRigCams;
  25783. /**
  25784. * Attach a post process to the camera.
  25785. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25786. * @param postProcess The post process to attach to the camera
  25787. * @param insertAt The position of the post process in case several of them are in use in the scene
  25788. * @returns the position the post process has been inserted at
  25789. */
  25790. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25791. /**
  25792. * Detach a post process to the camera.
  25793. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25794. * @param postProcess The post process to detach from the camera
  25795. */
  25796. detachPostProcess(postProcess: PostProcess): void;
  25797. /**
  25798. * Gets the current world matrix of the camera
  25799. */
  25800. getWorldMatrix(): Matrix;
  25801. /** @hidden */
  25802. _getViewMatrix(): Matrix;
  25803. /**
  25804. * Gets the current view matrix of the camera.
  25805. * @param force forces the camera to recompute the matrix without looking at the cached state
  25806. * @returns the view matrix
  25807. */
  25808. getViewMatrix(force?: boolean): Matrix;
  25809. /**
  25810. * Freeze the projection matrix.
  25811. * It will prevent the cache check of the camera projection compute and can speed up perf
  25812. * if no parameter of the camera are meant to change
  25813. * @param projection Defines manually a projection if necessary
  25814. */
  25815. freezeProjectionMatrix(projection?: Matrix): void;
  25816. /**
  25817. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25818. */
  25819. unfreezeProjectionMatrix(): void;
  25820. /**
  25821. * Gets the current projection matrix of the camera.
  25822. * @param force forces the camera to recompute the matrix without looking at the cached state
  25823. * @returns the projection matrix
  25824. */
  25825. getProjectionMatrix(force?: boolean): Matrix;
  25826. /**
  25827. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25828. * @returns a Matrix
  25829. */
  25830. getTransformationMatrix(): Matrix;
  25831. private _updateFrustumPlanes;
  25832. /**
  25833. * Checks if a cullable object (mesh...) is in the camera frustum
  25834. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25835. * @param target The object to check
  25836. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25837. * @returns true if the object is in frustum otherwise false
  25838. */
  25839. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25840. /**
  25841. * Checks if a cullable object (mesh...) is in the camera frustum
  25842. * Unlike isInFrustum this cheks the full bounding box
  25843. * @param target The object to check
  25844. * @returns true if the object is in frustum otherwise false
  25845. */
  25846. isCompletelyInFrustum(target: ICullable): boolean;
  25847. /**
  25848. * Gets a ray in the forward direction from the camera.
  25849. * @param length Defines the length of the ray to create
  25850. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25851. * @param origin Defines the start point of the ray which defaults to the camera position
  25852. * @returns the forward ray
  25853. */
  25854. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25855. /**
  25856. * Releases resources associated with this node.
  25857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25859. */
  25860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25861. /** @hidden */
  25862. _isLeftCamera: boolean;
  25863. /**
  25864. * Gets the left camera of a rig setup in case of Rigged Camera
  25865. */
  25866. readonly isLeftCamera: boolean;
  25867. /** @hidden */
  25868. _isRightCamera: boolean;
  25869. /**
  25870. * Gets the right camera of a rig setup in case of Rigged Camera
  25871. */
  25872. readonly isRightCamera: boolean;
  25873. /**
  25874. * Gets the left camera of a rig setup in case of Rigged Camera
  25875. */
  25876. readonly leftCamera: Nullable<FreeCamera>;
  25877. /**
  25878. * Gets the right camera of a rig setup in case of Rigged Camera
  25879. */
  25880. readonly rightCamera: Nullable<FreeCamera>;
  25881. /**
  25882. * Gets the left camera target of a rig setup in case of Rigged Camera
  25883. * @returns the target position
  25884. */
  25885. getLeftTarget(): Nullable<Vector3>;
  25886. /**
  25887. * Gets the right camera target of a rig setup in case of Rigged Camera
  25888. * @returns the target position
  25889. */
  25890. getRightTarget(): Nullable<Vector3>;
  25891. /**
  25892. * @hidden
  25893. */
  25894. setCameraRigMode(mode: number, rigParams: any): void;
  25895. /** @hidden */
  25896. static _setStereoscopicRigMode(camera: Camera): void;
  25897. /** @hidden */
  25898. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25899. /** @hidden */
  25900. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25901. /** @hidden */
  25902. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25903. /** @hidden */
  25904. _getVRProjectionMatrix(): Matrix;
  25905. protected _updateCameraRotationMatrix(): void;
  25906. protected _updateWebVRCameraRotationMatrix(): void;
  25907. /**
  25908. * This function MUST be overwritten by the different WebVR cameras available.
  25909. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25910. * @hidden
  25911. */
  25912. _getWebVRProjectionMatrix(): Matrix;
  25913. /**
  25914. * This function MUST be overwritten by the different WebVR cameras available.
  25915. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25916. * @hidden
  25917. */
  25918. _getWebVRViewMatrix(): Matrix;
  25919. /** @hidden */
  25920. setCameraRigParameter(name: string, value: any): void;
  25921. /**
  25922. * needs to be overridden by children so sub has required properties to be copied
  25923. * @hidden
  25924. */
  25925. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25926. /**
  25927. * May need to be overridden by children
  25928. * @hidden
  25929. */
  25930. _updateRigCameras(): void;
  25931. /** @hidden */
  25932. _setupInputs(): void;
  25933. /**
  25934. * Serialiaze the camera setup to a json represention
  25935. * @returns the JSON representation
  25936. */
  25937. serialize(): any;
  25938. /**
  25939. * Clones the current camera.
  25940. * @param name The cloned camera name
  25941. * @returns the cloned camera
  25942. */
  25943. clone(name: string): Camera;
  25944. /**
  25945. * Gets the direction of the camera relative to a given local axis.
  25946. * @param localAxis Defines the reference axis to provide a relative direction.
  25947. * @return the direction
  25948. */
  25949. getDirection(localAxis: Vector3): Vector3;
  25950. /**
  25951. * Returns the current camera absolute rotation
  25952. */
  25953. readonly absoluteRotation: Quaternion;
  25954. /**
  25955. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25956. * @param localAxis Defines the reference axis to provide a relative direction.
  25957. * @param result Defines the vector to store the result in
  25958. */
  25959. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25960. /**
  25961. * Gets a camera constructor for a given camera type
  25962. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25963. * @param name The name of the camera the result will be able to instantiate
  25964. * @param scene The scene the result will construct the camera in
  25965. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25966. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25967. * @returns a factory method to construc the camera
  25968. */
  25969. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25970. /**
  25971. * Compute the world matrix of the camera.
  25972. * @returns the camera world matrix
  25973. */
  25974. computeWorldMatrix(): Matrix;
  25975. /**
  25976. * Parse a JSON and creates the camera from the parsed information
  25977. * @param parsedCamera The JSON to parse
  25978. * @param scene The scene to instantiate the camera in
  25979. * @returns the newly constructed camera
  25980. */
  25981. static Parse(parsedCamera: any, scene: Scene): Camera;
  25982. }
  25983. }
  25984. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25985. import { Nullable } from "babylonjs/types";
  25986. import { Scene } from "babylonjs/scene";
  25987. import { Vector4 } from "babylonjs/Maths/math.vector";
  25988. import { Mesh } from "babylonjs/Meshes/mesh";
  25989. /**
  25990. * Class containing static functions to help procedurally build meshes
  25991. */
  25992. export class DiscBuilder {
  25993. /**
  25994. * Creates a plane polygonal mesh. By default, this is a disc
  25995. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25996. * * 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
  25997. * * 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
  25998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26001. * @param name defines the name of the mesh
  26002. * @param options defines the options used to create the mesh
  26003. * @param scene defines the hosting scene
  26004. * @returns the plane polygonal mesh
  26005. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26006. */
  26007. static CreateDisc(name: string, options: {
  26008. radius?: number;
  26009. tessellation?: number;
  26010. arc?: number;
  26011. updatable?: boolean;
  26012. sideOrientation?: number;
  26013. frontUVs?: Vector4;
  26014. backUVs?: Vector4;
  26015. }, scene?: Nullable<Scene>): Mesh;
  26016. }
  26017. }
  26018. declare module "babylonjs/Particles/solidParticleSystem" {
  26019. import { Vector3 } from "babylonjs/Maths/math.vector";
  26020. import { Mesh } from "babylonjs/Meshes/mesh";
  26021. import { Scene, IDisposable } from "babylonjs/scene";
  26022. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26023. /**
  26024. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26025. *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.
  26026. * The SPS is also a particle system. It provides some methods to manage the particles.
  26027. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26028. *
  26029. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26030. */
  26031. export class SolidParticleSystem implements IDisposable {
  26032. /**
  26033. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26034. * Example : var p = SPS.particles[i];
  26035. */
  26036. particles: SolidParticle[];
  26037. /**
  26038. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26039. */
  26040. nbParticles: number;
  26041. /**
  26042. * If the particles must ever face the camera (default false). Useful for planar particles.
  26043. */
  26044. billboard: boolean;
  26045. /**
  26046. * Recompute normals when adding a shape
  26047. */
  26048. recomputeNormals: boolean;
  26049. /**
  26050. * This a counter ofr your own usage. It's not set by any SPS functions.
  26051. */
  26052. counter: number;
  26053. /**
  26054. * The SPS name. This name is also given to the underlying mesh.
  26055. */
  26056. name: string;
  26057. /**
  26058. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26059. */
  26060. mesh: Mesh;
  26061. /**
  26062. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26063. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26064. */
  26065. vars: any;
  26066. /**
  26067. * This array is populated when the SPS is set as 'pickable'.
  26068. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26069. * Each element of this array is an object `{idx: int, faceId: int}`.
  26070. * `idx` is the picked particle index in the `SPS.particles` array
  26071. * `faceId` is the picked face index counted within this particle.
  26072. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26073. */
  26074. pickedParticles: {
  26075. idx: number;
  26076. faceId: number;
  26077. }[];
  26078. /**
  26079. * This array is populated when `enableDepthSort` is set to true.
  26080. * Each element of this array is an instance of the class DepthSortedParticle.
  26081. */
  26082. depthSortedParticles: DepthSortedParticle[];
  26083. /**
  26084. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26085. * @hidden
  26086. */
  26087. _bSphereOnly: boolean;
  26088. /**
  26089. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26090. * @hidden
  26091. */
  26092. _bSphereRadiusFactor: number;
  26093. private _scene;
  26094. private _positions;
  26095. private _indices;
  26096. private _normals;
  26097. private _colors;
  26098. private _uvs;
  26099. private _indices32;
  26100. private _positions32;
  26101. private _normals32;
  26102. private _fixedNormal32;
  26103. private _colors32;
  26104. private _uvs32;
  26105. private _index;
  26106. private _updatable;
  26107. private _pickable;
  26108. private _isVisibilityBoxLocked;
  26109. private _alwaysVisible;
  26110. private _depthSort;
  26111. private _expandable;
  26112. private _shapeCounter;
  26113. private _copy;
  26114. private _color;
  26115. private _computeParticleColor;
  26116. private _computeParticleTexture;
  26117. private _computeParticleRotation;
  26118. private _computeParticleVertex;
  26119. private _computeBoundingBox;
  26120. private _depthSortParticles;
  26121. private _camera;
  26122. private _mustUnrotateFixedNormals;
  26123. private _particlesIntersect;
  26124. private _needs32Bits;
  26125. private _isNotBuilt;
  26126. /**
  26127. * Creates a SPS (Solid Particle System) object.
  26128. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26129. * @param scene (Scene) is the scene in which the SPS is added.
  26130. * @param options defines the options of the sps e.g.
  26131. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26132. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26133. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26134. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26135. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26136. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26137. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26138. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26139. */
  26140. constructor(name: string, scene: Scene, options?: {
  26141. updatable?: boolean;
  26142. isPickable?: boolean;
  26143. enableDepthSort?: boolean;
  26144. particleIntersection?: boolean;
  26145. boundingSphereOnly?: boolean;
  26146. bSphereRadiusFactor?: number;
  26147. expandable?: boolean;
  26148. });
  26149. /**
  26150. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26151. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26152. * @returns the created mesh
  26153. */
  26154. buildMesh(): Mesh;
  26155. /**
  26156. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26157. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26158. * Thus the particles generated from `digest()` have their property `position` set yet.
  26159. * @param mesh ( Mesh ) is the mesh to be digested
  26160. * @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
  26161. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26162. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26163. * @returns the current SPS
  26164. */
  26165. digest(mesh: Mesh, options?: {
  26166. facetNb?: number;
  26167. number?: number;
  26168. delta?: number;
  26169. }): SolidParticleSystem;
  26170. private _unrotateFixedNormals;
  26171. private _resetCopy;
  26172. private _meshBuilder;
  26173. private _posToShape;
  26174. private _uvsToShapeUV;
  26175. private _addParticle;
  26176. /**
  26177. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26178. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26179. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26180. * @param nb (positive integer) the number of particles to be created from this model
  26181. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26182. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26183. * @returns the number of shapes in the system
  26184. */
  26185. addShape(mesh: Mesh, nb: number, options?: {
  26186. positionFunction?: any;
  26187. vertexFunction?: any;
  26188. }): number;
  26189. private _rebuildParticle;
  26190. /**
  26191. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26192. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26193. * @returns the SPS.
  26194. */
  26195. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26196. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26197. * Returns an array with the removed particles.
  26198. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26199. * The SPS can't be empty so at least one particle needs to remain in place.
  26200. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26201. * @param start index of the first particle to remove
  26202. * @param end index of the last particle to remove (included)
  26203. * @returns an array populated with the removed particles
  26204. */
  26205. removeParticles(start: number, end: number): SolidParticle[];
  26206. /**
  26207. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26208. * This method calls `updateParticle()` for each particle of the SPS.
  26209. * For an animated SPS, it is usually called within the render loop.
  26210. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26211. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26212. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26213. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26214. * @returns the SPS.
  26215. */
  26216. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26217. /**
  26218. * Disposes the SPS.
  26219. */
  26220. dispose(): void;
  26221. /**
  26222. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26224. * @returns the SPS.
  26225. */
  26226. refreshVisibleSize(): SolidParticleSystem;
  26227. /**
  26228. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26229. * @param size the size (float) of the visibility box
  26230. * note : this doesn't lock the SPS mesh bounding box.
  26231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26232. */
  26233. setVisibilityBox(size: number): void;
  26234. /**
  26235. * Gets whether the SPS as always visible or not
  26236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26237. */
  26238. /**
  26239. * Sets the SPS as always visible or not
  26240. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26241. */
  26242. isAlwaysVisible: boolean;
  26243. /**
  26244. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26245. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26246. */
  26247. /**
  26248. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26250. */
  26251. isVisibilityBoxLocked: boolean;
  26252. /**
  26253. * Tells to `setParticles()` to compute the particle rotations or not.
  26254. * Default value : true. The SPS is faster when it's set to false.
  26255. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26256. */
  26257. /**
  26258. * Gets if `setParticles()` computes the particle rotations or not.
  26259. * Default value : true. The SPS is faster when it's set to false.
  26260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26261. */
  26262. computeParticleRotation: boolean;
  26263. /**
  26264. * Tells to `setParticles()` to compute the particle colors or not.
  26265. * Default value : true. The SPS is faster when it's set to false.
  26266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26267. */
  26268. /**
  26269. * Gets if `setParticles()` computes the particle colors or not.
  26270. * Default value : true. The SPS is faster when it's set to false.
  26271. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26272. */
  26273. computeParticleColor: boolean;
  26274. /**
  26275. * Gets if `setParticles()` computes the particle textures or not.
  26276. * Default value : true. The SPS is faster when it's set to false.
  26277. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26278. */
  26279. computeParticleTexture: boolean;
  26280. /**
  26281. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26282. * Default value : false. The SPS is faster when it's set to false.
  26283. * Note : the particle custom vertex positions aren't stored values.
  26284. */
  26285. /**
  26286. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26287. * Default value : false. The SPS is faster when it's set to false.
  26288. * Note : the particle custom vertex positions aren't stored values.
  26289. */
  26290. computeParticleVertex: boolean;
  26291. /**
  26292. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26293. */
  26294. /**
  26295. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26296. */
  26297. computeBoundingBox: boolean;
  26298. /**
  26299. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26300. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26301. * Default : `true`
  26302. */
  26303. /**
  26304. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26305. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26306. * Default : `true`
  26307. */
  26308. depthSortParticles: boolean;
  26309. /**
  26310. * Gets if the SPS is created as expandable at construction time.
  26311. * Default : `false`
  26312. */
  26313. readonly expandable: boolean;
  26314. /**
  26315. * This function does nothing. It may be overwritten to set all the particle first values.
  26316. * The SPS doesn't call this function, you may have to call it by your own.
  26317. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26318. */
  26319. initParticles(): void;
  26320. /**
  26321. * This function does nothing. It may be overwritten to recycle a particle.
  26322. * The SPS doesn't call this function, you may have to call it by your own.
  26323. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26324. * @param particle The particle to recycle
  26325. * @returns the recycled particle
  26326. */
  26327. recycleParticle(particle: SolidParticle): SolidParticle;
  26328. /**
  26329. * Updates a particle : this function should be overwritten by the user.
  26330. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26331. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26332. * @example : just set a particle position or velocity and recycle conditions
  26333. * @param particle The particle to update
  26334. * @returns the updated particle
  26335. */
  26336. updateParticle(particle: SolidParticle): SolidParticle;
  26337. /**
  26338. * Updates a vertex of a particle : it can be overwritten by the user.
  26339. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26340. * @param particle the current particle
  26341. * @param vertex the current index of the current particle
  26342. * @param pt the index of the current vertex in the particle shape
  26343. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26344. * @example : just set a vertex particle position
  26345. * @returns the updated vertex
  26346. */
  26347. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26348. /**
  26349. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26350. * This does nothing and may be overwritten by the user.
  26351. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26352. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26353. * @param update the boolean update value actually passed to setParticles()
  26354. */
  26355. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26356. /**
  26357. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26358. * This will be passed three parameters.
  26359. * This does nothing and may be overwritten by the user.
  26360. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26361. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26362. * @param update the boolean update value actually passed to setParticles()
  26363. */
  26364. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26365. }
  26366. }
  26367. declare module "babylonjs/Particles/solidParticle" {
  26368. import { Nullable } from "babylonjs/types";
  26369. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26370. import { Color4 } from "babylonjs/Maths/math.color";
  26371. import { Mesh } from "babylonjs/Meshes/mesh";
  26372. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26373. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26374. import { Plane } from "babylonjs/Maths/math.plane";
  26375. /**
  26376. * Represents one particle of a solid particle system.
  26377. */
  26378. export class SolidParticle {
  26379. /**
  26380. * particle global index
  26381. */
  26382. idx: number;
  26383. /**
  26384. * The color of the particle
  26385. */
  26386. color: Nullable<Color4>;
  26387. /**
  26388. * The world space position of the particle.
  26389. */
  26390. position: Vector3;
  26391. /**
  26392. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26393. */
  26394. rotation: Vector3;
  26395. /**
  26396. * The world space rotation quaternion of the particle.
  26397. */
  26398. rotationQuaternion: Nullable<Quaternion>;
  26399. /**
  26400. * The scaling of the particle.
  26401. */
  26402. scaling: Vector3;
  26403. /**
  26404. * The uvs of the particle.
  26405. */
  26406. uvs: Vector4;
  26407. /**
  26408. * The current speed of the particle.
  26409. */
  26410. velocity: Vector3;
  26411. /**
  26412. * The pivot point in the particle local space.
  26413. */
  26414. pivot: Vector3;
  26415. /**
  26416. * Must the particle be translated from its pivot point in its local space ?
  26417. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26418. * Default : false
  26419. */
  26420. translateFromPivot: boolean;
  26421. /**
  26422. * Is the particle active or not ?
  26423. */
  26424. alive: boolean;
  26425. /**
  26426. * Is the particle visible or not ?
  26427. */
  26428. isVisible: boolean;
  26429. /**
  26430. * Index of this particle in the global "positions" array (Internal use)
  26431. * @hidden
  26432. */
  26433. _pos: number;
  26434. /**
  26435. * @hidden Index of this particle in the global "indices" array (Internal use)
  26436. */
  26437. _ind: number;
  26438. /**
  26439. * @hidden ModelShape of this particle (Internal use)
  26440. */
  26441. _model: ModelShape;
  26442. /**
  26443. * ModelShape id of this particle
  26444. */
  26445. shapeId: number;
  26446. /**
  26447. * Index of the particle in its shape id
  26448. */
  26449. idxInShape: number;
  26450. /**
  26451. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26452. */
  26453. _modelBoundingInfo: BoundingInfo;
  26454. /**
  26455. * @hidden Particle BoundingInfo object (Internal use)
  26456. */
  26457. _boundingInfo: BoundingInfo;
  26458. /**
  26459. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26460. */
  26461. _sps: SolidParticleSystem;
  26462. /**
  26463. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26464. */
  26465. _stillInvisible: boolean;
  26466. /**
  26467. * @hidden Last computed particle rotation matrix
  26468. */
  26469. _rotationMatrix: number[];
  26470. /**
  26471. * Parent particle Id, if any.
  26472. * Default null.
  26473. */
  26474. parentId: Nullable<number>;
  26475. /**
  26476. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26477. * The possible values are :
  26478. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26479. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26480. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26482. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26483. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26484. * */
  26485. cullingStrategy: number;
  26486. /**
  26487. * @hidden Internal global position in the SPS.
  26488. */
  26489. _globalPosition: Vector3;
  26490. /**
  26491. * Creates a Solid Particle object.
  26492. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26493. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26494. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26495. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26496. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26497. * @param shapeId (integer) is the model shape identifier in the SPS.
  26498. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26499. * @param sps defines the sps it is associated to
  26500. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26501. */
  26502. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26503. /**
  26504. * Legacy support, changed scale to scaling
  26505. */
  26506. /**
  26507. * Legacy support, changed scale to scaling
  26508. */
  26509. scale: Vector3;
  26510. /**
  26511. * Legacy support, changed quaternion to rotationQuaternion
  26512. */
  26513. /**
  26514. * Legacy support, changed quaternion to rotationQuaternion
  26515. */
  26516. quaternion: Nullable<Quaternion>;
  26517. /**
  26518. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26519. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26520. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26521. * @returns true if it intersects
  26522. */
  26523. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26524. /**
  26525. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26526. * A particle is in the frustum if its bounding box intersects the frustum
  26527. * @param frustumPlanes defines the frustum to test
  26528. * @returns true if the particle is in the frustum planes
  26529. */
  26530. isInFrustum(frustumPlanes: Plane[]): boolean;
  26531. /**
  26532. * get the rotation matrix of the particle
  26533. * @hidden
  26534. */
  26535. getRotationMatrix(m: Matrix): void;
  26536. }
  26537. /**
  26538. * Represents the shape of the model used by one particle of a solid particle system.
  26539. * SPS internal tool, don't use it manually.
  26540. */
  26541. export class ModelShape {
  26542. /**
  26543. * The shape id
  26544. * @hidden
  26545. */
  26546. shapeID: number;
  26547. /**
  26548. * flat array of model positions (internal use)
  26549. * @hidden
  26550. */
  26551. _shape: Vector3[];
  26552. /**
  26553. * flat array of model UVs (internal use)
  26554. * @hidden
  26555. */
  26556. _shapeUV: number[];
  26557. /**
  26558. * color array of the model
  26559. * @hidden
  26560. */
  26561. _shapeColors: number[];
  26562. /**
  26563. * indices array of the model
  26564. * @hidden
  26565. */
  26566. _indices: number[];
  26567. /**
  26568. * normals array of the model
  26569. * @hidden
  26570. */
  26571. _normals: number[];
  26572. /**
  26573. * length of the shape in the model indices array (internal use)
  26574. * @hidden
  26575. */
  26576. _indicesLength: number;
  26577. /**
  26578. * Custom position function (internal use)
  26579. * @hidden
  26580. */
  26581. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26582. /**
  26583. * Custom vertex function (internal use)
  26584. * @hidden
  26585. */
  26586. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26587. /**
  26588. * 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.
  26589. * SPS internal tool, don't use it manually.
  26590. * @hidden
  26591. */
  26592. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26593. }
  26594. /**
  26595. * Represents a Depth Sorted Particle in the solid particle system.
  26596. */
  26597. export class DepthSortedParticle {
  26598. /**
  26599. * Index of the particle in the "indices" array
  26600. */
  26601. ind: number;
  26602. /**
  26603. * Length of the particle shape in the "indices" array
  26604. */
  26605. indicesLength: number;
  26606. /**
  26607. * Squared distance from the particle to the camera
  26608. */
  26609. sqDistance: number;
  26610. }
  26611. }
  26612. declare module "babylonjs/Collisions/meshCollisionData" {
  26613. import { Collider } from "babylonjs/Collisions/collider";
  26614. import { Vector3 } from "babylonjs/Maths/math.vector";
  26615. import { Nullable } from "babylonjs/types";
  26616. import { Observer } from "babylonjs/Misc/observable";
  26617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26618. /**
  26619. * @hidden
  26620. */
  26621. export class _MeshCollisionData {
  26622. _checkCollisions: boolean;
  26623. _collisionMask: number;
  26624. _collisionGroup: number;
  26625. _collider: Nullable<Collider>;
  26626. _oldPositionForCollisions: Vector3;
  26627. _diffPositionForCollisions: Vector3;
  26628. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26629. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26630. }
  26631. }
  26632. declare module "babylonjs/Meshes/abstractMesh" {
  26633. import { Observable } from "babylonjs/Misc/observable";
  26634. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26635. import { Camera } from "babylonjs/Cameras/camera";
  26636. import { Scene, IDisposable } from "babylonjs/scene";
  26637. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26638. import { Node } from "babylonjs/node";
  26639. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26640. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26642. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26643. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26644. import { Material } from "babylonjs/Materials/material";
  26645. import { Light } from "babylonjs/Lights/light";
  26646. import { Skeleton } from "babylonjs/Bones/skeleton";
  26647. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26648. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26649. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26650. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26651. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26652. import { Plane } from "babylonjs/Maths/math.plane";
  26653. import { Ray } from "babylonjs/Culling/ray";
  26654. import { Collider } from "babylonjs/Collisions/collider";
  26655. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26656. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26657. /** @hidden */
  26658. class _FacetDataStorage {
  26659. facetPositions: Vector3[];
  26660. facetNormals: Vector3[];
  26661. facetPartitioning: number[][];
  26662. facetNb: number;
  26663. partitioningSubdivisions: number;
  26664. partitioningBBoxRatio: number;
  26665. facetDataEnabled: boolean;
  26666. facetParameters: any;
  26667. bbSize: Vector3;
  26668. subDiv: {
  26669. max: number;
  26670. X: number;
  26671. Y: number;
  26672. Z: number;
  26673. };
  26674. facetDepthSort: boolean;
  26675. facetDepthSortEnabled: boolean;
  26676. depthSortedIndices: IndicesArray;
  26677. depthSortedFacets: {
  26678. ind: number;
  26679. sqDistance: number;
  26680. }[];
  26681. facetDepthSortFunction: (f1: {
  26682. ind: number;
  26683. sqDistance: number;
  26684. }, f2: {
  26685. ind: number;
  26686. sqDistance: number;
  26687. }) => number;
  26688. facetDepthSortFrom: Vector3;
  26689. facetDepthSortOrigin: Vector3;
  26690. invertedMatrix: Matrix;
  26691. }
  26692. /**
  26693. * @hidden
  26694. **/
  26695. class _InternalAbstractMeshDataInfo {
  26696. _hasVertexAlpha: boolean;
  26697. _useVertexColors: boolean;
  26698. _numBoneInfluencers: number;
  26699. _applyFog: boolean;
  26700. _receiveShadows: boolean;
  26701. _facetData: _FacetDataStorage;
  26702. _visibility: number;
  26703. _skeleton: Nullable<Skeleton>;
  26704. _layerMask: number;
  26705. _computeBonesUsingShaders: boolean;
  26706. _isActive: boolean;
  26707. _onlyForInstances: boolean;
  26708. _isActiveIntermediate: boolean;
  26709. _onlyForInstancesIntermediate: boolean;
  26710. _actAsRegularMesh: boolean;
  26711. }
  26712. /**
  26713. * Class used to store all common mesh properties
  26714. */
  26715. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26716. /** No occlusion */
  26717. static OCCLUSION_TYPE_NONE: number;
  26718. /** Occlusion set to optimisitic */
  26719. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26720. /** Occlusion set to strict */
  26721. static OCCLUSION_TYPE_STRICT: number;
  26722. /** Use an accurante occlusion algorithm */
  26723. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26724. /** Use a conservative occlusion algorithm */
  26725. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26726. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26727. * Test order :
  26728. * Is the bounding sphere outside the frustum ?
  26729. * If not, are the bounding box vertices outside the frustum ?
  26730. * It not, then the cullable object is in the frustum.
  26731. */
  26732. static readonly CULLINGSTRATEGY_STANDARD: number;
  26733. /** Culling strategy : Bounding Sphere Only.
  26734. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26735. * It's also less accurate than the standard because some not visible objects can still be selected.
  26736. * Test : is the bounding sphere outside the frustum ?
  26737. * If not, then the cullable object is in the frustum.
  26738. */
  26739. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26740. /** Culling strategy : Optimistic Inclusion.
  26741. * This in an inclusion test first, then the standard exclusion test.
  26742. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26743. * 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.
  26744. * Anyway, it's as accurate as the standard strategy.
  26745. * Test :
  26746. * Is the cullable object bounding sphere center in the frustum ?
  26747. * If not, apply the default culling strategy.
  26748. */
  26749. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26750. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26751. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26752. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26753. * 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.
  26754. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26755. * Test :
  26756. * Is the cullable object bounding sphere center in the frustum ?
  26757. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26758. */
  26759. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26760. /**
  26761. * No billboard
  26762. */
  26763. static readonly BILLBOARDMODE_NONE: number;
  26764. /** Billboard on X axis */
  26765. static readonly BILLBOARDMODE_X: number;
  26766. /** Billboard on Y axis */
  26767. static readonly BILLBOARDMODE_Y: number;
  26768. /** Billboard on Z axis */
  26769. static readonly BILLBOARDMODE_Z: number;
  26770. /** Billboard on all axes */
  26771. static readonly BILLBOARDMODE_ALL: number;
  26772. /** Billboard on using position instead of orientation */
  26773. static readonly BILLBOARDMODE_USE_POSITION: number;
  26774. /** @hidden */
  26775. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26776. /**
  26777. * The culling strategy to use to check whether the mesh must be rendered or not.
  26778. * This value can be changed at any time and will be used on the next render mesh selection.
  26779. * The possible values are :
  26780. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26781. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26782. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26783. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26784. * Please read each static variable documentation to get details about the culling process.
  26785. * */
  26786. cullingStrategy: number;
  26787. /**
  26788. * Gets the number of facets in the mesh
  26789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26790. */
  26791. readonly facetNb: number;
  26792. /**
  26793. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26795. */
  26796. partitioningSubdivisions: number;
  26797. /**
  26798. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26799. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26801. */
  26802. partitioningBBoxRatio: number;
  26803. /**
  26804. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26805. * Works only for updatable meshes.
  26806. * Doesn't work with multi-materials
  26807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26808. */
  26809. mustDepthSortFacets: boolean;
  26810. /**
  26811. * The location (Vector3) where the facet depth sort must be computed from.
  26812. * By default, the active camera position.
  26813. * Used only when facet depth sort is enabled
  26814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26815. */
  26816. facetDepthSortFrom: Vector3;
  26817. /**
  26818. * gets a boolean indicating if facetData is enabled
  26819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26820. */
  26821. readonly isFacetDataEnabled: boolean;
  26822. /** @hidden */
  26823. _updateNonUniformScalingState(value: boolean): boolean;
  26824. /**
  26825. * An event triggered when this mesh collides with another one
  26826. */
  26827. onCollideObservable: Observable<AbstractMesh>;
  26828. /** Set a function to call when this mesh collides with another one */
  26829. onCollide: () => void;
  26830. /**
  26831. * An event triggered when the collision's position changes
  26832. */
  26833. onCollisionPositionChangeObservable: Observable<Vector3>;
  26834. /** Set a function to call when the collision's position changes */
  26835. onCollisionPositionChange: () => void;
  26836. /**
  26837. * An event triggered when material is changed
  26838. */
  26839. onMaterialChangedObservable: Observable<AbstractMesh>;
  26840. /**
  26841. * Gets or sets the orientation for POV movement & rotation
  26842. */
  26843. definedFacingForward: boolean;
  26844. /** @hidden */
  26845. _occlusionQuery: Nullable<WebGLQuery>;
  26846. /** @hidden */
  26847. _renderingGroup: Nullable<RenderingGroup>;
  26848. /**
  26849. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26850. */
  26851. /**
  26852. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26853. */
  26854. visibility: number;
  26855. /** Gets or sets the alpha index used to sort transparent meshes
  26856. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26857. */
  26858. alphaIndex: number;
  26859. /**
  26860. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26861. */
  26862. isVisible: boolean;
  26863. /**
  26864. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26865. */
  26866. isPickable: boolean;
  26867. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26868. showSubMeshesBoundingBox: boolean;
  26869. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26870. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26871. */
  26872. isBlocker: boolean;
  26873. /**
  26874. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26875. */
  26876. enablePointerMoveEvents: boolean;
  26877. /**
  26878. * Specifies the rendering group id for this mesh (0 by default)
  26879. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26880. */
  26881. renderingGroupId: number;
  26882. private _material;
  26883. /** Gets or sets current material */
  26884. material: Nullable<Material>;
  26885. /**
  26886. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26887. * @see http://doc.babylonjs.com/babylon101/shadows
  26888. */
  26889. receiveShadows: boolean;
  26890. /** Defines color to use when rendering outline */
  26891. outlineColor: Color3;
  26892. /** Define width to use when rendering outline */
  26893. outlineWidth: number;
  26894. /** Defines color to use when rendering overlay */
  26895. overlayColor: Color3;
  26896. /** Defines alpha to use when rendering overlay */
  26897. overlayAlpha: number;
  26898. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26899. hasVertexAlpha: boolean;
  26900. /** 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) */
  26901. useVertexColors: boolean;
  26902. /**
  26903. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26904. */
  26905. computeBonesUsingShaders: boolean;
  26906. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26907. numBoneInfluencers: number;
  26908. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26909. applyFog: boolean;
  26910. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26911. useOctreeForRenderingSelection: boolean;
  26912. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26913. useOctreeForPicking: boolean;
  26914. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26915. useOctreeForCollisions: boolean;
  26916. /**
  26917. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26918. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26919. */
  26920. layerMask: number;
  26921. /**
  26922. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26923. */
  26924. alwaysSelectAsActiveMesh: boolean;
  26925. /**
  26926. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26927. */
  26928. doNotSyncBoundingInfo: boolean;
  26929. /**
  26930. * Gets or sets the current action manager
  26931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26932. */
  26933. actionManager: Nullable<AbstractActionManager>;
  26934. private _meshCollisionData;
  26935. /**
  26936. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26937. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26938. */
  26939. ellipsoid: Vector3;
  26940. /**
  26941. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26942. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26943. */
  26944. ellipsoidOffset: Vector3;
  26945. /**
  26946. * Gets or sets a collision mask used to mask collisions (default is -1).
  26947. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26948. */
  26949. collisionMask: number;
  26950. /**
  26951. * Gets or sets the current collision group mask (-1 by default).
  26952. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26953. */
  26954. collisionGroup: number;
  26955. /**
  26956. * Defines edge width used when edgesRenderer is enabled
  26957. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26958. */
  26959. edgesWidth: number;
  26960. /**
  26961. * Defines edge color used when edgesRenderer is enabled
  26962. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26963. */
  26964. edgesColor: Color4;
  26965. /** @hidden */
  26966. _edgesRenderer: Nullable<IEdgesRenderer>;
  26967. /** @hidden */
  26968. _masterMesh: Nullable<AbstractMesh>;
  26969. /** @hidden */
  26970. _boundingInfo: Nullable<BoundingInfo>;
  26971. /** @hidden */
  26972. _renderId: number;
  26973. /**
  26974. * Gets or sets the list of subMeshes
  26975. * @see http://doc.babylonjs.com/how_to/multi_materials
  26976. */
  26977. subMeshes: SubMesh[];
  26978. /** @hidden */
  26979. _intersectionsInProgress: AbstractMesh[];
  26980. /** @hidden */
  26981. _unIndexed: boolean;
  26982. /** @hidden */
  26983. _lightSources: Light[];
  26984. /** Gets the list of lights affecting that mesh */
  26985. readonly lightSources: Light[];
  26986. /** @hidden */
  26987. readonly _positions: Nullable<Vector3[]>;
  26988. /** @hidden */
  26989. _waitingData: {
  26990. lods: Nullable<any>;
  26991. actions: Nullable<any>;
  26992. freezeWorldMatrix: Nullable<boolean>;
  26993. };
  26994. /** @hidden */
  26995. _bonesTransformMatrices: Nullable<Float32Array>;
  26996. /** @hidden */
  26997. _transformMatrixTexture: Nullable<RawTexture>;
  26998. /**
  26999. * Gets or sets a skeleton to apply skining transformations
  27000. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27001. */
  27002. skeleton: Nullable<Skeleton>;
  27003. /**
  27004. * An event triggered when the mesh is rebuilt.
  27005. */
  27006. onRebuildObservable: Observable<AbstractMesh>;
  27007. /**
  27008. * Creates a new AbstractMesh
  27009. * @param name defines the name of the mesh
  27010. * @param scene defines the hosting scene
  27011. */
  27012. constructor(name: string, scene?: Nullable<Scene>);
  27013. /**
  27014. * Returns the string "AbstractMesh"
  27015. * @returns "AbstractMesh"
  27016. */
  27017. getClassName(): string;
  27018. /**
  27019. * Gets a string representation of the current mesh
  27020. * @param fullDetails defines a boolean indicating if full details must be included
  27021. * @returns a string representation of the current mesh
  27022. */
  27023. toString(fullDetails?: boolean): string;
  27024. /**
  27025. * @hidden
  27026. */
  27027. protected _getEffectiveParent(): Nullable<Node>;
  27028. /** @hidden */
  27029. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27030. /** @hidden */
  27031. _rebuild(): void;
  27032. /** @hidden */
  27033. _resyncLightSources(): void;
  27034. /** @hidden */
  27035. _resyncLighSource(light: Light): void;
  27036. /** @hidden */
  27037. _unBindEffect(): void;
  27038. /** @hidden */
  27039. _removeLightSource(light: Light, dispose: boolean): void;
  27040. private _markSubMeshesAsDirty;
  27041. /** @hidden */
  27042. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27043. /** @hidden */
  27044. _markSubMeshesAsAttributesDirty(): void;
  27045. /** @hidden */
  27046. _markSubMeshesAsMiscDirty(): void;
  27047. /**
  27048. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27049. */
  27050. scaling: Vector3;
  27051. /**
  27052. * Returns true if the mesh is blocked. Implemented by child classes
  27053. */
  27054. readonly isBlocked: boolean;
  27055. /**
  27056. * Returns the mesh itself by default. Implemented by child classes
  27057. * @param camera defines the camera to use to pick the right LOD level
  27058. * @returns the currentAbstractMesh
  27059. */
  27060. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27061. /**
  27062. * Returns 0 by default. Implemented by child classes
  27063. * @returns an integer
  27064. */
  27065. getTotalVertices(): number;
  27066. /**
  27067. * Returns a positive integer : the total number of indices in this mesh geometry.
  27068. * @returns the numner of indices or zero if the mesh has no geometry.
  27069. */
  27070. getTotalIndices(): number;
  27071. /**
  27072. * Returns null by default. Implemented by child classes
  27073. * @returns null
  27074. */
  27075. getIndices(): Nullable<IndicesArray>;
  27076. /**
  27077. * Returns the array of the requested vertex data kind. Implemented by child classes
  27078. * @param kind defines the vertex data kind to use
  27079. * @returns null
  27080. */
  27081. getVerticesData(kind: string): Nullable<FloatArray>;
  27082. /**
  27083. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27084. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27085. * Note that a new underlying VertexBuffer object is created each call.
  27086. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27087. * @param kind defines vertex data kind:
  27088. * * VertexBuffer.PositionKind
  27089. * * VertexBuffer.UVKind
  27090. * * VertexBuffer.UV2Kind
  27091. * * VertexBuffer.UV3Kind
  27092. * * VertexBuffer.UV4Kind
  27093. * * VertexBuffer.UV5Kind
  27094. * * VertexBuffer.UV6Kind
  27095. * * VertexBuffer.ColorKind
  27096. * * VertexBuffer.MatricesIndicesKind
  27097. * * VertexBuffer.MatricesIndicesExtraKind
  27098. * * VertexBuffer.MatricesWeightsKind
  27099. * * VertexBuffer.MatricesWeightsExtraKind
  27100. * @param data defines the data source
  27101. * @param updatable defines if the data must be flagged as updatable (or static)
  27102. * @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
  27103. * @returns the current mesh
  27104. */
  27105. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27106. /**
  27107. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27108. * If the mesh has no geometry, it is simply returned as it is.
  27109. * @param kind defines vertex data kind:
  27110. * * VertexBuffer.PositionKind
  27111. * * VertexBuffer.UVKind
  27112. * * VertexBuffer.UV2Kind
  27113. * * VertexBuffer.UV3Kind
  27114. * * VertexBuffer.UV4Kind
  27115. * * VertexBuffer.UV5Kind
  27116. * * VertexBuffer.UV6Kind
  27117. * * VertexBuffer.ColorKind
  27118. * * VertexBuffer.MatricesIndicesKind
  27119. * * VertexBuffer.MatricesIndicesExtraKind
  27120. * * VertexBuffer.MatricesWeightsKind
  27121. * * VertexBuffer.MatricesWeightsExtraKind
  27122. * @param data defines the data source
  27123. * @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
  27124. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27125. * @returns the current mesh
  27126. */
  27127. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27128. /**
  27129. * Sets the mesh indices,
  27130. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27131. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27132. * @param totalVertices Defines the total number of vertices
  27133. * @returns the current mesh
  27134. */
  27135. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27136. /**
  27137. * Gets a boolean indicating if specific vertex data is present
  27138. * @param kind defines the vertex data kind to use
  27139. * @returns true is data kind is present
  27140. */
  27141. isVerticesDataPresent(kind: string): boolean;
  27142. /**
  27143. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27144. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27145. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27146. * @returns a BoundingInfo
  27147. */
  27148. getBoundingInfo(): BoundingInfo;
  27149. /**
  27150. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27151. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27152. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27153. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27154. * @returns the current mesh
  27155. */
  27156. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27157. /**
  27158. * Overwrite the current bounding info
  27159. * @param boundingInfo defines the new bounding info
  27160. * @returns the current mesh
  27161. */
  27162. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27163. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27164. readonly useBones: boolean;
  27165. /** @hidden */
  27166. _preActivate(): void;
  27167. /** @hidden */
  27168. _preActivateForIntermediateRendering(renderId: number): void;
  27169. /** @hidden */
  27170. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27171. /** @hidden */
  27172. _postActivate(): void;
  27173. /** @hidden */
  27174. _freeze(): void;
  27175. /** @hidden */
  27176. _unFreeze(): void;
  27177. /**
  27178. * Gets the current world matrix
  27179. * @returns a Matrix
  27180. */
  27181. getWorldMatrix(): Matrix;
  27182. /** @hidden */
  27183. _getWorldMatrixDeterminant(): number;
  27184. /**
  27185. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27186. */
  27187. readonly isAnInstance: boolean;
  27188. /**
  27189. * Gets a boolean indicating if this mesh has instances
  27190. */
  27191. readonly hasInstances: boolean;
  27192. /**
  27193. * Perform relative position change from the point of view of behind the front of the mesh.
  27194. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27195. * Supports definition of mesh facing forward or backward
  27196. * @param amountRight defines the distance on the right axis
  27197. * @param amountUp defines the distance on the up axis
  27198. * @param amountForward defines the distance on the forward axis
  27199. * @returns the current mesh
  27200. */
  27201. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27202. /**
  27203. * Calculate relative position change from the point of view of behind the front of the mesh.
  27204. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27205. * Supports definition of mesh facing forward or backward
  27206. * @param amountRight defines the distance on the right axis
  27207. * @param amountUp defines the distance on the up axis
  27208. * @param amountForward defines the distance on the forward axis
  27209. * @returns the new displacement vector
  27210. */
  27211. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27212. /**
  27213. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27214. * Supports definition of mesh facing forward or backward
  27215. * @param flipBack defines the flip
  27216. * @param twirlClockwise defines the twirl
  27217. * @param tiltRight defines the tilt
  27218. * @returns the current mesh
  27219. */
  27220. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27221. /**
  27222. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27223. * Supports definition of mesh facing forward or backward.
  27224. * @param flipBack defines the flip
  27225. * @param twirlClockwise defines the twirl
  27226. * @param tiltRight defines the tilt
  27227. * @returns the new rotation vector
  27228. */
  27229. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27230. /**
  27231. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27232. * This means the mesh underlying bounding box and sphere are recomputed.
  27233. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27234. * @returns the current mesh
  27235. */
  27236. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27237. /** @hidden */
  27238. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27239. /** @hidden */
  27240. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27241. /** @hidden */
  27242. _updateBoundingInfo(): AbstractMesh;
  27243. /** @hidden */
  27244. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27245. /** @hidden */
  27246. protected _afterComputeWorldMatrix(): void;
  27247. /** @hidden */
  27248. readonly _effectiveMesh: AbstractMesh;
  27249. /**
  27250. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27251. * A mesh is in the frustum if its bounding box intersects the frustum
  27252. * @param frustumPlanes defines the frustum to test
  27253. * @returns true if the mesh is in the frustum planes
  27254. */
  27255. isInFrustum(frustumPlanes: Plane[]): boolean;
  27256. /**
  27257. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27258. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27259. * @param frustumPlanes defines the frustum to test
  27260. * @returns true if the mesh is completely in the frustum planes
  27261. */
  27262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27263. /**
  27264. * True if the mesh intersects another mesh or a SolidParticle object
  27265. * @param mesh defines a target mesh or SolidParticle to test
  27266. * @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)
  27267. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27268. * @returns true if there is an intersection
  27269. */
  27270. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27271. /**
  27272. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27273. * @param point defines the point to test
  27274. * @returns true if there is an intersection
  27275. */
  27276. intersectsPoint(point: Vector3): boolean;
  27277. /**
  27278. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27279. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27280. */
  27281. checkCollisions: boolean;
  27282. /**
  27283. * Gets Collider object used to compute collisions (not physics)
  27284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27285. */
  27286. readonly collider: Nullable<Collider>;
  27287. /**
  27288. * Move the mesh using collision engine
  27289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27290. * @param displacement defines the requested displacement vector
  27291. * @returns the current mesh
  27292. */
  27293. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27294. private _onCollisionPositionChange;
  27295. /** @hidden */
  27296. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27297. /** @hidden */
  27298. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27299. /** @hidden */
  27300. _checkCollision(collider: Collider): AbstractMesh;
  27301. /** @hidden */
  27302. _generatePointsArray(): boolean;
  27303. /**
  27304. * Checks if the passed Ray intersects with the mesh
  27305. * @param ray defines the ray to use
  27306. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27308. * @returns the picking info
  27309. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27310. */
  27311. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27312. /**
  27313. * Clones the current mesh
  27314. * @param name defines the mesh name
  27315. * @param newParent defines the new mesh parent
  27316. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27317. * @returns the new mesh
  27318. */
  27319. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27320. /**
  27321. * Disposes all the submeshes of the current meshnp
  27322. * @returns the current mesh
  27323. */
  27324. releaseSubMeshes(): AbstractMesh;
  27325. /**
  27326. * Releases resources associated with this abstract mesh.
  27327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27329. */
  27330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27331. /**
  27332. * Adds the passed mesh as a child to the current mesh
  27333. * @param mesh defines the child mesh
  27334. * @returns the current mesh
  27335. */
  27336. addChild(mesh: AbstractMesh): AbstractMesh;
  27337. /**
  27338. * Removes the passed mesh from the current mesh children list
  27339. * @param mesh defines the child mesh
  27340. * @returns the current mesh
  27341. */
  27342. removeChild(mesh: AbstractMesh): AbstractMesh;
  27343. /** @hidden */
  27344. private _initFacetData;
  27345. /**
  27346. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27347. * This method can be called within the render loop.
  27348. * 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
  27349. * @returns the current mesh
  27350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27351. */
  27352. updateFacetData(): AbstractMesh;
  27353. /**
  27354. * Returns the facetLocalNormals array.
  27355. * The normals are expressed in the mesh local spac
  27356. * @returns an array of Vector3
  27357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27358. */
  27359. getFacetLocalNormals(): Vector3[];
  27360. /**
  27361. * Returns the facetLocalPositions array.
  27362. * The facet positions are expressed in the mesh local space
  27363. * @returns an array of Vector3
  27364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27365. */
  27366. getFacetLocalPositions(): Vector3[];
  27367. /**
  27368. * Returns the facetLocalPartioning array
  27369. * @returns an array of array of numbers
  27370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27371. */
  27372. getFacetLocalPartitioning(): number[][];
  27373. /**
  27374. * Returns the i-th facet position in the world system.
  27375. * This method allocates a new Vector3 per call
  27376. * @param i defines the facet index
  27377. * @returns a new Vector3
  27378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27379. */
  27380. getFacetPosition(i: number): Vector3;
  27381. /**
  27382. * Sets the reference Vector3 with the i-th facet position in the world system
  27383. * @param i defines the facet index
  27384. * @param ref defines the target vector
  27385. * @returns the current mesh
  27386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27387. */
  27388. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27389. /**
  27390. * Returns the i-th facet normal in the world system.
  27391. * This method allocates a new Vector3 per call
  27392. * @param i defines the facet index
  27393. * @returns a new Vector3
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27395. */
  27396. getFacetNormal(i: number): Vector3;
  27397. /**
  27398. * Sets the reference Vector3 with the i-th facet normal in the world system
  27399. * @param i defines the facet index
  27400. * @param ref defines the target vector
  27401. * @returns the current mesh
  27402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27403. */
  27404. getFacetNormalToRef(i: number, ref: Vector3): this;
  27405. /**
  27406. * 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)
  27407. * @param x defines x coordinate
  27408. * @param y defines y coordinate
  27409. * @param z defines z coordinate
  27410. * @returns the array of facet indexes
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27412. */
  27413. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27414. /**
  27415. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27416. * @param projected sets as the (x,y,z) world projection on the facet
  27417. * @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
  27418. * @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
  27419. * @param x defines x coordinate
  27420. * @param y defines y coordinate
  27421. * @param z defines z coordinate
  27422. * @returns the face index if found (or null instead)
  27423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27424. */
  27425. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27426. /**
  27427. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27428. * @param projected sets as the (x,y,z) local projection on the facet
  27429. * @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
  27430. * @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
  27431. * @param x defines x coordinate
  27432. * @param y defines y coordinate
  27433. * @param z defines z coordinate
  27434. * @returns the face index if found (or null instead)
  27435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27436. */
  27437. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27438. /**
  27439. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27440. * @returns the parameters
  27441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27442. */
  27443. getFacetDataParameters(): any;
  27444. /**
  27445. * Disables the feature FacetData and frees the related memory
  27446. * @returns the current mesh
  27447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27448. */
  27449. disableFacetData(): AbstractMesh;
  27450. /**
  27451. * Updates the AbstractMesh indices array
  27452. * @param indices defines the data source
  27453. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27454. * @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)
  27455. * @returns the current mesh
  27456. */
  27457. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27458. /**
  27459. * Creates new normals data for the mesh
  27460. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27461. * @returns the current mesh
  27462. */
  27463. createNormals(updatable: boolean): AbstractMesh;
  27464. /**
  27465. * Align the mesh with a normal
  27466. * @param normal defines the normal to use
  27467. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27468. * @returns the current mesh
  27469. */
  27470. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27471. /** @hidden */
  27472. _checkOcclusionQuery(): boolean;
  27473. /**
  27474. * Disables the mesh edge rendering mode
  27475. * @returns the currentAbstractMesh
  27476. */
  27477. disableEdgesRendering(): AbstractMesh;
  27478. /**
  27479. * Enables the edge rendering mode on the mesh.
  27480. * This mode makes the mesh edges visible
  27481. * @param epsilon defines the maximal distance between two angles to detect a face
  27482. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27483. * @returns the currentAbstractMesh
  27484. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27485. */
  27486. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27487. }
  27488. }
  27489. declare module "babylonjs/Actions/actionEvent" {
  27490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27491. import { Nullable } from "babylonjs/types";
  27492. import { Sprite } from "babylonjs/Sprites/sprite";
  27493. import { Scene } from "babylonjs/scene";
  27494. import { Vector2 } from "babylonjs/Maths/math.vector";
  27495. /**
  27496. * Interface used to define ActionEvent
  27497. */
  27498. export interface IActionEvent {
  27499. /** The mesh or sprite that triggered the action */
  27500. source: any;
  27501. /** The X mouse cursor position at the time of the event */
  27502. pointerX: number;
  27503. /** The Y mouse cursor position at the time of the event */
  27504. pointerY: number;
  27505. /** The mesh that is currently pointed at (can be null) */
  27506. meshUnderPointer: Nullable<AbstractMesh>;
  27507. /** the original (browser) event that triggered the ActionEvent */
  27508. sourceEvent?: any;
  27509. /** additional data for the event */
  27510. additionalData?: any;
  27511. }
  27512. /**
  27513. * ActionEvent is the event being sent when an action is triggered.
  27514. */
  27515. export class ActionEvent implements IActionEvent {
  27516. /** The mesh or sprite that triggered the action */
  27517. source: any;
  27518. /** The X mouse cursor position at the time of the event */
  27519. pointerX: number;
  27520. /** The Y mouse cursor position at the time of the event */
  27521. pointerY: number;
  27522. /** The mesh that is currently pointed at (can be null) */
  27523. meshUnderPointer: Nullable<AbstractMesh>;
  27524. /** the original (browser) event that triggered the ActionEvent */
  27525. sourceEvent?: any;
  27526. /** additional data for the event */
  27527. additionalData?: any;
  27528. /**
  27529. * Creates a new ActionEvent
  27530. * @param source The mesh or sprite that triggered the action
  27531. * @param pointerX The X mouse cursor position at the time of the event
  27532. * @param pointerY The Y mouse cursor position at the time of the event
  27533. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27534. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27535. * @param additionalData additional data for the event
  27536. */
  27537. constructor(
  27538. /** The mesh or sprite that triggered the action */
  27539. source: any,
  27540. /** The X mouse cursor position at the time of the event */
  27541. pointerX: number,
  27542. /** The Y mouse cursor position at the time of the event */
  27543. pointerY: number,
  27544. /** The mesh that is currently pointed at (can be null) */
  27545. meshUnderPointer: Nullable<AbstractMesh>,
  27546. /** the original (browser) event that triggered the ActionEvent */
  27547. sourceEvent?: any,
  27548. /** additional data for the event */
  27549. additionalData?: any);
  27550. /**
  27551. * Helper function to auto-create an ActionEvent from a source mesh.
  27552. * @param source The source mesh that triggered the event
  27553. * @param evt The original (browser) event
  27554. * @param additionalData additional data for the event
  27555. * @returns the new ActionEvent
  27556. */
  27557. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27558. /**
  27559. * Helper function to auto-create an ActionEvent from a source sprite
  27560. * @param source The source sprite that triggered the event
  27561. * @param scene Scene associated with the sprite
  27562. * @param evt The original (browser) event
  27563. * @param additionalData additional data for the event
  27564. * @returns the new ActionEvent
  27565. */
  27566. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27567. /**
  27568. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27569. * @param scene the scene where the event occurred
  27570. * @param evt The original (browser) event
  27571. * @returns the new ActionEvent
  27572. */
  27573. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27574. /**
  27575. * Helper function to auto-create an ActionEvent from a primitive
  27576. * @param prim defines the target primitive
  27577. * @param pointerPos defines the pointer position
  27578. * @param evt The original (browser) event
  27579. * @param additionalData additional data for the event
  27580. * @returns the new ActionEvent
  27581. */
  27582. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27583. }
  27584. }
  27585. declare module "babylonjs/Actions/abstractActionManager" {
  27586. import { IDisposable } from "babylonjs/scene";
  27587. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27588. import { IAction } from "babylonjs/Actions/action";
  27589. import { Nullable } from "babylonjs/types";
  27590. /**
  27591. * Abstract class used to decouple action Manager from scene and meshes.
  27592. * Do not instantiate.
  27593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27594. */
  27595. export abstract class AbstractActionManager implements IDisposable {
  27596. /** Gets the list of active triggers */
  27597. static Triggers: {
  27598. [key: string]: number;
  27599. };
  27600. /** Gets the cursor to use when hovering items */
  27601. hoverCursor: string;
  27602. /** Gets the list of actions */
  27603. actions: IAction[];
  27604. /**
  27605. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27606. */
  27607. isRecursive: boolean;
  27608. /**
  27609. * Releases all associated resources
  27610. */
  27611. abstract dispose(): void;
  27612. /**
  27613. * Does this action manager has pointer triggers
  27614. */
  27615. abstract readonly hasPointerTriggers: boolean;
  27616. /**
  27617. * Does this action manager has pick triggers
  27618. */
  27619. abstract readonly hasPickTriggers: boolean;
  27620. /**
  27621. * Process a specific trigger
  27622. * @param trigger defines the trigger to process
  27623. * @param evt defines the event details to be processed
  27624. */
  27625. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27626. /**
  27627. * Does this action manager handles actions of any of the given triggers
  27628. * @param triggers defines the triggers to be tested
  27629. * @return a boolean indicating whether one (or more) of the triggers is handled
  27630. */
  27631. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27632. /**
  27633. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27634. * speed.
  27635. * @param triggerA defines the trigger to be tested
  27636. * @param triggerB defines the trigger to be tested
  27637. * @return a boolean indicating whether one (or more) of the triggers is handled
  27638. */
  27639. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27640. /**
  27641. * Does this action manager handles actions of a given trigger
  27642. * @param trigger defines the trigger to be tested
  27643. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27644. * @return whether the trigger is handled
  27645. */
  27646. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27647. /**
  27648. * Serialize this manager to a JSON object
  27649. * @param name defines the property name to store this manager
  27650. * @returns a JSON representation of this manager
  27651. */
  27652. abstract serialize(name: string): any;
  27653. /**
  27654. * Registers an action to this action manager
  27655. * @param action defines the action to be registered
  27656. * @return the action amended (prepared) after registration
  27657. */
  27658. abstract registerAction(action: IAction): Nullable<IAction>;
  27659. /**
  27660. * Unregisters an action to this action manager
  27661. * @param action defines the action to be unregistered
  27662. * @return a boolean indicating whether the action has been unregistered
  27663. */
  27664. abstract unregisterAction(action: IAction): Boolean;
  27665. /**
  27666. * Does exist one action manager with at least one trigger
  27667. **/
  27668. static readonly HasTriggers: boolean;
  27669. /**
  27670. * Does exist one action manager with at least one pick trigger
  27671. **/
  27672. static readonly HasPickTriggers: boolean;
  27673. /**
  27674. * Does exist one action manager that handles actions of a given trigger
  27675. * @param trigger defines the trigger to be tested
  27676. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27677. **/
  27678. static HasSpecificTrigger(trigger: number): boolean;
  27679. }
  27680. }
  27681. declare module "babylonjs/node" {
  27682. import { Scene } from "babylonjs/scene";
  27683. import { Nullable } from "babylonjs/types";
  27684. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27685. import { Engine } from "babylonjs/Engines/engine";
  27686. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27687. import { Observable } from "babylonjs/Misc/observable";
  27688. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27689. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27690. import { Animatable } from "babylonjs/Animations/animatable";
  27691. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27692. import { Animation } from "babylonjs/Animations/animation";
  27693. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27695. /**
  27696. * Defines how a node can be built from a string name.
  27697. */
  27698. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27699. /**
  27700. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27701. */
  27702. export class Node implements IBehaviorAware<Node> {
  27703. /** @hidden */
  27704. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27705. private static _NodeConstructors;
  27706. /**
  27707. * Add a new node constructor
  27708. * @param type defines the type name of the node to construct
  27709. * @param constructorFunc defines the constructor function
  27710. */
  27711. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27712. /**
  27713. * Returns a node constructor based on type name
  27714. * @param type defines the type name
  27715. * @param name defines the new node name
  27716. * @param scene defines the hosting scene
  27717. * @param options defines optional options to transmit to constructors
  27718. * @returns the new constructor or null
  27719. */
  27720. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27721. /**
  27722. * Gets or sets the name of the node
  27723. */
  27724. name: string;
  27725. /**
  27726. * Gets or sets the id of the node
  27727. */
  27728. id: string;
  27729. /**
  27730. * Gets or sets the unique id of the node
  27731. */
  27732. uniqueId: number;
  27733. /**
  27734. * Gets or sets a string used to store user defined state for the node
  27735. */
  27736. state: string;
  27737. /**
  27738. * Gets or sets an object used to store user defined information for the node
  27739. */
  27740. metadata: any;
  27741. /**
  27742. * For internal use only. Please do not use.
  27743. */
  27744. reservedDataStore: any;
  27745. /**
  27746. * List of inspectable custom properties (used by the Inspector)
  27747. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27748. */
  27749. inspectableCustomProperties: IInspectable[];
  27750. private _doNotSerialize;
  27751. /**
  27752. * Gets or sets a boolean used to define if the node must be serialized
  27753. */
  27754. doNotSerialize: boolean;
  27755. /** @hidden */
  27756. _isDisposed: boolean;
  27757. /**
  27758. * Gets a list of Animations associated with the node
  27759. */
  27760. animations: import("babylonjs/Animations/animation").Animation[];
  27761. protected _ranges: {
  27762. [name: string]: Nullable<AnimationRange>;
  27763. };
  27764. /**
  27765. * Callback raised when the node is ready to be used
  27766. */
  27767. onReady: Nullable<(node: Node) => void>;
  27768. private _isEnabled;
  27769. private _isParentEnabled;
  27770. private _isReady;
  27771. /** @hidden */
  27772. _currentRenderId: number;
  27773. private _parentUpdateId;
  27774. /** @hidden */
  27775. _childUpdateId: number;
  27776. /** @hidden */
  27777. _waitingParentId: Nullable<string>;
  27778. /** @hidden */
  27779. _scene: Scene;
  27780. /** @hidden */
  27781. _cache: any;
  27782. private _parentNode;
  27783. private _children;
  27784. /** @hidden */
  27785. _worldMatrix: Matrix;
  27786. /** @hidden */
  27787. _worldMatrixDeterminant: number;
  27788. /** @hidden */
  27789. _worldMatrixDeterminantIsDirty: boolean;
  27790. /** @hidden */
  27791. private _sceneRootNodesIndex;
  27792. /**
  27793. * Gets a boolean indicating if the node has been disposed
  27794. * @returns true if the node was disposed
  27795. */
  27796. isDisposed(): boolean;
  27797. /**
  27798. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27799. * @see https://doc.babylonjs.com/how_to/parenting
  27800. */
  27801. parent: Nullable<Node>;
  27802. private addToSceneRootNodes;
  27803. private removeFromSceneRootNodes;
  27804. private _animationPropertiesOverride;
  27805. /**
  27806. * Gets or sets the animation properties override
  27807. */
  27808. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27809. /**
  27810. * Gets a string idenfifying the name of the class
  27811. * @returns "Node" string
  27812. */
  27813. getClassName(): string;
  27814. /** @hidden */
  27815. readonly _isNode: boolean;
  27816. /**
  27817. * An event triggered when the mesh is disposed
  27818. */
  27819. onDisposeObservable: Observable<Node>;
  27820. private _onDisposeObserver;
  27821. /**
  27822. * Sets a callback that will be raised when the node will be disposed
  27823. */
  27824. onDispose: () => void;
  27825. /**
  27826. * Creates a new Node
  27827. * @param name the name and id to be given to this node
  27828. * @param scene the scene this node will be added to
  27829. * @param addToRootNodes the node will be added to scene.rootNodes
  27830. */
  27831. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27832. /**
  27833. * Gets the scene of the node
  27834. * @returns a scene
  27835. */
  27836. getScene(): Scene;
  27837. /**
  27838. * Gets the engine of the node
  27839. * @returns a Engine
  27840. */
  27841. getEngine(): Engine;
  27842. private _behaviors;
  27843. /**
  27844. * Attach a behavior to the node
  27845. * @see http://doc.babylonjs.com/features/behaviour
  27846. * @param behavior defines the behavior to attach
  27847. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27848. * @returns the current Node
  27849. */
  27850. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27851. /**
  27852. * Remove an attached behavior
  27853. * @see http://doc.babylonjs.com/features/behaviour
  27854. * @param behavior defines the behavior to attach
  27855. * @returns the current Node
  27856. */
  27857. removeBehavior(behavior: Behavior<Node>): Node;
  27858. /**
  27859. * Gets the list of attached behaviors
  27860. * @see http://doc.babylonjs.com/features/behaviour
  27861. */
  27862. readonly behaviors: Behavior<Node>[];
  27863. /**
  27864. * Gets an attached behavior by name
  27865. * @param name defines the name of the behavior to look for
  27866. * @see http://doc.babylonjs.com/features/behaviour
  27867. * @returns null if behavior was not found else the requested behavior
  27868. */
  27869. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27870. /**
  27871. * Returns the latest update of the World matrix
  27872. * @returns a Matrix
  27873. */
  27874. getWorldMatrix(): Matrix;
  27875. /** @hidden */
  27876. _getWorldMatrixDeterminant(): number;
  27877. /**
  27878. * Returns directly the latest state of the mesh World matrix.
  27879. * A Matrix is returned.
  27880. */
  27881. readonly worldMatrixFromCache: Matrix;
  27882. /** @hidden */
  27883. _initCache(): void;
  27884. /** @hidden */
  27885. updateCache(force?: boolean): void;
  27886. /** @hidden */
  27887. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27888. /** @hidden */
  27889. _updateCache(ignoreParentClass?: boolean): void;
  27890. /** @hidden */
  27891. _isSynchronized(): boolean;
  27892. /** @hidden */
  27893. _markSyncedWithParent(): void;
  27894. /** @hidden */
  27895. isSynchronizedWithParent(): boolean;
  27896. /** @hidden */
  27897. isSynchronized(): boolean;
  27898. /**
  27899. * Is this node ready to be used/rendered
  27900. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27901. * @return true if the node is ready
  27902. */
  27903. isReady(completeCheck?: boolean): boolean;
  27904. /**
  27905. * Is this node enabled?
  27906. * 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
  27907. * @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
  27908. * @return whether this node (and its parent) is enabled
  27909. */
  27910. isEnabled(checkAncestors?: boolean): boolean;
  27911. /** @hidden */
  27912. protected _syncParentEnabledState(): void;
  27913. /**
  27914. * Set the enabled state of this node
  27915. * @param value defines the new enabled state
  27916. */
  27917. setEnabled(value: boolean): void;
  27918. /**
  27919. * Is this node a descendant of the given node?
  27920. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27921. * @param ancestor defines the parent node to inspect
  27922. * @returns a boolean indicating if this node is a descendant of the given node
  27923. */
  27924. isDescendantOf(ancestor: Node): boolean;
  27925. /** @hidden */
  27926. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27927. /**
  27928. * Will return all nodes that have this node as ascendant
  27929. * @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
  27930. * @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
  27931. * @return all children nodes of all types
  27932. */
  27933. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27934. /**
  27935. * Get all child-meshes of this node
  27936. * @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)
  27937. * @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
  27938. * @returns an array of AbstractMesh
  27939. */
  27940. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27941. /**
  27942. * Get all direct children of this node
  27943. * @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
  27944. * @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)
  27945. * @returns an array of Node
  27946. */
  27947. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27948. /** @hidden */
  27949. _setReady(state: boolean): void;
  27950. /**
  27951. * Get an animation by name
  27952. * @param name defines the name of the animation to look for
  27953. * @returns null if not found else the requested animation
  27954. */
  27955. getAnimationByName(name: string): Nullable<Animation>;
  27956. /**
  27957. * Creates an animation range for this node
  27958. * @param name defines the name of the range
  27959. * @param from defines the starting key
  27960. * @param to defines the end key
  27961. */
  27962. createAnimationRange(name: string, from: number, to: number): void;
  27963. /**
  27964. * Delete a specific animation range
  27965. * @param name defines the name of the range to delete
  27966. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27967. */
  27968. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27969. /**
  27970. * Get an animation range by name
  27971. * @param name defines the name of the animation range to look for
  27972. * @returns null if not found else the requested animation range
  27973. */
  27974. getAnimationRange(name: string): Nullable<AnimationRange>;
  27975. /**
  27976. * Gets the list of all animation ranges defined on this node
  27977. * @returns an array
  27978. */
  27979. getAnimationRanges(): Nullable<AnimationRange>[];
  27980. /**
  27981. * Will start the animation sequence
  27982. * @param name defines the range frames for animation sequence
  27983. * @param loop defines if the animation should loop (false by default)
  27984. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27985. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27986. * @returns the object created for this animation. If range does not exist, it will return null
  27987. */
  27988. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27989. /**
  27990. * Serialize animation ranges into a JSON compatible object
  27991. * @returns serialization object
  27992. */
  27993. serializeAnimationRanges(): any;
  27994. /**
  27995. * Computes the world matrix of the node
  27996. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27997. * @returns the world matrix
  27998. */
  27999. computeWorldMatrix(force?: boolean): Matrix;
  28000. /**
  28001. * Releases resources associated with this node.
  28002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28004. */
  28005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28006. /**
  28007. * Parse animation range data from a serialization object and store them into a given node
  28008. * @param node defines where to store the animation ranges
  28009. * @param parsedNode defines the serialization object to read data from
  28010. * @param scene defines the hosting scene
  28011. */
  28012. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28013. /**
  28014. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28015. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28016. * @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
  28017. * @returns the new bounding vectors
  28018. */
  28019. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28020. min: Vector3;
  28021. max: Vector3;
  28022. };
  28023. }
  28024. }
  28025. declare module "babylonjs/Animations/animation" {
  28026. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28027. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28028. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28029. import { Nullable } from "babylonjs/types";
  28030. import { Scene } from "babylonjs/scene";
  28031. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28032. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28033. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28034. import { Node } from "babylonjs/node";
  28035. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28036. import { Size } from "babylonjs/Maths/math.size";
  28037. import { Animatable } from "babylonjs/Animations/animatable";
  28038. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28039. /**
  28040. * @hidden
  28041. */
  28042. export class _IAnimationState {
  28043. key: number;
  28044. repeatCount: number;
  28045. workValue?: any;
  28046. loopMode?: number;
  28047. offsetValue?: any;
  28048. highLimitValue?: any;
  28049. }
  28050. /**
  28051. * Class used to store any kind of animation
  28052. */
  28053. export class Animation {
  28054. /**Name of the animation */
  28055. name: string;
  28056. /**Property to animate */
  28057. targetProperty: string;
  28058. /**The frames per second of the animation */
  28059. framePerSecond: number;
  28060. /**The data type of the animation */
  28061. dataType: number;
  28062. /**The loop mode of the animation */
  28063. loopMode?: number | undefined;
  28064. /**Specifies if blending should be enabled */
  28065. enableBlending?: boolean | undefined;
  28066. /**
  28067. * Use matrix interpolation instead of using direct key value when animating matrices
  28068. */
  28069. static AllowMatricesInterpolation: boolean;
  28070. /**
  28071. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28072. */
  28073. static AllowMatrixDecomposeForInterpolation: boolean;
  28074. /**
  28075. * Stores the key frames of the animation
  28076. */
  28077. private _keys;
  28078. /**
  28079. * Stores the easing function of the animation
  28080. */
  28081. private _easingFunction;
  28082. /**
  28083. * @hidden Internal use only
  28084. */
  28085. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28086. /**
  28087. * The set of event that will be linked to this animation
  28088. */
  28089. private _events;
  28090. /**
  28091. * Stores an array of target property paths
  28092. */
  28093. targetPropertyPath: string[];
  28094. /**
  28095. * Stores the blending speed of the animation
  28096. */
  28097. blendingSpeed: number;
  28098. /**
  28099. * Stores the animation ranges for the animation
  28100. */
  28101. private _ranges;
  28102. /**
  28103. * @hidden Internal use
  28104. */
  28105. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28106. /**
  28107. * Sets up an animation
  28108. * @param property The property to animate
  28109. * @param animationType The animation type to apply
  28110. * @param framePerSecond The frames per second of the animation
  28111. * @param easingFunction The easing function used in the animation
  28112. * @returns The created animation
  28113. */
  28114. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28115. /**
  28116. * Create and start an animation on a node
  28117. * @param name defines the name of the global animation that will be run on all nodes
  28118. * @param node defines the root node where the animation will take place
  28119. * @param targetProperty defines property to animate
  28120. * @param framePerSecond defines the number of frame per second yo use
  28121. * @param totalFrame defines the number of frames in total
  28122. * @param from defines the initial value
  28123. * @param to defines the final value
  28124. * @param loopMode defines which loop mode you want to use (off by default)
  28125. * @param easingFunction defines the easing function to use (linear by default)
  28126. * @param onAnimationEnd defines the callback to call when animation end
  28127. * @returns the animatable created for this animation
  28128. */
  28129. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28130. /**
  28131. * Create and start an animation on a node and its descendants
  28132. * @param name defines the name of the global animation that will be run on all nodes
  28133. * @param node defines the root node where the animation will take place
  28134. * @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
  28135. * @param targetProperty defines property to animate
  28136. * @param framePerSecond defines the number of frame per second to use
  28137. * @param totalFrame defines the number of frames in total
  28138. * @param from defines the initial value
  28139. * @param to defines the final value
  28140. * @param loopMode defines which loop mode you want to use (off by default)
  28141. * @param easingFunction defines the easing function to use (linear by default)
  28142. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28143. * @returns the list of animatables created for all nodes
  28144. * @example https://www.babylonjs-playground.com/#MH0VLI
  28145. */
  28146. 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[]>;
  28147. /**
  28148. * Creates a new animation, merges it with the existing animations and starts it
  28149. * @param name Name of the animation
  28150. * @param node Node which contains the scene that begins the animations
  28151. * @param targetProperty Specifies which property to animate
  28152. * @param framePerSecond The frames per second of the animation
  28153. * @param totalFrame The total number of frames
  28154. * @param from The frame at the beginning of the animation
  28155. * @param to The frame at the end of the animation
  28156. * @param loopMode Specifies the loop mode of the animation
  28157. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28158. * @param onAnimationEnd Callback to run once the animation is complete
  28159. * @returns Nullable animation
  28160. */
  28161. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28162. /**
  28163. * Transition property of an host to the target Value
  28164. * @param property The property to transition
  28165. * @param targetValue The target Value of the property
  28166. * @param host The object where the property to animate belongs
  28167. * @param scene Scene used to run the animation
  28168. * @param frameRate Framerate (in frame/s) to use
  28169. * @param transition The transition type we want to use
  28170. * @param duration The duration of the animation, in milliseconds
  28171. * @param onAnimationEnd Callback trigger at the end of the animation
  28172. * @returns Nullable animation
  28173. */
  28174. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28175. /**
  28176. * Return the array of runtime animations currently using this animation
  28177. */
  28178. readonly runtimeAnimations: RuntimeAnimation[];
  28179. /**
  28180. * Specifies if any of the runtime animations are currently running
  28181. */
  28182. readonly hasRunningRuntimeAnimations: boolean;
  28183. /**
  28184. * Initializes the animation
  28185. * @param name Name of the animation
  28186. * @param targetProperty Property to animate
  28187. * @param framePerSecond The frames per second of the animation
  28188. * @param dataType The data type of the animation
  28189. * @param loopMode The loop mode of the animation
  28190. * @param enableBlending Specifies if blending should be enabled
  28191. */
  28192. constructor(
  28193. /**Name of the animation */
  28194. name: string,
  28195. /**Property to animate */
  28196. targetProperty: string,
  28197. /**The frames per second of the animation */
  28198. framePerSecond: number,
  28199. /**The data type of the animation */
  28200. dataType: number,
  28201. /**The loop mode of the animation */
  28202. loopMode?: number | undefined,
  28203. /**Specifies if blending should be enabled */
  28204. enableBlending?: boolean | undefined);
  28205. /**
  28206. * Converts the animation to a string
  28207. * @param fullDetails support for multiple levels of logging within scene loading
  28208. * @returns String form of the animation
  28209. */
  28210. toString(fullDetails?: boolean): string;
  28211. /**
  28212. * Add an event to this animation
  28213. * @param event Event to add
  28214. */
  28215. addEvent(event: AnimationEvent): void;
  28216. /**
  28217. * Remove all events found at the given frame
  28218. * @param frame The frame to remove events from
  28219. */
  28220. removeEvents(frame: number): void;
  28221. /**
  28222. * Retrieves all the events from the animation
  28223. * @returns Events from the animation
  28224. */
  28225. getEvents(): AnimationEvent[];
  28226. /**
  28227. * Creates an animation range
  28228. * @param name Name of the animation range
  28229. * @param from Starting frame of the animation range
  28230. * @param to Ending frame of the animation
  28231. */
  28232. createRange(name: string, from: number, to: number): void;
  28233. /**
  28234. * Deletes an animation range by name
  28235. * @param name Name of the animation range to delete
  28236. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28237. */
  28238. deleteRange(name: string, deleteFrames?: boolean): void;
  28239. /**
  28240. * Gets the animation range by name, or null if not defined
  28241. * @param name Name of the animation range
  28242. * @returns Nullable animation range
  28243. */
  28244. getRange(name: string): Nullable<AnimationRange>;
  28245. /**
  28246. * Gets the key frames from the animation
  28247. * @returns The key frames of the animation
  28248. */
  28249. getKeys(): Array<IAnimationKey>;
  28250. /**
  28251. * Gets the highest frame rate of the animation
  28252. * @returns Highest frame rate of the animation
  28253. */
  28254. getHighestFrame(): number;
  28255. /**
  28256. * Gets the easing function of the animation
  28257. * @returns Easing function of the animation
  28258. */
  28259. getEasingFunction(): IEasingFunction;
  28260. /**
  28261. * Sets the easing function of the animation
  28262. * @param easingFunction A custom mathematical formula for animation
  28263. */
  28264. setEasingFunction(easingFunction: EasingFunction): void;
  28265. /**
  28266. * Interpolates a scalar 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 scalar value
  28271. */
  28272. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28273. /**
  28274. * Interpolates a scalar cubically
  28275. * @param startValue Start value of the animation curve
  28276. * @param outTangent End tangent of the animation
  28277. * @param endValue End value of the animation curve
  28278. * @param inTangent Start tangent of the animation curve
  28279. * @param gradient Scalar amount to interpolate
  28280. * @returns Interpolated scalar value
  28281. */
  28282. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28283. /**
  28284. * Interpolates a quaternion using a spherical linear interpolation
  28285. * @param startValue Start value of the animation curve
  28286. * @param endValue End value of the animation curve
  28287. * @param gradient Scalar amount to interpolate
  28288. * @returns Interpolated quaternion value
  28289. */
  28290. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28291. /**
  28292. * Interpolates a quaternion cubically
  28293. * @param startValue Start value of the animation curve
  28294. * @param outTangent End tangent of the animation curve
  28295. * @param endValue End value of the animation curve
  28296. * @param inTangent Start tangent of the animation curve
  28297. * @param gradient Scalar amount to interpolate
  28298. * @returns Interpolated quaternion value
  28299. */
  28300. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28301. /**
  28302. * Interpolates a Vector3 linearl
  28303. * @param startValue Start value of the animation curve
  28304. * @param endValue End value of the animation curve
  28305. * @param gradient Scalar amount to interpolate
  28306. * @returns Interpolated scalar value
  28307. */
  28308. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28309. /**
  28310. * Interpolates a Vector3 cubically
  28311. * @param startValue Start value of the animation curve
  28312. * @param outTangent End tangent of the animation
  28313. * @param endValue End value of the animation curve
  28314. * @param inTangent Start tangent of the animation curve
  28315. * @param gradient Scalar amount to interpolate
  28316. * @returns InterpolatedVector3 value
  28317. */
  28318. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28319. /**
  28320. * Interpolates a Vector2 linearly
  28321. * @param startValue Start value of the animation curve
  28322. * @param endValue End value of the animation curve
  28323. * @param gradient Scalar amount to interpolate
  28324. * @returns Interpolated Vector2 value
  28325. */
  28326. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28327. /**
  28328. * Interpolates a Vector2 cubically
  28329. * @param startValue Start value of the animation curve
  28330. * @param outTangent End tangent of the animation
  28331. * @param endValue End value of the animation curve
  28332. * @param inTangent Start tangent of the animation curve
  28333. * @param gradient Scalar amount to interpolate
  28334. * @returns Interpolated Vector2 value
  28335. */
  28336. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28337. /**
  28338. * Interpolates a size linearly
  28339. * @param startValue Start value of the animation curve
  28340. * @param endValue End value of the animation curve
  28341. * @param gradient Scalar amount to interpolate
  28342. * @returns Interpolated Size value
  28343. */
  28344. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28345. /**
  28346. * Interpolates a Color3 linearly
  28347. * @param startValue Start value of the animation curve
  28348. * @param endValue End value of the animation curve
  28349. * @param gradient Scalar amount to interpolate
  28350. * @returns Interpolated Color3 value
  28351. */
  28352. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28353. /**
  28354. * Interpolates a Color4 linearly
  28355. * @param startValue Start value of the animation curve
  28356. * @param endValue End value of the animation curve
  28357. * @param gradient Scalar amount to interpolate
  28358. * @returns Interpolated Color3 value
  28359. */
  28360. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28361. /**
  28362. * @hidden Internal use only
  28363. */
  28364. _getKeyValue(value: any): any;
  28365. /**
  28366. * @hidden Internal use only
  28367. */
  28368. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28369. /**
  28370. * Defines the function to use to interpolate matrices
  28371. * @param startValue defines the start matrix
  28372. * @param endValue defines the end matrix
  28373. * @param gradient defines the gradient between both matrices
  28374. * @param result defines an optional target matrix where to store the interpolation
  28375. * @returns the interpolated matrix
  28376. */
  28377. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28378. /**
  28379. * Makes a copy of the animation
  28380. * @returns Cloned animation
  28381. */
  28382. clone(): Animation;
  28383. /**
  28384. * Sets the key frames of the animation
  28385. * @param values The animation key frames to set
  28386. */
  28387. setKeys(values: Array<IAnimationKey>): void;
  28388. /**
  28389. * Serializes the animation to an object
  28390. * @returns Serialized object
  28391. */
  28392. serialize(): any;
  28393. /**
  28394. * Float animation type
  28395. */
  28396. static readonly ANIMATIONTYPE_FLOAT: number;
  28397. /**
  28398. * Vector3 animation type
  28399. */
  28400. static readonly ANIMATIONTYPE_VECTOR3: number;
  28401. /**
  28402. * Quaternion animation type
  28403. */
  28404. static readonly ANIMATIONTYPE_QUATERNION: number;
  28405. /**
  28406. * Matrix animation type
  28407. */
  28408. static readonly ANIMATIONTYPE_MATRIX: number;
  28409. /**
  28410. * Color3 animation type
  28411. */
  28412. static readonly ANIMATIONTYPE_COLOR3: number;
  28413. /**
  28414. * Color3 animation type
  28415. */
  28416. static readonly ANIMATIONTYPE_COLOR4: number;
  28417. /**
  28418. * Vector2 animation type
  28419. */
  28420. static readonly ANIMATIONTYPE_VECTOR2: number;
  28421. /**
  28422. * Size animation type
  28423. */
  28424. static readonly ANIMATIONTYPE_SIZE: number;
  28425. /**
  28426. * Relative Loop Mode
  28427. */
  28428. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28429. /**
  28430. * Cycle Loop Mode
  28431. */
  28432. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28433. /**
  28434. * Constant Loop Mode
  28435. */
  28436. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28437. /** @hidden */
  28438. static _UniversalLerp(left: any, right: any, amount: number): any;
  28439. /**
  28440. * Parses an animation object and creates an animation
  28441. * @param parsedAnimation Parsed animation object
  28442. * @returns Animation object
  28443. */
  28444. static Parse(parsedAnimation: any): Animation;
  28445. /**
  28446. * Appends the serialized animations from the source animations
  28447. * @param source Source containing the animations
  28448. * @param destination Target to store the animations
  28449. */
  28450. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28451. }
  28452. }
  28453. declare module "babylonjs/Animations/animatable.interface" {
  28454. import { Nullable } from "babylonjs/types";
  28455. import { Animation } from "babylonjs/Animations/animation";
  28456. /**
  28457. * Interface containing an array of animations
  28458. */
  28459. export interface IAnimatable {
  28460. /**
  28461. * Array of animations
  28462. */
  28463. animations: Nullable<Array<Animation>>;
  28464. }
  28465. }
  28466. declare module "babylonjs/Materials/fresnelParameters" {
  28467. import { Color3 } from "babylonjs/Maths/math.color";
  28468. /**
  28469. * This represents all the required information to add a fresnel effect on a material:
  28470. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28471. */
  28472. export class FresnelParameters {
  28473. private _isEnabled;
  28474. /**
  28475. * Define if the fresnel effect is enable or not.
  28476. */
  28477. isEnabled: boolean;
  28478. /**
  28479. * Define the color used on edges (grazing angle)
  28480. */
  28481. leftColor: Color3;
  28482. /**
  28483. * Define the color used on center
  28484. */
  28485. rightColor: Color3;
  28486. /**
  28487. * Define bias applied to computed fresnel term
  28488. */
  28489. bias: number;
  28490. /**
  28491. * Defined the power exponent applied to fresnel term
  28492. */
  28493. power: number;
  28494. /**
  28495. * Clones the current fresnel and its valuues
  28496. * @returns a clone fresnel configuration
  28497. */
  28498. clone(): FresnelParameters;
  28499. /**
  28500. * Serializes the current fresnel parameters to a JSON representation.
  28501. * @return the JSON serialization
  28502. */
  28503. serialize(): any;
  28504. /**
  28505. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28506. * @param parsedFresnelParameters Define the JSON representation
  28507. * @returns the parsed parameters
  28508. */
  28509. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28510. }
  28511. }
  28512. declare module "babylonjs/Misc/decorators" {
  28513. import { Nullable } from "babylonjs/types";
  28514. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28515. import { Scene } from "babylonjs/scene";
  28516. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28517. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28518. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28519. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28520. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28521. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28522. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28523. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28524. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28525. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28526. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28527. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28528. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28529. /**
  28530. * Decorator used to define property that can be serialized as reference to a camera
  28531. * @param sourceName defines the name of the property to decorate
  28532. */
  28533. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28534. /**
  28535. * Class used to help serialization objects
  28536. */
  28537. export class SerializationHelper {
  28538. /** @hidden */
  28539. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28540. /** @hidden */
  28541. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28542. /** @hidden */
  28543. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28544. /** @hidden */
  28545. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28546. /**
  28547. * Appends the serialized animations from the source animations
  28548. * @param source Source containing the animations
  28549. * @param destination Target to store the animations
  28550. */
  28551. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28552. /**
  28553. * Static function used to serialized a specific entity
  28554. * @param entity defines the entity to serialize
  28555. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28556. * @returns a JSON compatible object representing the serialization of the entity
  28557. */
  28558. static Serialize<T>(entity: T, serializationObject?: any): any;
  28559. /**
  28560. * Creates a new entity from a serialization data object
  28561. * @param creationFunction defines a function used to instanciated the new entity
  28562. * @param source defines the source serialization data
  28563. * @param scene defines the hosting scene
  28564. * @param rootUrl defines the root url for resources
  28565. * @returns a new entity
  28566. */
  28567. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28568. /**
  28569. * Clones an object
  28570. * @param creationFunction defines the function used to instanciate the new object
  28571. * @param source defines the source object
  28572. * @returns the cloned object
  28573. */
  28574. static Clone<T>(creationFunction: () => T, source: T): T;
  28575. /**
  28576. * Instanciates a new object based on a source one (some data will be shared between both object)
  28577. * @param creationFunction defines the function used to instanciate the new object
  28578. * @param source defines the source object
  28579. * @returns the new object
  28580. */
  28581. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28582. }
  28583. }
  28584. declare module "babylonjs/Misc/guid" {
  28585. /**
  28586. * Class used to manipulate GUIDs
  28587. */
  28588. export class GUID {
  28589. /**
  28590. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28591. * Be aware Math.random() could cause collisions, but:
  28592. * "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"
  28593. * @returns a pseudo random id
  28594. */
  28595. static RandomId(): string;
  28596. }
  28597. }
  28598. declare module "babylonjs/Materials/Textures/baseTexture" {
  28599. import { Observable } from "babylonjs/Misc/observable";
  28600. import { Nullable } from "babylonjs/types";
  28601. import { Scene } from "babylonjs/scene";
  28602. import { Matrix } from "babylonjs/Maths/math.vector";
  28603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28604. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28605. import { ISize } from "babylonjs/Maths/math.size";
  28606. /**
  28607. * Base class of all the textures in babylon.
  28608. * It groups all the common properties the materials, post process, lights... might need
  28609. * in order to make a correct use of the texture.
  28610. */
  28611. export class BaseTexture implements IAnimatable {
  28612. /**
  28613. * Default anisotropic filtering level for the application.
  28614. * It is set to 4 as a good tradeoff between perf and quality.
  28615. */
  28616. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28617. /**
  28618. * Gets or sets the unique id of the texture
  28619. */
  28620. uniqueId: number;
  28621. /**
  28622. * Define the name of the texture.
  28623. */
  28624. name: string;
  28625. /**
  28626. * Gets or sets an object used to store user defined information.
  28627. */
  28628. metadata: any;
  28629. /**
  28630. * For internal use only. Please do not use.
  28631. */
  28632. reservedDataStore: any;
  28633. private _hasAlpha;
  28634. /**
  28635. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28636. */
  28637. hasAlpha: boolean;
  28638. /**
  28639. * Defines if the alpha value should be determined via the rgb values.
  28640. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28641. */
  28642. getAlphaFromRGB: boolean;
  28643. /**
  28644. * Intensity or strength of the texture.
  28645. * It is commonly used by materials to fine tune the intensity of the texture
  28646. */
  28647. level: number;
  28648. /**
  28649. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28650. * This is part of the texture as textures usually maps to one uv set.
  28651. */
  28652. coordinatesIndex: number;
  28653. private _coordinatesMode;
  28654. /**
  28655. * How a texture is mapped.
  28656. *
  28657. * | Value | Type | Description |
  28658. * | ----- | ----------------------------------- | ----------- |
  28659. * | 0 | EXPLICIT_MODE | |
  28660. * | 1 | SPHERICAL_MODE | |
  28661. * | 2 | PLANAR_MODE | |
  28662. * | 3 | CUBIC_MODE | |
  28663. * | 4 | PROJECTION_MODE | |
  28664. * | 5 | SKYBOX_MODE | |
  28665. * | 6 | INVCUBIC_MODE | |
  28666. * | 7 | EQUIRECTANGULAR_MODE | |
  28667. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28668. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28669. */
  28670. coordinatesMode: number;
  28671. /**
  28672. * | Value | Type | Description |
  28673. * | ----- | ------------------ | ----------- |
  28674. * | 0 | CLAMP_ADDRESSMODE | |
  28675. * | 1 | WRAP_ADDRESSMODE | |
  28676. * | 2 | MIRROR_ADDRESSMODE | |
  28677. */
  28678. wrapU: number;
  28679. /**
  28680. * | Value | Type | Description |
  28681. * | ----- | ------------------ | ----------- |
  28682. * | 0 | CLAMP_ADDRESSMODE | |
  28683. * | 1 | WRAP_ADDRESSMODE | |
  28684. * | 2 | MIRROR_ADDRESSMODE | |
  28685. */
  28686. wrapV: number;
  28687. /**
  28688. * | Value | Type | Description |
  28689. * | ----- | ------------------ | ----------- |
  28690. * | 0 | CLAMP_ADDRESSMODE | |
  28691. * | 1 | WRAP_ADDRESSMODE | |
  28692. * | 2 | MIRROR_ADDRESSMODE | |
  28693. */
  28694. wrapR: number;
  28695. /**
  28696. * With compliant hardware and browser (supporting anisotropic filtering)
  28697. * this defines the level of anisotropic filtering in the texture.
  28698. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28699. */
  28700. anisotropicFilteringLevel: number;
  28701. /**
  28702. * Define if the texture is a cube texture or if false a 2d texture.
  28703. */
  28704. isCube: boolean;
  28705. /**
  28706. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28707. */
  28708. is3D: boolean;
  28709. /**
  28710. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28711. * HDR texture are usually stored in linear space.
  28712. * This only impacts the PBR and Background materials
  28713. */
  28714. gammaSpace: boolean;
  28715. /**
  28716. * Gets or sets whether or not the texture contains RGBD data.
  28717. */
  28718. isRGBD: boolean;
  28719. /**
  28720. * Is Z inverted in the texture (useful in a cube texture).
  28721. */
  28722. invertZ: boolean;
  28723. /**
  28724. * Are mip maps generated for this texture or not.
  28725. */
  28726. readonly noMipmap: boolean;
  28727. /**
  28728. * @hidden
  28729. */
  28730. lodLevelInAlpha: boolean;
  28731. /**
  28732. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28733. */
  28734. lodGenerationOffset: number;
  28735. /**
  28736. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28737. */
  28738. lodGenerationScale: number;
  28739. /**
  28740. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28741. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28742. * average roughness values.
  28743. */
  28744. linearSpecularLOD: boolean;
  28745. /**
  28746. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28747. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28748. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28749. */
  28750. irradianceTexture: Nullable<BaseTexture>;
  28751. /**
  28752. * Define if the texture is a render target.
  28753. */
  28754. isRenderTarget: boolean;
  28755. /**
  28756. * Define the unique id of the texture in the scene.
  28757. */
  28758. readonly uid: string;
  28759. /**
  28760. * Return a string representation of the texture.
  28761. * @returns the texture as a string
  28762. */
  28763. toString(): string;
  28764. /**
  28765. * Get the class name of the texture.
  28766. * @returns "BaseTexture"
  28767. */
  28768. getClassName(): string;
  28769. /**
  28770. * Define the list of animation attached to the texture.
  28771. */
  28772. animations: import("babylonjs/Animations/animation").Animation[];
  28773. /**
  28774. * An event triggered when the texture is disposed.
  28775. */
  28776. onDisposeObservable: Observable<BaseTexture>;
  28777. private _onDisposeObserver;
  28778. /**
  28779. * Callback triggered when the texture has been disposed.
  28780. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28781. */
  28782. onDispose: () => void;
  28783. /**
  28784. * Define the current state of the loading sequence when in delayed load mode.
  28785. */
  28786. delayLoadState: number;
  28787. private _scene;
  28788. /** @hidden */
  28789. _texture: Nullable<InternalTexture>;
  28790. private _uid;
  28791. /**
  28792. * Define if the texture is preventinga material to render or not.
  28793. * If not and the texture is not ready, the engine will use a default black texture instead.
  28794. */
  28795. readonly isBlocking: boolean;
  28796. /**
  28797. * Instantiates a new BaseTexture.
  28798. * Base class of all the textures in babylon.
  28799. * It groups all the common properties the materials, post process, lights... might need
  28800. * in order to make a correct use of the texture.
  28801. * @param scene Define the scene the texture blongs to
  28802. */
  28803. constructor(scene: Nullable<Scene>);
  28804. /**
  28805. * Get the scene the texture belongs to.
  28806. * @returns the scene or null if undefined
  28807. */
  28808. getScene(): Nullable<Scene>;
  28809. /**
  28810. * Get the texture transform matrix used to offset tile the texture for istance.
  28811. * @returns the transformation matrix
  28812. */
  28813. getTextureMatrix(): Matrix;
  28814. /**
  28815. * Get the texture reflection matrix used to rotate/transform the reflection.
  28816. * @returns the reflection matrix
  28817. */
  28818. getReflectionTextureMatrix(): Matrix;
  28819. /**
  28820. * Get the underlying lower level texture from Babylon.
  28821. * @returns the insternal texture
  28822. */
  28823. getInternalTexture(): Nullable<InternalTexture>;
  28824. /**
  28825. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28826. * @returns true if ready or not blocking
  28827. */
  28828. isReadyOrNotBlocking(): boolean;
  28829. /**
  28830. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28831. * @returns true if fully ready
  28832. */
  28833. isReady(): boolean;
  28834. private _cachedSize;
  28835. /**
  28836. * Get the size of the texture.
  28837. * @returns the texture size.
  28838. */
  28839. getSize(): ISize;
  28840. /**
  28841. * Get the base size of the texture.
  28842. * It can be different from the size if the texture has been resized for POT for instance
  28843. * @returns the base size
  28844. */
  28845. getBaseSize(): ISize;
  28846. /**
  28847. * Update the sampling mode of the texture.
  28848. * Default is Trilinear mode.
  28849. *
  28850. * | Value | Type | Description |
  28851. * | ----- | ------------------ | ----------- |
  28852. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28853. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28854. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28855. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28856. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28857. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28858. * | 7 | NEAREST_LINEAR | |
  28859. * | 8 | NEAREST_NEAREST | |
  28860. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28861. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28862. * | 11 | LINEAR_LINEAR | |
  28863. * | 12 | LINEAR_NEAREST | |
  28864. *
  28865. * > _mag_: magnification filter (close to the viewer)
  28866. * > _min_: minification filter (far from the viewer)
  28867. * > _mip_: filter used between mip map levels
  28868. *@param samplingMode Define the new sampling mode of the texture
  28869. */
  28870. updateSamplingMode(samplingMode: number): void;
  28871. /**
  28872. * Scales the texture if is `canRescale()`
  28873. * @param ratio the resize factor we want to use to rescale
  28874. */
  28875. scale(ratio: number): void;
  28876. /**
  28877. * Get if the texture can rescale.
  28878. */
  28879. readonly canRescale: boolean;
  28880. /** @hidden */
  28881. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28882. /** @hidden */
  28883. _rebuild(): void;
  28884. /**
  28885. * Triggers the load sequence in delayed load mode.
  28886. */
  28887. delayLoad(): void;
  28888. /**
  28889. * Clones the texture.
  28890. * @returns the cloned texture
  28891. */
  28892. clone(): Nullable<BaseTexture>;
  28893. /**
  28894. * Get the texture underlying type (INT, FLOAT...)
  28895. */
  28896. readonly textureType: number;
  28897. /**
  28898. * Get the texture underlying format (RGB, RGBA...)
  28899. */
  28900. readonly textureFormat: number;
  28901. /**
  28902. * Indicates that textures need to be re-calculated for all materials
  28903. */
  28904. protected _markAllSubMeshesAsTexturesDirty(): void;
  28905. /**
  28906. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28907. * This will returns an RGBA array buffer containing either in values (0-255) or
  28908. * float values (0-1) depending of the underlying buffer type.
  28909. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28910. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28911. * @param buffer defines a user defined buffer to fill with data (can be null)
  28912. * @returns The Array buffer containing the pixels data.
  28913. */
  28914. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28915. /**
  28916. * Release and destroy the underlying lower level texture aka internalTexture.
  28917. */
  28918. releaseInternalTexture(): void;
  28919. /** @hidden */
  28920. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28921. /** @hidden */
  28922. readonly _lodTextureMid: Nullable<BaseTexture>;
  28923. /** @hidden */
  28924. readonly _lodTextureLow: Nullable<BaseTexture>;
  28925. /**
  28926. * Dispose the texture and release its associated resources.
  28927. */
  28928. dispose(): void;
  28929. /**
  28930. * Serialize the texture into a JSON representation that can be parsed later on.
  28931. * @returns the JSON representation of the texture
  28932. */
  28933. serialize(): any;
  28934. /**
  28935. * Helper function to be called back once a list of texture contains only ready textures.
  28936. * @param textures Define the list of textures to wait for
  28937. * @param callback Define the callback triggered once the entire list will be ready
  28938. */
  28939. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28940. }
  28941. }
  28942. declare module "babylonjs/Materials/effect" {
  28943. import { Observable } from "babylonjs/Misc/observable";
  28944. import { Nullable } from "babylonjs/types";
  28945. import { IDisposable } from "babylonjs/scene";
  28946. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28947. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28948. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28949. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28950. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28951. import { Engine } from "babylonjs/Engines/engine";
  28952. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28955. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28956. /**
  28957. * Options to be used when creating an effect.
  28958. */
  28959. export interface IEffectCreationOptions {
  28960. /**
  28961. * Atrributes that will be used in the shader.
  28962. */
  28963. attributes: string[];
  28964. /**
  28965. * Uniform varible names that will be set in the shader.
  28966. */
  28967. uniformsNames: string[];
  28968. /**
  28969. * Uniform buffer varible names that will be set in the shader.
  28970. */
  28971. uniformBuffersNames: string[];
  28972. /**
  28973. * Sampler texture variable names that will be set in the shader.
  28974. */
  28975. samplers: string[];
  28976. /**
  28977. * Define statements that will be set in the shader.
  28978. */
  28979. defines: any;
  28980. /**
  28981. * Possible fallbacks for this effect to improve performance when needed.
  28982. */
  28983. fallbacks: Nullable<IEffectFallbacks>;
  28984. /**
  28985. * Callback that will be called when the shader is compiled.
  28986. */
  28987. onCompiled: Nullable<(effect: Effect) => void>;
  28988. /**
  28989. * Callback that will be called if an error occurs during shader compilation.
  28990. */
  28991. onError: Nullable<(effect: Effect, errors: string) => void>;
  28992. /**
  28993. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28994. */
  28995. indexParameters?: any;
  28996. /**
  28997. * Max number of lights that can be used in the shader.
  28998. */
  28999. maxSimultaneousLights?: number;
  29000. /**
  29001. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29002. */
  29003. transformFeedbackVaryings?: Nullable<string[]>;
  29004. }
  29005. /**
  29006. * Effect containing vertex and fragment shader that can be executed on an object.
  29007. */
  29008. export class Effect implements IDisposable {
  29009. /**
  29010. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29011. */
  29012. static ShadersRepository: string;
  29013. /**
  29014. * Name of the effect.
  29015. */
  29016. name: any;
  29017. /**
  29018. * String container all the define statements that should be set on the shader.
  29019. */
  29020. defines: string;
  29021. /**
  29022. * Callback that will be called when the shader is compiled.
  29023. */
  29024. onCompiled: Nullable<(effect: Effect) => void>;
  29025. /**
  29026. * Callback that will be called if an error occurs during shader compilation.
  29027. */
  29028. onError: Nullable<(effect: Effect, errors: string) => void>;
  29029. /**
  29030. * Callback that will be called when effect is bound.
  29031. */
  29032. onBind: Nullable<(effect: Effect) => void>;
  29033. /**
  29034. * Unique ID of the effect.
  29035. */
  29036. uniqueId: number;
  29037. /**
  29038. * Observable that will be called when the shader is compiled.
  29039. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29040. */
  29041. onCompileObservable: Observable<Effect>;
  29042. /**
  29043. * Observable that will be called if an error occurs during shader compilation.
  29044. */
  29045. onErrorObservable: Observable<Effect>;
  29046. /** @hidden */
  29047. _onBindObservable: Nullable<Observable<Effect>>;
  29048. /**
  29049. * Observable that will be called when effect is bound.
  29050. */
  29051. readonly onBindObservable: Observable<Effect>;
  29052. /** @hidden */
  29053. _bonesComputationForcedToCPU: boolean;
  29054. private static _uniqueIdSeed;
  29055. private _engine;
  29056. private _uniformBuffersNames;
  29057. private _uniformsNames;
  29058. private _samplerList;
  29059. private _samplers;
  29060. private _isReady;
  29061. private _compilationError;
  29062. private _allFallbacksProcessed;
  29063. private _attributesNames;
  29064. private _attributes;
  29065. private _uniforms;
  29066. /**
  29067. * Key for the effect.
  29068. * @hidden
  29069. */
  29070. _key: string;
  29071. private _indexParameters;
  29072. private _fallbacks;
  29073. private _vertexSourceCode;
  29074. private _fragmentSourceCode;
  29075. private _vertexSourceCodeOverride;
  29076. private _fragmentSourceCodeOverride;
  29077. private _transformFeedbackVaryings;
  29078. /**
  29079. * Compiled shader to webGL program.
  29080. * @hidden
  29081. */
  29082. _pipelineContext: Nullable<IPipelineContext>;
  29083. private _valueCache;
  29084. private static _baseCache;
  29085. /**
  29086. * Instantiates an effect.
  29087. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29088. * @param baseName Name of the effect.
  29089. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29090. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29091. * @param samplers List of sampler variables that will be passed to the shader.
  29092. * @param engine Engine to be used to render the effect
  29093. * @param defines Define statements to be added to the shader.
  29094. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29095. * @param onCompiled Callback that will be called when the shader is compiled.
  29096. * @param onError Callback that will be called if an error occurs during shader compilation.
  29097. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29098. */
  29099. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29100. private _useFinalCode;
  29101. /**
  29102. * Unique key for this effect
  29103. */
  29104. readonly key: string;
  29105. /**
  29106. * If the effect has been compiled and prepared.
  29107. * @returns if the effect is compiled and prepared.
  29108. */
  29109. isReady(): boolean;
  29110. private _isReadyInternal;
  29111. /**
  29112. * The engine the effect was initialized with.
  29113. * @returns the engine.
  29114. */
  29115. getEngine(): Engine;
  29116. /**
  29117. * The pipeline context for this effect
  29118. * @returns the associated pipeline context
  29119. */
  29120. getPipelineContext(): Nullable<IPipelineContext>;
  29121. /**
  29122. * The set of names of attribute variables for the shader.
  29123. * @returns An array of attribute names.
  29124. */
  29125. getAttributesNames(): string[];
  29126. /**
  29127. * Returns the attribute at the given index.
  29128. * @param index The index of the attribute.
  29129. * @returns The location of the attribute.
  29130. */
  29131. getAttributeLocation(index: number): number;
  29132. /**
  29133. * Returns the attribute based on the name of the variable.
  29134. * @param name of the attribute to look up.
  29135. * @returns the attribute location.
  29136. */
  29137. getAttributeLocationByName(name: string): number;
  29138. /**
  29139. * The number of attributes.
  29140. * @returns the numnber of attributes.
  29141. */
  29142. getAttributesCount(): number;
  29143. /**
  29144. * Gets the index of a uniform variable.
  29145. * @param uniformName of the uniform to look up.
  29146. * @returns the index.
  29147. */
  29148. getUniformIndex(uniformName: string): number;
  29149. /**
  29150. * Returns the attribute based on the name of the variable.
  29151. * @param uniformName of the uniform to look up.
  29152. * @returns the location of the uniform.
  29153. */
  29154. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29155. /**
  29156. * Returns an array of sampler variable names
  29157. * @returns The array of sampler variable neames.
  29158. */
  29159. getSamplers(): string[];
  29160. /**
  29161. * The error from the last compilation.
  29162. * @returns the error string.
  29163. */
  29164. getCompilationError(): string;
  29165. /**
  29166. * Gets a boolean indicating that all fallbacks were used during compilation
  29167. * @returns true if all fallbacks were used
  29168. */
  29169. allFallbacksProcessed(): boolean;
  29170. /**
  29171. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29172. * @param func The callback to be used.
  29173. */
  29174. executeWhenCompiled(func: (effect: Effect) => void): void;
  29175. private _checkIsReady;
  29176. private _loadShader;
  29177. /**
  29178. * Recompiles the webGL program
  29179. * @param vertexSourceCode The source code for the vertex shader.
  29180. * @param fragmentSourceCode The source code for the fragment shader.
  29181. * @param onCompiled Callback called when completed.
  29182. * @param onError Callback called on error.
  29183. * @hidden
  29184. */
  29185. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29186. /**
  29187. * Prepares the effect
  29188. * @hidden
  29189. */
  29190. _prepareEffect(): void;
  29191. private _processCompilationErrors;
  29192. /**
  29193. * Checks if the effect is supported. (Must be called after compilation)
  29194. */
  29195. readonly isSupported: boolean;
  29196. /**
  29197. * Binds a texture to the engine to be used as output of the shader.
  29198. * @param channel Name of the output variable.
  29199. * @param texture Texture to bind.
  29200. * @hidden
  29201. */
  29202. _bindTexture(channel: string, texture: InternalTexture): void;
  29203. /**
  29204. * Sets a texture on the engine to be used in the shader.
  29205. * @param channel Name of the sampler variable.
  29206. * @param texture Texture to set.
  29207. */
  29208. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29209. /**
  29210. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29211. * @param channel Name of the sampler variable.
  29212. * @param texture Texture to set.
  29213. */
  29214. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29215. /**
  29216. * Sets an array of textures on the engine to be used in the shader.
  29217. * @param channel Name of the variable.
  29218. * @param textures Textures to set.
  29219. */
  29220. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29221. /**
  29222. * 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)
  29223. * @param channel Name of the sampler variable.
  29224. * @param postProcess Post process to get the input texture from.
  29225. */
  29226. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29227. /**
  29228. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29229. * 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)
  29230. * @param channel Name of the sampler variable.
  29231. * @param postProcess Post process to get the output texture from.
  29232. */
  29233. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29234. /** @hidden */
  29235. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29236. /** @hidden */
  29237. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29238. /** @hidden */
  29239. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29240. /** @hidden */
  29241. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29242. /**
  29243. * Binds a buffer to a uniform.
  29244. * @param buffer Buffer to bind.
  29245. * @param name Name of the uniform variable to bind to.
  29246. */
  29247. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29248. /**
  29249. * Binds block to a uniform.
  29250. * @param blockName Name of the block to bind.
  29251. * @param index Index to bind.
  29252. */
  29253. bindUniformBlock(blockName: string, index: number): void;
  29254. /**
  29255. * Sets an interger value on a uniform variable.
  29256. * @param uniformName Name of the variable.
  29257. * @param value Value to be set.
  29258. * @returns this effect.
  29259. */
  29260. setInt(uniformName: string, value: number): Effect;
  29261. /**
  29262. * Sets an int array on a uniform variable.
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setIntArray(uniformName: string, array: Int32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29275. /**
  29276. * 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)
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29289. /**
  29290. * Sets an float array on a uniform variable.
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29303. /**
  29304. * 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)
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29317. /**
  29318. * Sets an array on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param array array to be set.
  29321. * @returns this effect.
  29322. */
  29323. setArray(uniformName: string, array: number[]): Effect;
  29324. /**
  29325. * 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)
  29326. * @param uniformName Name of the variable.
  29327. * @param array array to be set.
  29328. * @returns this effect.
  29329. */
  29330. setArray2(uniformName: string, array: number[]): Effect;
  29331. /**
  29332. * 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)
  29333. * @param uniformName Name of the variable.
  29334. * @param array array to be set.
  29335. * @returns this effect.
  29336. */
  29337. setArray3(uniformName: string, array: number[]): Effect;
  29338. /**
  29339. * 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)
  29340. * @param uniformName Name of the variable.
  29341. * @param array array to be set.
  29342. * @returns this effect.
  29343. */
  29344. setArray4(uniformName: string, array: number[]): Effect;
  29345. /**
  29346. * Sets matrices on a uniform variable.
  29347. * @param uniformName Name of the variable.
  29348. * @param matrices matrices to be set.
  29349. * @returns this effect.
  29350. */
  29351. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29352. /**
  29353. * Sets matrix on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param matrix matrix to be set.
  29356. * @returns this effect.
  29357. */
  29358. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29359. /**
  29360. * 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)
  29361. * @param uniformName Name of the variable.
  29362. * @param matrix matrix to be set.
  29363. * @returns this effect.
  29364. */
  29365. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29366. /**
  29367. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29368. * @param uniformName Name of the variable.
  29369. * @param matrix matrix to be set.
  29370. * @returns this effect.
  29371. */
  29372. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29373. /**
  29374. * Sets a float on a uniform variable.
  29375. * @param uniformName Name of the variable.
  29376. * @param value value to be set.
  29377. * @returns this effect.
  29378. */
  29379. setFloat(uniformName: string, value: number): Effect;
  29380. /**
  29381. * Sets a boolean on a uniform variable.
  29382. * @param uniformName Name of the variable.
  29383. * @param bool value to be set.
  29384. * @returns this effect.
  29385. */
  29386. setBool(uniformName: string, bool: boolean): Effect;
  29387. /**
  29388. * Sets a Vector2 on a uniform variable.
  29389. * @param uniformName Name of the variable.
  29390. * @param vector2 vector2 to be set.
  29391. * @returns this effect.
  29392. */
  29393. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29394. /**
  29395. * Sets a float2 on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param x First float in float2.
  29398. * @param y Second float in float2.
  29399. * @returns this effect.
  29400. */
  29401. setFloat2(uniformName: string, x: number, y: number): Effect;
  29402. /**
  29403. * Sets a Vector3 on a uniform variable.
  29404. * @param uniformName Name of the variable.
  29405. * @param vector3 Value to be set.
  29406. * @returns this effect.
  29407. */
  29408. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29409. /**
  29410. * Sets a float3 on a uniform variable.
  29411. * @param uniformName Name of the variable.
  29412. * @param x First float in float3.
  29413. * @param y Second float in float3.
  29414. * @param z Third float in float3.
  29415. * @returns this effect.
  29416. */
  29417. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29418. /**
  29419. * Sets a Vector4 on a uniform variable.
  29420. * @param uniformName Name of the variable.
  29421. * @param vector4 Value to be set.
  29422. * @returns this effect.
  29423. */
  29424. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29425. /**
  29426. * Sets a float4 on a uniform variable.
  29427. * @param uniformName Name of the variable.
  29428. * @param x First float in float4.
  29429. * @param y Second float in float4.
  29430. * @param z Third float in float4.
  29431. * @param w Fourth float in float4.
  29432. * @returns this effect.
  29433. */
  29434. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29435. /**
  29436. * Sets a Color3 on a uniform variable.
  29437. * @param uniformName Name of the variable.
  29438. * @param color3 Value to be set.
  29439. * @returns this effect.
  29440. */
  29441. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29442. /**
  29443. * Sets a Color4 on a uniform variable.
  29444. * @param uniformName Name of the variable.
  29445. * @param color3 Value to be set.
  29446. * @param alpha Alpha value to be set.
  29447. * @returns this effect.
  29448. */
  29449. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29450. /**
  29451. * Sets a Color4 on a uniform variable
  29452. * @param uniformName defines the name of the variable
  29453. * @param color4 defines the value to be set
  29454. * @returns this effect.
  29455. */
  29456. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29457. /** Release all associated resources */
  29458. dispose(): void;
  29459. /**
  29460. * This function will add a new shader to the shader store
  29461. * @param name the name of the shader
  29462. * @param pixelShader optional pixel shader content
  29463. * @param vertexShader optional vertex shader content
  29464. */
  29465. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29466. /**
  29467. * Store of each shader (The can be looked up using effect.key)
  29468. */
  29469. static ShadersStore: {
  29470. [key: string]: string;
  29471. };
  29472. /**
  29473. * Store of each included file for a shader (The can be looked up using effect.key)
  29474. */
  29475. static IncludesShadersStore: {
  29476. [key: string]: string;
  29477. };
  29478. /**
  29479. * Resets the cache of effects.
  29480. */
  29481. static ResetCache(): void;
  29482. }
  29483. }
  29484. declare module "babylonjs/Engines/engineCapabilities" {
  29485. /**
  29486. * Interface used to describe the capabilities of the engine relatively to the current browser
  29487. */
  29488. export interface EngineCapabilities {
  29489. /** Maximum textures units per fragment shader */
  29490. maxTexturesImageUnits: number;
  29491. /** Maximum texture units per vertex shader */
  29492. maxVertexTextureImageUnits: number;
  29493. /** Maximum textures units in the entire pipeline */
  29494. maxCombinedTexturesImageUnits: number;
  29495. /** Maximum texture size */
  29496. maxTextureSize: number;
  29497. /** Maximum cube texture size */
  29498. maxCubemapTextureSize: number;
  29499. /** Maximum render texture size */
  29500. maxRenderTextureSize: number;
  29501. /** Maximum number of vertex attributes */
  29502. maxVertexAttribs: number;
  29503. /** Maximum number of varyings */
  29504. maxVaryingVectors: number;
  29505. /** Maximum number of uniforms per vertex shader */
  29506. maxVertexUniformVectors: number;
  29507. /** Maximum number of uniforms per fragment shader */
  29508. maxFragmentUniformVectors: number;
  29509. /** Defines if standard derivates (dx/dy) are supported */
  29510. standardDerivatives: boolean;
  29511. /** Defines if s3tc texture compression is supported */
  29512. s3tc?: WEBGL_compressed_texture_s3tc;
  29513. /** Defines if pvrtc texture compression is supported */
  29514. pvrtc: any;
  29515. /** Defines if etc1 texture compression is supported */
  29516. etc1: any;
  29517. /** Defines if etc2 texture compression is supported */
  29518. etc2: any;
  29519. /** Defines if astc texture compression is supported */
  29520. astc: any;
  29521. /** Defines if float textures are supported */
  29522. textureFloat: boolean;
  29523. /** Defines if vertex array objects are supported */
  29524. vertexArrayObject: boolean;
  29525. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29526. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29527. /** Gets the maximum level of anisotropy supported */
  29528. maxAnisotropy: number;
  29529. /** Defines if instancing is supported */
  29530. instancedArrays: boolean;
  29531. /** Defines if 32 bits indices are supported */
  29532. uintIndices: boolean;
  29533. /** Defines if high precision shaders are supported */
  29534. highPrecisionShaderSupported: boolean;
  29535. /** Defines if depth reading in the fragment shader is supported */
  29536. fragmentDepthSupported: boolean;
  29537. /** Defines if float texture linear filtering is supported*/
  29538. textureFloatLinearFiltering: boolean;
  29539. /** Defines if rendering to float textures is supported */
  29540. textureFloatRender: boolean;
  29541. /** Defines if half float textures are supported*/
  29542. textureHalfFloat: boolean;
  29543. /** Defines if half float texture linear filtering is supported*/
  29544. textureHalfFloatLinearFiltering: boolean;
  29545. /** Defines if rendering to half float textures is supported */
  29546. textureHalfFloatRender: boolean;
  29547. /** Defines if textureLOD shader command is supported */
  29548. textureLOD: boolean;
  29549. /** Defines if draw buffers extension is supported */
  29550. drawBuffersExtension: boolean;
  29551. /** Defines if depth textures are supported */
  29552. depthTextureExtension: boolean;
  29553. /** Defines if float color buffer are supported */
  29554. colorBufferFloat: boolean;
  29555. /** Gets disjoint timer query extension (null if not supported) */
  29556. timerQuery?: EXT_disjoint_timer_query;
  29557. /** Defines if timestamp can be used with timer query */
  29558. canUseTimestampForTimerQuery: boolean;
  29559. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29560. multiview?: any;
  29561. /** Function used to let the system compiles shaders in background */
  29562. parallelShaderCompile?: {
  29563. COMPLETION_STATUS_KHR: number;
  29564. };
  29565. /** Max number of texture samples for MSAA */
  29566. maxMSAASamples: number;
  29567. /** Defines if the blend min max extension is supported */
  29568. blendMinMax: boolean;
  29569. }
  29570. }
  29571. declare module "babylonjs/States/depthCullingState" {
  29572. import { Nullable } from "babylonjs/types";
  29573. /**
  29574. * @hidden
  29575. **/
  29576. export class DepthCullingState {
  29577. private _isDepthTestDirty;
  29578. private _isDepthMaskDirty;
  29579. private _isDepthFuncDirty;
  29580. private _isCullFaceDirty;
  29581. private _isCullDirty;
  29582. private _isZOffsetDirty;
  29583. private _isFrontFaceDirty;
  29584. private _depthTest;
  29585. private _depthMask;
  29586. private _depthFunc;
  29587. private _cull;
  29588. private _cullFace;
  29589. private _zOffset;
  29590. private _frontFace;
  29591. /**
  29592. * Initializes the state.
  29593. */
  29594. constructor();
  29595. readonly isDirty: boolean;
  29596. zOffset: number;
  29597. cullFace: Nullable<number>;
  29598. cull: Nullable<boolean>;
  29599. depthFunc: Nullable<number>;
  29600. depthMask: boolean;
  29601. depthTest: boolean;
  29602. frontFace: Nullable<number>;
  29603. reset(): void;
  29604. apply(gl: WebGLRenderingContext): void;
  29605. }
  29606. }
  29607. declare module "babylonjs/States/stencilState" {
  29608. /**
  29609. * @hidden
  29610. **/
  29611. export class StencilState {
  29612. /** 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 */
  29613. static readonly ALWAYS: number;
  29614. /** Passed to stencilOperation to specify that stencil value must be kept */
  29615. static readonly KEEP: number;
  29616. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29617. static readonly REPLACE: number;
  29618. private _isStencilTestDirty;
  29619. private _isStencilMaskDirty;
  29620. private _isStencilFuncDirty;
  29621. private _isStencilOpDirty;
  29622. private _stencilTest;
  29623. private _stencilMask;
  29624. private _stencilFunc;
  29625. private _stencilFuncRef;
  29626. private _stencilFuncMask;
  29627. private _stencilOpStencilFail;
  29628. private _stencilOpDepthFail;
  29629. private _stencilOpStencilDepthPass;
  29630. readonly isDirty: boolean;
  29631. stencilFunc: number;
  29632. stencilFuncRef: number;
  29633. stencilFuncMask: number;
  29634. stencilOpStencilFail: number;
  29635. stencilOpDepthFail: number;
  29636. stencilOpStencilDepthPass: number;
  29637. stencilMask: number;
  29638. stencilTest: boolean;
  29639. constructor();
  29640. reset(): void;
  29641. apply(gl: WebGLRenderingContext): void;
  29642. }
  29643. }
  29644. declare module "babylonjs/States/alphaCullingState" {
  29645. /**
  29646. * @hidden
  29647. **/
  29648. export class AlphaState {
  29649. private _isAlphaBlendDirty;
  29650. private _isBlendFunctionParametersDirty;
  29651. private _isBlendEquationParametersDirty;
  29652. private _isBlendConstantsDirty;
  29653. private _alphaBlend;
  29654. private _blendFunctionParameters;
  29655. private _blendEquationParameters;
  29656. private _blendConstants;
  29657. /**
  29658. * Initializes the state.
  29659. */
  29660. constructor();
  29661. readonly isDirty: boolean;
  29662. alphaBlend: boolean;
  29663. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29664. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29665. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29666. reset(): void;
  29667. apply(gl: WebGLRenderingContext): void;
  29668. }
  29669. }
  29670. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29671. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29672. /** @hidden */
  29673. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29674. attributeProcessor(attribute: string): string;
  29675. varyingProcessor(varying: string, isFragment: boolean): string;
  29676. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29677. }
  29678. }
  29679. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29680. /**
  29681. * Interface for attribute information associated with buffer instanciation
  29682. */
  29683. export interface InstancingAttributeInfo {
  29684. /**
  29685. * Index/offset of the attribute in the vertex shader
  29686. */
  29687. index: number;
  29688. /**
  29689. * size of the attribute, 1, 2, 3 or 4
  29690. */
  29691. attributeSize: number;
  29692. /**
  29693. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29694. * default is FLOAT
  29695. */
  29696. attributeType: number;
  29697. /**
  29698. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29699. */
  29700. normalized: boolean;
  29701. /**
  29702. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29703. */
  29704. offset: number;
  29705. /**
  29706. * Name of the GLSL attribute, for debugging purpose only
  29707. */
  29708. attributeName: string;
  29709. }
  29710. }
  29711. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29712. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29713. import { Nullable } from "babylonjs/types";
  29714. module "babylonjs/Engines/thinEngine" {
  29715. interface ThinEngine {
  29716. /**
  29717. * Update a video texture
  29718. * @param texture defines the texture to update
  29719. * @param video defines the video element to use
  29720. * @param invertY defines if data must be stored with Y axis inverted
  29721. */
  29722. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29723. }
  29724. }
  29725. }
  29726. declare module "babylonjs/Materials/Textures/videoTexture" {
  29727. import { Observable } from "babylonjs/Misc/observable";
  29728. import { Nullable } from "babylonjs/types";
  29729. import { Scene } from "babylonjs/scene";
  29730. import { Texture } from "babylonjs/Materials/Textures/texture";
  29731. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29732. /**
  29733. * Settings for finer control over video usage
  29734. */
  29735. export interface VideoTextureSettings {
  29736. /**
  29737. * Applies `autoplay` to video, if specified
  29738. */
  29739. autoPlay?: boolean;
  29740. /**
  29741. * Applies `loop` to video, if specified
  29742. */
  29743. loop?: boolean;
  29744. /**
  29745. * Automatically updates internal texture from video at every frame in the render loop
  29746. */
  29747. autoUpdateTexture: boolean;
  29748. /**
  29749. * Image src displayed during the video loading or until the user interacts with the video.
  29750. */
  29751. poster?: string;
  29752. }
  29753. /**
  29754. * If you want to display a video in your scene, this is the special texture for that.
  29755. * This special texture works similar to other textures, with the exception of a few parameters.
  29756. * @see https://doc.babylonjs.com/how_to/video_texture
  29757. */
  29758. export class VideoTexture extends Texture {
  29759. /**
  29760. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29761. */
  29762. readonly autoUpdateTexture: boolean;
  29763. /**
  29764. * The video instance used by the texture internally
  29765. */
  29766. readonly video: HTMLVideoElement;
  29767. private _onUserActionRequestedObservable;
  29768. /**
  29769. * Event triggerd when a dom action is required by the user to play the video.
  29770. * This happens due to recent changes in browser policies preventing video to auto start.
  29771. */
  29772. readonly onUserActionRequestedObservable: Observable<Texture>;
  29773. private _generateMipMaps;
  29774. private _engine;
  29775. private _stillImageCaptured;
  29776. private _displayingPosterTexture;
  29777. private _settings;
  29778. private _createInternalTextureOnEvent;
  29779. private _frameId;
  29780. /**
  29781. * Creates a video texture.
  29782. * If you want to display a video in your scene, this is the special texture for that.
  29783. * This special texture works similar to other textures, with the exception of a few parameters.
  29784. * @see https://doc.babylonjs.com/how_to/video_texture
  29785. * @param name optional name, will detect from video source, if not defined
  29786. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29787. * @param scene is obviously the current scene.
  29788. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29789. * @param invertY is false by default but can be used to invert video on Y axis
  29790. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29791. * @param settings allows finer control over video usage
  29792. */
  29793. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29794. private _getName;
  29795. private _getVideo;
  29796. private _createInternalTexture;
  29797. private reset;
  29798. /**
  29799. * @hidden Internal method to initiate `update`.
  29800. */
  29801. _rebuild(): void;
  29802. /**
  29803. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29804. */
  29805. update(): void;
  29806. /**
  29807. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29808. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29809. */
  29810. updateTexture(isVisible: boolean): void;
  29811. protected _updateInternalTexture: () => void;
  29812. /**
  29813. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29814. * @param url New url.
  29815. */
  29816. updateURL(url: string): void;
  29817. /**
  29818. * Dispose the texture and release its associated resources.
  29819. */
  29820. dispose(): void;
  29821. /**
  29822. * Creates a video texture straight from a stream.
  29823. * @param scene Define the scene the texture should be created in
  29824. * @param stream Define the stream the texture should be created from
  29825. * @returns The created video texture as a promise
  29826. */
  29827. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29828. /**
  29829. * Creates a video texture straight from your WebCam video feed.
  29830. * @param scene Define the scene the texture should be created in
  29831. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29832. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29833. * @returns The created video texture as a promise
  29834. */
  29835. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29836. minWidth: number;
  29837. maxWidth: number;
  29838. minHeight: number;
  29839. maxHeight: number;
  29840. deviceId: string;
  29841. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29842. /**
  29843. * Creates a video texture straight from your WebCam video feed.
  29844. * @param scene Define the scene the texture should be created in
  29845. * @param onReady Define a callback to triggered once the texture will be ready
  29846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29848. */
  29849. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29850. minWidth: number;
  29851. maxWidth: number;
  29852. minHeight: number;
  29853. maxHeight: number;
  29854. deviceId: string;
  29855. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29856. }
  29857. }
  29858. declare module "babylonjs/Engines/thinEngine" {
  29859. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29860. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29861. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29862. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29863. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29864. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29865. import { Observable } from "babylonjs/Misc/observable";
  29866. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29867. import { StencilState } from "babylonjs/States/stencilState";
  29868. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29870. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29871. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29872. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29873. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29874. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29875. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29876. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29878. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29879. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29880. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29881. /**
  29882. * Defines the interface used by objects working like Scene
  29883. * @hidden
  29884. */
  29885. interface ISceneLike {
  29886. _addPendingData(data: any): void;
  29887. _removePendingData(data: any): void;
  29888. offlineProvider: IOfflineProvider;
  29889. }
  29890. /** Interface defining initialization parameters for Engine class */
  29891. export interface EngineOptions extends WebGLContextAttributes {
  29892. /**
  29893. * Defines if the engine should no exceed a specified device ratio
  29894. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29895. */
  29896. limitDeviceRatio?: number;
  29897. /**
  29898. * Defines if webvr should be enabled automatically
  29899. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29900. */
  29901. autoEnableWebVR?: boolean;
  29902. /**
  29903. * Defines if webgl2 should be turned off even if supported
  29904. * @see http://doc.babylonjs.com/features/webgl2
  29905. */
  29906. disableWebGL2Support?: boolean;
  29907. /**
  29908. * Defines if webaudio should be initialized as well
  29909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29910. */
  29911. audioEngine?: boolean;
  29912. /**
  29913. * Defines if animations should run using a deterministic lock step
  29914. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29915. */
  29916. deterministicLockstep?: boolean;
  29917. /** Defines the maximum steps to use with deterministic lock step mode */
  29918. lockstepMaxSteps?: number;
  29919. /**
  29920. * Defines that engine should ignore context lost events
  29921. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29922. */
  29923. doNotHandleContextLost?: boolean;
  29924. /**
  29925. * Defines that engine should ignore modifying touch action attribute and style
  29926. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29927. */
  29928. doNotHandleTouchAction?: boolean;
  29929. /**
  29930. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29931. */
  29932. useHighPrecisionFloats?: boolean;
  29933. }
  29934. /**
  29935. * The base engine class (root of all engines)
  29936. */
  29937. export class ThinEngine {
  29938. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29939. static ExceptionList: ({
  29940. key: string;
  29941. capture: string;
  29942. captureConstraint: number;
  29943. targets: string[];
  29944. } | {
  29945. key: string;
  29946. capture: null;
  29947. captureConstraint: null;
  29948. targets: string[];
  29949. })[];
  29950. /** @hidden */
  29951. static _TextureLoaders: IInternalTextureLoader[];
  29952. /**
  29953. * Returns the current npm package of the sdk
  29954. */
  29955. static readonly NpmPackage: string;
  29956. /**
  29957. * Returns the current version of the framework
  29958. */
  29959. static readonly Version: string;
  29960. /**
  29961. * Returns a string describing the current engine
  29962. */
  29963. readonly description: string;
  29964. /**
  29965. * Gets or sets the epsilon value used by collision engine
  29966. */
  29967. static CollisionsEpsilon: number;
  29968. /**
  29969. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29970. */
  29971. static ShadersRepository: string;
  29972. /** @hidden */
  29973. _shaderProcessor: IShaderProcessor;
  29974. /**
  29975. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29976. */
  29977. forcePOTTextures: boolean;
  29978. /**
  29979. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29980. */
  29981. isFullscreen: boolean;
  29982. /**
  29983. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29984. */
  29985. cullBackFaces: boolean;
  29986. /**
  29987. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29988. */
  29989. renderEvenInBackground: boolean;
  29990. /**
  29991. * Gets or sets a boolean indicating that cache can be kept between frames
  29992. */
  29993. preventCacheWipeBetweenFrames: boolean;
  29994. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29995. validateShaderPrograms: boolean;
  29996. /**
  29997. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29998. */
  29999. disableUniformBuffers: boolean;
  30000. /** @hidden */
  30001. _uniformBuffers: UniformBuffer[];
  30002. /**
  30003. * Gets a boolean indicating that the engine supports uniform buffers
  30004. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30005. */
  30006. readonly supportsUniformBuffers: boolean;
  30007. /** @hidden */
  30008. _gl: WebGLRenderingContext;
  30009. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30010. protected _windowIsBackground: boolean;
  30011. protected _webGLVersion: number;
  30012. protected _highPrecisionShadersAllowed: boolean;
  30013. /** @hidden */
  30014. readonly _shouldUseHighPrecisionShader: boolean;
  30015. /**
  30016. * Gets a boolean indicating that only power of 2 textures are supported
  30017. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30018. */
  30019. readonly needPOTTextures: boolean;
  30020. /** @hidden */
  30021. _badOS: boolean;
  30022. /** @hidden */
  30023. _badDesktopOS: boolean;
  30024. private _hardwareScalingLevel;
  30025. /** @hidden */
  30026. _caps: EngineCapabilities;
  30027. private _isStencilEnable;
  30028. protected _colorWrite: boolean;
  30029. private _glVersion;
  30030. private _glRenderer;
  30031. private _glVendor;
  30032. /** @hidden */
  30033. _videoTextureSupported: boolean;
  30034. protected _renderingQueueLaunched: boolean;
  30035. protected _activeRenderLoops: (() => void)[];
  30036. /**
  30037. * Observable signaled when a context lost event is raised
  30038. */
  30039. onContextLostObservable: Observable<ThinEngine>;
  30040. /**
  30041. * Observable signaled when a context restored event is raised
  30042. */
  30043. onContextRestoredObservable: Observable<ThinEngine>;
  30044. private _onContextLost;
  30045. private _onContextRestored;
  30046. protected _contextWasLost: boolean;
  30047. /** @hidden */
  30048. _doNotHandleContextLost: boolean;
  30049. /**
  30050. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30052. */
  30053. doNotHandleContextLost: boolean;
  30054. /**
  30055. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30056. */
  30057. disableVertexArrayObjects: boolean;
  30058. /** @hidden */
  30059. protected _depthCullingState: DepthCullingState;
  30060. /** @hidden */
  30061. protected _stencilState: StencilState;
  30062. /** @hidden */
  30063. protected _alphaState: AlphaState;
  30064. /** @hidden */
  30065. _internalTexturesCache: InternalTexture[];
  30066. /** @hidden */
  30067. protected _activeChannel: number;
  30068. private _currentTextureChannel;
  30069. /** @hidden */
  30070. protected _boundTexturesCache: {
  30071. [key: string]: Nullable<InternalTexture>;
  30072. };
  30073. /** @hidden */
  30074. protected _currentEffect: Nullable<Effect>;
  30075. /** @hidden */
  30076. protected _currentProgram: Nullable<WebGLProgram>;
  30077. private _compiledEffects;
  30078. private _vertexAttribArraysEnabled;
  30079. /** @hidden */
  30080. protected _cachedViewport: Nullable<IViewportLike>;
  30081. private _cachedVertexArrayObject;
  30082. /** @hidden */
  30083. protected _cachedVertexBuffers: any;
  30084. /** @hidden */
  30085. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30086. /** @hidden */
  30087. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30088. /** @hidden */
  30089. _currentRenderTarget: Nullable<InternalTexture>;
  30090. private _uintIndicesCurrentlySet;
  30091. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30092. /** @hidden */
  30093. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30094. private _currentBufferPointers;
  30095. private _currentInstanceLocations;
  30096. private _currentInstanceBuffers;
  30097. private _textureUnits;
  30098. /** @hidden */
  30099. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30100. /** @hidden */
  30101. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30102. /** @hidden */
  30103. _bindedRenderFunction: any;
  30104. private _vaoRecordInProgress;
  30105. private _mustWipeVertexAttributes;
  30106. private _emptyTexture;
  30107. private _emptyCubeTexture;
  30108. private _emptyTexture3D;
  30109. /** @hidden */
  30110. _frameHandler: number;
  30111. private _nextFreeTextureSlots;
  30112. private _maxSimultaneousTextures;
  30113. private _activeRequests;
  30114. protected _texturesSupported: string[];
  30115. /** @hidden */
  30116. _textureFormatInUse: Nullable<string>;
  30117. protected readonly _supportsHardwareTextureRescaling: boolean;
  30118. /**
  30119. * Gets the list of texture formats supported
  30120. */
  30121. readonly texturesSupported: Array<string>;
  30122. /**
  30123. * Gets the list of texture formats in use
  30124. */
  30125. readonly textureFormatInUse: Nullable<string>;
  30126. /**
  30127. * Gets the current viewport
  30128. */
  30129. readonly currentViewport: Nullable<IViewportLike>;
  30130. /**
  30131. * Gets the default empty texture
  30132. */
  30133. readonly emptyTexture: InternalTexture;
  30134. /**
  30135. * Gets the default empty 3D texture
  30136. */
  30137. readonly emptyTexture3D: InternalTexture;
  30138. /**
  30139. * Gets the default empty cube texture
  30140. */
  30141. readonly emptyCubeTexture: InternalTexture;
  30142. /**
  30143. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30144. */
  30145. readonly premultipliedAlpha: boolean;
  30146. /**
  30147. * Observable event triggered before each texture is initialized
  30148. */
  30149. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30150. /**
  30151. * Creates a new engine
  30152. * @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
  30153. * @param antialias defines enable antialiasing (default: false)
  30154. * @param options defines further options to be sent to the getContext() function
  30155. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30156. */
  30157. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30158. private _rebuildInternalTextures;
  30159. private _rebuildEffects;
  30160. /**
  30161. * Gets a boolean indicating if all created effects are ready
  30162. * @returns true if all effects are ready
  30163. */
  30164. areAllEffectsReady(): boolean;
  30165. protected _rebuildBuffers(): void;
  30166. private _initGLContext;
  30167. /**
  30168. * Gets version of the current webGL context
  30169. */
  30170. readonly webGLVersion: number;
  30171. /**
  30172. * Gets a string idenfifying the name of the class
  30173. * @returns "Engine" string
  30174. */
  30175. getClassName(): string;
  30176. /**
  30177. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30178. */
  30179. readonly isStencilEnable: boolean;
  30180. /** @hidden */
  30181. _prepareWorkingCanvas(): void;
  30182. /**
  30183. * Reset the texture cache to empty state
  30184. */
  30185. resetTextureCache(): void;
  30186. /**
  30187. * Gets an object containing information about the current webGL context
  30188. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30189. */
  30190. getGlInfo(): {
  30191. vendor: string;
  30192. renderer: string;
  30193. version: string;
  30194. };
  30195. /**
  30196. * Defines the hardware scaling level.
  30197. * By default the hardware scaling level is computed from the window device ratio.
  30198. * 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.
  30199. * @param level defines the level to use
  30200. */
  30201. setHardwareScalingLevel(level: number): void;
  30202. /**
  30203. * Gets the current hardware scaling level.
  30204. * By default the hardware scaling level is computed from the window device ratio.
  30205. * 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.
  30206. * @returns a number indicating the current hardware scaling level
  30207. */
  30208. getHardwareScalingLevel(): number;
  30209. /**
  30210. * Gets the list of loaded textures
  30211. * @returns an array containing all loaded textures
  30212. */
  30213. getLoadedTexturesCache(): InternalTexture[];
  30214. /**
  30215. * Gets the object containing all engine capabilities
  30216. * @returns the EngineCapabilities object
  30217. */
  30218. getCaps(): EngineCapabilities;
  30219. /**
  30220. * stop executing a render loop function and remove it from the execution array
  30221. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30222. */
  30223. stopRenderLoop(renderFunction?: () => void): void;
  30224. /** @hidden */
  30225. _renderLoop(): void;
  30226. /**
  30227. * Gets the HTML canvas attached with the current webGL context
  30228. * @returns a HTML canvas
  30229. */
  30230. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30231. /**
  30232. * Gets host window
  30233. * @returns the host window object
  30234. */
  30235. getHostWindow(): Nullable<Window>;
  30236. /**
  30237. * Gets the current render width
  30238. * @param useScreen defines if screen size must be used (or the current render target if any)
  30239. * @returns a number defining the current render width
  30240. */
  30241. getRenderWidth(useScreen?: boolean): number;
  30242. /**
  30243. * Gets the current render height
  30244. * @param useScreen defines if screen size must be used (or the current render target if any)
  30245. * @returns a number defining the current render height
  30246. */
  30247. getRenderHeight(useScreen?: boolean): number;
  30248. /**
  30249. * Can be used to override the current requestAnimationFrame requester.
  30250. * @hidden
  30251. */
  30252. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30253. /**
  30254. * Register and execute a render loop. The engine can have more than one render function
  30255. * @param renderFunction defines the function to continuously execute
  30256. */
  30257. runRenderLoop(renderFunction: () => void): void;
  30258. /**
  30259. * Clear the current render buffer or the current render target (if any is set up)
  30260. * @param color defines the color to use
  30261. * @param backBuffer defines if the back buffer must be cleared
  30262. * @param depth defines if the depth buffer must be cleared
  30263. * @param stencil defines if the stencil buffer must be cleared
  30264. */
  30265. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30266. private _viewportCached;
  30267. /** @hidden */
  30268. _viewport(x: number, y: number, width: number, height: number): void;
  30269. /**
  30270. * Set the WebGL's viewport
  30271. * @param viewport defines the viewport element to be used
  30272. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30273. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30274. */
  30275. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30276. /**
  30277. * Begin a new frame
  30278. */
  30279. beginFrame(): void;
  30280. /**
  30281. * Enf the current frame
  30282. */
  30283. endFrame(): void;
  30284. /**
  30285. * Resize the view according to the canvas' size
  30286. */
  30287. resize(): void;
  30288. /**
  30289. * Force a specific size of the canvas
  30290. * @param width defines the new canvas' width
  30291. * @param height defines the new canvas' height
  30292. */
  30293. setSize(width: number, height: number): void;
  30294. /**
  30295. * Binds the frame buffer to the specified texture.
  30296. * @param texture The texture to render to or null for the default canvas
  30297. * @param faceIndex The face of the texture to render to in case of cube texture
  30298. * @param requiredWidth The width of the target to render to
  30299. * @param requiredHeight The height of the target to render to
  30300. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30301. * @param depthStencilTexture The depth stencil texture to use to render
  30302. * @param lodLevel defines le lod level to bind to the frame buffer
  30303. */
  30304. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30305. /** @hidden */
  30306. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30307. /**
  30308. * Unbind the current render target texture from the webGL context
  30309. * @param texture defines the render target texture to unbind
  30310. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30311. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30312. */
  30313. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30314. /**
  30315. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30316. */
  30317. flushFramebuffer(): void;
  30318. /**
  30319. * Unbind the current render target and bind the default framebuffer
  30320. */
  30321. restoreDefaultFramebuffer(): void;
  30322. /** @hidden */
  30323. protected _resetVertexBufferBinding(): void;
  30324. /**
  30325. * Creates a vertex buffer
  30326. * @param data the data for the vertex buffer
  30327. * @returns the new WebGL static buffer
  30328. */
  30329. createVertexBuffer(data: DataArray): DataBuffer;
  30330. private _createVertexBuffer;
  30331. /**
  30332. * Creates a dynamic vertex buffer
  30333. * @param data the data for the dynamic vertex buffer
  30334. * @returns the new WebGL dynamic buffer
  30335. */
  30336. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30337. protected _resetIndexBufferBinding(): void;
  30338. /**
  30339. * Creates a new index buffer
  30340. * @param indices defines the content of the index buffer
  30341. * @param updatable defines if the index buffer must be updatable
  30342. * @returns a new webGL buffer
  30343. */
  30344. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30345. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30346. /**
  30347. * Bind a webGL buffer to the webGL context
  30348. * @param buffer defines the buffer to bind
  30349. */
  30350. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30351. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30352. private bindBuffer;
  30353. /**
  30354. * update the bound buffer with the given data
  30355. * @param data defines the data to update
  30356. */
  30357. updateArrayBuffer(data: Float32Array): void;
  30358. private _vertexAttribPointer;
  30359. private _bindIndexBufferWithCache;
  30360. private _bindVertexBuffersAttributes;
  30361. /**
  30362. * Records a vertex array object
  30363. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30364. * @param vertexBuffers defines the list of vertex buffers to store
  30365. * @param indexBuffer defines the index buffer to store
  30366. * @param effect defines the effect to store
  30367. * @returns the new vertex array object
  30368. */
  30369. recordVertexArrayObject(vertexBuffers: {
  30370. [key: string]: VertexBuffer;
  30371. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30372. /**
  30373. * Bind a specific vertex array object
  30374. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30375. * @param vertexArrayObject defines the vertex array object to bind
  30376. * @param indexBuffer defines the index buffer to bind
  30377. */
  30378. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30379. /**
  30380. * Bind webGl buffers directly to the webGL context
  30381. * @param vertexBuffer defines the vertex buffer to bind
  30382. * @param indexBuffer defines the index buffer to bind
  30383. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30384. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30385. * @param effect defines the effect associated with the vertex buffer
  30386. */
  30387. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30388. private _unbindVertexArrayObject;
  30389. /**
  30390. * Bind a list of vertex buffers to the webGL context
  30391. * @param vertexBuffers defines the list of vertex buffers to bind
  30392. * @param indexBuffer defines the index buffer to bind
  30393. * @param effect defines the effect associated with the vertex buffers
  30394. */
  30395. bindBuffers(vertexBuffers: {
  30396. [key: string]: Nullable<VertexBuffer>;
  30397. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30398. /**
  30399. * Unbind all instance attributes
  30400. */
  30401. unbindInstanceAttributes(): void;
  30402. /**
  30403. * Release and free the memory of a vertex array object
  30404. * @param vao defines the vertex array object to delete
  30405. */
  30406. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30407. /** @hidden */
  30408. _releaseBuffer(buffer: DataBuffer): boolean;
  30409. protected _deleteBuffer(buffer: DataBuffer): void;
  30410. /**
  30411. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30412. * @param instancesBuffer defines the webGL buffer to update and bind
  30413. * @param data defines the data to store in the buffer
  30414. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30415. */
  30416. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30417. /**
  30418. * Apply all cached states (depth, culling, stencil and alpha)
  30419. */
  30420. applyStates(): void;
  30421. /**
  30422. * Send a draw order
  30423. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30424. * @param indexStart defines the starting index
  30425. * @param indexCount defines the number of index to draw
  30426. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30427. */
  30428. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30429. /**
  30430. * Draw a list of points
  30431. * @param verticesStart defines the index of first vertex to draw
  30432. * @param verticesCount defines the count of vertices to draw
  30433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30434. */
  30435. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30436. /**
  30437. * Draw a list of unindexed primitives
  30438. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30439. * @param verticesStart defines the index of first vertex to draw
  30440. * @param verticesCount defines the count of vertices to draw
  30441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30442. */
  30443. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30444. /**
  30445. * Draw a list of indexed primitives
  30446. * @param fillMode defines the primitive to use
  30447. * @param indexStart defines the starting index
  30448. * @param indexCount defines the number of index to draw
  30449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30450. */
  30451. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30452. /**
  30453. * Draw a list of unindexed primitives
  30454. * @param fillMode defines the primitive to use
  30455. * @param verticesStart defines the index of first vertex to draw
  30456. * @param verticesCount defines the count of vertices to draw
  30457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30458. */
  30459. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30460. private _drawMode;
  30461. /** @hidden */
  30462. protected _reportDrawCall(): void;
  30463. /** @hidden */
  30464. _releaseEffect(effect: Effect): void;
  30465. /** @hidden */
  30466. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30467. /**
  30468. * Create a new effect (used to store vertex/fragment shaders)
  30469. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30470. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30471. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30472. * @param samplers defines an array of string used to represent textures
  30473. * @param defines defines the string containing the defines to use to compile the shaders
  30474. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30475. * @param onCompiled defines a function to call when the effect creation is successful
  30476. * @param onError defines a function to call when the effect creation has failed
  30477. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30478. * @returns the new Effect
  30479. */
  30480. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30481. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30482. private _compileShader;
  30483. private _compileRawShader;
  30484. /**
  30485. * Directly creates a webGL program
  30486. * @param pipelineContext defines the pipeline context to attach to
  30487. * @param vertexCode defines the vertex shader code to use
  30488. * @param fragmentCode defines the fragment shader code to use
  30489. * @param context defines the webGL context to use (if not set, the current one will be used)
  30490. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30491. * @returns the new webGL program
  30492. */
  30493. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30494. /**
  30495. * Creates a webGL program
  30496. * @param pipelineContext defines the pipeline context to attach to
  30497. * @param vertexCode defines the vertex shader code to use
  30498. * @param fragmentCode defines the fragment shader code to use
  30499. * @param defines defines the string containing the defines to use to compile the shaders
  30500. * @param context defines the webGL context to use (if not set, the current one will be used)
  30501. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30502. * @returns the new webGL program
  30503. */
  30504. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30505. /**
  30506. * Creates a new pipeline context
  30507. * @returns the new pipeline
  30508. */
  30509. createPipelineContext(): IPipelineContext;
  30510. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30511. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30512. /** @hidden */
  30513. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30514. /** @hidden */
  30515. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30516. /** @hidden */
  30517. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30518. /**
  30519. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30520. * @param pipelineContext defines the pipeline context to use
  30521. * @param uniformsNames defines the list of uniform names
  30522. * @returns an array of webGL uniform locations
  30523. */
  30524. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30525. /**
  30526. * Gets the lsit of active attributes for a given webGL program
  30527. * @param pipelineContext defines the pipeline context to use
  30528. * @param attributesNames defines the list of attribute names to get
  30529. * @returns an array of indices indicating the offset of each attribute
  30530. */
  30531. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30532. /**
  30533. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30534. * @param effect defines the effect to activate
  30535. */
  30536. enableEffect(effect: Nullable<Effect>): void;
  30537. /**
  30538. * Set the value of an uniform to a number (int)
  30539. * @param uniform defines the webGL uniform location where to store the value
  30540. * @param value defines the int number to store
  30541. */
  30542. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30543. /**
  30544. * Set the value of an uniform to an array of int32
  30545. * @param uniform defines the webGL uniform location where to store the value
  30546. * @param array defines the array of int32 to store
  30547. */
  30548. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30549. /**
  30550. * Set the value of an uniform to an array of int32 (stored as vec2)
  30551. * @param uniform defines the webGL uniform location where to store the value
  30552. * @param array defines the array of int32 to store
  30553. */
  30554. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30555. /**
  30556. * Set the value of an uniform to an array of int32 (stored as vec3)
  30557. * @param uniform defines the webGL uniform location where to store the value
  30558. * @param array defines the array of int32 to store
  30559. */
  30560. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30561. /**
  30562. * Set the value of an uniform to an array of int32 (stored as vec4)
  30563. * @param uniform defines the webGL uniform location where to store the value
  30564. * @param array defines the array of int32 to store
  30565. */
  30566. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30567. /**
  30568. * Set the value of an uniform to an array of number
  30569. * @param uniform defines the webGL uniform location where to store the value
  30570. * @param array defines the array of number to store
  30571. */
  30572. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30573. /**
  30574. * Set the value of an uniform to an array of number (stored as vec2)
  30575. * @param uniform defines the webGL uniform location where to store the value
  30576. * @param array defines the array of number to store
  30577. */
  30578. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30579. /**
  30580. * Set the value of an uniform to an array of number (stored as vec3)
  30581. * @param uniform defines the webGL uniform location where to store the value
  30582. * @param array defines the array of number to store
  30583. */
  30584. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30585. /**
  30586. * Set the value of an uniform to an array of number (stored as vec4)
  30587. * @param uniform defines the webGL uniform location where to store the value
  30588. * @param array defines the array of number to store
  30589. */
  30590. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30591. /**
  30592. * Set the value of an uniform to an array of float32 (stored as matrices)
  30593. * @param uniform defines the webGL uniform location where to store the value
  30594. * @param matrices defines the array of float32 to store
  30595. */
  30596. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30597. /**
  30598. * Set the value of an uniform to a matrix (3x3)
  30599. * @param uniform defines the webGL uniform location where to store the value
  30600. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30601. */
  30602. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30603. /**
  30604. * Set the value of an uniform to a matrix (2x2)
  30605. * @param uniform defines the webGL uniform location where to store the value
  30606. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30607. */
  30608. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30609. /**
  30610. * Set the value of an uniform to a number (float)
  30611. * @param uniform defines the webGL uniform location where to store the value
  30612. * @param value defines the float number to store
  30613. */
  30614. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30615. /**
  30616. * Set the value of an uniform to a vec2
  30617. * @param uniform defines the webGL uniform location where to store the value
  30618. * @param x defines the 1st component of the value
  30619. * @param y defines the 2nd component of the value
  30620. */
  30621. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30622. /**
  30623. * Set the value of an uniform to a vec3
  30624. * @param uniform defines the webGL uniform location where to store the value
  30625. * @param x defines the 1st component of the value
  30626. * @param y defines the 2nd component of the value
  30627. * @param z defines the 3rd component of the value
  30628. */
  30629. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30630. /**
  30631. * Set the value of an uniform to a vec4
  30632. * @param uniform defines the webGL uniform location where to store the value
  30633. * @param x defines the 1st component of the value
  30634. * @param y defines the 2nd component of the value
  30635. * @param z defines the 3rd component of the value
  30636. * @param w defines the 4th component of the value
  30637. */
  30638. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30639. /**
  30640. * Gets the depth culling state manager
  30641. */
  30642. readonly depthCullingState: DepthCullingState;
  30643. /**
  30644. * Gets the alpha state manager
  30645. */
  30646. readonly alphaState: AlphaState;
  30647. /**
  30648. * Gets the stencil state manager
  30649. */
  30650. readonly stencilState: StencilState;
  30651. /**
  30652. * Clears the list of texture accessible through engine.
  30653. * This can help preventing texture load conflict due to name collision.
  30654. */
  30655. clearInternalTexturesCache(): void;
  30656. /**
  30657. * Force the entire cache to be cleared
  30658. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30659. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30660. */
  30661. wipeCaches(bruteForce?: boolean): void;
  30662. /** @hidden */
  30663. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30664. min: number;
  30665. mag: number;
  30666. };
  30667. /** @hidden */
  30668. _createTexture(): WebGLTexture;
  30669. /**
  30670. * Usually called from Texture.ts.
  30671. * Passed information to create a WebGLTexture
  30672. * @param urlArg defines a value which contains one of the following:
  30673. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30674. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30675. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30677. * @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)
  30678. * @param scene needed for loading to the correct scene
  30679. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30680. * @param onLoad optional callback to be called upon successful completion
  30681. * @param onError optional callback to be called upon failure
  30682. * @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
  30683. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30684. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30685. * @param forcedExtension defines the extension to use to pick the right loader
  30686. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30687. * @param mimeType defines an optional mime type
  30688. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30689. */
  30690. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30691. /**
  30692. * @hidden
  30693. */
  30694. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30695. /**
  30696. * Creates a raw texture
  30697. * @param data defines the data to store in the texture
  30698. * @param width defines the width of the texture
  30699. * @param height defines the height of the texture
  30700. * @param format defines the format of the data
  30701. * @param generateMipMaps defines if the engine should generate the mip levels
  30702. * @param invertY defines if data must be stored with Y axis inverted
  30703. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30704. * @param compression defines the compression used (null by default)
  30705. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30706. * @returns the raw texture inside an InternalTexture
  30707. */
  30708. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30709. /**
  30710. * Creates a new raw cube texture
  30711. * @param data defines the array of data to use to create each face
  30712. * @param size defines the size of the textures
  30713. * @param format defines the format of the data
  30714. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30715. * @param generateMipMaps defines if the engine should generate the mip levels
  30716. * @param invertY defines if data must be stored with Y axis inverted
  30717. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30718. * @param compression defines the compression used (null by default)
  30719. * @returns the cube texture as an InternalTexture
  30720. */
  30721. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30722. /**
  30723. * Creates a new raw 3D texture
  30724. * @param data defines the data used to create the texture
  30725. * @param width defines the width of the texture
  30726. * @param height defines the height of the texture
  30727. * @param depth defines the depth of the texture
  30728. * @param format defines the format of the texture
  30729. * @param generateMipMaps defines if the engine must generate mip levels
  30730. * @param invertY defines if data must be stored with Y axis inverted
  30731. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30732. * @param compression defines the compressed used (can be null)
  30733. * @param textureType defines the compressed used (can be null)
  30734. * @returns a new raw 3D texture (stored in an InternalTexture)
  30735. */
  30736. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30737. private _unpackFlipYCached;
  30738. /**
  30739. * In case you are sharing the context with other applications, it might
  30740. * be interested to not cache the unpack flip y state to ensure a consistent
  30741. * value would be set.
  30742. */
  30743. enableUnpackFlipYCached: boolean;
  30744. /** @hidden */
  30745. _unpackFlipY(value: boolean): void;
  30746. /** @hidden */
  30747. _getUnpackAlignement(): number;
  30748. /**
  30749. * Update the sampling mode of a given texture
  30750. * @param samplingMode defines the required sampling mode
  30751. * @param texture defines the texture to update
  30752. */
  30753. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30754. /** @hidden */
  30755. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30756. width: number;
  30757. height: number;
  30758. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30759. /** @hidden */
  30760. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30761. /** @hidden */
  30762. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30763. /** @hidden */
  30764. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30765. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30766. private _prepareWebGLTexture;
  30767. /** @hidden */
  30768. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30769. /** @hidden */
  30770. _releaseFramebufferObjects(texture: InternalTexture): void;
  30771. /** @hidden */
  30772. _releaseTexture(texture: InternalTexture): void;
  30773. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30774. protected _setProgram(program: WebGLProgram): void;
  30775. protected _boundUniforms: {
  30776. [key: number]: WebGLUniformLocation;
  30777. };
  30778. /**
  30779. * Binds an effect to the webGL context
  30780. * @param effect defines the effect to bind
  30781. */
  30782. bindSamplers(effect: Effect): void;
  30783. private _activateCurrentTexture;
  30784. /** @hidden */
  30785. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30786. /** @hidden */
  30787. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30788. /**
  30789. * Unbind all textures from the webGL context
  30790. */
  30791. unbindAllTextures(): void;
  30792. /**
  30793. * Sets a texture to the according uniform.
  30794. * @param channel The texture channel
  30795. * @param uniform The uniform to set
  30796. * @param texture The texture to apply
  30797. */
  30798. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30799. private _bindSamplerUniformToChannel;
  30800. private _getTextureWrapMode;
  30801. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30802. /**
  30803. * Sets an array of texture to the webGL context
  30804. * @param channel defines the channel where the texture array must be set
  30805. * @param uniform defines the associated uniform location
  30806. * @param textures defines the array of textures to bind
  30807. */
  30808. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30809. /** @hidden */
  30810. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30811. private _setTextureParameterFloat;
  30812. private _setTextureParameterInteger;
  30813. /**
  30814. * Unbind all vertex attributes from the webGL context
  30815. */
  30816. unbindAllAttributes(): void;
  30817. /**
  30818. * 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
  30819. */
  30820. releaseEffects(): void;
  30821. /**
  30822. * Dispose and release all associated resources
  30823. */
  30824. dispose(): void;
  30825. /**
  30826. * Attach a new callback raised when context lost event is fired
  30827. * @param callback defines the callback to call
  30828. */
  30829. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30830. /**
  30831. * Attach a new callback raised when context restored event is fired
  30832. * @param callback defines the callback to call
  30833. */
  30834. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30835. /**
  30836. * Get the current error code of the webGL context
  30837. * @returns the error code
  30838. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30839. */
  30840. getError(): number;
  30841. private _canRenderToFloatFramebuffer;
  30842. private _canRenderToHalfFloatFramebuffer;
  30843. private _canRenderToFramebuffer;
  30844. /** @hidden */
  30845. _getWebGLTextureType(type: number): number;
  30846. /** @hidden */
  30847. _getInternalFormat(format: number): number;
  30848. /** @hidden */
  30849. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30850. /** @hidden */
  30851. _getRGBAMultiSampleBufferFormat(type: number): number;
  30852. /** @hidden */
  30853. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30854. /**
  30855. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30856. * @returns true if the engine can be created
  30857. * @ignorenaming
  30858. */
  30859. static isSupported(): boolean;
  30860. /**
  30861. * Find the next highest power of two.
  30862. * @param x Number to start search from.
  30863. * @return Next highest power of two.
  30864. */
  30865. static CeilingPOT(x: number): number;
  30866. /**
  30867. * Find the next lowest power of two.
  30868. * @param x Number to start search from.
  30869. * @return Next lowest power of two.
  30870. */
  30871. static FloorPOT(x: number): number;
  30872. /**
  30873. * Find the nearest power of two.
  30874. * @param x Number to start search from.
  30875. * @return Next nearest power of two.
  30876. */
  30877. static NearestPOT(x: number): number;
  30878. /**
  30879. * Get the closest exponent of two
  30880. * @param value defines the value to approximate
  30881. * @param max defines the maximum value to return
  30882. * @param mode defines how to define the closest value
  30883. * @returns closest exponent of two of the given value
  30884. */
  30885. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30886. /**
  30887. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30888. * @param func - the function to be called
  30889. * @param requester - the object that will request the next frame. Falls back to window.
  30890. * @returns frame number
  30891. */
  30892. static QueueNewFrame(func: () => void, requester?: any): number;
  30893. }
  30894. }
  30895. declare module "babylonjs/Maths/sphericalPolynomial" {
  30896. import { Vector3 } from "babylonjs/Maths/math.vector";
  30897. import { Color3 } from "babylonjs/Maths/math.color";
  30898. /**
  30899. * Class representing spherical harmonics coefficients to the 3rd degree
  30900. */
  30901. export class SphericalHarmonics {
  30902. /**
  30903. * Defines whether or not the harmonics have been prescaled for rendering.
  30904. */
  30905. preScaled: boolean;
  30906. /**
  30907. * The l0,0 coefficients of the spherical harmonics
  30908. */
  30909. l00: Vector3;
  30910. /**
  30911. * The l1,-1 coefficients of the spherical harmonics
  30912. */
  30913. l1_1: Vector3;
  30914. /**
  30915. * The l1,0 coefficients of the spherical harmonics
  30916. */
  30917. l10: Vector3;
  30918. /**
  30919. * The l1,1 coefficients of the spherical harmonics
  30920. */
  30921. l11: Vector3;
  30922. /**
  30923. * The l2,-2 coefficients of the spherical harmonics
  30924. */
  30925. l2_2: Vector3;
  30926. /**
  30927. * The l2,-1 coefficients of the spherical harmonics
  30928. */
  30929. l2_1: Vector3;
  30930. /**
  30931. * The l2,0 coefficients of the spherical harmonics
  30932. */
  30933. l20: Vector3;
  30934. /**
  30935. * The l2,1 coefficients of the spherical harmonics
  30936. */
  30937. l21: Vector3;
  30938. /**
  30939. * The l2,2 coefficients of the spherical harmonics
  30940. */
  30941. l22: Vector3;
  30942. /**
  30943. * Adds a light to the spherical harmonics
  30944. * @param direction the direction of the light
  30945. * @param color the color of the light
  30946. * @param deltaSolidAngle the delta solid angle of the light
  30947. */
  30948. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30949. /**
  30950. * Scales the spherical harmonics by the given amount
  30951. * @param scale the amount to scale
  30952. */
  30953. scaleInPlace(scale: number): void;
  30954. /**
  30955. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30956. *
  30957. * ```
  30958. * E_lm = A_l * L_lm
  30959. * ```
  30960. *
  30961. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30962. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30963. * the scaling factors are given in equation 9.
  30964. */
  30965. convertIncidentRadianceToIrradiance(): void;
  30966. /**
  30967. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30968. *
  30969. * ```
  30970. * L = (1/pi) * E * rho
  30971. * ```
  30972. *
  30973. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30974. */
  30975. convertIrradianceToLambertianRadiance(): void;
  30976. /**
  30977. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30978. * required operations at run time.
  30979. *
  30980. * This is simply done by scaling back the SH with Ylm constants parameter.
  30981. * The trigonometric part being applied by the shader at run time.
  30982. */
  30983. preScaleForRendering(): void;
  30984. /**
  30985. * Constructs a spherical harmonics from an array.
  30986. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30987. * @returns the spherical harmonics
  30988. */
  30989. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30990. /**
  30991. * Gets the spherical harmonics from polynomial
  30992. * @param polynomial the spherical polynomial
  30993. * @returns the spherical harmonics
  30994. */
  30995. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30996. }
  30997. /**
  30998. * Class representing spherical polynomial coefficients to the 3rd degree
  30999. */
  31000. export class SphericalPolynomial {
  31001. private _harmonics;
  31002. /**
  31003. * The spherical harmonics used to create the polynomials.
  31004. */
  31005. readonly preScaledHarmonics: SphericalHarmonics;
  31006. /**
  31007. * The x coefficients of the spherical polynomial
  31008. */
  31009. x: Vector3;
  31010. /**
  31011. * The y coefficients of the spherical polynomial
  31012. */
  31013. y: Vector3;
  31014. /**
  31015. * The z coefficients of the spherical polynomial
  31016. */
  31017. z: Vector3;
  31018. /**
  31019. * The xx coefficients of the spherical polynomial
  31020. */
  31021. xx: Vector3;
  31022. /**
  31023. * The yy coefficients of the spherical polynomial
  31024. */
  31025. yy: Vector3;
  31026. /**
  31027. * The zz coefficients of the spherical polynomial
  31028. */
  31029. zz: Vector3;
  31030. /**
  31031. * The xy coefficients of the spherical polynomial
  31032. */
  31033. xy: Vector3;
  31034. /**
  31035. * The yz coefficients of the spherical polynomial
  31036. */
  31037. yz: Vector3;
  31038. /**
  31039. * The zx coefficients of the spherical polynomial
  31040. */
  31041. zx: Vector3;
  31042. /**
  31043. * Adds an ambient color to the spherical polynomial
  31044. * @param color the color to add
  31045. */
  31046. addAmbient(color: Color3): void;
  31047. /**
  31048. * Scales the spherical polynomial by the given amount
  31049. * @param scale the amount to scale
  31050. */
  31051. scaleInPlace(scale: number): void;
  31052. /**
  31053. * Gets the spherical polynomial from harmonics
  31054. * @param harmonics the spherical harmonics
  31055. * @returns the spherical polynomial
  31056. */
  31057. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31058. /**
  31059. * Constructs a spherical polynomial from an array.
  31060. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31061. * @returns the spherical polynomial
  31062. */
  31063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31064. }
  31065. }
  31066. declare module "babylonjs/Materials/Textures/internalTexture" {
  31067. import { Observable } from "babylonjs/Misc/observable";
  31068. import { Nullable, int } from "babylonjs/types";
  31069. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31071. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31072. /**
  31073. * Defines the source of the internal texture
  31074. */
  31075. export enum InternalTextureSource {
  31076. /**
  31077. * The source of the texture data is unknown
  31078. */
  31079. Unknown = 0,
  31080. /**
  31081. * Texture data comes from an URL
  31082. */
  31083. Url = 1,
  31084. /**
  31085. * Texture data is only used for temporary storage
  31086. */
  31087. Temp = 2,
  31088. /**
  31089. * Texture data comes from raw data (ArrayBuffer)
  31090. */
  31091. Raw = 3,
  31092. /**
  31093. * Texture content is dynamic (video or dynamic texture)
  31094. */
  31095. Dynamic = 4,
  31096. /**
  31097. * Texture content is generated by rendering to it
  31098. */
  31099. RenderTarget = 5,
  31100. /**
  31101. * Texture content is part of a multi render target process
  31102. */
  31103. MultiRenderTarget = 6,
  31104. /**
  31105. * Texture data comes from a cube data file
  31106. */
  31107. Cube = 7,
  31108. /**
  31109. * Texture data comes from a raw cube data
  31110. */
  31111. CubeRaw = 8,
  31112. /**
  31113. * Texture data come from a prefiltered cube data file
  31114. */
  31115. CubePrefiltered = 9,
  31116. /**
  31117. * Texture content is raw 3D data
  31118. */
  31119. Raw3D = 10,
  31120. /**
  31121. * Texture content is a depth texture
  31122. */
  31123. Depth = 11,
  31124. /**
  31125. * Texture data comes from a raw cube data encoded with RGBD
  31126. */
  31127. CubeRawRGBD = 12
  31128. }
  31129. /**
  31130. * Class used to store data associated with WebGL texture data for the engine
  31131. * This class should not be used directly
  31132. */
  31133. export class InternalTexture {
  31134. /** @hidden */
  31135. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31136. /**
  31137. * Defines if the texture is ready
  31138. */
  31139. isReady: boolean;
  31140. /**
  31141. * Defines if the texture is a cube texture
  31142. */
  31143. isCube: boolean;
  31144. /**
  31145. * Defines if the texture contains 3D data
  31146. */
  31147. is3D: boolean;
  31148. /**
  31149. * Defines if the texture contains multiview data
  31150. */
  31151. isMultiview: boolean;
  31152. /**
  31153. * Gets the URL used to load this texture
  31154. */
  31155. url: string;
  31156. /**
  31157. * Gets the sampling mode of the texture
  31158. */
  31159. samplingMode: number;
  31160. /**
  31161. * Gets a boolean indicating if the texture needs mipmaps generation
  31162. */
  31163. generateMipMaps: boolean;
  31164. /**
  31165. * Gets the number of samples used by the texture (WebGL2+ only)
  31166. */
  31167. samples: number;
  31168. /**
  31169. * Gets the type of the texture (int, float...)
  31170. */
  31171. type: number;
  31172. /**
  31173. * Gets the format of the texture (RGB, RGBA...)
  31174. */
  31175. format: number;
  31176. /**
  31177. * Observable called when the texture is loaded
  31178. */
  31179. onLoadedObservable: Observable<InternalTexture>;
  31180. /**
  31181. * Gets the width of the texture
  31182. */
  31183. width: number;
  31184. /**
  31185. * Gets the height of the texture
  31186. */
  31187. height: number;
  31188. /**
  31189. * Gets the depth of the texture
  31190. */
  31191. depth: number;
  31192. /**
  31193. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31194. */
  31195. baseWidth: number;
  31196. /**
  31197. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31198. */
  31199. baseHeight: number;
  31200. /**
  31201. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31202. */
  31203. baseDepth: number;
  31204. /**
  31205. * Gets a boolean indicating if the texture is inverted on Y axis
  31206. */
  31207. invertY: boolean;
  31208. /** @hidden */
  31209. _invertVScale: boolean;
  31210. /** @hidden */
  31211. _associatedChannel: number;
  31212. /** @hidden */
  31213. _source: InternalTextureSource;
  31214. /** @hidden */
  31215. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31216. /** @hidden */
  31217. _bufferView: Nullable<ArrayBufferView>;
  31218. /** @hidden */
  31219. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31220. /** @hidden */
  31221. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31222. /** @hidden */
  31223. _size: number;
  31224. /** @hidden */
  31225. _extension: string;
  31226. /** @hidden */
  31227. _files: Nullable<string[]>;
  31228. /** @hidden */
  31229. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31230. /** @hidden */
  31231. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31232. /** @hidden */
  31233. _framebuffer: Nullable<WebGLFramebuffer>;
  31234. /** @hidden */
  31235. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31236. /** @hidden */
  31237. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31238. /** @hidden */
  31239. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31240. /** @hidden */
  31241. _attachments: Nullable<number[]>;
  31242. /** @hidden */
  31243. _cachedCoordinatesMode: Nullable<number>;
  31244. /** @hidden */
  31245. _cachedWrapU: Nullable<number>;
  31246. /** @hidden */
  31247. _cachedWrapV: Nullable<number>;
  31248. /** @hidden */
  31249. _cachedWrapR: Nullable<number>;
  31250. /** @hidden */
  31251. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31252. /** @hidden */
  31253. _isDisabled: boolean;
  31254. /** @hidden */
  31255. _compression: Nullable<string>;
  31256. /** @hidden */
  31257. _generateStencilBuffer: boolean;
  31258. /** @hidden */
  31259. _generateDepthBuffer: boolean;
  31260. /** @hidden */
  31261. _comparisonFunction: number;
  31262. /** @hidden */
  31263. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31264. /** @hidden */
  31265. _lodGenerationScale: number;
  31266. /** @hidden */
  31267. _lodGenerationOffset: number;
  31268. /** @hidden */
  31269. _colorTextureArray: Nullable<WebGLTexture>;
  31270. /** @hidden */
  31271. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31272. /** @hidden */
  31273. _lodTextureHigh: Nullable<BaseTexture>;
  31274. /** @hidden */
  31275. _lodTextureMid: Nullable<BaseTexture>;
  31276. /** @hidden */
  31277. _lodTextureLow: Nullable<BaseTexture>;
  31278. /** @hidden */
  31279. _isRGBD: boolean;
  31280. /** @hidden */
  31281. _linearSpecularLOD: boolean;
  31282. /** @hidden */
  31283. _irradianceTexture: Nullable<BaseTexture>;
  31284. /** @hidden */
  31285. _webGLTexture: Nullable<WebGLTexture>;
  31286. /** @hidden */
  31287. _references: number;
  31288. private _engine;
  31289. /**
  31290. * Gets the Engine the texture belongs to.
  31291. * @returns The babylon engine
  31292. */
  31293. getEngine(): ThinEngine;
  31294. /**
  31295. * Gets the data source type of the texture
  31296. */
  31297. readonly source: InternalTextureSource;
  31298. /**
  31299. * Creates a new InternalTexture
  31300. * @param engine defines the engine to use
  31301. * @param source defines the type of data that will be used
  31302. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31303. */
  31304. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31305. /**
  31306. * Increments the number of references (ie. the number of Texture that point to it)
  31307. */
  31308. incrementReferences(): void;
  31309. /**
  31310. * Change the size of the texture (not the size of the content)
  31311. * @param width defines the new width
  31312. * @param height defines the new height
  31313. * @param depth defines the new depth (1 by default)
  31314. */
  31315. updateSize(width: int, height: int, depth?: int): void;
  31316. /** @hidden */
  31317. _rebuild(): void;
  31318. /** @hidden */
  31319. _swapAndDie(target: InternalTexture): void;
  31320. /**
  31321. * Dispose the current allocated resources
  31322. */
  31323. dispose(): void;
  31324. }
  31325. }
  31326. declare module "babylonjs/Audio/analyser" {
  31327. import { Scene } from "babylonjs/scene";
  31328. /**
  31329. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31331. */
  31332. export class Analyser {
  31333. /**
  31334. * Gets or sets the smoothing
  31335. * @ignorenaming
  31336. */
  31337. SMOOTHING: number;
  31338. /**
  31339. * Gets or sets the FFT table size
  31340. * @ignorenaming
  31341. */
  31342. FFT_SIZE: number;
  31343. /**
  31344. * Gets or sets the bar graph amplitude
  31345. * @ignorenaming
  31346. */
  31347. BARGRAPHAMPLITUDE: number;
  31348. /**
  31349. * Gets or sets the position of the debug canvas
  31350. * @ignorenaming
  31351. */
  31352. DEBUGCANVASPOS: {
  31353. x: number;
  31354. y: number;
  31355. };
  31356. /**
  31357. * Gets or sets the debug canvas size
  31358. * @ignorenaming
  31359. */
  31360. DEBUGCANVASSIZE: {
  31361. width: number;
  31362. height: number;
  31363. };
  31364. private _byteFreqs;
  31365. private _byteTime;
  31366. private _floatFreqs;
  31367. private _webAudioAnalyser;
  31368. private _debugCanvas;
  31369. private _debugCanvasContext;
  31370. private _scene;
  31371. private _registerFunc;
  31372. private _audioEngine;
  31373. /**
  31374. * Creates a new analyser
  31375. * @param scene defines hosting scene
  31376. */
  31377. constructor(scene: Scene);
  31378. /**
  31379. * Get the number of data values you will have to play with for the visualization
  31380. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31381. * @returns a number
  31382. */
  31383. getFrequencyBinCount(): number;
  31384. /**
  31385. * Gets the current frequency data as a byte array
  31386. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31387. * @returns a Uint8Array
  31388. */
  31389. getByteFrequencyData(): Uint8Array;
  31390. /**
  31391. * Gets the current waveform as a byte array
  31392. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31393. * @returns a Uint8Array
  31394. */
  31395. getByteTimeDomainData(): Uint8Array;
  31396. /**
  31397. * Gets the current frequency data as a float array
  31398. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31399. * @returns a Float32Array
  31400. */
  31401. getFloatFrequencyData(): Float32Array;
  31402. /**
  31403. * Renders the debug canvas
  31404. */
  31405. drawDebugCanvas(): void;
  31406. /**
  31407. * Stops rendering the debug canvas and removes it
  31408. */
  31409. stopDebugCanvas(): void;
  31410. /**
  31411. * Connects two audio nodes
  31412. * @param inputAudioNode defines first node to connect
  31413. * @param outputAudioNode defines second node to connect
  31414. */
  31415. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31416. /**
  31417. * Releases all associated resources
  31418. */
  31419. dispose(): void;
  31420. }
  31421. }
  31422. declare module "babylonjs/Audio/audioEngine" {
  31423. import { IDisposable } from "babylonjs/scene";
  31424. import { Analyser } from "babylonjs/Audio/analyser";
  31425. import { Nullable } from "babylonjs/types";
  31426. import { Observable } from "babylonjs/Misc/observable";
  31427. /**
  31428. * This represents an audio engine and it is responsible
  31429. * to play, synchronize and analyse sounds throughout the application.
  31430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31431. */
  31432. export interface IAudioEngine extends IDisposable {
  31433. /**
  31434. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31435. */
  31436. readonly canUseWebAudio: boolean;
  31437. /**
  31438. * Gets the current AudioContext if available.
  31439. */
  31440. readonly audioContext: Nullable<AudioContext>;
  31441. /**
  31442. * The master gain node defines the global audio volume of your audio engine.
  31443. */
  31444. readonly masterGain: GainNode;
  31445. /**
  31446. * Gets whether or not mp3 are supported by your browser.
  31447. */
  31448. readonly isMP3supported: boolean;
  31449. /**
  31450. * Gets whether or not ogg are supported by your browser.
  31451. */
  31452. readonly isOGGsupported: boolean;
  31453. /**
  31454. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31455. * @ignoreNaming
  31456. */
  31457. WarnedWebAudioUnsupported: boolean;
  31458. /**
  31459. * Defines if the audio engine relies on a custom unlocked button.
  31460. * In this case, the embedded button will not be displayed.
  31461. */
  31462. useCustomUnlockedButton: boolean;
  31463. /**
  31464. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31465. */
  31466. readonly unlocked: boolean;
  31467. /**
  31468. * Event raised when audio has been unlocked on the browser.
  31469. */
  31470. onAudioUnlockedObservable: Observable<AudioEngine>;
  31471. /**
  31472. * Event raised when audio has been locked on the browser.
  31473. */
  31474. onAudioLockedObservable: Observable<AudioEngine>;
  31475. /**
  31476. * Flags the audio engine in Locked state.
  31477. * This happens due to new browser policies preventing audio to autoplay.
  31478. */
  31479. lock(): void;
  31480. /**
  31481. * Unlocks the audio engine once a user action has been done on the dom.
  31482. * This is helpful to resume play once browser policies have been satisfied.
  31483. */
  31484. unlock(): void;
  31485. }
  31486. /**
  31487. * This represents the default audio engine used in babylon.
  31488. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31490. */
  31491. export class AudioEngine implements IAudioEngine {
  31492. private _audioContext;
  31493. private _audioContextInitialized;
  31494. private _muteButton;
  31495. private _hostElement;
  31496. /**
  31497. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31498. */
  31499. canUseWebAudio: boolean;
  31500. /**
  31501. * The master gain node defines the global audio volume of your audio engine.
  31502. */
  31503. masterGain: GainNode;
  31504. /**
  31505. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31506. * @ignoreNaming
  31507. */
  31508. WarnedWebAudioUnsupported: boolean;
  31509. /**
  31510. * Gets whether or not mp3 are supported by your browser.
  31511. */
  31512. isMP3supported: boolean;
  31513. /**
  31514. * Gets whether or not ogg are supported by your browser.
  31515. */
  31516. isOGGsupported: boolean;
  31517. /**
  31518. * Gets whether audio has been unlocked on the device.
  31519. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31520. * a user interaction has happened.
  31521. */
  31522. unlocked: boolean;
  31523. /**
  31524. * Defines if the audio engine relies on a custom unlocked button.
  31525. * In this case, the embedded button will not be displayed.
  31526. */
  31527. useCustomUnlockedButton: boolean;
  31528. /**
  31529. * Event raised when audio has been unlocked on the browser.
  31530. */
  31531. onAudioUnlockedObservable: Observable<AudioEngine>;
  31532. /**
  31533. * Event raised when audio has been locked on the browser.
  31534. */
  31535. onAudioLockedObservable: Observable<AudioEngine>;
  31536. /**
  31537. * Gets the current AudioContext if available.
  31538. */
  31539. readonly audioContext: Nullable<AudioContext>;
  31540. private _connectedAnalyser;
  31541. /**
  31542. * Instantiates a new audio engine.
  31543. *
  31544. * There should be only one per page as some browsers restrict the number
  31545. * of audio contexts you can create.
  31546. * @param hostElement defines the host element where to display the mute icon if necessary
  31547. */
  31548. constructor(hostElement?: Nullable<HTMLElement>);
  31549. /**
  31550. * Flags the audio engine in Locked state.
  31551. * This happens due to new browser policies preventing audio to autoplay.
  31552. */
  31553. lock(): void;
  31554. /**
  31555. * Unlocks the audio engine once a user action has been done on the dom.
  31556. * This is helpful to resume play once browser policies have been satisfied.
  31557. */
  31558. unlock(): void;
  31559. private _resumeAudioContext;
  31560. private _initializeAudioContext;
  31561. private _tryToRun;
  31562. private _triggerRunningState;
  31563. private _triggerSuspendedState;
  31564. private _displayMuteButton;
  31565. private _moveButtonToTopLeft;
  31566. private _onResize;
  31567. private _hideMuteButton;
  31568. /**
  31569. * Destroy and release the resources associated with the audio ccontext.
  31570. */
  31571. dispose(): void;
  31572. /**
  31573. * Gets the global volume sets on the master gain.
  31574. * @returns the global volume if set or -1 otherwise
  31575. */
  31576. getGlobalVolume(): number;
  31577. /**
  31578. * Sets the global volume of your experience (sets on the master gain).
  31579. * @param newVolume Defines the new global volume of the application
  31580. */
  31581. setGlobalVolume(newVolume: number): void;
  31582. /**
  31583. * Connect the audio engine to an audio analyser allowing some amazing
  31584. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31586. * @param analyser The analyser to connect to the engine
  31587. */
  31588. connectToAnalyser(analyser: Analyser): void;
  31589. }
  31590. }
  31591. declare module "babylonjs/Loading/loadingScreen" {
  31592. /**
  31593. * Interface used to present a loading screen while loading a scene
  31594. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31595. */
  31596. export interface ILoadingScreen {
  31597. /**
  31598. * Function called to display the loading screen
  31599. */
  31600. displayLoadingUI: () => void;
  31601. /**
  31602. * Function called to hide the loading screen
  31603. */
  31604. hideLoadingUI: () => void;
  31605. /**
  31606. * Gets or sets the color to use for the background
  31607. */
  31608. loadingUIBackgroundColor: string;
  31609. /**
  31610. * Gets or sets the text to display while loading
  31611. */
  31612. loadingUIText: string;
  31613. }
  31614. /**
  31615. * Class used for the default loading screen
  31616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31617. */
  31618. export class DefaultLoadingScreen implements ILoadingScreen {
  31619. private _renderingCanvas;
  31620. private _loadingText;
  31621. private _loadingDivBackgroundColor;
  31622. private _loadingDiv;
  31623. private _loadingTextDiv;
  31624. /** Gets or sets the logo url to use for the default loading screen */
  31625. static DefaultLogoUrl: string;
  31626. /** Gets or sets the spinner url to use for the default loading screen */
  31627. static DefaultSpinnerUrl: string;
  31628. /**
  31629. * Creates a new default loading screen
  31630. * @param _renderingCanvas defines the canvas used to render the scene
  31631. * @param _loadingText defines the default text to display
  31632. * @param _loadingDivBackgroundColor defines the default background color
  31633. */
  31634. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31635. /**
  31636. * Function called to display the loading screen
  31637. */
  31638. displayLoadingUI(): void;
  31639. /**
  31640. * Function called to hide the loading screen
  31641. */
  31642. hideLoadingUI(): void;
  31643. /**
  31644. * Gets or sets the text to display while loading
  31645. */
  31646. loadingUIText: string;
  31647. /**
  31648. * Gets or sets the color to use for the background
  31649. */
  31650. loadingUIBackgroundColor: string;
  31651. private _resizeLoadingUI;
  31652. }
  31653. }
  31654. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31655. /**
  31656. * Interface for any object that can request an animation frame
  31657. */
  31658. export interface ICustomAnimationFrameRequester {
  31659. /**
  31660. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31661. */
  31662. renderFunction?: Function;
  31663. /**
  31664. * Called to request the next frame to render to
  31665. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31666. */
  31667. requestAnimationFrame: Function;
  31668. /**
  31669. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31670. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31671. */
  31672. requestID?: number;
  31673. }
  31674. }
  31675. declare module "babylonjs/Misc/performanceMonitor" {
  31676. /**
  31677. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31678. */
  31679. export class PerformanceMonitor {
  31680. private _enabled;
  31681. private _rollingFrameTime;
  31682. private _lastFrameTimeMs;
  31683. /**
  31684. * constructor
  31685. * @param frameSampleSize The number of samples required to saturate the sliding window
  31686. */
  31687. constructor(frameSampleSize?: number);
  31688. /**
  31689. * Samples current frame
  31690. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31691. */
  31692. sampleFrame(timeMs?: number): void;
  31693. /**
  31694. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31695. */
  31696. readonly averageFrameTime: number;
  31697. /**
  31698. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31699. */
  31700. readonly averageFrameTimeVariance: number;
  31701. /**
  31702. * Returns the frame time of the most recent frame
  31703. */
  31704. readonly instantaneousFrameTime: number;
  31705. /**
  31706. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31707. */
  31708. readonly averageFPS: number;
  31709. /**
  31710. * Returns the average framerate in frames per second using the most recent frame time
  31711. */
  31712. readonly instantaneousFPS: number;
  31713. /**
  31714. * Returns true if enough samples have been taken to completely fill the sliding window
  31715. */
  31716. readonly isSaturated: boolean;
  31717. /**
  31718. * Enables contributions to the sliding window sample set
  31719. */
  31720. enable(): void;
  31721. /**
  31722. * Disables contributions to the sliding window sample set
  31723. * Samples will not be interpolated over the disabled period
  31724. */
  31725. disable(): void;
  31726. /**
  31727. * Returns true if sampling is enabled
  31728. */
  31729. readonly isEnabled: boolean;
  31730. /**
  31731. * Resets performance monitor
  31732. */
  31733. reset(): void;
  31734. }
  31735. /**
  31736. * RollingAverage
  31737. *
  31738. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31739. */
  31740. export class RollingAverage {
  31741. /**
  31742. * Current average
  31743. */
  31744. average: number;
  31745. /**
  31746. * Current variance
  31747. */
  31748. variance: number;
  31749. protected _samples: Array<number>;
  31750. protected _sampleCount: number;
  31751. protected _pos: number;
  31752. protected _m2: number;
  31753. /**
  31754. * constructor
  31755. * @param length The number of samples required to saturate the sliding window
  31756. */
  31757. constructor(length: number);
  31758. /**
  31759. * Adds a sample to the sample set
  31760. * @param v The sample value
  31761. */
  31762. add(v: number): void;
  31763. /**
  31764. * Returns previously added values or null if outside of history or outside the sliding window domain
  31765. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31766. * @return Value previously recorded with add() or null if outside of range
  31767. */
  31768. history(i: number): number;
  31769. /**
  31770. * Returns true if enough samples have been taken to completely fill the sliding window
  31771. * @return true if sample-set saturated
  31772. */
  31773. isSaturated(): boolean;
  31774. /**
  31775. * Resets the rolling average (equivalent to 0 samples taken so far)
  31776. */
  31777. reset(): void;
  31778. /**
  31779. * Wraps a value around the sample range boundaries
  31780. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31781. * @return Wrapped position in sample range
  31782. */
  31783. protected _wrapPosition(i: number): number;
  31784. }
  31785. }
  31786. declare module "babylonjs/Misc/perfCounter" {
  31787. /**
  31788. * This class is used to track a performance counter which is number based.
  31789. * The user has access to many properties which give statistics of different nature.
  31790. *
  31791. * The implementer can track two kinds of Performance Counter: time and count.
  31792. * 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.
  31793. * 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.
  31794. */
  31795. export class PerfCounter {
  31796. /**
  31797. * Gets or sets a global boolean to turn on and off all the counters
  31798. */
  31799. static Enabled: boolean;
  31800. /**
  31801. * Returns the smallest value ever
  31802. */
  31803. readonly min: number;
  31804. /**
  31805. * Returns the biggest value ever
  31806. */
  31807. readonly max: number;
  31808. /**
  31809. * Returns the average value since the performance counter is running
  31810. */
  31811. readonly average: number;
  31812. /**
  31813. * Returns the average value of the last second the counter was monitored
  31814. */
  31815. readonly lastSecAverage: number;
  31816. /**
  31817. * Returns the current value
  31818. */
  31819. readonly current: number;
  31820. /**
  31821. * Gets the accumulated total
  31822. */
  31823. readonly total: number;
  31824. /**
  31825. * Gets the total value count
  31826. */
  31827. readonly count: number;
  31828. /**
  31829. * Creates a new counter
  31830. */
  31831. constructor();
  31832. /**
  31833. * Call this method to start monitoring a new frame.
  31834. * 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.
  31835. */
  31836. fetchNewFrame(): void;
  31837. /**
  31838. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31839. * @param newCount the count value to add to the monitored count
  31840. * @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.
  31841. */
  31842. addCount(newCount: number, fetchResult: boolean): void;
  31843. /**
  31844. * Start monitoring this performance counter
  31845. */
  31846. beginMonitoring(): void;
  31847. /**
  31848. * Compute the time lapsed since the previous beginMonitoring() call.
  31849. * @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
  31850. */
  31851. endMonitoring(newFrame?: boolean): void;
  31852. private _fetchResult;
  31853. private _startMonitoringTime;
  31854. private _min;
  31855. private _max;
  31856. private _average;
  31857. private _current;
  31858. private _totalValueCount;
  31859. private _totalAccumulated;
  31860. private _lastSecAverage;
  31861. private _lastSecAccumulated;
  31862. private _lastSecTime;
  31863. private _lastSecValueCount;
  31864. }
  31865. }
  31866. declare module "babylonjs/Engines/engine" {
  31867. import { Observable } from "babylonjs/Misc/observable";
  31868. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  31869. import { Scene } from "babylonjs/scene";
  31870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31871. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31872. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31873. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31874. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31875. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31876. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31877. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31878. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31880. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31881. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31882. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31883. import { Material } from "babylonjs/Materials/material";
  31884. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31885. /**
  31886. * Defines the interface used by display changed events
  31887. */
  31888. export interface IDisplayChangedEventArgs {
  31889. /** Gets the vrDisplay object (if any) */
  31890. vrDisplay: Nullable<any>;
  31891. /** Gets a boolean indicating if webVR is supported */
  31892. vrSupported: boolean;
  31893. }
  31894. /**
  31895. * Defines the interface used by objects containing a viewport (like a camera)
  31896. */
  31897. interface IViewportOwnerLike {
  31898. /**
  31899. * Gets or sets the viewport
  31900. */
  31901. viewport: IViewportLike;
  31902. }
  31903. /**
  31904. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31905. */
  31906. export class Engine extends ThinEngine {
  31907. /** Defines that alpha blending is disabled */
  31908. static readonly ALPHA_DISABLE: number;
  31909. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31910. static readonly ALPHA_ADD: number;
  31911. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31912. static readonly ALPHA_COMBINE: number;
  31913. /** Defines that alpha blending to DEST - SRC * DEST */
  31914. static readonly ALPHA_SUBTRACT: number;
  31915. /** Defines that alpha blending to SRC * DEST */
  31916. static readonly ALPHA_MULTIPLY: number;
  31917. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31918. static readonly ALPHA_MAXIMIZED: number;
  31919. /** Defines that alpha blending to SRC + DEST */
  31920. static readonly ALPHA_ONEONE: number;
  31921. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31922. static readonly ALPHA_PREMULTIPLIED: number;
  31923. /**
  31924. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31925. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31926. */
  31927. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31928. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31929. static readonly ALPHA_INTERPOLATE: number;
  31930. /**
  31931. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31932. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31933. */
  31934. static readonly ALPHA_SCREENMODE: number;
  31935. /** Defines that the ressource is not delayed*/
  31936. static readonly DELAYLOADSTATE_NONE: number;
  31937. /** Defines that the ressource was successfully delay loaded */
  31938. static readonly DELAYLOADSTATE_LOADED: number;
  31939. /** Defines that the ressource is currently delay loading */
  31940. static readonly DELAYLOADSTATE_LOADING: number;
  31941. /** Defines that the ressource is delayed and has not started loading */
  31942. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31944. static readonly NEVER: number;
  31945. /** 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 */
  31946. static readonly ALWAYS: number;
  31947. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31948. static readonly LESS: number;
  31949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31950. static readonly EQUAL: number;
  31951. /** 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 */
  31952. static readonly LEQUAL: number;
  31953. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31954. static readonly GREATER: number;
  31955. /** 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 */
  31956. static readonly GEQUAL: number;
  31957. /** 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 */
  31958. static readonly NOTEQUAL: number;
  31959. /** Passed to stencilOperation to specify that stencil value must be kept */
  31960. static readonly KEEP: number;
  31961. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31962. static readonly REPLACE: number;
  31963. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31964. static readonly INCR: number;
  31965. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31966. static readonly DECR: number;
  31967. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31968. static readonly INVERT: number;
  31969. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31970. static readonly INCR_WRAP: number;
  31971. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31972. static readonly DECR_WRAP: number;
  31973. /** Texture is not repeating outside of 0..1 UVs */
  31974. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31975. /** Texture is repeating outside of 0..1 UVs */
  31976. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31977. /** Texture is repeating and mirrored */
  31978. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31979. /** ALPHA */
  31980. static readonly TEXTUREFORMAT_ALPHA: number;
  31981. /** LUMINANCE */
  31982. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31983. /** LUMINANCE_ALPHA */
  31984. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31985. /** RGB */
  31986. static readonly TEXTUREFORMAT_RGB: number;
  31987. /** RGBA */
  31988. static readonly TEXTUREFORMAT_RGBA: number;
  31989. /** RED */
  31990. static readonly TEXTUREFORMAT_RED: number;
  31991. /** RED (2nd reference) */
  31992. static readonly TEXTUREFORMAT_R: number;
  31993. /** RG */
  31994. static readonly TEXTUREFORMAT_RG: number;
  31995. /** RED_INTEGER */
  31996. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31997. /** RED_INTEGER (2nd reference) */
  31998. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31999. /** RG_INTEGER */
  32000. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32001. /** RGB_INTEGER */
  32002. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32003. /** RGBA_INTEGER */
  32004. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32005. /** UNSIGNED_BYTE */
  32006. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32007. /** UNSIGNED_BYTE (2nd reference) */
  32008. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32009. /** FLOAT */
  32010. static readonly TEXTURETYPE_FLOAT: number;
  32011. /** HALF_FLOAT */
  32012. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32013. /** BYTE */
  32014. static readonly TEXTURETYPE_BYTE: number;
  32015. /** SHORT */
  32016. static readonly TEXTURETYPE_SHORT: number;
  32017. /** UNSIGNED_SHORT */
  32018. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32019. /** INT */
  32020. static readonly TEXTURETYPE_INT: number;
  32021. /** UNSIGNED_INT */
  32022. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32023. /** UNSIGNED_SHORT_4_4_4_4 */
  32024. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32025. /** UNSIGNED_SHORT_5_5_5_1 */
  32026. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32027. /** UNSIGNED_SHORT_5_6_5 */
  32028. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32029. /** UNSIGNED_INT_2_10_10_10_REV */
  32030. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32031. /** UNSIGNED_INT_24_8 */
  32032. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32033. /** UNSIGNED_INT_10F_11F_11F_REV */
  32034. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32035. /** UNSIGNED_INT_5_9_9_9_REV */
  32036. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32037. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32038. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32039. /** nearest is mag = nearest and min = nearest and mip = linear */
  32040. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32041. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32042. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32043. /** Trilinear is mag = linear and min = linear and mip = linear */
  32044. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32045. /** nearest is mag = nearest and min = nearest and mip = linear */
  32046. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32047. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32048. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32049. /** Trilinear is mag = linear and min = linear and mip = linear */
  32050. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32051. /** mag = nearest and min = nearest and mip = nearest */
  32052. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32053. /** mag = nearest and min = linear and mip = nearest */
  32054. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32055. /** mag = nearest and min = linear and mip = linear */
  32056. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32057. /** mag = nearest and min = linear and mip = none */
  32058. static readonly TEXTURE_NEAREST_LINEAR: number;
  32059. /** mag = nearest and min = nearest and mip = none */
  32060. static readonly TEXTURE_NEAREST_NEAREST: number;
  32061. /** mag = linear and min = nearest and mip = nearest */
  32062. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32063. /** mag = linear and min = nearest and mip = linear */
  32064. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32065. /** mag = linear and min = linear and mip = none */
  32066. static readonly TEXTURE_LINEAR_LINEAR: number;
  32067. /** mag = linear and min = nearest and mip = none */
  32068. static readonly TEXTURE_LINEAR_NEAREST: number;
  32069. /** Explicit coordinates mode */
  32070. static readonly TEXTURE_EXPLICIT_MODE: number;
  32071. /** Spherical coordinates mode */
  32072. static readonly TEXTURE_SPHERICAL_MODE: number;
  32073. /** Planar coordinates mode */
  32074. static readonly TEXTURE_PLANAR_MODE: number;
  32075. /** Cubic coordinates mode */
  32076. static readonly TEXTURE_CUBIC_MODE: number;
  32077. /** Projection coordinates mode */
  32078. static readonly TEXTURE_PROJECTION_MODE: number;
  32079. /** Skybox coordinates mode */
  32080. static readonly TEXTURE_SKYBOX_MODE: number;
  32081. /** Inverse Cubic coordinates mode */
  32082. static readonly TEXTURE_INVCUBIC_MODE: number;
  32083. /** Equirectangular coordinates mode */
  32084. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32085. /** Equirectangular Fixed coordinates mode */
  32086. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32087. /** Equirectangular Fixed Mirrored coordinates mode */
  32088. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32089. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32090. static readonly SCALEMODE_FLOOR: number;
  32091. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32092. static readonly SCALEMODE_NEAREST: number;
  32093. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32094. static readonly SCALEMODE_CEILING: number;
  32095. /**
  32096. * Returns the current npm package of the sdk
  32097. */
  32098. static readonly NpmPackage: string;
  32099. /**
  32100. * Returns the current version of the framework
  32101. */
  32102. static readonly Version: string;
  32103. /** Gets the list of created engines */
  32104. static readonly Instances: Engine[];
  32105. /**
  32106. * Gets the latest created engine
  32107. */
  32108. static readonly LastCreatedEngine: Nullable<Engine>;
  32109. /**
  32110. * Gets the latest created scene
  32111. */
  32112. static readonly LastCreatedScene: Nullable<Scene>;
  32113. /**
  32114. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32115. * @param flag defines which part of the materials must be marked as dirty
  32116. * @param predicate defines a predicate used to filter which materials should be affected
  32117. */
  32118. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32119. /**
  32120. * Method called to create the default loading screen.
  32121. * This can be overriden in your own app.
  32122. * @param canvas The rendering canvas element
  32123. * @returns The loading screen
  32124. */
  32125. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32126. /**
  32127. * Method called to create the default rescale post process on each engine.
  32128. */
  32129. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32130. /**
  32131. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32132. **/
  32133. enableOfflineSupport: boolean;
  32134. /**
  32135. * 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)
  32136. **/
  32137. disableManifestCheck: boolean;
  32138. /**
  32139. * Gets the list of created scenes
  32140. */
  32141. scenes: Scene[];
  32142. /**
  32143. * Event raised when a new scene is created
  32144. */
  32145. onNewSceneAddedObservable: Observable<Scene>;
  32146. /**
  32147. * Gets the list of created postprocesses
  32148. */
  32149. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32150. /**
  32151. * Gets a boolean indicating if the pointer is currently locked
  32152. */
  32153. isPointerLock: boolean;
  32154. /**
  32155. * Observable event triggered each time the rendering canvas is resized
  32156. */
  32157. onResizeObservable: Observable<Engine>;
  32158. /**
  32159. * Observable event triggered each time the canvas loses focus
  32160. */
  32161. onCanvasBlurObservable: Observable<Engine>;
  32162. /**
  32163. * Observable event triggered each time the canvas gains focus
  32164. */
  32165. onCanvasFocusObservable: Observable<Engine>;
  32166. /**
  32167. * Observable event triggered each time the canvas receives pointerout event
  32168. */
  32169. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32170. /**
  32171. * Observable raised when the engine begins a new frame
  32172. */
  32173. onBeginFrameObservable: Observable<Engine>;
  32174. /**
  32175. * If set, will be used to request the next animation frame for the render loop
  32176. */
  32177. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32178. /**
  32179. * Observable raised when the engine ends the current frame
  32180. */
  32181. onEndFrameObservable: Observable<Engine>;
  32182. /**
  32183. * Observable raised when the engine is about to compile a shader
  32184. */
  32185. onBeforeShaderCompilationObservable: Observable<Engine>;
  32186. /**
  32187. * Observable raised when the engine has jsut compiled a shader
  32188. */
  32189. onAfterShaderCompilationObservable: Observable<Engine>;
  32190. /**
  32191. * Gets the audio engine
  32192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32193. * @ignorenaming
  32194. */
  32195. static audioEngine: IAudioEngine;
  32196. /**
  32197. * Default AudioEngine factory responsible of creating the Audio Engine.
  32198. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32199. */
  32200. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32201. /**
  32202. * Default offline support factory responsible of creating a tool used to store data locally.
  32203. * By default, this will create a Database object if the workload has been embedded.
  32204. */
  32205. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32206. private _loadingScreen;
  32207. private _pointerLockRequested;
  32208. private _dummyFramebuffer;
  32209. private _rescalePostProcess;
  32210. /** @hidden */
  32211. protected _alphaMode: number;
  32212. /** @hidden */
  32213. protected _alphaEquation: number;
  32214. private _deterministicLockstep;
  32215. private _lockstepMaxSteps;
  32216. protected readonly _supportsHardwareTextureRescaling: boolean;
  32217. private _fps;
  32218. private _deltaTime;
  32219. /** @hidden */
  32220. _drawCalls: PerfCounter;
  32221. /**
  32222. * Turn this value on if you want to pause FPS computation when in background
  32223. */
  32224. disablePerformanceMonitorInBackground: boolean;
  32225. private _performanceMonitor;
  32226. /**
  32227. * Gets the performance monitor attached to this engine
  32228. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32229. */
  32230. readonly performanceMonitor: PerformanceMonitor;
  32231. private _onFocus;
  32232. private _onBlur;
  32233. private _onCanvasPointerOut;
  32234. private _onCanvasBlur;
  32235. private _onCanvasFocus;
  32236. private _onFullscreenChange;
  32237. private _onPointerLockChange;
  32238. /**
  32239. * Creates a new engine
  32240. * @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
  32241. * @param antialias defines enable antialiasing (default: false)
  32242. * @param options defines further options to be sent to the getContext() function
  32243. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32244. */
  32245. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32246. /**
  32247. * Gets current aspect ratio
  32248. * @param viewportOwner defines the camera to use to get the aspect ratio
  32249. * @param useScreen defines if screen size must be used (or the current render target if any)
  32250. * @returns a number defining the aspect ratio
  32251. */
  32252. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32253. /**
  32254. * Gets current screen aspect ratio
  32255. * @returns a number defining the aspect ratio
  32256. */
  32257. getScreenAspectRatio(): number;
  32258. /**
  32259. * Gets host document
  32260. * @returns the host document object
  32261. */
  32262. getHostDocument(): Document;
  32263. /**
  32264. * Gets the client rect of the HTML canvas attached with the current webGL context
  32265. * @returns a client rectanglee
  32266. */
  32267. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32268. /**
  32269. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32270. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32271. * @returns true if engine is in deterministic lock step mode
  32272. */
  32273. isDeterministicLockStep(): boolean;
  32274. /**
  32275. * Gets the max steps when engine is running in deterministic lock step
  32276. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32277. * @returns the max steps
  32278. */
  32279. getLockstepMaxSteps(): number;
  32280. /**
  32281. * Force the mipmap generation for the given render target texture
  32282. * @param texture defines the render target texture to use
  32283. */
  32284. generateMipMapsForCubemap(texture: InternalTexture): void;
  32285. /** States */
  32286. /**
  32287. * Set various states to the webGL context
  32288. * @param culling defines backface culling state
  32289. * @param zOffset defines the value to apply to zOffset (0 by default)
  32290. * @param force defines if states must be applied even if cache is up to date
  32291. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32292. */
  32293. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32294. /**
  32295. * Set the z offset to apply to current rendering
  32296. * @param value defines the offset to apply
  32297. */
  32298. setZOffset(value: number): void;
  32299. /**
  32300. * Gets the current value of the zOffset
  32301. * @returns the current zOffset state
  32302. */
  32303. getZOffset(): number;
  32304. /**
  32305. * Enable or disable depth buffering
  32306. * @param enable defines the state to set
  32307. */
  32308. setDepthBuffer(enable: boolean): void;
  32309. /**
  32310. * Gets a boolean indicating if depth writing is enabled
  32311. * @returns the current depth writing state
  32312. */
  32313. getDepthWrite(): boolean;
  32314. /**
  32315. * Enable or disable depth writing
  32316. * @param enable defines the state to set
  32317. */
  32318. setDepthWrite(enable: boolean): void;
  32319. /**
  32320. * Enable or disable color writing
  32321. * @param enable defines the state to set
  32322. */
  32323. setColorWrite(enable: boolean): void;
  32324. /**
  32325. * Gets a boolean indicating if color writing is enabled
  32326. * @returns the current color writing state
  32327. */
  32328. getColorWrite(): boolean;
  32329. /**
  32330. * Sets alpha constants used by some alpha blending modes
  32331. * @param r defines the red component
  32332. * @param g defines the green component
  32333. * @param b defines the blue component
  32334. * @param a defines the alpha component
  32335. */
  32336. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32337. /**
  32338. * Sets the current alpha mode
  32339. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32340. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32342. */
  32343. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32344. /**
  32345. * Gets the current alpha mode
  32346. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32347. * @returns the current alpha mode
  32348. */
  32349. getAlphaMode(): number;
  32350. /**
  32351. * Sets the current alpha equation
  32352. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32353. */
  32354. setAlphaEquation(equation: number): void;
  32355. /**
  32356. * Gets the current alpha equation.
  32357. * @returns the current alpha equation
  32358. */
  32359. getAlphaEquation(): number;
  32360. /**
  32361. * Gets a boolean indicating if stencil buffer is enabled
  32362. * @returns the current stencil buffer state
  32363. */
  32364. getStencilBuffer(): boolean;
  32365. /**
  32366. * Enable or disable the stencil buffer
  32367. * @param enable defines if the stencil buffer must be enabled or disabled
  32368. */
  32369. setStencilBuffer(enable: boolean): void;
  32370. /**
  32371. * Gets the current stencil mask
  32372. * @returns a number defining the new stencil mask to use
  32373. */
  32374. getStencilMask(): number;
  32375. /**
  32376. * Sets the current stencil mask
  32377. * @param mask defines the new stencil mask to use
  32378. */
  32379. setStencilMask(mask: number): void;
  32380. /**
  32381. * Gets the current stencil function
  32382. * @returns a number defining the stencil function to use
  32383. */
  32384. getStencilFunction(): number;
  32385. /**
  32386. * Gets the current stencil reference value
  32387. * @returns a number defining the stencil reference value to use
  32388. */
  32389. getStencilFunctionReference(): number;
  32390. /**
  32391. * Gets the current stencil mask
  32392. * @returns a number defining the stencil mask to use
  32393. */
  32394. getStencilFunctionMask(): number;
  32395. /**
  32396. * Sets the current stencil function
  32397. * @param stencilFunc defines the new stencil function to use
  32398. */
  32399. setStencilFunction(stencilFunc: number): void;
  32400. /**
  32401. * Sets the current stencil reference
  32402. * @param reference defines the new stencil reference to use
  32403. */
  32404. setStencilFunctionReference(reference: number): void;
  32405. /**
  32406. * Sets the current stencil mask
  32407. * @param mask defines the new stencil mask to use
  32408. */
  32409. setStencilFunctionMask(mask: number): void;
  32410. /**
  32411. * Gets the current stencil operation when stencil fails
  32412. * @returns a number defining stencil operation to use when stencil fails
  32413. */
  32414. getStencilOperationFail(): number;
  32415. /**
  32416. * Gets the current stencil operation when depth fails
  32417. * @returns a number defining stencil operation to use when depth fails
  32418. */
  32419. getStencilOperationDepthFail(): number;
  32420. /**
  32421. * Gets the current stencil operation when stencil passes
  32422. * @returns a number defining stencil operation to use when stencil passes
  32423. */
  32424. getStencilOperationPass(): number;
  32425. /**
  32426. * Sets the stencil operation to use when stencil fails
  32427. * @param operation defines the stencil operation to use when stencil fails
  32428. */
  32429. setStencilOperationFail(operation: number): void;
  32430. /**
  32431. * Sets the stencil operation to use when depth fails
  32432. * @param operation defines the stencil operation to use when depth fails
  32433. */
  32434. setStencilOperationDepthFail(operation: number): void;
  32435. /**
  32436. * Sets the stencil operation to use when stencil passes
  32437. * @param operation defines the stencil operation to use when stencil passes
  32438. */
  32439. setStencilOperationPass(operation: number): void;
  32440. /**
  32441. * Sets a boolean indicating if the dithering state is enabled or disabled
  32442. * @param value defines the dithering state
  32443. */
  32444. setDitheringState(value: boolean): void;
  32445. /**
  32446. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32447. * @param value defines the rasterizer state
  32448. */
  32449. setRasterizerState(value: boolean): void;
  32450. /**
  32451. * Gets the current depth function
  32452. * @returns a number defining the depth function
  32453. */
  32454. getDepthFunction(): Nullable<number>;
  32455. /**
  32456. * Sets the current depth function
  32457. * @param depthFunc defines the function to use
  32458. */
  32459. setDepthFunction(depthFunc: number): void;
  32460. /**
  32461. * Sets the current depth function to GREATER
  32462. */
  32463. setDepthFunctionToGreater(): void;
  32464. /**
  32465. * Sets the current depth function to GEQUAL
  32466. */
  32467. setDepthFunctionToGreaterOrEqual(): void;
  32468. /**
  32469. * Sets the current depth function to LESS
  32470. */
  32471. setDepthFunctionToLess(): void;
  32472. /**
  32473. * Sets the current depth function to LEQUAL
  32474. */
  32475. setDepthFunctionToLessOrEqual(): void;
  32476. private _cachedStencilBuffer;
  32477. private _cachedStencilFunction;
  32478. private _cachedStencilMask;
  32479. private _cachedStencilOperationPass;
  32480. private _cachedStencilOperationFail;
  32481. private _cachedStencilOperationDepthFail;
  32482. private _cachedStencilReference;
  32483. /**
  32484. * Caches the the state of the stencil buffer
  32485. */
  32486. cacheStencilState(): void;
  32487. /**
  32488. * Restores the state of the stencil buffer
  32489. */
  32490. restoreStencilState(): void;
  32491. /**
  32492. * Directly set the WebGL Viewport
  32493. * @param x defines the x coordinate of the viewport (in screen space)
  32494. * @param y defines the y coordinate of the viewport (in screen space)
  32495. * @param width defines the width of the viewport (in screen space)
  32496. * @param height defines the height of the viewport (in screen space)
  32497. * @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
  32498. */
  32499. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32500. /**
  32501. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32502. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32503. * @param y defines the y-coordinate of the corner of the clear rectangle
  32504. * @param width defines the width of the clear rectangle
  32505. * @param height defines the height of the clear rectangle
  32506. * @param clearColor defines the clear color
  32507. */
  32508. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32509. /**
  32510. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32511. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32512. * @param y defines the y-coordinate of the corner of the clear rectangle
  32513. * @param width defines the width of the clear rectangle
  32514. * @param height defines the height of the clear rectangle
  32515. */
  32516. enableScissor(x: number, y: number, width: number, height: number): void;
  32517. /**
  32518. * Disable previously set scissor test rectangle
  32519. */
  32520. disableScissor(): void;
  32521. protected _reportDrawCall(): void;
  32522. /**
  32523. * Initializes a webVR display and starts listening to display change events
  32524. * The onVRDisplayChangedObservable will be notified upon these changes
  32525. * @returns The onVRDisplayChangedObservable
  32526. */
  32527. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32528. /** @hidden */
  32529. _prepareVRComponent(): void;
  32530. /** @hidden */
  32531. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32532. /** @hidden */
  32533. _submitVRFrame(): void;
  32534. /**
  32535. * Call this function to leave webVR mode
  32536. * Will do nothing if webVR is not supported or if there is no webVR device
  32537. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32538. */
  32539. disableVR(): void;
  32540. /**
  32541. * Gets a boolean indicating that the system is in VR mode and is presenting
  32542. * @returns true if VR mode is engaged
  32543. */
  32544. isVRPresenting(): boolean;
  32545. /** @hidden */
  32546. _requestVRFrame(): void;
  32547. /** @hidden */
  32548. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32549. /**
  32550. * Gets the source code of the vertex shader associated with a specific webGL program
  32551. * @param program defines the program to use
  32552. * @returns a string containing the source code of the vertex shader associated with the program
  32553. */
  32554. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32555. /**
  32556. * Gets the source code of the fragment shader associated with a specific webGL program
  32557. * @param program defines the program to use
  32558. * @returns a string containing the source code of the fragment shader associated with the program
  32559. */
  32560. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32561. /**
  32562. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32563. * @param x defines the x coordinate of the rectangle where pixels must be read
  32564. * @param y defines the y coordinate of the rectangle where pixels must be read
  32565. * @param width defines the width of the rectangle where pixels must be read
  32566. * @param height defines the height of the rectangle where pixels must be read
  32567. * @returns a Uint8Array containing RGBA colors
  32568. */
  32569. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32570. /**
  32571. * Sets a depth stencil texture from a render target to the according uniform.
  32572. * @param channel The texture channel
  32573. * @param uniform The uniform to set
  32574. * @param texture The render target texture containing the depth stencil texture to apply
  32575. */
  32576. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32577. /**
  32578. * Sets a texture to the webGL context from a postprocess
  32579. * @param channel defines the channel to use
  32580. * @param postProcess defines the source postprocess
  32581. */
  32582. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32583. /**
  32584. * Binds the output of the passed in post process to the texture channel specified
  32585. * @param channel The channel the texture should be bound to
  32586. * @param postProcess The post process which's output should be bound
  32587. */
  32588. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32589. /** @hidden */
  32590. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32591. protected _rebuildBuffers(): void;
  32592. _renderLoop(): void;
  32593. /**
  32594. * Toggle full screen mode
  32595. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32596. */
  32597. switchFullscreen(requestPointerLock: boolean): void;
  32598. /**
  32599. * Enters full screen mode
  32600. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32601. */
  32602. enterFullscreen(requestPointerLock: boolean): void;
  32603. /**
  32604. * Exits full screen mode
  32605. */
  32606. exitFullscreen(): void;
  32607. /**
  32608. * Enters Pointerlock mode
  32609. */
  32610. enterPointerlock(): void;
  32611. /**
  32612. * Exits Pointerlock mode
  32613. */
  32614. exitPointerlock(): void;
  32615. /**
  32616. * Begin a new frame
  32617. */
  32618. beginFrame(): void;
  32619. /**
  32620. * Enf the current frame
  32621. */
  32622. endFrame(): void;
  32623. resize(): void;
  32624. /**
  32625. * Set the compressed texture format to use, based on the formats you have, and the formats
  32626. * supported by the hardware / browser.
  32627. *
  32628. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32629. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32630. * to API arguments needed to compressed textures. This puts the burden on the container
  32631. * generator to house the arcane code for determining these for current & future formats.
  32632. *
  32633. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32634. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32635. *
  32636. * Note: The result of this call is not taken into account when a texture is base64.
  32637. *
  32638. * @param formatsAvailable defines the list of those format families you have created
  32639. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32640. *
  32641. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32642. * @returns The extension selected.
  32643. */
  32644. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32645. /**
  32646. * Force a specific size of the canvas
  32647. * @param width defines the new canvas' width
  32648. * @param height defines the new canvas' height
  32649. */
  32650. setSize(width: number, height: number): void;
  32651. /**
  32652. * Updates a dynamic vertex buffer.
  32653. * @param vertexBuffer the vertex buffer to update
  32654. * @param data the data used to update the vertex buffer
  32655. * @param byteOffset the byte offset of the data
  32656. * @param byteLength the byte length of the data
  32657. */
  32658. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32659. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32660. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32661. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32662. _releaseTexture(texture: InternalTexture): void;
  32663. /**
  32664. * @hidden
  32665. * Rescales a texture
  32666. * @param source input texutre
  32667. * @param destination destination texture
  32668. * @param scene scene to use to render the resize
  32669. * @param internalFormat format to use when resizing
  32670. * @param onComplete callback to be called when resize has completed
  32671. */
  32672. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32673. /**
  32674. * Gets the current framerate
  32675. * @returns a number representing the framerate
  32676. */
  32677. getFps(): number;
  32678. /**
  32679. * Gets the time spent between current and previous frame
  32680. * @returns a number representing the delta time in ms
  32681. */
  32682. getDeltaTime(): number;
  32683. private _measureFps;
  32684. /** @hidden */
  32685. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32686. /**
  32687. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32688. * @param renderTarget The render target to set the frame buffer for
  32689. */
  32690. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32691. /**
  32692. * Update a dynamic index buffer
  32693. * @param indexBuffer defines the target index buffer
  32694. * @param indices defines the data to update
  32695. * @param offset defines the offset in the target index buffer where update should start
  32696. */
  32697. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32698. /**
  32699. * Updates the sample count of a render target texture
  32700. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32701. * @param texture defines the texture to update
  32702. * @param samples defines the sample count to set
  32703. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32704. */
  32705. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32706. /**
  32707. * Updates a depth texture Comparison Mode and Function.
  32708. * If the comparison Function is equal to 0, the mode will be set to none.
  32709. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32710. * @param texture The texture to set the comparison function for
  32711. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32712. */
  32713. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32714. /**
  32715. * Creates a webGL buffer to use with instanciation
  32716. * @param capacity defines the size of the buffer
  32717. * @returns the webGL buffer
  32718. */
  32719. createInstancesBuffer(capacity: number): DataBuffer;
  32720. /**
  32721. * Delete a webGL buffer used with instanciation
  32722. * @param buffer defines the webGL buffer to delete
  32723. */
  32724. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32725. /** @hidden */
  32726. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32727. dispose(): void;
  32728. private _disableTouchAction;
  32729. /**
  32730. * Display the loading screen
  32731. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32732. */
  32733. displayLoadingUI(): void;
  32734. /**
  32735. * Hide the loading screen
  32736. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32737. */
  32738. hideLoadingUI(): void;
  32739. /**
  32740. * Gets the current loading screen object
  32741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32742. */
  32743. /**
  32744. * Sets the current loading screen object
  32745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32746. */
  32747. loadingScreen: ILoadingScreen;
  32748. /**
  32749. * Sets the current loading screen text
  32750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32751. */
  32752. loadingUIText: string;
  32753. /**
  32754. * Sets the current loading screen background color
  32755. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32756. */
  32757. loadingUIBackgroundColor: string;
  32758. /** Pointerlock and fullscreen */
  32759. /**
  32760. * Ask the browser to promote the current element to pointerlock mode
  32761. * @param element defines the DOM element to promote
  32762. */
  32763. static _RequestPointerlock(element: HTMLElement): void;
  32764. /**
  32765. * Asks the browser to exit pointerlock mode
  32766. */
  32767. static _ExitPointerlock(): void;
  32768. /**
  32769. * Ask the browser to promote the current element to fullscreen rendering mode
  32770. * @param element defines the DOM element to promote
  32771. */
  32772. static _RequestFullscreen(element: HTMLElement): void;
  32773. /**
  32774. * Asks the browser to exit fullscreen mode
  32775. */
  32776. static _ExitFullscreen(): void;
  32777. }
  32778. }
  32779. declare module "babylonjs/Engines/engineStore" {
  32780. import { Nullable } from "babylonjs/types";
  32781. import { Engine } from "babylonjs/Engines/engine";
  32782. import { Scene } from "babylonjs/scene";
  32783. /**
  32784. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32785. * during the life time of the application.
  32786. */
  32787. export class EngineStore {
  32788. /** Gets the list of created engines */
  32789. static Instances: import("babylonjs/Engines/engine").Engine[];
  32790. /** @hidden */
  32791. static _LastCreatedScene: Nullable<Scene>;
  32792. /**
  32793. * Gets the latest created engine
  32794. */
  32795. static readonly LastCreatedEngine: Nullable<Engine>;
  32796. /**
  32797. * Gets the latest created scene
  32798. */
  32799. static readonly LastCreatedScene: Nullable<Scene>;
  32800. /**
  32801. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32802. * @ignorenaming
  32803. */
  32804. static UseFallbackTexture: boolean;
  32805. /**
  32806. * Texture content used if a texture cannot loaded
  32807. * @ignorenaming
  32808. */
  32809. static FallbackTexture: string;
  32810. }
  32811. }
  32812. declare module "babylonjs/Misc/promise" {
  32813. /**
  32814. * Helper class that provides a small promise polyfill
  32815. */
  32816. export class PromisePolyfill {
  32817. /**
  32818. * Static function used to check if the polyfill is required
  32819. * If this is the case then the function will inject the polyfill to window.Promise
  32820. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32821. */
  32822. static Apply(force?: boolean): void;
  32823. }
  32824. }
  32825. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32826. /**
  32827. * Interface for screenshot methods with describe argument called `size` as object with options
  32828. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32829. */
  32830. export interface IScreenshotSize {
  32831. /**
  32832. * number in pixels for canvas height
  32833. */
  32834. height?: number;
  32835. /**
  32836. * multiplier allowing render at a higher or lower resolution
  32837. * If value is defined then height and width will be ignored and taken from camera
  32838. */
  32839. precision?: number;
  32840. /**
  32841. * number in pixels for canvas width
  32842. */
  32843. width?: number;
  32844. }
  32845. }
  32846. declare module "babylonjs/Misc/tools" {
  32847. import { Nullable, float } from "babylonjs/types";
  32848. import { DomManagement } from "babylonjs/Misc/domManagement";
  32849. import { WebRequest } from "babylonjs/Misc/webRequest";
  32850. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32851. import { ReadFileError } from "babylonjs/Misc/fileTools";
  32852. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32853. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32854. import { Camera } from "babylonjs/Cameras/camera";
  32855. import { Engine } from "babylonjs/Engines/engine";
  32856. interface IColor4Like {
  32857. r: float;
  32858. g: float;
  32859. b: float;
  32860. a: float;
  32861. }
  32862. /**
  32863. * Class containing a set of static utilities functions
  32864. */
  32865. export class Tools {
  32866. /**
  32867. * Gets or sets the base URL to use to load assets
  32868. */
  32869. static BaseUrl: string;
  32870. /**
  32871. * Enable/Disable Custom HTTP Request Headers globally.
  32872. * default = false
  32873. * @see CustomRequestHeaders
  32874. */
  32875. static UseCustomRequestHeaders: boolean;
  32876. /**
  32877. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32878. * i.e. when loading files, where the server/service expects an Authorization header
  32879. */
  32880. static CustomRequestHeaders: {
  32881. [key: string]: string;
  32882. };
  32883. /**
  32884. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32885. */
  32886. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32887. /**
  32888. * Default behaviour for cors in the application.
  32889. * It can be a string if the expected behavior is identical in the entire app.
  32890. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32891. */
  32892. static CorsBehavior: string | ((url: string | string[]) => string);
  32893. /**
  32894. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32895. * @ignorenaming
  32896. */
  32897. static UseFallbackTexture: boolean;
  32898. /**
  32899. * Use this object to register external classes like custom textures or material
  32900. * to allow the laoders to instantiate them
  32901. */
  32902. static RegisteredExternalClasses: {
  32903. [key: string]: Object;
  32904. };
  32905. /**
  32906. * Texture content used if a texture cannot loaded
  32907. * @ignorenaming
  32908. */
  32909. static fallbackTexture: string;
  32910. /**
  32911. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32912. * @param u defines the coordinate on X axis
  32913. * @param v defines the coordinate on Y axis
  32914. * @param width defines the width of the source data
  32915. * @param height defines the height of the source data
  32916. * @param pixels defines the source byte array
  32917. * @param color defines the output color
  32918. */
  32919. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32920. /**
  32921. * Interpolates between a and b via alpha
  32922. * @param a The lower value (returned when alpha = 0)
  32923. * @param b The upper value (returned when alpha = 1)
  32924. * @param alpha The interpolation-factor
  32925. * @return The mixed value
  32926. */
  32927. static Mix(a: number, b: number, alpha: number): number;
  32928. /**
  32929. * Tries to instantiate a new object from a given class name
  32930. * @param className defines the class name to instantiate
  32931. * @returns the new object or null if the system was not able to do the instantiation
  32932. */
  32933. static Instantiate(className: string): any;
  32934. /**
  32935. * Provides a slice function that will work even on IE
  32936. * @param data defines the array to slice
  32937. * @param start defines the start of the data (optional)
  32938. * @param end defines the end of the data (optional)
  32939. * @returns the new sliced array
  32940. */
  32941. static Slice<T>(data: T, start?: number, end?: number): T;
  32942. /**
  32943. * Polyfill for setImmediate
  32944. * @param action defines the action to execute after the current execution block
  32945. */
  32946. static SetImmediate(action: () => void): void;
  32947. /**
  32948. * Function indicating if a number is an exponent of 2
  32949. * @param value defines the value to test
  32950. * @returns true if the value is an exponent of 2
  32951. */
  32952. static IsExponentOfTwo(value: number): boolean;
  32953. private static _tmpFloatArray;
  32954. /**
  32955. * Returns the nearest 32-bit single precision float representation of a Number
  32956. * @param value A Number. If the parameter is of a different type, it will get converted
  32957. * to a number or to NaN if it cannot be converted
  32958. * @returns number
  32959. */
  32960. static FloatRound(value: number): number;
  32961. /**
  32962. * Extracts the filename from a path
  32963. * @param path defines the path to use
  32964. * @returns the filename
  32965. */
  32966. static GetFilename(path: string): string;
  32967. /**
  32968. * Extracts the "folder" part of a path (everything before the filename).
  32969. * @param uri The URI to extract the info from
  32970. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32971. * @returns The "folder" part of the path
  32972. */
  32973. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32974. /**
  32975. * Extracts text content from a DOM element hierarchy
  32976. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32977. */
  32978. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32979. /**
  32980. * Convert an angle in radians to degrees
  32981. * @param angle defines the angle to convert
  32982. * @returns the angle in degrees
  32983. */
  32984. static ToDegrees(angle: number): number;
  32985. /**
  32986. * Convert an angle in degrees to radians
  32987. * @param angle defines the angle to convert
  32988. * @returns the angle in radians
  32989. */
  32990. static ToRadians(angle: number): number;
  32991. /**
  32992. * Returns an array if obj is not an array
  32993. * @param obj defines the object to evaluate as an array
  32994. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32995. * @returns either obj directly if obj is an array or a new array containing obj
  32996. */
  32997. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32998. /**
  32999. * Gets the pointer prefix to use
  33000. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33001. */
  33002. static GetPointerPrefix(): string;
  33003. /**
  33004. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33005. * @param url define the url we are trying
  33006. * @param element define the dom element where to configure the cors policy
  33007. */
  33008. static SetCorsBehavior(url: string | string[], element: {
  33009. crossOrigin: string | null;
  33010. }): void;
  33011. /**
  33012. * Removes unwanted characters from an url
  33013. * @param url defines the url to clean
  33014. * @returns the cleaned url
  33015. */
  33016. static CleanUrl(url: string): string;
  33017. /**
  33018. * Gets or sets a function used to pre-process url before using them to load assets
  33019. */
  33020. static PreprocessUrl: (url: string) => string;
  33021. /**
  33022. * Loads an image as an HTMLImageElement.
  33023. * @param input url string, ArrayBuffer, or Blob to load
  33024. * @param onLoad callback called when the image successfully loads
  33025. * @param onError callback called when the image fails to load
  33026. * @param offlineProvider offline provider for caching
  33027. * @param mimeType optional mime type
  33028. * @returns the HTMLImageElement of the loaded image
  33029. */
  33030. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33031. /**
  33032. * Loads a file from a url
  33033. * @param url url string, ArrayBuffer, or Blob to load
  33034. * @param onSuccess callback called when the file successfully loads
  33035. * @param onProgress callback called while file is loading (if the server supports this mode)
  33036. * @param offlineProvider defines the offline provider for caching
  33037. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33038. * @param onError callback called when the file fails to load
  33039. * @returns a file request object
  33040. */
  33041. 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;
  33042. /**
  33043. * Loads a file from a url
  33044. * @param url the file url to load
  33045. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33046. */
  33047. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33048. /**
  33049. * Load a script (identified by an url). When the url returns, the
  33050. * content of this file is added into a new script element, attached to the DOM (body element)
  33051. * @param scriptUrl defines the url of the script to laod
  33052. * @param onSuccess defines the callback called when the script is loaded
  33053. * @param onError defines the callback to call if an error occurs
  33054. * @param scriptId defines the id of the script element
  33055. */
  33056. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33057. /**
  33058. * Load an asynchronous script (identified by an url). When the url returns, the
  33059. * content of this file is added into a new script element, attached to the DOM (body element)
  33060. * @param scriptUrl defines the url of the script to laod
  33061. * @param scriptId defines the id of the script element
  33062. * @returns a promise request object
  33063. */
  33064. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33065. /**
  33066. * Loads a file from a blob
  33067. * @param fileToLoad defines the blob to use
  33068. * @param callback defines the callback to call when data is loaded
  33069. * @param progressCallback defines the callback to call during loading process
  33070. * @returns a file request object
  33071. */
  33072. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33073. /**
  33074. * Reads a file from a File object
  33075. * @param file defines the file to load
  33076. * @param onSuccess defines the callback to call when data is loaded
  33077. * @param onProgress defines the callback to call during loading process
  33078. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33079. * @param onError defines the callback to call when an error occurs
  33080. * @returns a file request object
  33081. */
  33082. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33083. /**
  33084. * Creates a data url from a given string content
  33085. * @param content defines the content to convert
  33086. * @returns the new data url link
  33087. */
  33088. static FileAsURL(content: string): string;
  33089. /**
  33090. * Format the given number to a specific decimal format
  33091. * @param value defines the number to format
  33092. * @param decimals defines the number of decimals to use
  33093. * @returns the formatted string
  33094. */
  33095. static Format(value: number, decimals?: number): string;
  33096. /**
  33097. * Tries to copy an object by duplicating every property
  33098. * @param source defines the source object
  33099. * @param destination defines the target object
  33100. * @param doNotCopyList defines a list of properties to avoid
  33101. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33102. */
  33103. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33104. /**
  33105. * Gets a boolean indicating if the given object has no own property
  33106. * @param obj defines the object to test
  33107. * @returns true if object has no own property
  33108. */
  33109. static IsEmpty(obj: any): boolean;
  33110. /**
  33111. * Function used to register events at window level
  33112. * @param windowElement defines the Window object to use
  33113. * @param events defines the events to register
  33114. */
  33115. static RegisterTopRootEvents(windowElement: Window, events: {
  33116. name: string;
  33117. handler: Nullable<(e: FocusEvent) => any>;
  33118. }[]): void;
  33119. /**
  33120. * Function used to unregister events from window level
  33121. * @param windowElement defines the Window object to use
  33122. * @param events defines the events to unregister
  33123. */
  33124. static UnregisterTopRootEvents(windowElement: Window, events: {
  33125. name: string;
  33126. handler: Nullable<(e: FocusEvent) => any>;
  33127. }[]): void;
  33128. /**
  33129. * @ignore
  33130. */
  33131. static _ScreenshotCanvas: HTMLCanvasElement;
  33132. /**
  33133. * Dumps the current bound framebuffer
  33134. * @param width defines the rendering width
  33135. * @param height defines the rendering height
  33136. * @param engine defines the hosting engine
  33137. * @param successCallback defines the callback triggered once the data are available
  33138. * @param mimeType defines the mime type of the result
  33139. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33140. */
  33141. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33142. /**
  33143. * Converts the canvas data to blob.
  33144. * This acts as a polyfill for browsers not supporting the to blob function.
  33145. * @param canvas Defines the canvas to extract the data from
  33146. * @param successCallback Defines the callback triggered once the data are available
  33147. * @param mimeType Defines the mime type of the result
  33148. */
  33149. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33150. /**
  33151. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33152. * @param successCallback defines the callback triggered once the data are available
  33153. * @param mimeType defines the mime type of the result
  33154. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33155. */
  33156. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33157. /**
  33158. * Downloads a blob in the browser
  33159. * @param blob defines the blob to download
  33160. * @param fileName defines the name of the downloaded file
  33161. */
  33162. static Download(blob: Blob, fileName: string): void;
  33163. /**
  33164. * Captures a screenshot of the current rendering
  33165. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33166. * @param engine defines the rendering engine
  33167. * @param camera defines the source camera
  33168. * @param size This parameter can be set to a single number or to an object with the
  33169. * following (optional) properties: precision, width, height. If a single number is passed,
  33170. * it will be used for both width and height. If an object is passed, the screenshot size
  33171. * will be derived from the parameters. The precision property is a multiplier allowing
  33172. * rendering at a higher or lower resolution
  33173. * @param successCallback defines the callback receives a single parameter which contains the
  33174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33175. * src parameter of an <img> to display it
  33176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33177. * Check your browser for supported MIME types
  33178. */
  33179. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33180. /**
  33181. * Captures a screenshot of the current rendering
  33182. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33183. * @param engine defines the rendering engine
  33184. * @param camera defines the source camera
  33185. * @param size This parameter can be set to a single number or to an object with the
  33186. * following (optional) properties: precision, width, height. If a single number is passed,
  33187. * it will be used for both width and height. If an object is passed, the screenshot size
  33188. * will be derived from the parameters. The precision property is a multiplier allowing
  33189. * rendering at a higher or lower resolution
  33190. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33191. * Check your browser for supported MIME types
  33192. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33193. * to the src parameter of an <img> to display it
  33194. */
  33195. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33196. /**
  33197. * Generates an image screenshot from the specified camera.
  33198. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33199. * @param engine The engine to use for rendering
  33200. * @param camera The camera to use for rendering
  33201. * @param size This parameter can be set to a single number or to an object with the
  33202. * following (optional) properties: precision, width, height. If a single number is passed,
  33203. * it will be used for both width and height. If an object is passed, the screenshot size
  33204. * will be derived from the parameters. The precision property is a multiplier allowing
  33205. * rendering at a higher or lower resolution
  33206. * @param successCallback The callback receives a single parameter which contains the
  33207. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33208. * src parameter of an <img> to display it
  33209. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33210. * Check your browser for supported MIME types
  33211. * @param samples Texture samples (default: 1)
  33212. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33213. * @param fileName A name for for the downloaded file.
  33214. */
  33215. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33216. /**
  33217. * Generates an image screenshot from the specified camera.
  33218. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33219. * @param engine The engine to use for rendering
  33220. * @param camera The camera to use for rendering
  33221. * @param size This parameter can be set to a single number or to an object with the
  33222. * following (optional) properties: precision, width, height. If a single number is passed,
  33223. * it will be used for both width and height. If an object is passed, the screenshot size
  33224. * will be derived from the parameters. The precision property is a multiplier allowing
  33225. * rendering at a higher or lower resolution
  33226. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33227. * Check your browser for supported MIME types
  33228. * @param samples Texture samples (default: 1)
  33229. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33230. * @param fileName A name for for the downloaded file.
  33231. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33232. * to the src parameter of an <img> to display it
  33233. */
  33234. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33235. /**
  33236. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33237. * Be aware Math.random() could cause collisions, but:
  33238. * "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"
  33239. * @returns a pseudo random id
  33240. */
  33241. static RandomId(): string;
  33242. /**
  33243. * Test if the given uri is a base64 string
  33244. * @param uri The uri to test
  33245. * @return True if the uri is a base64 string or false otherwise
  33246. */
  33247. static IsBase64(uri: string): boolean;
  33248. /**
  33249. * Decode the given base64 uri.
  33250. * @param uri The uri to decode
  33251. * @return The decoded base64 data.
  33252. */
  33253. static DecodeBase64(uri: string): ArrayBuffer;
  33254. /**
  33255. * Gets the absolute url.
  33256. * @param url the input url
  33257. * @return the absolute url
  33258. */
  33259. static GetAbsoluteUrl(url: string): string;
  33260. /**
  33261. * No log
  33262. */
  33263. static readonly NoneLogLevel: number;
  33264. /**
  33265. * Only message logs
  33266. */
  33267. static readonly MessageLogLevel: number;
  33268. /**
  33269. * Only warning logs
  33270. */
  33271. static readonly WarningLogLevel: number;
  33272. /**
  33273. * Only error logs
  33274. */
  33275. static readonly ErrorLogLevel: number;
  33276. /**
  33277. * All logs
  33278. */
  33279. static readonly AllLogLevel: number;
  33280. /**
  33281. * Gets a value indicating the number of loading errors
  33282. * @ignorenaming
  33283. */
  33284. static readonly errorsCount: number;
  33285. /**
  33286. * Callback called when a new log is added
  33287. */
  33288. static OnNewCacheEntry: (entry: string) => void;
  33289. /**
  33290. * Log a message to the console
  33291. * @param message defines the message to log
  33292. */
  33293. static Log(message: string): void;
  33294. /**
  33295. * Write a warning message to the console
  33296. * @param message defines the message to log
  33297. */
  33298. static Warn(message: string): void;
  33299. /**
  33300. * Write an error message to the console
  33301. * @param message defines the message to log
  33302. */
  33303. static Error(message: string): void;
  33304. /**
  33305. * Gets current log cache (list of logs)
  33306. */
  33307. static readonly LogCache: string;
  33308. /**
  33309. * Clears the log cache
  33310. */
  33311. static ClearLogCache(): void;
  33312. /**
  33313. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33314. */
  33315. static LogLevels: number;
  33316. /**
  33317. * Checks if the window object exists
  33318. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33319. */
  33320. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33321. /**
  33322. * No performance log
  33323. */
  33324. static readonly PerformanceNoneLogLevel: number;
  33325. /**
  33326. * Use user marks to log performance
  33327. */
  33328. static readonly PerformanceUserMarkLogLevel: number;
  33329. /**
  33330. * Log performance to the console
  33331. */
  33332. static readonly PerformanceConsoleLogLevel: number;
  33333. private static _performance;
  33334. /**
  33335. * Sets the current performance log level
  33336. */
  33337. static PerformanceLogLevel: number;
  33338. private static _StartPerformanceCounterDisabled;
  33339. private static _EndPerformanceCounterDisabled;
  33340. private static _StartUserMark;
  33341. private static _EndUserMark;
  33342. private static _StartPerformanceConsole;
  33343. private static _EndPerformanceConsole;
  33344. /**
  33345. * Starts a performance counter
  33346. */
  33347. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33348. /**
  33349. * Ends a specific performance coutner
  33350. */
  33351. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33352. /**
  33353. * Gets either window.performance.now() if supported or Date.now() else
  33354. */
  33355. static readonly Now: number;
  33356. /**
  33357. * This method will return the name of the class used to create the instance of the given object.
  33358. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33359. * @param object the object to get the class name from
  33360. * @param isType defines if the object is actually a type
  33361. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33362. */
  33363. static GetClassName(object: any, isType?: boolean): string;
  33364. /**
  33365. * Gets the first element of an array satisfying a given predicate
  33366. * @param array defines the array to browse
  33367. * @param predicate defines the predicate to use
  33368. * @returns null if not found or the element
  33369. */
  33370. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33371. /**
  33372. * This method will return the name of the full name of the class, including its owning module (if any).
  33373. * 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).
  33374. * @param object the object to get the class name from
  33375. * @param isType defines if the object is actually a type
  33376. * @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.
  33377. * @ignorenaming
  33378. */
  33379. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33380. /**
  33381. * Returns a promise that resolves after the given amount of time.
  33382. * @param delay Number of milliseconds to delay
  33383. * @returns Promise that resolves after the given amount of time
  33384. */
  33385. static DelayAsync(delay: number): Promise<void>;
  33386. }
  33387. /**
  33388. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33389. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33390. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33391. * @param name The name of the class, case should be preserved
  33392. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33393. */
  33394. export function className(name: string, module?: string): (target: Object) => void;
  33395. /**
  33396. * An implementation of a loop for asynchronous functions.
  33397. */
  33398. export class AsyncLoop {
  33399. /**
  33400. * Defines the number of iterations for the loop
  33401. */
  33402. iterations: number;
  33403. /**
  33404. * Defines the current index of the loop.
  33405. */
  33406. index: number;
  33407. private _done;
  33408. private _fn;
  33409. private _successCallback;
  33410. /**
  33411. * Constructor.
  33412. * @param iterations the number of iterations.
  33413. * @param func the function to run each iteration
  33414. * @param successCallback the callback that will be called upon succesful execution
  33415. * @param offset starting offset.
  33416. */
  33417. constructor(
  33418. /**
  33419. * Defines the number of iterations for the loop
  33420. */
  33421. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33422. /**
  33423. * Execute the next iteration. Must be called after the last iteration was finished.
  33424. */
  33425. executeNext(): void;
  33426. /**
  33427. * Break the loop and run the success callback.
  33428. */
  33429. breakLoop(): void;
  33430. /**
  33431. * Create and run an async loop.
  33432. * @param iterations the number of iterations.
  33433. * @param fn the function to run each iteration
  33434. * @param successCallback the callback that will be called upon succesful execution
  33435. * @param offset starting offset.
  33436. * @returns the created async loop object
  33437. */
  33438. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33439. /**
  33440. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33441. * @param iterations total number of iterations
  33442. * @param syncedIterations number of synchronous iterations in each async iteration.
  33443. * @param fn the function to call each iteration.
  33444. * @param callback a success call back that will be called when iterating stops.
  33445. * @param breakFunction a break condition (optional)
  33446. * @param timeout timeout settings for the setTimeout function. default - 0.
  33447. * @returns the created async loop object
  33448. */
  33449. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33450. }
  33451. }
  33452. declare module "babylonjs/Misc/stringDictionary" {
  33453. import { Nullable } from "babylonjs/types";
  33454. /**
  33455. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33456. * The underlying implementation relies on an associative array to ensure the best performances.
  33457. * The value can be anything including 'null' but except 'undefined'
  33458. */
  33459. export class StringDictionary<T> {
  33460. /**
  33461. * This will clear this dictionary and copy the content from the 'source' one.
  33462. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33463. * @param source the dictionary to take the content from and copy to this dictionary
  33464. */
  33465. copyFrom(source: StringDictionary<T>): void;
  33466. /**
  33467. * Get a value based from its key
  33468. * @param key the given key to get the matching value from
  33469. * @return the value if found, otherwise undefined is returned
  33470. */
  33471. get(key: string): T | undefined;
  33472. /**
  33473. * Get a value from its key or add it if it doesn't exist.
  33474. * This method will ensure you that a given key/data will be present in the dictionary.
  33475. * @param key the given key to get the matching value from
  33476. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33477. * The factory will only be invoked if there's no data for the given key.
  33478. * @return the value corresponding to the key.
  33479. */
  33480. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33481. /**
  33482. * Get a value from its key if present in the dictionary otherwise add it
  33483. * @param key the key to get the value from
  33484. * @param val if there's no such key/value pair in the dictionary add it with this value
  33485. * @return the value corresponding to the key
  33486. */
  33487. getOrAdd(key: string, val: T): T;
  33488. /**
  33489. * Check if there's a given key in the dictionary
  33490. * @param key the key to check for
  33491. * @return true if the key is present, false otherwise
  33492. */
  33493. contains(key: string): boolean;
  33494. /**
  33495. * Add a new key and its corresponding value
  33496. * @param key the key to add
  33497. * @param value the value corresponding to the key
  33498. * @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
  33499. */
  33500. add(key: string, value: T): boolean;
  33501. /**
  33502. * Update a specific value associated to a key
  33503. * @param key defines the key to use
  33504. * @param value defines the value to store
  33505. * @returns true if the value was updated (or false if the key was not found)
  33506. */
  33507. set(key: string, value: T): boolean;
  33508. /**
  33509. * Get the element of the given key and remove it from the dictionary
  33510. * @param key defines the key to search
  33511. * @returns the value associated with the key or null if not found
  33512. */
  33513. getAndRemove(key: string): Nullable<T>;
  33514. /**
  33515. * Remove a key/value from the dictionary.
  33516. * @param key the key to remove
  33517. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33518. */
  33519. remove(key: string): boolean;
  33520. /**
  33521. * Clear the whole content of the dictionary
  33522. */
  33523. clear(): void;
  33524. /**
  33525. * Gets the current count
  33526. */
  33527. readonly count: number;
  33528. /**
  33529. * Execute a callback on each key/val of the dictionary.
  33530. * Note that you can remove any element in this dictionary in the callback implementation
  33531. * @param callback the callback to execute on a given key/value pair
  33532. */
  33533. forEach(callback: (key: string, val: T) => void): void;
  33534. /**
  33535. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33536. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33537. * Note that you can remove any element in this dictionary in the callback implementation
  33538. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33539. * @returns the first item
  33540. */
  33541. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33542. private _count;
  33543. private _data;
  33544. }
  33545. }
  33546. declare module "babylonjs/Collisions/collisionCoordinator" {
  33547. import { Nullable } from "babylonjs/types";
  33548. import { Scene } from "babylonjs/scene";
  33549. import { Vector3 } from "babylonjs/Maths/math.vector";
  33550. import { Collider } from "babylonjs/Collisions/collider";
  33551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33552. /** @hidden */
  33553. export interface ICollisionCoordinator {
  33554. createCollider(): Collider;
  33555. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33556. init(scene: Scene): void;
  33557. }
  33558. /** @hidden */
  33559. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33560. private _scene;
  33561. private _scaledPosition;
  33562. private _scaledVelocity;
  33563. private _finalPosition;
  33564. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33565. createCollider(): Collider;
  33566. init(scene: Scene): void;
  33567. private _collideWithWorld;
  33568. }
  33569. }
  33570. declare module "babylonjs/Inputs/scene.inputManager" {
  33571. import { Nullable } from "babylonjs/types";
  33572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33573. import { Vector2 } from "babylonjs/Maths/math.vector";
  33574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33575. import { Scene } from "babylonjs/scene";
  33576. /**
  33577. * Class used to manage all inputs for the scene.
  33578. */
  33579. export class InputManager {
  33580. /** The distance in pixel that you have to move to prevent some events */
  33581. static DragMovementThreshold: number;
  33582. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33583. static LongPressDelay: number;
  33584. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33585. static DoubleClickDelay: number;
  33586. /** If you need to check double click without raising a single click at first click, enable this flag */
  33587. static ExclusiveDoubleClickMode: boolean;
  33588. private _wheelEventName;
  33589. private _onPointerMove;
  33590. private _onPointerDown;
  33591. private _onPointerUp;
  33592. private _initClickEvent;
  33593. private _initActionManager;
  33594. private _delayedSimpleClick;
  33595. private _delayedSimpleClickTimeout;
  33596. private _previousDelayedSimpleClickTimeout;
  33597. private _meshPickProceed;
  33598. private _previousButtonPressed;
  33599. private _currentPickResult;
  33600. private _previousPickResult;
  33601. private _totalPointersPressed;
  33602. private _doubleClickOccured;
  33603. private _pointerOverMesh;
  33604. private _pickedDownMesh;
  33605. private _pickedUpMesh;
  33606. private _pointerX;
  33607. private _pointerY;
  33608. private _unTranslatedPointerX;
  33609. private _unTranslatedPointerY;
  33610. private _startingPointerPosition;
  33611. private _previousStartingPointerPosition;
  33612. private _startingPointerTime;
  33613. private _previousStartingPointerTime;
  33614. private _pointerCaptures;
  33615. private _onKeyDown;
  33616. private _onKeyUp;
  33617. private _onCanvasFocusObserver;
  33618. private _onCanvasBlurObserver;
  33619. private _scene;
  33620. /**
  33621. * Creates a new InputManager
  33622. * @param scene defines the hosting scene
  33623. */
  33624. constructor(scene: Scene);
  33625. /**
  33626. * Gets the mesh that is currently under the pointer
  33627. */
  33628. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33629. /**
  33630. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33631. */
  33632. readonly unTranslatedPointer: Vector2;
  33633. /**
  33634. * Gets or sets the current on-screen X position of the pointer
  33635. */
  33636. pointerX: number;
  33637. /**
  33638. * Gets or sets the current on-screen Y position of the pointer
  33639. */
  33640. pointerY: number;
  33641. private _updatePointerPosition;
  33642. private _processPointerMove;
  33643. private _setRayOnPointerInfo;
  33644. private _checkPrePointerObservable;
  33645. /**
  33646. * Use this method to simulate a pointer move on a mesh
  33647. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33648. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33649. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33650. */
  33651. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33652. /**
  33653. * Use this method to simulate a pointer down on a mesh
  33654. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33655. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33656. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33657. */
  33658. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33659. private _processPointerDown;
  33660. /** @hidden */
  33661. _isPointerSwiping(): boolean;
  33662. /**
  33663. * Use this method to simulate a pointer up on a mesh
  33664. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33665. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33666. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33667. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33668. */
  33669. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33670. private _processPointerUp;
  33671. /**
  33672. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33673. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33674. * @returns true if the pointer was captured
  33675. */
  33676. isPointerCaptured(pointerId?: number): boolean;
  33677. /**
  33678. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33679. * @param attachUp defines if you want to attach events to pointerup
  33680. * @param attachDown defines if you want to attach events to pointerdown
  33681. * @param attachMove defines if you want to attach events to pointermove
  33682. */
  33683. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33684. /**
  33685. * Detaches all event handlers
  33686. */
  33687. detachControl(): void;
  33688. /**
  33689. * Force the value of meshUnderPointer
  33690. * @param mesh defines the mesh to use
  33691. */
  33692. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33693. /**
  33694. * Gets the mesh under the pointer
  33695. * @returns a Mesh or null if no mesh is under the pointer
  33696. */
  33697. getPointerOverMesh(): Nullable<AbstractMesh>;
  33698. }
  33699. }
  33700. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33701. /**
  33702. * Helper class used to generate session unique ID
  33703. */
  33704. export class UniqueIdGenerator {
  33705. private static _UniqueIdCounter;
  33706. /**
  33707. * Gets an unique (relatively to the current scene) Id
  33708. */
  33709. static readonly UniqueId: number;
  33710. }
  33711. }
  33712. declare module "babylonjs/Animations/animationGroup" {
  33713. import { Animatable } from "babylonjs/Animations/animatable";
  33714. import { Animation } from "babylonjs/Animations/animation";
  33715. import { Scene, IDisposable } from "babylonjs/scene";
  33716. import { Observable } from "babylonjs/Misc/observable";
  33717. import { Nullable } from "babylonjs/types";
  33718. import "babylonjs/Animations/animatable";
  33719. /**
  33720. * This class defines the direct association between an animation and a target
  33721. */
  33722. export class TargetedAnimation {
  33723. /**
  33724. * Animation to perform
  33725. */
  33726. animation: Animation;
  33727. /**
  33728. * Target to animate
  33729. */
  33730. target: any;
  33731. /**
  33732. * Serialize the object
  33733. * @returns the JSON object representing the current entity
  33734. */
  33735. serialize(): any;
  33736. }
  33737. /**
  33738. * Use this class to create coordinated animations on multiple targets
  33739. */
  33740. export class AnimationGroup implements IDisposable {
  33741. /** The name of the animation group */
  33742. name: string;
  33743. private _scene;
  33744. private _targetedAnimations;
  33745. private _animatables;
  33746. private _from;
  33747. private _to;
  33748. private _isStarted;
  33749. private _isPaused;
  33750. private _speedRatio;
  33751. private _loopAnimation;
  33752. /**
  33753. * Gets or sets the unique id of the node
  33754. */
  33755. uniqueId: number;
  33756. /**
  33757. * This observable will notify when one animation have ended
  33758. */
  33759. onAnimationEndObservable: Observable<TargetedAnimation>;
  33760. /**
  33761. * Observer raised when one animation loops
  33762. */
  33763. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33764. /**
  33765. * This observable will notify when all animations have ended.
  33766. */
  33767. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33768. /**
  33769. * This observable will notify when all animations have paused.
  33770. */
  33771. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33772. /**
  33773. * This observable will notify when all animations are playing.
  33774. */
  33775. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33776. /**
  33777. * Gets the first frame
  33778. */
  33779. readonly from: number;
  33780. /**
  33781. * Gets the last frame
  33782. */
  33783. readonly to: number;
  33784. /**
  33785. * Define if the animations are started
  33786. */
  33787. readonly isStarted: boolean;
  33788. /**
  33789. * Gets a value indicating that the current group is playing
  33790. */
  33791. readonly isPlaying: boolean;
  33792. /**
  33793. * Gets or sets the speed ratio to use for all animations
  33794. */
  33795. /**
  33796. * Gets or sets the speed ratio to use for all animations
  33797. */
  33798. speedRatio: number;
  33799. /**
  33800. * Gets or sets if all animations should loop or not
  33801. */
  33802. loopAnimation: boolean;
  33803. /**
  33804. * Gets the targeted animations for this animation group
  33805. */
  33806. readonly targetedAnimations: Array<TargetedAnimation>;
  33807. /**
  33808. * returning the list of animatables controlled by this animation group.
  33809. */
  33810. readonly animatables: Array<Animatable>;
  33811. /**
  33812. * Instantiates a new Animation Group.
  33813. * This helps managing several animations at once.
  33814. * @see http://doc.babylonjs.com/how_to/group
  33815. * @param name Defines the name of the group
  33816. * @param scene Defines the scene the group belongs to
  33817. */
  33818. constructor(
  33819. /** The name of the animation group */
  33820. name: string, scene?: Nullable<Scene>);
  33821. /**
  33822. * Add an animation (with its target) in the group
  33823. * @param animation defines the animation we want to add
  33824. * @param target defines the target of the animation
  33825. * @returns the TargetedAnimation object
  33826. */
  33827. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33828. /**
  33829. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33830. * It can add constant keys at begin or end
  33831. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33832. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33833. * @returns the animation group
  33834. */
  33835. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33836. /**
  33837. * Start all animations on given targets
  33838. * @param loop defines if animations must loop
  33839. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33840. * @param from defines the from key (optional)
  33841. * @param to defines the to key (optional)
  33842. * @returns the current animation group
  33843. */
  33844. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33845. /**
  33846. * Pause all animations
  33847. * @returns the animation group
  33848. */
  33849. pause(): AnimationGroup;
  33850. /**
  33851. * Play all animations to initial state
  33852. * This function will start() the animations if they were not started or will restart() them if they were paused
  33853. * @param loop defines if animations must loop
  33854. * @returns the animation group
  33855. */
  33856. play(loop?: boolean): AnimationGroup;
  33857. /**
  33858. * Reset all animations to initial state
  33859. * @returns the animation group
  33860. */
  33861. reset(): AnimationGroup;
  33862. /**
  33863. * Restart animations from key 0
  33864. * @returns the animation group
  33865. */
  33866. restart(): AnimationGroup;
  33867. /**
  33868. * Stop all animations
  33869. * @returns the animation group
  33870. */
  33871. stop(): AnimationGroup;
  33872. /**
  33873. * Set animation weight for all animatables
  33874. * @param weight defines the weight to use
  33875. * @return the animationGroup
  33876. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33877. */
  33878. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33879. /**
  33880. * Synchronize and normalize all animatables with a source animatable
  33881. * @param root defines the root animatable to synchronize with
  33882. * @return the animationGroup
  33883. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33884. */
  33885. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33886. /**
  33887. * Goes to a specific frame in this animation group
  33888. * @param frame the frame number to go to
  33889. * @return the animationGroup
  33890. */
  33891. goToFrame(frame: number): AnimationGroup;
  33892. /**
  33893. * Dispose all associated resources
  33894. */
  33895. dispose(): void;
  33896. private _checkAnimationGroupEnded;
  33897. /**
  33898. * Clone the current animation group and returns a copy
  33899. * @param newName defines the name of the new group
  33900. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33901. * @returns the new aniamtion group
  33902. */
  33903. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33904. /**
  33905. * Serializes the animationGroup to an object
  33906. * @returns Serialized object
  33907. */
  33908. serialize(): any;
  33909. /**
  33910. * Returns a new AnimationGroup object parsed from the source provided.
  33911. * @param parsedAnimationGroup defines the source
  33912. * @param scene defines the scene that will receive the animationGroup
  33913. * @returns a new AnimationGroup
  33914. */
  33915. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33916. /**
  33917. * Returns the string "AnimationGroup"
  33918. * @returns "AnimationGroup"
  33919. */
  33920. getClassName(): string;
  33921. /**
  33922. * Creates a detailled string about the object
  33923. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33924. * @returns a string representing the object
  33925. */
  33926. toString(fullDetails?: boolean): string;
  33927. }
  33928. }
  33929. declare module "babylonjs/scene" {
  33930. import { Nullable } from "babylonjs/types";
  33931. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33932. import { Observable } from "babylonjs/Misc/observable";
  33933. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33934. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33935. import { Geometry } from "babylonjs/Meshes/geometry";
  33936. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33939. import { Mesh } from "babylonjs/Meshes/mesh";
  33940. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33941. import { Bone } from "babylonjs/Bones/bone";
  33942. import { Skeleton } from "babylonjs/Bones/skeleton";
  33943. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33944. import { Camera } from "babylonjs/Cameras/camera";
  33945. import { AbstractScene } from "babylonjs/abstractScene";
  33946. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33947. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33948. import { Material } from "babylonjs/Materials/material";
  33949. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33950. import { Effect } from "babylonjs/Materials/effect";
  33951. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33952. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33953. import { Light } from "babylonjs/Lights/light";
  33954. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33955. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33956. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33957. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33958. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33959. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33960. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33961. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33962. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33963. import { Engine } from "babylonjs/Engines/engine";
  33964. import { Node } from "babylonjs/node";
  33965. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33966. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33967. import { WebRequest } from "babylonjs/Misc/webRequest";
  33968. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33969. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33970. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33971. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33972. import { Plane } from "babylonjs/Maths/math.plane";
  33973. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  33974. import { Ray } from "babylonjs/Culling/ray";
  33975. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33976. import { Animation } from "babylonjs/Animations/animation";
  33977. import { Animatable } from "babylonjs/Animations/animatable";
  33978. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33980. import { Collider } from "babylonjs/Collisions/collider";
  33981. /**
  33982. * Define an interface for all classes that will hold resources
  33983. */
  33984. export interface IDisposable {
  33985. /**
  33986. * Releases all held resources
  33987. */
  33988. dispose(): void;
  33989. }
  33990. /** Interface defining initialization parameters for Scene class */
  33991. export interface SceneOptions {
  33992. /**
  33993. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33994. * It will improve performance when the number of geometries becomes important.
  33995. */
  33996. useGeometryUniqueIdsMap?: boolean;
  33997. /**
  33998. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33999. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34000. */
  34001. useMaterialMeshMap?: boolean;
  34002. /**
  34003. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34004. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34005. */
  34006. useClonedMeshhMap?: boolean;
  34007. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34008. virtual?: boolean;
  34009. }
  34010. /**
  34011. * Represents a scene to be rendered by the engine.
  34012. * @see http://doc.babylonjs.com/features/scene
  34013. */
  34014. export class Scene extends AbstractScene implements IAnimatable {
  34015. /** The fog is deactivated */
  34016. static readonly FOGMODE_NONE: number;
  34017. /** The fog density is following an exponential function */
  34018. static readonly FOGMODE_EXP: number;
  34019. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34020. static readonly FOGMODE_EXP2: number;
  34021. /** The fog density is following a linear function. */
  34022. static readonly FOGMODE_LINEAR: number;
  34023. /**
  34024. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34026. */
  34027. static MinDeltaTime: number;
  34028. /**
  34029. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34031. */
  34032. static MaxDeltaTime: number;
  34033. /**
  34034. * Factory used to create the default material.
  34035. * @param name The name of the material to create
  34036. * @param scene The scene to create the material for
  34037. * @returns The default material
  34038. */
  34039. static DefaultMaterialFactory(scene: Scene): Material;
  34040. /**
  34041. * Factory used to create the a collision coordinator.
  34042. * @returns The collision coordinator
  34043. */
  34044. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34045. /** @hidden */
  34046. _inputManager: InputManager;
  34047. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34048. cameraToUseForPointers: Nullable<Camera>;
  34049. /** @hidden */
  34050. readonly _isScene: boolean;
  34051. /**
  34052. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34053. */
  34054. autoClear: boolean;
  34055. /**
  34056. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34057. */
  34058. autoClearDepthAndStencil: boolean;
  34059. /**
  34060. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34061. */
  34062. clearColor: Color4;
  34063. /**
  34064. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34065. */
  34066. ambientColor: Color3;
  34067. /**
  34068. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34069. * It should only be one of the following (if not the default embedded one):
  34070. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34071. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34072. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34073. * The material properties need to be setup according to the type of texture in use.
  34074. */
  34075. environmentBRDFTexture: BaseTexture;
  34076. /** @hidden */
  34077. protected _environmentTexture: Nullable<BaseTexture>;
  34078. /**
  34079. * Texture used in all pbr material as the reflection texture.
  34080. * As in the majority of the scene they are the same (exception for multi room and so on),
  34081. * this is easier to reference from here than from all the materials.
  34082. */
  34083. /**
  34084. * Texture used in all pbr material as the reflection texture.
  34085. * As in the majority of the scene they are the same (exception for multi room and so on),
  34086. * this is easier to set here than in all the materials.
  34087. */
  34088. environmentTexture: Nullable<BaseTexture>;
  34089. /** @hidden */
  34090. protected _environmentIntensity: number;
  34091. /**
  34092. * Intensity of the environment in all pbr material.
  34093. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34094. * As in the majority of the scene they are the same (exception for multi room and so on),
  34095. * this is easier to reference from here than from all the materials.
  34096. */
  34097. /**
  34098. * Intensity of the environment in all pbr material.
  34099. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34100. * As in the majority of the scene they are the same (exception for multi room and so on),
  34101. * this is easier to set here than in all the materials.
  34102. */
  34103. environmentIntensity: number;
  34104. /** @hidden */
  34105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34106. /**
  34107. * Default image processing configuration used either in the rendering
  34108. * Forward main pass or through the imageProcessingPostProcess if present.
  34109. * As in the majority of the scene they are the same (exception for multi camera),
  34110. * this is easier to reference from here than from all the materials and post process.
  34111. *
  34112. * No setter as we it is a shared configuration, you can set the values instead.
  34113. */
  34114. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34115. private _forceWireframe;
  34116. /**
  34117. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34118. */
  34119. forceWireframe: boolean;
  34120. private _forcePointsCloud;
  34121. /**
  34122. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34123. */
  34124. forcePointsCloud: boolean;
  34125. /**
  34126. * Gets or sets the active clipplane 1
  34127. */
  34128. clipPlane: Nullable<Plane>;
  34129. /**
  34130. * Gets or sets the active clipplane 2
  34131. */
  34132. clipPlane2: Nullable<Plane>;
  34133. /**
  34134. * Gets or sets the active clipplane 3
  34135. */
  34136. clipPlane3: Nullable<Plane>;
  34137. /**
  34138. * Gets or sets the active clipplane 4
  34139. */
  34140. clipPlane4: Nullable<Plane>;
  34141. /**
  34142. * Gets or sets a boolean indicating if animations are enabled
  34143. */
  34144. animationsEnabled: boolean;
  34145. private _animationPropertiesOverride;
  34146. /**
  34147. * Gets or sets the animation properties override
  34148. */
  34149. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34150. /**
  34151. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34152. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34153. */
  34154. useConstantAnimationDeltaTime: boolean;
  34155. /**
  34156. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34157. * Please note that it requires to run a ray cast through the scene on every frame
  34158. */
  34159. constantlyUpdateMeshUnderPointer: boolean;
  34160. /**
  34161. * Defines the HTML cursor to use when hovering over interactive elements
  34162. */
  34163. hoverCursor: string;
  34164. /**
  34165. * Defines the HTML default cursor to use (empty by default)
  34166. */
  34167. defaultCursor: string;
  34168. /**
  34169. * Defines wether cursors are handled by the scene.
  34170. */
  34171. doNotHandleCursors: boolean;
  34172. /**
  34173. * This is used to call preventDefault() on pointer down
  34174. * in order to block unwanted artifacts like system double clicks
  34175. */
  34176. preventDefaultOnPointerDown: boolean;
  34177. /**
  34178. * This is used to call preventDefault() on pointer up
  34179. * in order to block unwanted artifacts like system double clicks
  34180. */
  34181. preventDefaultOnPointerUp: boolean;
  34182. /**
  34183. * Gets or sets user defined metadata
  34184. */
  34185. metadata: any;
  34186. /**
  34187. * For internal use only. Please do not use.
  34188. */
  34189. reservedDataStore: any;
  34190. /**
  34191. * Gets the name of the plugin used to load this scene (null by default)
  34192. */
  34193. loadingPluginName: string;
  34194. /**
  34195. * Use this array to add regular expressions used to disable offline support for specific urls
  34196. */
  34197. disableOfflineSupportExceptionRules: RegExp[];
  34198. /**
  34199. * An event triggered when the scene is disposed.
  34200. */
  34201. onDisposeObservable: Observable<Scene>;
  34202. private _onDisposeObserver;
  34203. /** Sets a function to be executed when this scene is disposed. */
  34204. onDispose: () => void;
  34205. /**
  34206. * An event triggered before rendering the scene (right after animations and physics)
  34207. */
  34208. onBeforeRenderObservable: Observable<Scene>;
  34209. private _onBeforeRenderObserver;
  34210. /** Sets a function to be executed before rendering this scene */
  34211. beforeRender: Nullable<() => void>;
  34212. /**
  34213. * An event triggered after rendering the scene
  34214. */
  34215. onAfterRenderObservable: Observable<Scene>;
  34216. /**
  34217. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34218. */
  34219. onAfterRenderCameraObservable: Observable<Camera>;
  34220. private _onAfterRenderObserver;
  34221. /** Sets a function to be executed after rendering this scene */
  34222. afterRender: Nullable<() => void>;
  34223. /**
  34224. * An event triggered before animating the scene
  34225. */
  34226. onBeforeAnimationsObservable: Observable<Scene>;
  34227. /**
  34228. * An event triggered after animations processing
  34229. */
  34230. onAfterAnimationsObservable: Observable<Scene>;
  34231. /**
  34232. * An event triggered before draw calls are ready to be sent
  34233. */
  34234. onBeforeDrawPhaseObservable: Observable<Scene>;
  34235. /**
  34236. * An event triggered after draw calls have been sent
  34237. */
  34238. onAfterDrawPhaseObservable: Observable<Scene>;
  34239. /**
  34240. * An event triggered when the scene is ready
  34241. */
  34242. onReadyObservable: Observable<Scene>;
  34243. /**
  34244. * An event triggered before rendering a camera
  34245. */
  34246. onBeforeCameraRenderObservable: Observable<Camera>;
  34247. private _onBeforeCameraRenderObserver;
  34248. /** Sets a function to be executed before rendering a camera*/
  34249. beforeCameraRender: () => void;
  34250. /**
  34251. * An event triggered after rendering a camera
  34252. */
  34253. onAfterCameraRenderObservable: Observable<Camera>;
  34254. private _onAfterCameraRenderObserver;
  34255. /** Sets a function to be executed after rendering a camera*/
  34256. afterCameraRender: () => void;
  34257. /**
  34258. * An event triggered when active meshes evaluation is about to start
  34259. */
  34260. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34261. /**
  34262. * An event triggered when active meshes evaluation is done
  34263. */
  34264. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34265. /**
  34266. * An event triggered when particles rendering is about to start
  34267. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34268. */
  34269. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34270. /**
  34271. * An event triggered when particles rendering is done
  34272. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34273. */
  34274. onAfterParticlesRenderingObservable: Observable<Scene>;
  34275. /**
  34276. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34277. */
  34278. onDataLoadedObservable: Observable<Scene>;
  34279. /**
  34280. * An event triggered when a camera is created
  34281. */
  34282. onNewCameraAddedObservable: Observable<Camera>;
  34283. /**
  34284. * An event triggered when a camera is removed
  34285. */
  34286. onCameraRemovedObservable: Observable<Camera>;
  34287. /**
  34288. * An event triggered when a light is created
  34289. */
  34290. onNewLightAddedObservable: Observable<Light>;
  34291. /**
  34292. * An event triggered when a light is removed
  34293. */
  34294. onLightRemovedObservable: Observable<Light>;
  34295. /**
  34296. * An event triggered when a geometry is created
  34297. */
  34298. onNewGeometryAddedObservable: Observable<Geometry>;
  34299. /**
  34300. * An event triggered when a geometry is removed
  34301. */
  34302. onGeometryRemovedObservable: Observable<Geometry>;
  34303. /**
  34304. * An event triggered when a transform node is created
  34305. */
  34306. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34307. /**
  34308. * An event triggered when a transform node is removed
  34309. */
  34310. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34311. /**
  34312. * An event triggered when a mesh is created
  34313. */
  34314. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34315. /**
  34316. * An event triggered when a mesh is removed
  34317. */
  34318. onMeshRemovedObservable: Observable<AbstractMesh>;
  34319. /**
  34320. * An event triggered when a skeleton is created
  34321. */
  34322. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34323. /**
  34324. * An event triggered when a skeleton is removed
  34325. */
  34326. onSkeletonRemovedObservable: Observable<Skeleton>;
  34327. /**
  34328. * An event triggered when a material is created
  34329. */
  34330. onNewMaterialAddedObservable: Observable<Material>;
  34331. /**
  34332. * An event triggered when a material is removed
  34333. */
  34334. onMaterialRemovedObservable: Observable<Material>;
  34335. /**
  34336. * An event triggered when a texture is created
  34337. */
  34338. onNewTextureAddedObservable: Observable<BaseTexture>;
  34339. /**
  34340. * An event triggered when a texture is removed
  34341. */
  34342. onTextureRemovedObservable: Observable<BaseTexture>;
  34343. /**
  34344. * An event triggered when render targets are about to be rendered
  34345. * Can happen multiple times per frame.
  34346. */
  34347. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34348. /**
  34349. * An event triggered when render targets were rendered.
  34350. * Can happen multiple times per frame.
  34351. */
  34352. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34353. /**
  34354. * An event triggered before calculating deterministic simulation step
  34355. */
  34356. onBeforeStepObservable: Observable<Scene>;
  34357. /**
  34358. * An event triggered after calculating deterministic simulation step
  34359. */
  34360. onAfterStepObservable: Observable<Scene>;
  34361. /**
  34362. * An event triggered when the activeCamera property is updated
  34363. */
  34364. onActiveCameraChanged: Observable<Scene>;
  34365. /**
  34366. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34367. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34368. * 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)
  34369. */
  34370. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34371. /**
  34372. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34373. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34374. * 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)
  34375. */
  34376. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34377. /**
  34378. * This Observable will when a mesh has been imported into the scene.
  34379. */
  34380. onMeshImportedObservable: Observable<AbstractMesh>;
  34381. /**
  34382. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34383. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34384. */
  34385. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34386. /** @hidden */
  34387. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34388. /**
  34389. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34390. */
  34391. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34392. /**
  34393. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34394. */
  34395. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34396. /**
  34397. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34398. */
  34399. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34400. /** Callback called when a pointer move is detected */
  34401. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34402. /** Callback called when a pointer down is detected */
  34403. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34404. /** Callback called when a pointer up is detected */
  34405. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34406. /** Callback called when a pointer pick is detected */
  34407. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34408. /**
  34409. * 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).
  34410. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34411. */
  34412. onPrePointerObservable: Observable<PointerInfoPre>;
  34413. /**
  34414. * Observable event triggered each time an input event is received from the rendering canvas
  34415. */
  34416. onPointerObservable: Observable<PointerInfo>;
  34417. /**
  34418. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34419. */
  34420. readonly unTranslatedPointer: Vector2;
  34421. /**
  34422. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34423. */
  34424. static DragMovementThreshold: number;
  34425. /**
  34426. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34427. */
  34428. static LongPressDelay: number;
  34429. /**
  34430. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34431. */
  34432. static DoubleClickDelay: number;
  34433. /** If you need to check double click without raising a single click at first click, enable this flag */
  34434. static ExclusiveDoubleClickMode: boolean;
  34435. /** @hidden */
  34436. _mirroredCameraPosition: Nullable<Vector3>;
  34437. /**
  34438. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34439. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34440. */
  34441. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34442. /**
  34443. * Observable event triggered each time an keyboard event is received from the hosting window
  34444. */
  34445. onKeyboardObservable: Observable<KeyboardInfo>;
  34446. private _useRightHandedSystem;
  34447. /**
  34448. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34449. */
  34450. useRightHandedSystem: boolean;
  34451. private _timeAccumulator;
  34452. private _currentStepId;
  34453. private _currentInternalStep;
  34454. /**
  34455. * Sets the step Id used by deterministic lock step
  34456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34457. * @param newStepId defines the step Id
  34458. */
  34459. setStepId(newStepId: number): void;
  34460. /**
  34461. * Gets the step Id used by deterministic lock step
  34462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34463. * @returns the step Id
  34464. */
  34465. getStepId(): number;
  34466. /**
  34467. * Gets the internal step used by deterministic lock step
  34468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34469. * @returns the internal step
  34470. */
  34471. getInternalStep(): number;
  34472. private _fogEnabled;
  34473. /**
  34474. * Gets or sets a boolean indicating if fog is enabled on this scene
  34475. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34476. * (Default is true)
  34477. */
  34478. fogEnabled: boolean;
  34479. private _fogMode;
  34480. /**
  34481. * Gets or sets the fog mode to use
  34482. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34483. * | mode | value |
  34484. * | --- | --- |
  34485. * | FOGMODE_NONE | 0 |
  34486. * | FOGMODE_EXP | 1 |
  34487. * | FOGMODE_EXP2 | 2 |
  34488. * | FOGMODE_LINEAR | 3 |
  34489. */
  34490. fogMode: number;
  34491. /**
  34492. * Gets or sets the fog color to use
  34493. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34494. * (Default is Color3(0.2, 0.2, 0.3))
  34495. */
  34496. fogColor: Color3;
  34497. /**
  34498. * Gets or sets the fog density to use
  34499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34500. * (Default is 0.1)
  34501. */
  34502. fogDensity: number;
  34503. /**
  34504. * Gets or sets the fog start distance to use
  34505. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34506. * (Default is 0)
  34507. */
  34508. fogStart: number;
  34509. /**
  34510. * Gets or sets the fog end distance to use
  34511. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34512. * (Default is 1000)
  34513. */
  34514. fogEnd: number;
  34515. private _shadowsEnabled;
  34516. /**
  34517. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34518. */
  34519. shadowsEnabled: boolean;
  34520. private _lightsEnabled;
  34521. /**
  34522. * Gets or sets a boolean indicating if lights are enabled on this scene
  34523. */
  34524. lightsEnabled: boolean;
  34525. /** All of the active cameras added to this scene. */
  34526. activeCameras: Camera[];
  34527. /** @hidden */
  34528. _activeCamera: Nullable<Camera>;
  34529. /** Gets or sets the current active camera */
  34530. activeCamera: Nullable<Camera>;
  34531. private _defaultMaterial;
  34532. /** The default material used on meshes when no material is affected */
  34533. /** The default material used on meshes when no material is affected */
  34534. defaultMaterial: Material;
  34535. private _texturesEnabled;
  34536. /**
  34537. * Gets or sets a boolean indicating if textures are enabled on this scene
  34538. */
  34539. texturesEnabled: boolean;
  34540. /**
  34541. * Gets or sets a boolean indicating if particles are enabled on this scene
  34542. */
  34543. particlesEnabled: boolean;
  34544. /**
  34545. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34546. */
  34547. spritesEnabled: boolean;
  34548. private _skeletonsEnabled;
  34549. /**
  34550. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34551. */
  34552. skeletonsEnabled: boolean;
  34553. /**
  34554. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34555. */
  34556. lensFlaresEnabled: boolean;
  34557. /**
  34558. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34559. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34560. */
  34561. collisionsEnabled: boolean;
  34562. private _collisionCoordinator;
  34563. /** @hidden */
  34564. readonly collisionCoordinator: ICollisionCoordinator;
  34565. /**
  34566. * Defines the gravity applied to this scene (used only for collisions)
  34567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34568. */
  34569. gravity: Vector3;
  34570. /**
  34571. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34572. */
  34573. postProcessesEnabled: boolean;
  34574. /**
  34575. * The list of postprocesses added to the scene
  34576. */
  34577. postProcesses: PostProcess[];
  34578. /**
  34579. * Gets the current postprocess manager
  34580. */
  34581. postProcessManager: PostProcessManager;
  34582. /**
  34583. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34584. */
  34585. renderTargetsEnabled: boolean;
  34586. /**
  34587. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34588. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34589. */
  34590. dumpNextRenderTargets: boolean;
  34591. /**
  34592. * The list of user defined render targets added to the scene
  34593. */
  34594. customRenderTargets: RenderTargetTexture[];
  34595. /**
  34596. * Defines if texture loading must be delayed
  34597. * If true, textures will only be loaded when they need to be rendered
  34598. */
  34599. useDelayedTextureLoading: boolean;
  34600. /**
  34601. * Gets the list of meshes imported to the scene through SceneLoader
  34602. */
  34603. importedMeshesFiles: String[];
  34604. /**
  34605. * Gets or sets a boolean indicating if probes are enabled on this scene
  34606. */
  34607. probesEnabled: boolean;
  34608. /**
  34609. * Gets or sets the current offline provider to use to store scene data
  34610. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34611. */
  34612. offlineProvider: IOfflineProvider;
  34613. /**
  34614. * Gets or sets the action manager associated with the scene
  34615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34616. */
  34617. actionManager: AbstractActionManager;
  34618. private _meshesForIntersections;
  34619. /**
  34620. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34621. */
  34622. proceduralTexturesEnabled: boolean;
  34623. private _engine;
  34624. private _totalVertices;
  34625. /** @hidden */
  34626. _activeIndices: PerfCounter;
  34627. /** @hidden */
  34628. _activeParticles: PerfCounter;
  34629. /** @hidden */
  34630. _activeBones: PerfCounter;
  34631. private _animationRatio;
  34632. /** @hidden */
  34633. _animationTimeLast: number;
  34634. /** @hidden */
  34635. _animationTime: number;
  34636. /**
  34637. * Gets or sets a general scale for animation speed
  34638. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34639. */
  34640. animationTimeScale: number;
  34641. /** @hidden */
  34642. _cachedMaterial: Nullable<Material>;
  34643. /** @hidden */
  34644. _cachedEffect: Nullable<Effect>;
  34645. /** @hidden */
  34646. _cachedVisibility: Nullable<number>;
  34647. private _renderId;
  34648. private _frameId;
  34649. private _executeWhenReadyTimeoutId;
  34650. private _intermediateRendering;
  34651. private _viewUpdateFlag;
  34652. private _projectionUpdateFlag;
  34653. /** @hidden */
  34654. _toBeDisposed: Nullable<IDisposable>[];
  34655. private _activeRequests;
  34656. /** @hidden */
  34657. _pendingData: any[];
  34658. private _isDisposed;
  34659. /**
  34660. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34661. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34662. */
  34663. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34664. private _activeMeshes;
  34665. private _processedMaterials;
  34666. private _renderTargets;
  34667. /** @hidden */
  34668. _activeParticleSystems: SmartArray<IParticleSystem>;
  34669. private _activeSkeletons;
  34670. private _softwareSkinnedMeshes;
  34671. private _renderingManager;
  34672. /** @hidden */
  34673. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34674. private _transformMatrix;
  34675. private _sceneUbo;
  34676. /** @hidden */
  34677. _viewMatrix: Matrix;
  34678. private _projectionMatrix;
  34679. /** @hidden */
  34680. _forcedViewPosition: Nullable<Vector3>;
  34681. /** @hidden */
  34682. _frustumPlanes: Plane[];
  34683. /**
  34684. * Gets the list of frustum planes (built from the active camera)
  34685. */
  34686. readonly frustumPlanes: Plane[];
  34687. /**
  34688. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34689. * This is useful if there are more lights that the maximum simulteanous authorized
  34690. */
  34691. requireLightSorting: boolean;
  34692. /** @hidden */
  34693. readonly useMaterialMeshMap: boolean;
  34694. /** @hidden */
  34695. readonly useClonedMeshhMap: boolean;
  34696. private _externalData;
  34697. private _uid;
  34698. /**
  34699. * @hidden
  34700. * Backing store of defined scene components.
  34701. */
  34702. _components: ISceneComponent[];
  34703. /**
  34704. * @hidden
  34705. * Backing store of defined scene components.
  34706. */
  34707. _serializableComponents: ISceneSerializableComponent[];
  34708. /**
  34709. * List of components to register on the next registration step.
  34710. */
  34711. private _transientComponents;
  34712. /**
  34713. * Registers the transient components if needed.
  34714. */
  34715. private _registerTransientComponents;
  34716. /**
  34717. * @hidden
  34718. * Add a component to the scene.
  34719. * Note that the ccomponent could be registered on th next frame if this is called after
  34720. * the register component stage.
  34721. * @param component Defines the component to add to the scene
  34722. */
  34723. _addComponent(component: ISceneComponent): void;
  34724. /**
  34725. * @hidden
  34726. * Gets a component from the scene.
  34727. * @param name defines the name of the component to retrieve
  34728. * @returns the component or null if not present
  34729. */
  34730. _getComponent(name: string): Nullable<ISceneComponent>;
  34731. /**
  34732. * @hidden
  34733. * Defines the actions happening before camera updates.
  34734. */
  34735. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34736. /**
  34737. * @hidden
  34738. * Defines the actions happening before clear the canvas.
  34739. */
  34740. _beforeClearStage: Stage<SimpleStageAction>;
  34741. /**
  34742. * @hidden
  34743. * Defines the actions when collecting render targets for the frame.
  34744. */
  34745. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34746. /**
  34747. * @hidden
  34748. * Defines the actions happening for one camera in the frame.
  34749. */
  34750. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34751. /**
  34752. * @hidden
  34753. * Defines the actions happening during the per mesh ready checks.
  34754. */
  34755. _isReadyForMeshStage: Stage<MeshStageAction>;
  34756. /**
  34757. * @hidden
  34758. * Defines the actions happening before evaluate active mesh checks.
  34759. */
  34760. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34761. /**
  34762. * @hidden
  34763. * Defines the actions happening during the evaluate sub mesh checks.
  34764. */
  34765. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34766. /**
  34767. * @hidden
  34768. * Defines the actions happening during the active mesh stage.
  34769. */
  34770. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34771. /**
  34772. * @hidden
  34773. * Defines the actions happening during the per camera render target step.
  34774. */
  34775. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34776. /**
  34777. * @hidden
  34778. * Defines the actions happening just before the active camera is drawing.
  34779. */
  34780. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34781. /**
  34782. * @hidden
  34783. * Defines the actions happening just before a render target is drawing.
  34784. */
  34785. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34786. /**
  34787. * @hidden
  34788. * Defines the actions happening just before a rendering group is drawing.
  34789. */
  34790. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34791. /**
  34792. * @hidden
  34793. * Defines the actions happening just before a mesh is drawing.
  34794. */
  34795. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34796. /**
  34797. * @hidden
  34798. * Defines the actions happening just after a mesh has been drawn.
  34799. */
  34800. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34801. /**
  34802. * @hidden
  34803. * Defines the actions happening just after a rendering group has been drawn.
  34804. */
  34805. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34806. /**
  34807. * @hidden
  34808. * Defines the actions happening just after the active camera has been drawn.
  34809. */
  34810. _afterCameraDrawStage: Stage<CameraStageAction>;
  34811. /**
  34812. * @hidden
  34813. * Defines the actions happening just after a render target has been drawn.
  34814. */
  34815. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34816. /**
  34817. * @hidden
  34818. * Defines the actions happening just after rendering all cameras and computing intersections.
  34819. */
  34820. _afterRenderStage: Stage<SimpleStageAction>;
  34821. /**
  34822. * @hidden
  34823. * Defines the actions happening when a pointer move event happens.
  34824. */
  34825. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34826. /**
  34827. * @hidden
  34828. * Defines the actions happening when a pointer down event happens.
  34829. */
  34830. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34831. /**
  34832. * @hidden
  34833. * Defines the actions happening when a pointer up event happens.
  34834. */
  34835. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34836. /**
  34837. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34838. */
  34839. private geometriesByUniqueId;
  34840. /**
  34841. * Creates a new Scene
  34842. * @param engine defines the engine to use to render this scene
  34843. * @param options defines the scene options
  34844. */
  34845. constructor(engine: Engine, options?: SceneOptions);
  34846. /**
  34847. * Gets a string idenfifying the name of the class
  34848. * @returns "Scene" string
  34849. */
  34850. getClassName(): string;
  34851. private _defaultMeshCandidates;
  34852. /**
  34853. * @hidden
  34854. */
  34855. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34856. private _defaultSubMeshCandidates;
  34857. /**
  34858. * @hidden
  34859. */
  34860. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34861. /**
  34862. * Sets the default candidate providers for the scene.
  34863. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34864. * and getCollidingSubMeshCandidates to their default function
  34865. */
  34866. setDefaultCandidateProviders(): void;
  34867. /**
  34868. * Gets the mesh that is currently under the pointer
  34869. */
  34870. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34871. /**
  34872. * Gets or sets the current on-screen X position of the pointer
  34873. */
  34874. pointerX: number;
  34875. /**
  34876. * Gets or sets the current on-screen Y position of the pointer
  34877. */
  34878. pointerY: number;
  34879. /**
  34880. * Gets the cached material (ie. the latest rendered one)
  34881. * @returns the cached material
  34882. */
  34883. getCachedMaterial(): Nullable<Material>;
  34884. /**
  34885. * Gets the cached effect (ie. the latest rendered one)
  34886. * @returns the cached effect
  34887. */
  34888. getCachedEffect(): Nullable<Effect>;
  34889. /**
  34890. * Gets the cached visibility state (ie. the latest rendered one)
  34891. * @returns the cached visibility state
  34892. */
  34893. getCachedVisibility(): Nullable<number>;
  34894. /**
  34895. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34896. * @param material defines the current material
  34897. * @param effect defines the current effect
  34898. * @param visibility defines the current visibility state
  34899. * @returns true if one parameter is not cached
  34900. */
  34901. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34902. /**
  34903. * Gets the engine associated with the scene
  34904. * @returns an Engine
  34905. */
  34906. getEngine(): Engine;
  34907. /**
  34908. * Gets the total number of vertices rendered per frame
  34909. * @returns the total number of vertices rendered per frame
  34910. */
  34911. getTotalVertices(): number;
  34912. /**
  34913. * Gets the performance counter for total vertices
  34914. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34915. */
  34916. readonly totalVerticesPerfCounter: PerfCounter;
  34917. /**
  34918. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34919. * @returns the total number of active indices rendered per frame
  34920. */
  34921. getActiveIndices(): number;
  34922. /**
  34923. * Gets the performance counter for active indices
  34924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34925. */
  34926. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34927. /**
  34928. * Gets the total number of active particles rendered per frame
  34929. * @returns the total number of active particles rendered per frame
  34930. */
  34931. getActiveParticles(): number;
  34932. /**
  34933. * Gets the performance counter for active particles
  34934. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34935. */
  34936. readonly activeParticlesPerfCounter: PerfCounter;
  34937. /**
  34938. * Gets the total number of active bones rendered per frame
  34939. * @returns the total number of active bones rendered per frame
  34940. */
  34941. getActiveBones(): number;
  34942. /**
  34943. * Gets the performance counter for active bones
  34944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34945. */
  34946. readonly activeBonesPerfCounter: PerfCounter;
  34947. /**
  34948. * Gets the array of active meshes
  34949. * @returns an array of AbstractMesh
  34950. */
  34951. getActiveMeshes(): SmartArray<AbstractMesh>;
  34952. /**
  34953. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34954. * @returns a number
  34955. */
  34956. getAnimationRatio(): number;
  34957. /**
  34958. * Gets an unique Id for the current render phase
  34959. * @returns a number
  34960. */
  34961. getRenderId(): number;
  34962. /**
  34963. * Gets an unique Id for the current frame
  34964. * @returns a number
  34965. */
  34966. getFrameId(): number;
  34967. /** Call this function if you want to manually increment the render Id*/
  34968. incrementRenderId(): void;
  34969. private _createUbo;
  34970. /**
  34971. * Use this method to simulate a pointer move on a mesh
  34972. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34973. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34974. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34975. * @returns the current scene
  34976. */
  34977. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34978. /**
  34979. * Use this method to simulate a pointer down on a mesh
  34980. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34981. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34982. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34983. * @returns the current scene
  34984. */
  34985. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34986. /**
  34987. * Use this method to simulate a pointer up on a mesh
  34988. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34989. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34990. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34991. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34992. * @returns the current scene
  34993. */
  34994. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34995. /**
  34996. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34997. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34998. * @returns true if the pointer was captured
  34999. */
  35000. isPointerCaptured(pointerId?: number): boolean;
  35001. /**
  35002. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35003. * @param attachUp defines if you want to attach events to pointerup
  35004. * @param attachDown defines if you want to attach events to pointerdown
  35005. * @param attachMove defines if you want to attach events to pointermove
  35006. */
  35007. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35008. /** Detaches all event handlers*/
  35009. detachControl(): void;
  35010. /**
  35011. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35012. * Delay loaded resources are not taking in account
  35013. * @return true if all required resources are ready
  35014. */
  35015. isReady(): boolean;
  35016. /** Resets all cached information relative to material (including effect and visibility) */
  35017. resetCachedMaterial(): void;
  35018. /**
  35019. * Registers a function to be called before every frame render
  35020. * @param func defines the function to register
  35021. */
  35022. registerBeforeRender(func: () => void): void;
  35023. /**
  35024. * Unregisters a function called before every frame render
  35025. * @param func defines the function to unregister
  35026. */
  35027. unregisterBeforeRender(func: () => void): void;
  35028. /**
  35029. * Registers a function to be called after every frame render
  35030. * @param func defines the function to register
  35031. */
  35032. registerAfterRender(func: () => void): void;
  35033. /**
  35034. * Unregisters a function called after every frame render
  35035. * @param func defines the function to unregister
  35036. */
  35037. unregisterAfterRender(func: () => void): void;
  35038. private _executeOnceBeforeRender;
  35039. /**
  35040. * The provided function will run before render once and will be disposed afterwards.
  35041. * A timeout delay can be provided so that the function will be executed in N ms.
  35042. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35043. * @param func The function to be executed.
  35044. * @param timeout optional delay in ms
  35045. */
  35046. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35047. /** @hidden */
  35048. _addPendingData(data: any): void;
  35049. /** @hidden */
  35050. _removePendingData(data: any): void;
  35051. /**
  35052. * Returns the number of items waiting to be loaded
  35053. * @returns the number of items waiting to be loaded
  35054. */
  35055. getWaitingItemsCount(): number;
  35056. /**
  35057. * Returns a boolean indicating if the scene is still loading data
  35058. */
  35059. readonly isLoading: boolean;
  35060. /**
  35061. * Registers a function to be executed when the scene is ready
  35062. * @param {Function} func - the function to be executed
  35063. */
  35064. executeWhenReady(func: () => void): void;
  35065. /**
  35066. * Returns a promise that resolves when the scene is ready
  35067. * @returns A promise that resolves when the scene is ready
  35068. */
  35069. whenReadyAsync(): Promise<void>;
  35070. /** @hidden */
  35071. _checkIsReady(): void;
  35072. /**
  35073. * Gets all animatable attached to the scene
  35074. */
  35075. readonly animatables: Animatable[];
  35076. /**
  35077. * Resets the last animation time frame.
  35078. * Useful to override when animations start running when loading a scene for the first time.
  35079. */
  35080. resetLastAnimationTimeFrame(): void;
  35081. /**
  35082. * Gets the current view matrix
  35083. * @returns a Matrix
  35084. */
  35085. getViewMatrix(): Matrix;
  35086. /**
  35087. * Gets the current projection matrix
  35088. * @returns a Matrix
  35089. */
  35090. getProjectionMatrix(): Matrix;
  35091. /**
  35092. * Gets the current transform matrix
  35093. * @returns a Matrix made of View * Projection
  35094. */
  35095. getTransformMatrix(): Matrix;
  35096. /**
  35097. * Sets the current transform matrix
  35098. * @param viewL defines the View matrix to use
  35099. * @param projectionL defines the Projection matrix to use
  35100. * @param viewR defines the right View matrix to use (if provided)
  35101. * @param projectionR defines the right Projection matrix to use (if provided)
  35102. */
  35103. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35104. /**
  35105. * Gets the uniform buffer used to store scene data
  35106. * @returns a UniformBuffer
  35107. */
  35108. getSceneUniformBuffer(): UniformBuffer;
  35109. /**
  35110. * Gets an unique (relatively to the current scene) Id
  35111. * @returns an unique number for the scene
  35112. */
  35113. getUniqueId(): number;
  35114. /**
  35115. * Add a mesh to the list of scene's meshes
  35116. * @param newMesh defines the mesh to add
  35117. * @param recursive if all child meshes should also be added to the scene
  35118. */
  35119. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35120. /**
  35121. * Remove a mesh for the list of scene's meshes
  35122. * @param toRemove defines the mesh to remove
  35123. * @param recursive if all child meshes should also be removed from the scene
  35124. * @returns the index where the mesh was in the mesh list
  35125. */
  35126. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35127. /**
  35128. * Add a transform node to the list of scene's transform nodes
  35129. * @param newTransformNode defines the transform node to add
  35130. */
  35131. addTransformNode(newTransformNode: TransformNode): void;
  35132. /**
  35133. * Remove a transform node for the list of scene's transform nodes
  35134. * @param toRemove defines the transform node to remove
  35135. * @returns the index where the transform node was in the transform node list
  35136. */
  35137. removeTransformNode(toRemove: TransformNode): number;
  35138. /**
  35139. * Remove a skeleton for the list of scene's skeletons
  35140. * @param toRemove defines the skeleton to remove
  35141. * @returns the index where the skeleton was in the skeleton list
  35142. */
  35143. removeSkeleton(toRemove: Skeleton): number;
  35144. /**
  35145. * Remove a morph target for the list of scene's morph targets
  35146. * @param toRemove defines the morph target to remove
  35147. * @returns the index where the morph target was in the morph target list
  35148. */
  35149. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35150. /**
  35151. * Remove a light for the list of scene's lights
  35152. * @param toRemove defines the light to remove
  35153. * @returns the index where the light was in the light list
  35154. */
  35155. removeLight(toRemove: Light): number;
  35156. /**
  35157. * Remove a camera for the list of scene's cameras
  35158. * @param toRemove defines the camera to remove
  35159. * @returns the index where the camera was in the camera list
  35160. */
  35161. removeCamera(toRemove: Camera): number;
  35162. /**
  35163. * Remove a particle system for the list of scene's particle systems
  35164. * @param toRemove defines the particle system to remove
  35165. * @returns the index where the particle system was in the particle system list
  35166. */
  35167. removeParticleSystem(toRemove: IParticleSystem): number;
  35168. /**
  35169. * Remove a animation for the list of scene's animations
  35170. * @param toRemove defines the animation to remove
  35171. * @returns the index where the animation was in the animation list
  35172. */
  35173. removeAnimation(toRemove: Animation): number;
  35174. /**
  35175. * Will stop the animation of the given target
  35176. * @param target - the target
  35177. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35178. * @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)
  35179. */
  35180. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35181. /**
  35182. * Removes the given animation group from this scene.
  35183. * @param toRemove The animation group to remove
  35184. * @returns The index of the removed animation group
  35185. */
  35186. removeAnimationGroup(toRemove: AnimationGroup): number;
  35187. /**
  35188. * Removes the given multi-material from this scene.
  35189. * @param toRemove The multi-material to remove
  35190. * @returns The index of the removed multi-material
  35191. */
  35192. removeMultiMaterial(toRemove: MultiMaterial): number;
  35193. /**
  35194. * Removes the given material from this scene.
  35195. * @param toRemove The material to remove
  35196. * @returns The index of the removed material
  35197. */
  35198. removeMaterial(toRemove: Material): number;
  35199. /**
  35200. * Removes the given action manager from this scene.
  35201. * @param toRemove The action manager to remove
  35202. * @returns The index of the removed action manager
  35203. */
  35204. removeActionManager(toRemove: AbstractActionManager): number;
  35205. /**
  35206. * Removes the given texture from this scene.
  35207. * @param toRemove The texture to remove
  35208. * @returns The index of the removed texture
  35209. */
  35210. removeTexture(toRemove: BaseTexture): number;
  35211. /**
  35212. * Adds the given light to this scene
  35213. * @param newLight The light to add
  35214. */
  35215. addLight(newLight: Light): void;
  35216. /**
  35217. * Sorts the list list based on light priorities
  35218. */
  35219. sortLightsByPriority(): void;
  35220. /**
  35221. * Adds the given camera to this scene
  35222. * @param newCamera The camera to add
  35223. */
  35224. addCamera(newCamera: Camera): void;
  35225. /**
  35226. * Adds the given skeleton to this scene
  35227. * @param newSkeleton The skeleton to add
  35228. */
  35229. addSkeleton(newSkeleton: Skeleton): void;
  35230. /**
  35231. * Adds the given particle system to this scene
  35232. * @param newParticleSystem The particle system to add
  35233. */
  35234. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35235. /**
  35236. * Adds the given animation to this scene
  35237. * @param newAnimation The animation to add
  35238. */
  35239. addAnimation(newAnimation: Animation): void;
  35240. /**
  35241. * Adds the given animation group to this scene.
  35242. * @param newAnimationGroup The animation group to add
  35243. */
  35244. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35245. /**
  35246. * Adds the given multi-material to this scene
  35247. * @param newMultiMaterial The multi-material to add
  35248. */
  35249. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35250. /**
  35251. * Adds the given material to this scene
  35252. * @param newMaterial The material to add
  35253. */
  35254. addMaterial(newMaterial: Material): void;
  35255. /**
  35256. * Adds the given morph target to this scene
  35257. * @param newMorphTargetManager The morph target to add
  35258. */
  35259. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35260. /**
  35261. * Adds the given geometry to this scene
  35262. * @param newGeometry The geometry to add
  35263. */
  35264. addGeometry(newGeometry: Geometry): void;
  35265. /**
  35266. * Adds the given action manager to this scene
  35267. * @param newActionManager The action manager to add
  35268. */
  35269. addActionManager(newActionManager: AbstractActionManager): void;
  35270. /**
  35271. * Adds the given texture to this scene.
  35272. * @param newTexture The texture to add
  35273. */
  35274. addTexture(newTexture: BaseTexture): void;
  35275. /**
  35276. * Switch active camera
  35277. * @param newCamera defines the new active camera
  35278. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35279. */
  35280. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35281. /**
  35282. * sets the active camera of the scene using its ID
  35283. * @param id defines the camera's ID
  35284. * @return the new active camera or null if none found.
  35285. */
  35286. setActiveCameraByID(id: string): Nullable<Camera>;
  35287. /**
  35288. * sets the active camera of the scene using its name
  35289. * @param name defines the camera's name
  35290. * @returns the new active camera or null if none found.
  35291. */
  35292. setActiveCameraByName(name: string): Nullable<Camera>;
  35293. /**
  35294. * get an animation group using its name
  35295. * @param name defines the material's name
  35296. * @return the animation group or null if none found.
  35297. */
  35298. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35299. /**
  35300. * Get a material using its unique id
  35301. * @param uniqueId defines the material's unique id
  35302. * @return the material or null if none found.
  35303. */
  35304. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35305. /**
  35306. * get a material using its id
  35307. * @param id defines the material's ID
  35308. * @return the material or null if none found.
  35309. */
  35310. getMaterialByID(id: string): Nullable<Material>;
  35311. /**
  35312. * Gets a the last added material using a given id
  35313. * @param id defines the material's ID
  35314. * @return the last material with the given id or null if none found.
  35315. */
  35316. getLastMaterialByID(id: string): Nullable<Material>;
  35317. /**
  35318. * Gets a material using its name
  35319. * @param name defines the material's name
  35320. * @return the material or null if none found.
  35321. */
  35322. getMaterialByName(name: string): Nullable<Material>;
  35323. /**
  35324. * Get a texture using its unique id
  35325. * @param uniqueId defines the texture's unique id
  35326. * @return the texture or null if none found.
  35327. */
  35328. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35329. /**
  35330. * Gets a camera using its id
  35331. * @param id defines the id to look for
  35332. * @returns the camera or null if not found
  35333. */
  35334. getCameraByID(id: string): Nullable<Camera>;
  35335. /**
  35336. * Gets a camera using its unique id
  35337. * @param uniqueId defines the unique id to look for
  35338. * @returns the camera or null if not found
  35339. */
  35340. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35341. /**
  35342. * Gets a camera using its name
  35343. * @param name defines the camera's name
  35344. * @return the camera or null if none found.
  35345. */
  35346. getCameraByName(name: string): Nullable<Camera>;
  35347. /**
  35348. * Gets a bone using its id
  35349. * @param id defines the bone's id
  35350. * @return the bone or null if not found
  35351. */
  35352. getBoneByID(id: string): Nullable<Bone>;
  35353. /**
  35354. * Gets a bone using its id
  35355. * @param name defines the bone's name
  35356. * @return the bone or null if not found
  35357. */
  35358. getBoneByName(name: string): Nullable<Bone>;
  35359. /**
  35360. * Gets a light node using its name
  35361. * @param name defines the the light's name
  35362. * @return the light or null if none found.
  35363. */
  35364. getLightByName(name: string): Nullable<Light>;
  35365. /**
  35366. * Gets a light node using its id
  35367. * @param id defines the light's id
  35368. * @return the light or null if none found.
  35369. */
  35370. getLightByID(id: string): Nullable<Light>;
  35371. /**
  35372. * Gets a light node using its scene-generated unique ID
  35373. * @param uniqueId defines the light's unique id
  35374. * @return the light or null if none found.
  35375. */
  35376. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35377. /**
  35378. * Gets a particle system by id
  35379. * @param id defines the particle system id
  35380. * @return the corresponding system or null if none found
  35381. */
  35382. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35383. /**
  35384. * Gets a geometry using its ID
  35385. * @param id defines the geometry's id
  35386. * @return the geometry or null if none found.
  35387. */
  35388. getGeometryByID(id: string): Nullable<Geometry>;
  35389. private _getGeometryByUniqueID;
  35390. /**
  35391. * Add a new geometry to this scene
  35392. * @param geometry defines the geometry to be added to the scene.
  35393. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35394. * @return a boolean defining if the geometry was added or not
  35395. */
  35396. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35397. /**
  35398. * Removes an existing geometry
  35399. * @param geometry defines the geometry to be removed from the scene
  35400. * @return a boolean defining if the geometry was removed or not
  35401. */
  35402. removeGeometry(geometry: Geometry): boolean;
  35403. /**
  35404. * Gets the list of geometries attached to the scene
  35405. * @returns an array of Geometry
  35406. */
  35407. getGeometries(): Geometry[];
  35408. /**
  35409. * Gets the first added mesh found of a given ID
  35410. * @param id defines the id to search for
  35411. * @return the mesh found or null if not found at all
  35412. */
  35413. getMeshByID(id: string): Nullable<AbstractMesh>;
  35414. /**
  35415. * Gets a list of meshes using their id
  35416. * @param id defines the id to search for
  35417. * @returns a list of meshes
  35418. */
  35419. getMeshesByID(id: string): Array<AbstractMesh>;
  35420. /**
  35421. * Gets the first added transform node found of a given ID
  35422. * @param id defines the id to search for
  35423. * @return the found transform node or null if not found at all.
  35424. */
  35425. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35426. /**
  35427. * Gets a transform node with its auto-generated unique id
  35428. * @param uniqueId efines the unique id to search for
  35429. * @return the found transform node or null if not found at all.
  35430. */
  35431. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35432. /**
  35433. * Gets a list of transform nodes using their id
  35434. * @param id defines the id to search for
  35435. * @returns a list of transform nodes
  35436. */
  35437. getTransformNodesByID(id: string): Array<TransformNode>;
  35438. /**
  35439. * Gets a mesh with its auto-generated unique id
  35440. * @param uniqueId defines the unique id to search for
  35441. * @return the found mesh or null if not found at all.
  35442. */
  35443. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35444. /**
  35445. * Gets a the last added mesh using a given id
  35446. * @param id defines the id to search for
  35447. * @return the found mesh or null if not found at all.
  35448. */
  35449. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35450. /**
  35451. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35452. * @param id defines the id to search for
  35453. * @return the found node or null if not found at all
  35454. */
  35455. getLastEntryByID(id: string): Nullable<Node>;
  35456. /**
  35457. * Gets a node (Mesh, Camera, Light) using a given id
  35458. * @param id defines the id to search for
  35459. * @return the found node or null if not found at all
  35460. */
  35461. getNodeByID(id: string): Nullable<Node>;
  35462. /**
  35463. * Gets a node (Mesh, Camera, Light) using a given name
  35464. * @param name defines the name to search for
  35465. * @return the found node or null if not found at all.
  35466. */
  35467. getNodeByName(name: string): Nullable<Node>;
  35468. /**
  35469. * Gets a mesh using a given name
  35470. * @param name defines the name to search for
  35471. * @return the found mesh or null if not found at all.
  35472. */
  35473. getMeshByName(name: string): Nullable<AbstractMesh>;
  35474. /**
  35475. * Gets a transform node using a given name
  35476. * @param name defines the name to search for
  35477. * @return the found transform node or null if not found at all.
  35478. */
  35479. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35480. /**
  35481. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35482. * @param id defines the id to search for
  35483. * @return the found skeleton or null if not found at all.
  35484. */
  35485. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35486. /**
  35487. * Gets a skeleton using a given auto generated unique id
  35488. * @param uniqueId defines the unique id to search for
  35489. * @return the found skeleton or null if not found at all.
  35490. */
  35491. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35492. /**
  35493. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35494. * @param id defines the id to search for
  35495. * @return the found skeleton or null if not found at all.
  35496. */
  35497. getSkeletonById(id: string): Nullable<Skeleton>;
  35498. /**
  35499. * Gets a skeleton using a given name
  35500. * @param name defines the name to search for
  35501. * @return the found skeleton or null if not found at all.
  35502. */
  35503. getSkeletonByName(name: string): Nullable<Skeleton>;
  35504. /**
  35505. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35506. * @param id defines the id to search for
  35507. * @return the found morph target manager or null if not found at all.
  35508. */
  35509. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35510. /**
  35511. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35512. * @param id defines the id to search for
  35513. * @return the found morph target or null if not found at all.
  35514. */
  35515. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35516. /**
  35517. * Gets a boolean indicating if the given mesh is active
  35518. * @param mesh defines the mesh to look for
  35519. * @returns true if the mesh is in the active list
  35520. */
  35521. isActiveMesh(mesh: AbstractMesh): boolean;
  35522. /**
  35523. * Return a unique id as a string which can serve as an identifier for the scene
  35524. */
  35525. readonly uid: string;
  35526. /**
  35527. * Add an externaly attached data from its key.
  35528. * This method call will fail and return false, if such key already exists.
  35529. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35530. * @param key the unique key that identifies the data
  35531. * @param data the data object to associate to the key for this Engine instance
  35532. * @return true if no such key were already present and the data was added successfully, false otherwise
  35533. */
  35534. addExternalData<T>(key: string, data: T): boolean;
  35535. /**
  35536. * Get an externaly attached data from its key
  35537. * @param key the unique key that identifies the data
  35538. * @return the associated data, if present (can be null), or undefined if not present
  35539. */
  35540. getExternalData<T>(key: string): Nullable<T>;
  35541. /**
  35542. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35543. * @param key the unique key that identifies the data
  35544. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35545. * @return the associated data, can be null if the factory returned null.
  35546. */
  35547. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35548. /**
  35549. * Remove an externaly attached data from the Engine instance
  35550. * @param key the unique key that identifies the data
  35551. * @return true if the data was successfully removed, false if it doesn't exist
  35552. */
  35553. removeExternalData(key: string): boolean;
  35554. private _evaluateSubMesh;
  35555. /**
  35556. * Clear the processed materials smart array preventing retention point in material dispose.
  35557. */
  35558. freeProcessedMaterials(): void;
  35559. private _preventFreeActiveMeshesAndRenderingGroups;
  35560. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35561. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35562. * when disposing several meshes in a row or a hierarchy of meshes.
  35563. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35564. */
  35565. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35566. /**
  35567. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35568. */
  35569. freeActiveMeshes(): void;
  35570. /**
  35571. * Clear the info related to rendering groups preventing retention points during dispose.
  35572. */
  35573. freeRenderingGroups(): void;
  35574. /** @hidden */
  35575. _isInIntermediateRendering(): boolean;
  35576. /**
  35577. * Lambda returning the list of potentially active meshes.
  35578. */
  35579. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35580. /**
  35581. * Lambda returning the list of potentially active sub meshes.
  35582. */
  35583. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35584. /**
  35585. * Lambda returning the list of potentially intersecting sub meshes.
  35586. */
  35587. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35588. /**
  35589. * Lambda returning the list of potentially colliding sub meshes.
  35590. */
  35591. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35592. private _activeMeshesFrozen;
  35593. /**
  35594. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35595. * @returns the current scene
  35596. */
  35597. freezeActiveMeshes(): Scene;
  35598. /**
  35599. * Use this function to restart evaluating active meshes on every frame
  35600. * @returns the current scene
  35601. */
  35602. unfreezeActiveMeshes(): Scene;
  35603. private _evaluateActiveMeshes;
  35604. private _activeMesh;
  35605. /**
  35606. * Update the transform matrix to update from the current active camera
  35607. * @param force defines a boolean used to force the update even if cache is up to date
  35608. */
  35609. updateTransformMatrix(force?: boolean): void;
  35610. private _bindFrameBuffer;
  35611. /** @hidden */
  35612. _allowPostProcessClearColor: boolean;
  35613. /** @hidden */
  35614. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35615. private _processSubCameras;
  35616. private _checkIntersections;
  35617. /** @hidden */
  35618. _advancePhysicsEngineStep(step: number): void;
  35619. /**
  35620. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35621. */
  35622. getDeterministicFrameTime: () => number;
  35623. /** @hidden */
  35624. _animate(): void;
  35625. /** Execute all animations (for a frame) */
  35626. animate(): void;
  35627. /**
  35628. * Render the scene
  35629. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35630. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35631. */
  35632. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35633. /**
  35634. * Freeze all materials
  35635. * A frozen material will not be updatable but should be faster to render
  35636. */
  35637. freezeMaterials(): void;
  35638. /**
  35639. * Unfreeze all materials
  35640. * A frozen material will not be updatable but should be faster to render
  35641. */
  35642. unfreezeMaterials(): void;
  35643. /**
  35644. * Releases all held ressources
  35645. */
  35646. dispose(): void;
  35647. /**
  35648. * Gets if the scene is already disposed
  35649. */
  35650. readonly isDisposed: boolean;
  35651. /**
  35652. * Call this function to reduce memory footprint of the scene.
  35653. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35654. */
  35655. clearCachedVertexData(): void;
  35656. /**
  35657. * This function will remove the local cached buffer data from texture.
  35658. * It will save memory but will prevent the texture from being rebuilt
  35659. */
  35660. cleanCachedTextureBuffer(): void;
  35661. /**
  35662. * Get the world extend vectors with an optional filter
  35663. *
  35664. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35665. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35666. */
  35667. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35668. min: Vector3;
  35669. max: Vector3;
  35670. };
  35671. /**
  35672. * Creates a ray that can be used to pick in the scene
  35673. * @param x defines the x coordinate of the origin (on-screen)
  35674. * @param y defines the y coordinate of the origin (on-screen)
  35675. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35676. * @param camera defines the camera to use for the picking
  35677. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35678. * @returns a Ray
  35679. */
  35680. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35681. /**
  35682. * Creates a ray that can be used to pick in the scene
  35683. * @param x defines the x coordinate of the origin (on-screen)
  35684. * @param y defines the y coordinate of the origin (on-screen)
  35685. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35686. * @param result defines the ray where to store the picking ray
  35687. * @param camera defines the camera to use for the picking
  35688. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35689. * @returns the current scene
  35690. */
  35691. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35692. /**
  35693. * Creates a ray that can be used to pick in the scene
  35694. * @param x defines the x coordinate of the origin (on-screen)
  35695. * @param y defines the y coordinate of the origin (on-screen)
  35696. * @param camera defines the camera to use for the picking
  35697. * @returns a Ray
  35698. */
  35699. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35700. /**
  35701. * Creates a ray that can be used to pick in the scene
  35702. * @param x defines the x coordinate of the origin (on-screen)
  35703. * @param y defines the y coordinate of the origin (on-screen)
  35704. * @param result defines the ray where to store the picking ray
  35705. * @param camera defines the camera to use for the picking
  35706. * @returns the current scene
  35707. */
  35708. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35709. /** Launch a ray to try to pick a mesh in the scene
  35710. * @param x position on screen
  35711. * @param y position on screen
  35712. * @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
  35713. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35714. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35715. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35716. * @returns a PickingInfo
  35717. */
  35718. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35719. /** Use the given ray to pick a mesh in the scene
  35720. * @param ray The ray to use to pick meshes
  35721. * @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
  35722. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35723. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35724. * @returns a PickingInfo
  35725. */
  35726. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35727. /**
  35728. * Launch a ray to try to pick a mesh in the scene
  35729. * @param x X position on screen
  35730. * @param y Y position on screen
  35731. * @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
  35732. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35734. * @returns an array of PickingInfo
  35735. */
  35736. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35737. /**
  35738. * Launch a ray to try to pick a mesh in the scene
  35739. * @param ray Ray to use
  35740. * @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
  35741. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35742. * @returns an array of PickingInfo
  35743. */
  35744. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35745. /**
  35746. * Force the value of meshUnderPointer
  35747. * @param mesh defines the mesh to use
  35748. */
  35749. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35750. /**
  35751. * Gets the mesh under the pointer
  35752. * @returns a Mesh or null if no mesh is under the pointer
  35753. */
  35754. getPointerOverMesh(): Nullable<AbstractMesh>;
  35755. /** @hidden */
  35756. _rebuildGeometries(): void;
  35757. /** @hidden */
  35758. _rebuildTextures(): void;
  35759. private _getByTags;
  35760. /**
  35761. * Get a list of meshes by tags
  35762. * @param tagsQuery defines the tags query to use
  35763. * @param forEach defines a predicate used to filter results
  35764. * @returns an array of Mesh
  35765. */
  35766. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35767. /**
  35768. * Get a list of cameras by tags
  35769. * @param tagsQuery defines the tags query to use
  35770. * @param forEach defines a predicate used to filter results
  35771. * @returns an array of Camera
  35772. */
  35773. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35774. /**
  35775. * Get a list of lights by tags
  35776. * @param tagsQuery defines the tags query to use
  35777. * @param forEach defines a predicate used to filter results
  35778. * @returns an array of Light
  35779. */
  35780. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35781. /**
  35782. * Get a list of materials by tags
  35783. * @param tagsQuery defines the tags query to use
  35784. * @param forEach defines a predicate used to filter results
  35785. * @returns an array of Material
  35786. */
  35787. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35788. /**
  35789. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35790. * This allowed control for front to back rendering or reversly depending of the special needs.
  35791. *
  35792. * @param renderingGroupId The rendering group id corresponding to its index
  35793. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35794. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35795. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35796. */
  35797. 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;
  35798. /**
  35799. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35800. *
  35801. * @param renderingGroupId The rendering group id corresponding to its index
  35802. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35803. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35804. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35805. */
  35806. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35807. /**
  35808. * Gets the current auto clear configuration for one rendering group of the rendering
  35809. * manager.
  35810. * @param index the rendering group index to get the information for
  35811. * @returns The auto clear setup for the requested rendering group
  35812. */
  35813. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35814. private _blockMaterialDirtyMechanism;
  35815. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35816. blockMaterialDirtyMechanism: boolean;
  35817. /**
  35818. * Will flag all materials as dirty to trigger new shader compilation
  35819. * @param flag defines the flag used to specify which material part must be marked as dirty
  35820. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35821. */
  35822. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35823. /** @hidden */
  35824. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  35825. /** @hidden */
  35826. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35827. /** @hidden */
  35828. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  35829. /** @hidden */
  35830. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35831. /** @hidden */
  35832. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35833. /** @hidden */
  35834. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35835. }
  35836. }
  35837. declare module "babylonjs/assetContainer" {
  35838. import { AbstractScene } from "babylonjs/abstractScene";
  35839. import { Scene } from "babylonjs/scene";
  35840. import { Mesh } from "babylonjs/Meshes/mesh";
  35841. /**
  35842. * Set of assets to keep when moving a scene into an asset container.
  35843. */
  35844. export class KeepAssets extends AbstractScene {
  35845. }
  35846. /**
  35847. * Container with a set of assets that can be added or removed from a scene.
  35848. */
  35849. export class AssetContainer extends AbstractScene {
  35850. /**
  35851. * The scene the AssetContainer belongs to.
  35852. */
  35853. scene: Scene;
  35854. /**
  35855. * Instantiates an AssetContainer.
  35856. * @param scene The scene the AssetContainer belongs to.
  35857. */
  35858. constructor(scene: Scene);
  35859. /**
  35860. * Adds all the assets from the container to the scene.
  35861. */
  35862. addAllToScene(): void;
  35863. /**
  35864. * Removes all the assets in the container from the scene
  35865. */
  35866. removeAllFromScene(): void;
  35867. /**
  35868. * Disposes all the assets in the container
  35869. */
  35870. dispose(): void;
  35871. private _moveAssets;
  35872. /**
  35873. * Removes all the assets contained in the scene and adds them to the container.
  35874. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35875. */
  35876. moveAllFromScene(keepAssets?: KeepAssets): void;
  35877. /**
  35878. * 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.
  35879. * @returns the root mesh
  35880. */
  35881. createRootMesh(): Mesh;
  35882. }
  35883. }
  35884. declare module "babylonjs/abstractScene" {
  35885. import { Scene } from "babylonjs/scene";
  35886. import { Nullable } from "babylonjs/types";
  35887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35889. import { Geometry } from "babylonjs/Meshes/geometry";
  35890. import { Skeleton } from "babylonjs/Bones/skeleton";
  35891. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35892. import { AssetContainer } from "babylonjs/assetContainer";
  35893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35894. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35895. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35896. import { Material } from "babylonjs/Materials/material";
  35897. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35898. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35899. import { Camera } from "babylonjs/Cameras/camera";
  35900. import { Light } from "babylonjs/Lights/light";
  35901. import { Node } from "babylonjs/node";
  35902. import { Animation } from "babylonjs/Animations/animation";
  35903. /**
  35904. * Defines how the parser contract is defined.
  35905. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35906. */
  35907. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35908. /**
  35909. * Defines how the individual parser contract is defined.
  35910. * These parser can parse an individual asset
  35911. */
  35912. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35913. /**
  35914. * Base class of the scene acting as a container for the different elements composing a scene.
  35915. * This class is dynamically extended by the different components of the scene increasing
  35916. * flexibility and reducing coupling
  35917. */
  35918. export abstract class AbstractScene {
  35919. /**
  35920. * Stores the list of available parsers in the application.
  35921. */
  35922. private static _BabylonFileParsers;
  35923. /**
  35924. * Stores the list of available individual parsers in the application.
  35925. */
  35926. private static _IndividualBabylonFileParsers;
  35927. /**
  35928. * Adds a parser in the list of available ones
  35929. * @param name Defines the name of the parser
  35930. * @param parser Defines the parser to add
  35931. */
  35932. static AddParser(name: string, parser: BabylonFileParser): void;
  35933. /**
  35934. * Gets a general parser from the list of avaialble ones
  35935. * @param name Defines the name of the parser
  35936. * @returns the requested parser or null
  35937. */
  35938. static GetParser(name: string): Nullable<BabylonFileParser>;
  35939. /**
  35940. * Adds n individual parser in the list of available ones
  35941. * @param name Defines the name of the parser
  35942. * @param parser Defines the parser to add
  35943. */
  35944. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35945. /**
  35946. * Gets an individual parser from the list of avaialble ones
  35947. * @param name Defines the name of the parser
  35948. * @returns the requested parser or null
  35949. */
  35950. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35951. /**
  35952. * Parser json data and populate both a scene and its associated container object
  35953. * @param jsonData Defines the data to parse
  35954. * @param scene Defines the scene to parse the data for
  35955. * @param container Defines the container attached to the parsing sequence
  35956. * @param rootUrl Defines the root url of the data
  35957. */
  35958. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35959. /**
  35960. * Gets the list of root nodes (ie. nodes with no parent)
  35961. */
  35962. rootNodes: Node[];
  35963. /** All of the cameras added to this scene
  35964. * @see http://doc.babylonjs.com/babylon101/cameras
  35965. */
  35966. cameras: Camera[];
  35967. /**
  35968. * All of the lights added to this scene
  35969. * @see http://doc.babylonjs.com/babylon101/lights
  35970. */
  35971. lights: Light[];
  35972. /**
  35973. * All of the (abstract) meshes added to this scene
  35974. */
  35975. meshes: AbstractMesh[];
  35976. /**
  35977. * The list of skeletons added to the scene
  35978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35979. */
  35980. skeletons: Skeleton[];
  35981. /**
  35982. * All of the particle systems added to this scene
  35983. * @see http://doc.babylonjs.com/babylon101/particles
  35984. */
  35985. particleSystems: IParticleSystem[];
  35986. /**
  35987. * Gets a list of Animations associated with the scene
  35988. */
  35989. animations: Animation[];
  35990. /**
  35991. * All of the animation groups added to this scene
  35992. * @see http://doc.babylonjs.com/how_to/group
  35993. */
  35994. animationGroups: AnimationGroup[];
  35995. /**
  35996. * All of the multi-materials added to this scene
  35997. * @see http://doc.babylonjs.com/how_to/multi_materials
  35998. */
  35999. multiMaterials: MultiMaterial[];
  36000. /**
  36001. * All of the materials added to this scene
  36002. * In the context of a Scene, it is not supposed to be modified manually.
  36003. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  36004. * Note also that the order of the Material wihin the array is not significant and might change.
  36005. * @see http://doc.babylonjs.com/babylon101/materials
  36006. */
  36007. materials: Material[];
  36008. /**
  36009. * The list of morph target managers added to the scene
  36010. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36011. */
  36012. morphTargetManagers: MorphTargetManager[];
  36013. /**
  36014. * The list of geometries used in the scene.
  36015. */
  36016. geometries: Geometry[];
  36017. /**
  36018. * All of the tranform nodes added to this scene
  36019. * In the context of a Scene, it is not supposed to be modified manually.
  36020. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36021. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36022. * @see http://doc.babylonjs.com/how_to/transformnode
  36023. */
  36024. transformNodes: TransformNode[];
  36025. /**
  36026. * ActionManagers available on the scene.
  36027. */
  36028. actionManagers: AbstractActionManager[];
  36029. /**
  36030. * Textures to keep.
  36031. */
  36032. textures: BaseTexture[];
  36033. /**
  36034. * Environment texture for the scene
  36035. */
  36036. environmentTexture: Nullable<BaseTexture>;
  36037. }
  36038. }
  36039. declare module "babylonjs/Audio/sound" {
  36040. import { Observable } from "babylonjs/Misc/observable";
  36041. import { Vector3 } from "babylonjs/Maths/math.vector";
  36042. import { Nullable } from "babylonjs/types";
  36043. import { Scene } from "babylonjs/scene";
  36044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36045. /**
  36046. * Interface used to define options for Sound class
  36047. */
  36048. export interface ISoundOptions {
  36049. /**
  36050. * Does the sound autoplay once loaded.
  36051. */
  36052. autoplay?: boolean;
  36053. /**
  36054. * Does the sound loop after it finishes playing once.
  36055. */
  36056. loop?: boolean;
  36057. /**
  36058. * Sound's volume
  36059. */
  36060. volume?: number;
  36061. /**
  36062. * Is it a spatial sound?
  36063. */
  36064. spatialSound?: boolean;
  36065. /**
  36066. * Maximum distance to hear that sound
  36067. */
  36068. maxDistance?: number;
  36069. /**
  36070. * Uses user defined attenuation function
  36071. */
  36072. useCustomAttenuation?: boolean;
  36073. /**
  36074. * Define the roll off factor of spatial sounds.
  36075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36076. */
  36077. rolloffFactor?: number;
  36078. /**
  36079. * Define the reference distance the sound should be heard perfectly.
  36080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36081. */
  36082. refDistance?: number;
  36083. /**
  36084. * Define the distance attenuation model the sound will follow.
  36085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36086. */
  36087. distanceModel?: string;
  36088. /**
  36089. * Defines the playback speed (1 by default)
  36090. */
  36091. playbackRate?: number;
  36092. /**
  36093. * Defines if the sound is from a streaming source
  36094. */
  36095. streaming?: boolean;
  36096. /**
  36097. * Defines an optional length (in seconds) inside the sound file
  36098. */
  36099. length?: number;
  36100. /**
  36101. * Defines an optional offset (in seconds) inside the sound file
  36102. */
  36103. offset?: number;
  36104. /**
  36105. * If true, URLs will not be required to state the audio file codec to use.
  36106. */
  36107. skipCodecCheck?: boolean;
  36108. }
  36109. /**
  36110. * Defines a sound that can be played in the application.
  36111. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36113. */
  36114. export class Sound {
  36115. /**
  36116. * The name of the sound in the scene.
  36117. */
  36118. name: string;
  36119. /**
  36120. * Does the sound autoplay once loaded.
  36121. */
  36122. autoplay: boolean;
  36123. /**
  36124. * Does the sound loop after it finishes playing once.
  36125. */
  36126. loop: boolean;
  36127. /**
  36128. * Does the sound use a custom attenuation curve to simulate the falloff
  36129. * happening when the source gets further away from the camera.
  36130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36131. */
  36132. useCustomAttenuation: boolean;
  36133. /**
  36134. * The sound track id this sound belongs to.
  36135. */
  36136. soundTrackId: number;
  36137. /**
  36138. * Is this sound currently played.
  36139. */
  36140. isPlaying: boolean;
  36141. /**
  36142. * Is this sound currently paused.
  36143. */
  36144. isPaused: boolean;
  36145. /**
  36146. * Does this sound enables spatial sound.
  36147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36148. */
  36149. spatialSound: boolean;
  36150. /**
  36151. * Define the reference distance the sound should be heard perfectly.
  36152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36153. */
  36154. refDistance: number;
  36155. /**
  36156. * Define the roll off factor of spatial sounds.
  36157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36158. */
  36159. rolloffFactor: number;
  36160. /**
  36161. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36163. */
  36164. maxDistance: number;
  36165. /**
  36166. * Define the distance attenuation model the sound will follow.
  36167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36168. */
  36169. distanceModel: string;
  36170. /**
  36171. * @hidden
  36172. * Back Compat
  36173. **/
  36174. onended: () => any;
  36175. /**
  36176. * Observable event when the current playing sound finishes.
  36177. */
  36178. onEndedObservable: Observable<Sound>;
  36179. private _panningModel;
  36180. private _playbackRate;
  36181. private _streaming;
  36182. private _startTime;
  36183. private _startOffset;
  36184. private _position;
  36185. /** @hidden */
  36186. _positionInEmitterSpace: boolean;
  36187. private _localDirection;
  36188. private _volume;
  36189. private _isReadyToPlay;
  36190. private _isDirectional;
  36191. private _readyToPlayCallback;
  36192. private _audioBuffer;
  36193. private _soundSource;
  36194. private _streamingSource;
  36195. private _soundPanner;
  36196. private _soundGain;
  36197. private _inputAudioNode;
  36198. private _outputAudioNode;
  36199. private _coneInnerAngle;
  36200. private _coneOuterAngle;
  36201. private _coneOuterGain;
  36202. private _scene;
  36203. private _connectedTransformNode;
  36204. private _customAttenuationFunction;
  36205. private _registerFunc;
  36206. private _isOutputConnected;
  36207. private _htmlAudioElement;
  36208. private _urlType;
  36209. private _length?;
  36210. private _offset?;
  36211. /** @hidden */
  36212. static _SceneComponentInitialization: (scene: Scene) => void;
  36213. /**
  36214. * Create a sound and attach it to a scene
  36215. * @param name Name of your sound
  36216. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36217. * @param scene defines the scene the sound belongs to
  36218. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36219. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36220. */
  36221. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36222. /**
  36223. * Release the sound and its associated resources
  36224. */
  36225. dispose(): void;
  36226. /**
  36227. * Gets if the sounds is ready to be played or not.
  36228. * @returns true if ready, otherwise false
  36229. */
  36230. isReady(): boolean;
  36231. private _soundLoaded;
  36232. /**
  36233. * Sets the data of the sound from an audiobuffer
  36234. * @param audioBuffer The audioBuffer containing the data
  36235. */
  36236. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36237. /**
  36238. * Updates the current sounds options such as maxdistance, loop...
  36239. * @param options A JSON object containing values named as the object properties
  36240. */
  36241. updateOptions(options: ISoundOptions): void;
  36242. private _createSpatialParameters;
  36243. private _updateSpatialParameters;
  36244. /**
  36245. * Switch the panning model to HRTF:
  36246. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36248. */
  36249. switchPanningModelToHRTF(): void;
  36250. /**
  36251. * Switch the panning model to Equal Power:
  36252. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36254. */
  36255. switchPanningModelToEqualPower(): void;
  36256. private _switchPanningModel;
  36257. /**
  36258. * Connect this sound to a sound track audio node like gain...
  36259. * @param soundTrackAudioNode the sound track audio node to connect to
  36260. */
  36261. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36262. /**
  36263. * Transform this sound into a directional source
  36264. * @param coneInnerAngle Size of the inner cone in degree
  36265. * @param coneOuterAngle Size of the outer cone in degree
  36266. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36267. */
  36268. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36269. /**
  36270. * Gets or sets the inner angle for the directional cone.
  36271. */
  36272. /**
  36273. * Gets or sets the inner angle for the directional cone.
  36274. */
  36275. directionalConeInnerAngle: number;
  36276. /**
  36277. * Gets or sets the outer angle for the directional cone.
  36278. */
  36279. /**
  36280. * Gets or sets the outer angle for the directional cone.
  36281. */
  36282. directionalConeOuterAngle: number;
  36283. /**
  36284. * Sets the position of the emitter if spatial sound is enabled
  36285. * @param newPosition Defines the new posisiton
  36286. */
  36287. setPosition(newPosition: Vector3): void;
  36288. /**
  36289. * Sets the local direction of the emitter if spatial sound is enabled
  36290. * @param newLocalDirection Defines the new local direction
  36291. */
  36292. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36293. private _updateDirection;
  36294. /** @hidden */
  36295. updateDistanceFromListener(): void;
  36296. /**
  36297. * Sets a new custom attenuation function for the sound.
  36298. * @param callback Defines the function used for the attenuation
  36299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36300. */
  36301. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36302. /**
  36303. * Play the sound
  36304. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36305. * @param offset (optional) Start the sound at a specific time in seconds
  36306. * @param length (optional) Sound duration (in seconds)
  36307. */
  36308. play(time?: number, offset?: number, length?: number): void;
  36309. private _onended;
  36310. /**
  36311. * Stop the sound
  36312. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36313. */
  36314. stop(time?: number): void;
  36315. /**
  36316. * Put the sound in pause
  36317. */
  36318. pause(): void;
  36319. /**
  36320. * Sets a dedicated volume for this sounds
  36321. * @param newVolume Define the new volume of the sound
  36322. * @param time Define time for gradual change to new volume
  36323. */
  36324. setVolume(newVolume: number, time?: number): void;
  36325. /**
  36326. * Set the sound play back rate
  36327. * @param newPlaybackRate Define the playback rate the sound should be played at
  36328. */
  36329. setPlaybackRate(newPlaybackRate: number): void;
  36330. /**
  36331. * Gets the volume of the sound.
  36332. * @returns the volume of the sound
  36333. */
  36334. getVolume(): number;
  36335. /**
  36336. * Attach the sound to a dedicated mesh
  36337. * @param transformNode The transform node to connect the sound with
  36338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36339. */
  36340. attachToMesh(transformNode: TransformNode): void;
  36341. /**
  36342. * Detach the sound from the previously attached mesh
  36343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36344. */
  36345. detachFromMesh(): void;
  36346. private _onRegisterAfterWorldMatrixUpdate;
  36347. /**
  36348. * Clone the current sound in the scene.
  36349. * @returns the new sound clone
  36350. */
  36351. clone(): Nullable<Sound>;
  36352. /**
  36353. * Gets the current underlying audio buffer containing the data
  36354. * @returns the audio buffer
  36355. */
  36356. getAudioBuffer(): Nullable<AudioBuffer>;
  36357. /**
  36358. * Serializes the Sound in a JSON representation
  36359. * @returns the JSON representation of the sound
  36360. */
  36361. serialize(): any;
  36362. /**
  36363. * Parse a JSON representation of a sound to innstantiate in a given scene
  36364. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36365. * @param scene Define the scene the new parsed sound should be created in
  36366. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36367. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36368. * @returns the newly parsed sound
  36369. */
  36370. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36371. }
  36372. }
  36373. declare module "babylonjs/Actions/directAudioActions" {
  36374. import { Action } from "babylonjs/Actions/action";
  36375. import { Condition } from "babylonjs/Actions/condition";
  36376. import { Sound } from "babylonjs/Audio/sound";
  36377. /**
  36378. * This defines an action helpful to play a defined sound on a triggered action.
  36379. */
  36380. export class PlaySoundAction extends Action {
  36381. private _sound;
  36382. /**
  36383. * Instantiate the action
  36384. * @param triggerOptions defines the trigger options
  36385. * @param sound defines the sound to play
  36386. * @param condition defines the trigger related conditions
  36387. */
  36388. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36389. /** @hidden */
  36390. _prepare(): void;
  36391. /**
  36392. * Execute the action and play the sound.
  36393. */
  36394. execute(): void;
  36395. /**
  36396. * Serializes the actions and its related information.
  36397. * @param parent defines the object to serialize in
  36398. * @returns the serialized object
  36399. */
  36400. serialize(parent: any): any;
  36401. }
  36402. /**
  36403. * This defines an action helpful to stop a defined sound on a triggered action.
  36404. */
  36405. export class StopSoundAction extends Action {
  36406. private _sound;
  36407. /**
  36408. * Instantiate the action
  36409. * @param triggerOptions defines the trigger options
  36410. * @param sound defines the sound to stop
  36411. * @param condition defines the trigger related conditions
  36412. */
  36413. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36414. /** @hidden */
  36415. _prepare(): void;
  36416. /**
  36417. * Execute the action and stop the sound.
  36418. */
  36419. execute(): void;
  36420. /**
  36421. * Serializes the actions and its related information.
  36422. * @param parent defines the object to serialize in
  36423. * @returns the serialized object
  36424. */
  36425. serialize(parent: any): any;
  36426. }
  36427. }
  36428. declare module "babylonjs/Actions/interpolateValueAction" {
  36429. import { Action } from "babylonjs/Actions/action";
  36430. import { Condition } from "babylonjs/Actions/condition";
  36431. import { Observable } from "babylonjs/Misc/observable";
  36432. /**
  36433. * This defines an action responsible to change the value of a property
  36434. * by interpolating between its current value and the newly set one once triggered.
  36435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36436. */
  36437. export class InterpolateValueAction extends Action {
  36438. /**
  36439. * Defines the path of the property where the value should be interpolated
  36440. */
  36441. propertyPath: string;
  36442. /**
  36443. * Defines the target value at the end of the interpolation.
  36444. */
  36445. value: any;
  36446. /**
  36447. * Defines the time it will take for the property to interpolate to the value.
  36448. */
  36449. duration: number;
  36450. /**
  36451. * Defines if the other scene animations should be stopped when the action has been triggered
  36452. */
  36453. stopOtherAnimations?: boolean;
  36454. /**
  36455. * Defines a callback raised once the interpolation animation has been done.
  36456. */
  36457. onInterpolationDone?: () => void;
  36458. /**
  36459. * Observable triggered once the interpolation animation has been done.
  36460. */
  36461. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36462. private _target;
  36463. private _effectiveTarget;
  36464. private _property;
  36465. /**
  36466. * Instantiate the action
  36467. * @param triggerOptions defines the trigger options
  36468. * @param target defines the object containing the value to interpolate
  36469. * @param propertyPath defines the path to the property in the target object
  36470. * @param value defines the target value at the end of the interpolation
  36471. * @param duration deines the time it will take for the property to interpolate to the value.
  36472. * @param condition defines the trigger related conditions
  36473. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36474. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36475. */
  36476. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36477. /** @hidden */
  36478. _prepare(): void;
  36479. /**
  36480. * Execute the action starts the value interpolation.
  36481. */
  36482. execute(): void;
  36483. /**
  36484. * Serializes the actions and its related information.
  36485. * @param parent defines the object to serialize in
  36486. * @returns the serialized object
  36487. */
  36488. serialize(parent: any): any;
  36489. }
  36490. }
  36491. declare module "babylonjs/Actions/index" {
  36492. export * from "babylonjs/Actions/abstractActionManager";
  36493. export * from "babylonjs/Actions/action";
  36494. export * from "babylonjs/Actions/actionEvent";
  36495. export * from "babylonjs/Actions/actionManager";
  36496. export * from "babylonjs/Actions/condition";
  36497. export * from "babylonjs/Actions/directActions";
  36498. export * from "babylonjs/Actions/directAudioActions";
  36499. export * from "babylonjs/Actions/interpolateValueAction";
  36500. }
  36501. declare module "babylonjs/Animations/index" {
  36502. export * from "babylonjs/Animations/animatable";
  36503. export * from "babylonjs/Animations/animation";
  36504. export * from "babylonjs/Animations/animationGroup";
  36505. export * from "babylonjs/Animations/animationPropertiesOverride";
  36506. export * from "babylonjs/Animations/easing";
  36507. export * from "babylonjs/Animations/runtimeAnimation";
  36508. export * from "babylonjs/Animations/animationEvent";
  36509. export * from "babylonjs/Animations/animationGroup";
  36510. export * from "babylonjs/Animations/animationKey";
  36511. export * from "babylonjs/Animations/animationRange";
  36512. export * from "babylonjs/Animations/animatable.interface";
  36513. }
  36514. declare module "babylonjs/Audio/soundTrack" {
  36515. import { Sound } from "babylonjs/Audio/sound";
  36516. import { Analyser } from "babylonjs/Audio/analyser";
  36517. import { Scene } from "babylonjs/scene";
  36518. /**
  36519. * Options allowed during the creation of a sound track.
  36520. */
  36521. export interface ISoundTrackOptions {
  36522. /**
  36523. * The volume the sound track should take during creation
  36524. */
  36525. volume?: number;
  36526. /**
  36527. * Define if the sound track is the main sound track of the scene
  36528. */
  36529. mainTrack?: boolean;
  36530. }
  36531. /**
  36532. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36533. * It will be also used in a future release to apply effects on a specific track.
  36534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36535. */
  36536. export class SoundTrack {
  36537. /**
  36538. * The unique identifier of the sound track in the scene.
  36539. */
  36540. id: number;
  36541. /**
  36542. * The list of sounds included in the sound track.
  36543. */
  36544. soundCollection: Array<Sound>;
  36545. private _outputAudioNode;
  36546. private _scene;
  36547. private _isMainTrack;
  36548. private _connectedAnalyser;
  36549. private _options;
  36550. private _isInitialized;
  36551. /**
  36552. * Creates a new sound track.
  36553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36554. * @param scene Define the scene the sound track belongs to
  36555. * @param options
  36556. */
  36557. constructor(scene: Scene, options?: ISoundTrackOptions);
  36558. private _initializeSoundTrackAudioGraph;
  36559. /**
  36560. * Release the sound track and its associated resources
  36561. */
  36562. dispose(): void;
  36563. /**
  36564. * Adds a sound to this sound track
  36565. * @param sound define the cound to add
  36566. * @ignoreNaming
  36567. */
  36568. AddSound(sound: Sound): void;
  36569. /**
  36570. * Removes a sound to this sound track
  36571. * @param sound define the cound to remove
  36572. * @ignoreNaming
  36573. */
  36574. RemoveSound(sound: Sound): void;
  36575. /**
  36576. * Set a global volume for the full sound track.
  36577. * @param newVolume Define the new volume of the sound track
  36578. */
  36579. setVolume(newVolume: number): void;
  36580. /**
  36581. * Switch the panning model to HRTF:
  36582. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36584. */
  36585. switchPanningModelToHRTF(): void;
  36586. /**
  36587. * Switch the panning model to Equal Power:
  36588. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36590. */
  36591. switchPanningModelToEqualPower(): void;
  36592. /**
  36593. * Connect the sound track to an audio analyser allowing some amazing
  36594. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36596. * @param analyser The analyser to connect to the engine
  36597. */
  36598. connectToAnalyser(analyser: Analyser): void;
  36599. }
  36600. }
  36601. declare module "babylonjs/Audio/audioSceneComponent" {
  36602. import { Sound } from "babylonjs/Audio/sound";
  36603. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36604. import { Nullable } from "babylonjs/types";
  36605. import { Vector3 } from "babylonjs/Maths/math.vector";
  36606. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36607. import { Scene } from "babylonjs/scene";
  36608. import { AbstractScene } from "babylonjs/abstractScene";
  36609. import "babylonjs/Audio/audioEngine";
  36610. module "babylonjs/abstractScene" {
  36611. interface AbstractScene {
  36612. /**
  36613. * The list of sounds used in the scene.
  36614. */
  36615. sounds: Nullable<Array<Sound>>;
  36616. }
  36617. }
  36618. module "babylonjs/scene" {
  36619. interface Scene {
  36620. /**
  36621. * @hidden
  36622. * Backing field
  36623. */
  36624. _mainSoundTrack: SoundTrack;
  36625. /**
  36626. * The main sound track played by the scene.
  36627. * It cotains your primary collection of sounds.
  36628. */
  36629. mainSoundTrack: SoundTrack;
  36630. /**
  36631. * The list of sound tracks added to the scene
  36632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36633. */
  36634. soundTracks: Nullable<Array<SoundTrack>>;
  36635. /**
  36636. * Gets a sound using a given name
  36637. * @param name defines the name to search for
  36638. * @return the found sound or null if not found at all.
  36639. */
  36640. getSoundByName(name: string): Nullable<Sound>;
  36641. /**
  36642. * Gets or sets if audio support is enabled
  36643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36644. */
  36645. audioEnabled: boolean;
  36646. /**
  36647. * Gets or sets if audio will be output to headphones
  36648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36649. */
  36650. headphone: boolean;
  36651. /**
  36652. * Gets or sets custom audio listener position provider
  36653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36654. */
  36655. audioListenerPositionProvider: Nullable<() => Vector3>;
  36656. /**
  36657. * Gets or sets a refresh rate when using 3D audio positioning
  36658. */
  36659. audioPositioningRefreshRate: number;
  36660. }
  36661. }
  36662. /**
  36663. * Defines the sound scene component responsible to manage any sounds
  36664. * in a given scene.
  36665. */
  36666. export class AudioSceneComponent implements ISceneSerializableComponent {
  36667. /**
  36668. * The component name helpfull to identify the component in the list of scene components.
  36669. */
  36670. readonly name: string;
  36671. /**
  36672. * The scene the component belongs to.
  36673. */
  36674. scene: Scene;
  36675. private _audioEnabled;
  36676. /**
  36677. * Gets whether audio is enabled or not.
  36678. * Please use related enable/disable method to switch state.
  36679. */
  36680. readonly audioEnabled: boolean;
  36681. private _headphone;
  36682. /**
  36683. * Gets whether audio is outputing to headphone or not.
  36684. * Please use the according Switch methods to change output.
  36685. */
  36686. readonly headphone: boolean;
  36687. /**
  36688. * Gets or sets a refresh rate when using 3D audio positioning
  36689. */
  36690. audioPositioningRefreshRate: number;
  36691. private _audioListenerPositionProvider;
  36692. /**
  36693. * Gets the current audio listener position provider
  36694. */
  36695. /**
  36696. * Sets a custom listener position for all sounds in the scene
  36697. * By default, this is the position of the first active camera
  36698. */
  36699. audioListenerPositionProvider: Nullable<() => Vector3>;
  36700. /**
  36701. * Creates a new instance of the component for the given scene
  36702. * @param scene Defines the scene to register the component in
  36703. */
  36704. constructor(scene: Scene);
  36705. /**
  36706. * Registers the component in a given scene
  36707. */
  36708. register(): void;
  36709. /**
  36710. * Rebuilds the elements related to this component in case of
  36711. * context lost for instance.
  36712. */
  36713. rebuild(): void;
  36714. /**
  36715. * Serializes the component data to the specified json object
  36716. * @param serializationObject The object to serialize to
  36717. */
  36718. serialize(serializationObject: any): void;
  36719. /**
  36720. * Adds all the elements from the container to the scene
  36721. * @param container the container holding the elements
  36722. */
  36723. addFromContainer(container: AbstractScene): void;
  36724. /**
  36725. * Removes all the elements in the container from the scene
  36726. * @param container contains the elements to remove
  36727. * @param dispose if the removed element should be disposed (default: false)
  36728. */
  36729. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36730. /**
  36731. * Disposes the component and the associated ressources.
  36732. */
  36733. dispose(): void;
  36734. /**
  36735. * Disables audio in the associated scene.
  36736. */
  36737. disableAudio(): void;
  36738. /**
  36739. * Enables audio in the associated scene.
  36740. */
  36741. enableAudio(): void;
  36742. /**
  36743. * Switch audio to headphone output.
  36744. */
  36745. switchAudioModeForHeadphones(): void;
  36746. /**
  36747. * Switch audio to normal speakers.
  36748. */
  36749. switchAudioModeForNormalSpeakers(): void;
  36750. private _cachedCameraDirection;
  36751. private _cachedCameraPosition;
  36752. private _lastCheck;
  36753. private _afterRender;
  36754. }
  36755. }
  36756. declare module "babylonjs/Audio/weightedsound" {
  36757. import { Sound } from "babylonjs/Audio/sound";
  36758. /**
  36759. * Wraps one or more Sound objects and selects one with random weight for playback.
  36760. */
  36761. export class WeightedSound {
  36762. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36763. loop: boolean;
  36764. private _coneInnerAngle;
  36765. private _coneOuterAngle;
  36766. private _volume;
  36767. /** A Sound is currently playing. */
  36768. isPlaying: boolean;
  36769. /** A Sound is currently paused. */
  36770. isPaused: boolean;
  36771. private _sounds;
  36772. private _weights;
  36773. private _currentIndex?;
  36774. /**
  36775. * Creates a new WeightedSound from the list of sounds given.
  36776. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36777. * @param sounds Array of Sounds that will be selected from.
  36778. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36779. */
  36780. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36781. /**
  36782. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36783. */
  36784. /**
  36785. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36786. */
  36787. directionalConeInnerAngle: number;
  36788. /**
  36789. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36790. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36791. */
  36792. /**
  36793. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36794. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36795. */
  36796. directionalConeOuterAngle: number;
  36797. /**
  36798. * Playback volume.
  36799. */
  36800. /**
  36801. * Playback volume.
  36802. */
  36803. volume: number;
  36804. private _onended;
  36805. /**
  36806. * Suspend playback
  36807. */
  36808. pause(): void;
  36809. /**
  36810. * Stop playback
  36811. */
  36812. stop(): void;
  36813. /**
  36814. * Start playback.
  36815. * @param startOffset Position the clip head at a specific time in seconds.
  36816. */
  36817. play(startOffset?: number): void;
  36818. }
  36819. }
  36820. declare module "babylonjs/Audio/index" {
  36821. export * from "babylonjs/Audio/analyser";
  36822. export * from "babylonjs/Audio/audioEngine";
  36823. export * from "babylonjs/Audio/audioSceneComponent";
  36824. export * from "babylonjs/Audio/sound";
  36825. export * from "babylonjs/Audio/soundTrack";
  36826. export * from "babylonjs/Audio/weightedsound";
  36827. }
  36828. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36829. import { Behavior } from "babylonjs/Behaviors/behavior";
  36830. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36831. import { BackEase } from "babylonjs/Animations/easing";
  36832. /**
  36833. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36834. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36835. */
  36836. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36837. /**
  36838. * Gets the name of the behavior.
  36839. */
  36840. readonly name: string;
  36841. /**
  36842. * The easing function used by animations
  36843. */
  36844. static EasingFunction: BackEase;
  36845. /**
  36846. * The easing mode used by animations
  36847. */
  36848. static EasingMode: number;
  36849. /**
  36850. * The duration of the animation, in milliseconds
  36851. */
  36852. transitionDuration: number;
  36853. /**
  36854. * Length of the distance animated by the transition when lower radius is reached
  36855. */
  36856. lowerRadiusTransitionRange: number;
  36857. /**
  36858. * Length of the distance animated by the transition when upper radius is reached
  36859. */
  36860. upperRadiusTransitionRange: number;
  36861. private _autoTransitionRange;
  36862. /**
  36863. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36864. */
  36865. /**
  36866. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36867. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36868. */
  36869. autoTransitionRange: boolean;
  36870. private _attachedCamera;
  36871. private _onAfterCheckInputsObserver;
  36872. private _onMeshTargetChangedObserver;
  36873. /**
  36874. * Initializes the behavior.
  36875. */
  36876. init(): void;
  36877. /**
  36878. * Attaches the behavior to its arc rotate camera.
  36879. * @param camera Defines the camera to attach the behavior to
  36880. */
  36881. attach(camera: ArcRotateCamera): void;
  36882. /**
  36883. * Detaches the behavior from its current arc rotate camera.
  36884. */
  36885. detach(): void;
  36886. private _radiusIsAnimating;
  36887. private _radiusBounceTransition;
  36888. private _animatables;
  36889. private _cachedWheelPrecision;
  36890. /**
  36891. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36892. * @param radiusLimit The limit to check against.
  36893. * @return Bool to indicate if at limit.
  36894. */
  36895. private _isRadiusAtLimit;
  36896. /**
  36897. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36898. * @param radiusDelta The delta by which to animate to. Can be negative.
  36899. */
  36900. private _applyBoundRadiusAnimation;
  36901. /**
  36902. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36903. */
  36904. protected _clearAnimationLocks(): void;
  36905. /**
  36906. * Stops and removes all animations that have been applied to the camera
  36907. */
  36908. stopAllAnimations(): void;
  36909. }
  36910. }
  36911. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36912. import { Behavior } from "babylonjs/Behaviors/behavior";
  36913. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36914. import { ExponentialEase } from "babylonjs/Animations/easing";
  36915. import { Nullable } from "babylonjs/types";
  36916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36917. import { Vector3 } from "babylonjs/Maths/math.vector";
  36918. /**
  36919. * 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.
  36920. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36921. */
  36922. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36923. /**
  36924. * Gets the name of the behavior.
  36925. */
  36926. readonly name: string;
  36927. private _mode;
  36928. private _radiusScale;
  36929. private _positionScale;
  36930. private _defaultElevation;
  36931. private _elevationReturnTime;
  36932. private _elevationReturnWaitTime;
  36933. private _zoomStopsAnimation;
  36934. private _framingTime;
  36935. /**
  36936. * The easing function used by animations
  36937. */
  36938. static EasingFunction: ExponentialEase;
  36939. /**
  36940. * The easing mode used by animations
  36941. */
  36942. static EasingMode: number;
  36943. /**
  36944. * Sets the current mode used by the behavior
  36945. */
  36946. /**
  36947. * Gets current mode used by the behavior.
  36948. */
  36949. mode: number;
  36950. /**
  36951. * Sets the scale applied to the radius (1 by default)
  36952. */
  36953. /**
  36954. * Gets the scale applied to the radius
  36955. */
  36956. radiusScale: number;
  36957. /**
  36958. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36959. */
  36960. /**
  36961. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36962. */
  36963. positionScale: number;
  36964. /**
  36965. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36966. * behaviour is triggered, in radians.
  36967. */
  36968. /**
  36969. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36970. * behaviour is triggered, in radians.
  36971. */
  36972. defaultElevation: number;
  36973. /**
  36974. * Sets the time (in milliseconds) taken to return to the default beta position.
  36975. * Negative value indicates camera should not return to default.
  36976. */
  36977. /**
  36978. * Gets the time (in milliseconds) taken to return to the default beta position.
  36979. * Negative value indicates camera should not return to default.
  36980. */
  36981. elevationReturnTime: number;
  36982. /**
  36983. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36984. */
  36985. /**
  36986. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36987. */
  36988. elevationReturnWaitTime: number;
  36989. /**
  36990. * Sets the flag that indicates if user zooming should stop animation.
  36991. */
  36992. /**
  36993. * Gets the flag that indicates if user zooming should stop animation.
  36994. */
  36995. zoomStopsAnimation: boolean;
  36996. /**
  36997. * Sets the transition time when framing the mesh, in milliseconds
  36998. */
  36999. /**
  37000. * Gets the transition time when framing the mesh, in milliseconds
  37001. */
  37002. framingTime: number;
  37003. /**
  37004. * Define if the behavior should automatically change the configured
  37005. * camera limits and sensibilities.
  37006. */
  37007. autoCorrectCameraLimitsAndSensibility: boolean;
  37008. private _onPrePointerObservableObserver;
  37009. private _onAfterCheckInputsObserver;
  37010. private _onMeshTargetChangedObserver;
  37011. private _attachedCamera;
  37012. private _isPointerDown;
  37013. private _lastInteractionTime;
  37014. /**
  37015. * Initializes the behavior.
  37016. */
  37017. init(): void;
  37018. /**
  37019. * Attaches the behavior to its arc rotate camera.
  37020. * @param camera Defines the camera to attach the behavior to
  37021. */
  37022. attach(camera: ArcRotateCamera): void;
  37023. /**
  37024. * Detaches the behavior from its current arc rotate camera.
  37025. */
  37026. detach(): void;
  37027. private _animatables;
  37028. private _betaIsAnimating;
  37029. private _betaTransition;
  37030. private _radiusTransition;
  37031. private _vectorTransition;
  37032. /**
  37033. * Targets the given mesh and updates zoom level accordingly.
  37034. * @param mesh The mesh to target.
  37035. * @param radius Optional. If a cached radius position already exists, overrides default.
  37036. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37037. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37038. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37039. */
  37040. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37041. /**
  37042. * Targets the given mesh with its children and updates zoom level accordingly.
  37043. * @param mesh The mesh to target.
  37044. * @param radius Optional. If a cached radius position already exists, overrides default.
  37045. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37048. */
  37049. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37050. /**
  37051. * Targets the given meshes with their children and updates zoom level accordingly.
  37052. * @param meshes The mesh to target.
  37053. * @param radius Optional. If a cached radius position already exists, overrides default.
  37054. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37055. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37056. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37057. */
  37058. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37059. /**
  37060. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37061. * @param minimumWorld Determines the smaller position of the bounding box extend
  37062. * @param maximumWorld Determines the bigger position of the bounding box extend
  37063. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37064. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37065. */
  37066. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37067. /**
  37068. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37069. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37070. * frustum width.
  37071. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37072. * to fully enclose the mesh in the viewing frustum.
  37073. */
  37074. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37075. /**
  37076. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37077. * is automatically returned to its default position (expected to be above ground plane).
  37078. */
  37079. private _maintainCameraAboveGround;
  37080. /**
  37081. * Returns the frustum slope based on the canvas ratio and camera FOV
  37082. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37083. */
  37084. private _getFrustumSlope;
  37085. /**
  37086. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37087. */
  37088. private _clearAnimationLocks;
  37089. /**
  37090. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37091. */
  37092. private _applyUserInteraction;
  37093. /**
  37094. * Stops and removes all animations that have been applied to the camera
  37095. */
  37096. stopAllAnimations(): void;
  37097. /**
  37098. * Gets a value indicating if the user is moving the camera
  37099. */
  37100. readonly isUserIsMoving: boolean;
  37101. /**
  37102. * The camera can move all the way towards the mesh.
  37103. */
  37104. static IgnoreBoundsSizeMode: number;
  37105. /**
  37106. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37107. */
  37108. static FitFrustumSidesMode: number;
  37109. }
  37110. }
  37111. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37112. import { Nullable } from "babylonjs/types";
  37113. import { Camera } from "babylonjs/Cameras/camera";
  37114. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37115. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37116. /**
  37117. * Base class for Camera Pointer Inputs.
  37118. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37119. * for example usage.
  37120. */
  37121. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37122. /**
  37123. * Defines the camera the input is attached to.
  37124. */
  37125. abstract camera: Camera;
  37126. /**
  37127. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37128. */
  37129. protected _altKey: boolean;
  37130. protected _ctrlKey: boolean;
  37131. protected _metaKey: boolean;
  37132. protected _shiftKey: boolean;
  37133. /**
  37134. * Which mouse buttons were pressed at time of last mouse event.
  37135. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37136. */
  37137. protected _buttonsPressed: number;
  37138. /**
  37139. * Defines the buttons associated with the input to handle camera move.
  37140. */
  37141. buttons: number[];
  37142. /**
  37143. * Attach the input controls to a specific dom element to get the input from.
  37144. * @param element Defines the element the controls should be listened from
  37145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37146. */
  37147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37148. /**
  37149. * Detach the current controls from the specified dom element.
  37150. * @param element Defines the element to stop listening the inputs from
  37151. */
  37152. detachControl(element: Nullable<HTMLElement>): void;
  37153. /**
  37154. * Gets the class name of the current input.
  37155. * @returns the class name
  37156. */
  37157. getClassName(): string;
  37158. /**
  37159. * Get the friendly name associated with the input class.
  37160. * @returns the input friendly name
  37161. */
  37162. getSimpleName(): string;
  37163. /**
  37164. * Called on pointer POINTERDOUBLETAP event.
  37165. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37166. */
  37167. protected onDoubleTap(type: string): void;
  37168. /**
  37169. * Called on pointer POINTERMOVE event if only a single touch is active.
  37170. * Override this method to provide functionality.
  37171. */
  37172. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37173. /**
  37174. * Called on pointer POINTERMOVE event if multiple touches are active.
  37175. * Override this method to provide functionality.
  37176. */
  37177. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37178. /**
  37179. * Called on JS contextmenu event.
  37180. * Override this method to provide functionality.
  37181. */
  37182. protected onContextMenu(evt: PointerEvent): void;
  37183. /**
  37184. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37185. * press.
  37186. * Override this method to provide functionality.
  37187. */
  37188. protected onButtonDown(evt: PointerEvent): void;
  37189. /**
  37190. * Called each time a new POINTERUP event occurs. Ie, for each button
  37191. * release.
  37192. * Override this method to provide functionality.
  37193. */
  37194. protected onButtonUp(evt: PointerEvent): void;
  37195. /**
  37196. * Called when window becomes inactive.
  37197. * Override this method to provide functionality.
  37198. */
  37199. protected onLostFocus(): void;
  37200. private _pointerInput;
  37201. private _observer;
  37202. private _onLostFocus;
  37203. private pointA;
  37204. private pointB;
  37205. }
  37206. }
  37207. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37208. import { Nullable } from "babylonjs/types";
  37209. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37210. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37211. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37212. /**
  37213. * Manage the pointers inputs to control an arc rotate camera.
  37214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37215. */
  37216. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37217. /**
  37218. * Defines the camera the input is attached to.
  37219. */
  37220. camera: ArcRotateCamera;
  37221. /**
  37222. * Gets the class name of the current input.
  37223. * @returns the class name
  37224. */
  37225. getClassName(): string;
  37226. /**
  37227. * Defines the buttons associated with the input to handle camera move.
  37228. */
  37229. buttons: number[];
  37230. /**
  37231. * Defines the pointer angular sensibility along the X axis or how fast is
  37232. * the camera rotating.
  37233. */
  37234. angularSensibilityX: number;
  37235. /**
  37236. * Defines the pointer angular sensibility along the Y axis or how fast is
  37237. * the camera rotating.
  37238. */
  37239. angularSensibilityY: number;
  37240. /**
  37241. * Defines the pointer pinch precision or how fast is the camera zooming.
  37242. */
  37243. pinchPrecision: number;
  37244. /**
  37245. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37246. * from 0.
  37247. * It defines the percentage of current camera.radius to use as delta when
  37248. * pinch zoom is used.
  37249. */
  37250. pinchDeltaPercentage: number;
  37251. /**
  37252. * Defines the pointer panning sensibility or how fast is the camera moving.
  37253. */
  37254. panningSensibility: number;
  37255. /**
  37256. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37257. */
  37258. multiTouchPanning: boolean;
  37259. /**
  37260. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37261. * zoom (pinch) through multitouch.
  37262. */
  37263. multiTouchPanAndZoom: boolean;
  37264. /**
  37265. * Revers pinch action direction.
  37266. */
  37267. pinchInwards: boolean;
  37268. private _isPanClick;
  37269. private _twoFingerActivityCount;
  37270. private _isPinching;
  37271. /**
  37272. * Called on pointer POINTERMOVE event if only a single touch is active.
  37273. */
  37274. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37275. /**
  37276. * Called on pointer POINTERDOUBLETAP event.
  37277. */
  37278. protected onDoubleTap(type: string): void;
  37279. /**
  37280. * Called on pointer POINTERMOVE event if multiple touches are active.
  37281. */
  37282. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37283. /**
  37284. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37285. * press.
  37286. */
  37287. protected onButtonDown(evt: PointerEvent): void;
  37288. /**
  37289. * Called each time a new POINTERUP event occurs. Ie, for each button
  37290. * release.
  37291. */
  37292. protected onButtonUp(evt: PointerEvent): void;
  37293. /**
  37294. * Called when window becomes inactive.
  37295. */
  37296. protected onLostFocus(): void;
  37297. }
  37298. }
  37299. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37300. import { Nullable } from "babylonjs/types";
  37301. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37302. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37303. /**
  37304. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37306. */
  37307. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37308. /**
  37309. * Defines the camera the input is attached to.
  37310. */
  37311. camera: ArcRotateCamera;
  37312. /**
  37313. * Defines the list of key codes associated with the up action (increase alpha)
  37314. */
  37315. keysUp: number[];
  37316. /**
  37317. * Defines the list of key codes associated with the down action (decrease alpha)
  37318. */
  37319. keysDown: number[];
  37320. /**
  37321. * Defines the list of key codes associated with the left action (increase beta)
  37322. */
  37323. keysLeft: number[];
  37324. /**
  37325. * Defines the list of key codes associated with the right action (decrease beta)
  37326. */
  37327. keysRight: number[];
  37328. /**
  37329. * Defines the list of key codes associated with the reset action.
  37330. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37331. */
  37332. keysReset: number[];
  37333. /**
  37334. * Defines the panning sensibility of the inputs.
  37335. * (How fast is the camera paning)
  37336. */
  37337. panningSensibility: number;
  37338. /**
  37339. * Defines the zooming sensibility of the inputs.
  37340. * (How fast is the camera zooming)
  37341. */
  37342. zoomingSensibility: number;
  37343. /**
  37344. * Defines wether maintaining the alt key down switch the movement mode from
  37345. * orientation to zoom.
  37346. */
  37347. useAltToZoom: boolean;
  37348. /**
  37349. * Rotation speed of the camera
  37350. */
  37351. angularSpeed: number;
  37352. private _keys;
  37353. private _ctrlPressed;
  37354. private _altPressed;
  37355. private _onCanvasBlurObserver;
  37356. private _onKeyboardObserver;
  37357. private _engine;
  37358. private _scene;
  37359. /**
  37360. * Attach the input controls to a specific dom element to get the input from.
  37361. * @param element Defines the element the controls should be listened from
  37362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37363. */
  37364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37365. /**
  37366. * Detach the current controls from the specified dom element.
  37367. * @param element Defines the element to stop listening the inputs from
  37368. */
  37369. detachControl(element: Nullable<HTMLElement>): void;
  37370. /**
  37371. * Update the current camera state depending on the inputs that have been used this frame.
  37372. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37373. */
  37374. checkInputs(): void;
  37375. /**
  37376. * Gets the class name of the current intput.
  37377. * @returns the class name
  37378. */
  37379. getClassName(): string;
  37380. /**
  37381. * Get the friendly name associated with the input class.
  37382. * @returns the input friendly name
  37383. */
  37384. getSimpleName(): string;
  37385. }
  37386. }
  37387. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37388. import { Nullable } from "babylonjs/types";
  37389. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37390. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37391. /**
  37392. * Manage the mouse wheel inputs to control an arc rotate camera.
  37393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37394. */
  37395. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37396. /**
  37397. * Defines the camera the input is attached to.
  37398. */
  37399. camera: ArcRotateCamera;
  37400. /**
  37401. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37402. */
  37403. wheelPrecision: number;
  37404. /**
  37405. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37406. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37407. */
  37408. wheelDeltaPercentage: number;
  37409. private _wheel;
  37410. private _observer;
  37411. private computeDeltaFromMouseWheelLegacyEvent;
  37412. /**
  37413. * Attach the input controls to a specific dom element to get the input from.
  37414. * @param element Defines the element the controls should be listened from
  37415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37416. */
  37417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37418. /**
  37419. * Detach the current controls from the specified dom element.
  37420. * @param element Defines the element to stop listening the inputs from
  37421. */
  37422. detachControl(element: Nullable<HTMLElement>): void;
  37423. /**
  37424. * Gets the class name of the current intput.
  37425. * @returns the class name
  37426. */
  37427. getClassName(): string;
  37428. /**
  37429. * Get the friendly name associated with the input class.
  37430. * @returns the input friendly name
  37431. */
  37432. getSimpleName(): string;
  37433. }
  37434. }
  37435. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37436. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37437. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37438. /**
  37439. * Default Inputs manager for the ArcRotateCamera.
  37440. * It groups all the default supported inputs for ease of use.
  37441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37442. */
  37443. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37444. /**
  37445. * Instantiates a new ArcRotateCameraInputsManager.
  37446. * @param camera Defines the camera the inputs belong to
  37447. */
  37448. constructor(camera: ArcRotateCamera);
  37449. /**
  37450. * Add mouse wheel input support to the input manager.
  37451. * @returns the current input manager
  37452. */
  37453. addMouseWheel(): ArcRotateCameraInputsManager;
  37454. /**
  37455. * Add pointers input support to the input manager.
  37456. * @returns the current input manager
  37457. */
  37458. addPointers(): ArcRotateCameraInputsManager;
  37459. /**
  37460. * Add keyboard input support to the input manager.
  37461. * @returns the current input manager
  37462. */
  37463. addKeyboard(): ArcRotateCameraInputsManager;
  37464. }
  37465. }
  37466. declare module "babylonjs/Cameras/arcRotateCamera" {
  37467. import { Observable } from "babylonjs/Misc/observable";
  37468. import { Nullable } from "babylonjs/types";
  37469. import { Scene } from "babylonjs/scene";
  37470. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37472. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37473. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37474. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37475. import { Camera } from "babylonjs/Cameras/camera";
  37476. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37477. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37478. import { Collider } from "babylonjs/Collisions/collider";
  37479. /**
  37480. * This represents an orbital type of camera.
  37481. *
  37482. * 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.
  37483. * 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.
  37484. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37485. */
  37486. export class ArcRotateCamera extends TargetCamera {
  37487. /**
  37488. * Defines the rotation angle of the camera along the longitudinal axis.
  37489. */
  37490. alpha: number;
  37491. /**
  37492. * Defines the rotation angle of the camera along the latitudinal axis.
  37493. */
  37494. beta: number;
  37495. /**
  37496. * Defines the radius of the camera from it s target point.
  37497. */
  37498. radius: number;
  37499. protected _target: Vector3;
  37500. protected _targetHost: Nullable<AbstractMesh>;
  37501. /**
  37502. * Defines the target point of the camera.
  37503. * The camera looks towards it form the radius distance.
  37504. */
  37505. target: Vector3;
  37506. /**
  37507. * Define the current local position of the camera in the scene
  37508. */
  37509. position: Vector3;
  37510. protected _upVector: Vector3;
  37511. protected _upToYMatrix: Matrix;
  37512. protected _YToUpMatrix: Matrix;
  37513. /**
  37514. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37515. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37516. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37517. */
  37518. upVector: Vector3;
  37519. /**
  37520. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37521. */
  37522. setMatUp(): void;
  37523. /**
  37524. * Current inertia value on the longitudinal axis.
  37525. * The bigger this number the longer it will take for the camera to stop.
  37526. */
  37527. inertialAlphaOffset: number;
  37528. /**
  37529. * Current inertia value on the latitudinal axis.
  37530. * The bigger this number the longer it will take for the camera to stop.
  37531. */
  37532. inertialBetaOffset: number;
  37533. /**
  37534. * Current inertia value on the radius axis.
  37535. * The bigger this number the longer it will take for the camera to stop.
  37536. */
  37537. inertialRadiusOffset: number;
  37538. /**
  37539. * Minimum allowed angle on the longitudinal axis.
  37540. * This can help limiting how the Camera is able to move in the scene.
  37541. */
  37542. lowerAlphaLimit: Nullable<number>;
  37543. /**
  37544. * Maximum allowed angle on the longitudinal axis.
  37545. * This can help limiting how the Camera is able to move in the scene.
  37546. */
  37547. upperAlphaLimit: Nullable<number>;
  37548. /**
  37549. * Minimum allowed angle on the latitudinal axis.
  37550. * This can help limiting how the Camera is able to move in the scene.
  37551. */
  37552. lowerBetaLimit: number;
  37553. /**
  37554. * Maximum allowed angle on the latitudinal axis.
  37555. * This can help limiting how the Camera is able to move in the scene.
  37556. */
  37557. upperBetaLimit: number;
  37558. /**
  37559. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37560. * This can help limiting how the Camera is able to move in the scene.
  37561. */
  37562. lowerRadiusLimit: Nullable<number>;
  37563. /**
  37564. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37565. * This can help limiting how the Camera is able to move in the scene.
  37566. */
  37567. upperRadiusLimit: Nullable<number>;
  37568. /**
  37569. * Defines the current inertia value used during panning of the camera along the X axis.
  37570. */
  37571. inertialPanningX: number;
  37572. /**
  37573. * Defines the current inertia value used during panning of the camera along the Y axis.
  37574. */
  37575. inertialPanningY: number;
  37576. /**
  37577. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37578. * Basically if your fingers moves away from more than this distance you will be considered
  37579. * in pinch mode.
  37580. */
  37581. pinchToPanMaxDistance: number;
  37582. /**
  37583. * Defines the maximum distance the camera can pan.
  37584. * This could help keeping the cammera always in your scene.
  37585. */
  37586. panningDistanceLimit: Nullable<number>;
  37587. /**
  37588. * Defines the target of the camera before paning.
  37589. */
  37590. panningOriginTarget: Vector3;
  37591. /**
  37592. * Defines the value of the inertia used during panning.
  37593. * 0 would mean stop inertia and one would mean no decelleration at all.
  37594. */
  37595. panningInertia: number;
  37596. /**
  37597. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37598. */
  37599. angularSensibilityX: number;
  37600. /**
  37601. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37602. */
  37603. angularSensibilityY: number;
  37604. /**
  37605. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37606. */
  37607. pinchPrecision: number;
  37608. /**
  37609. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37610. * It will be used instead of pinchDeltaPrecision if different from 0.
  37611. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37612. */
  37613. pinchDeltaPercentage: number;
  37614. /**
  37615. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37616. */
  37617. panningSensibility: number;
  37618. /**
  37619. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37620. */
  37621. keysUp: number[];
  37622. /**
  37623. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37624. */
  37625. keysDown: number[];
  37626. /**
  37627. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37628. */
  37629. keysLeft: number[];
  37630. /**
  37631. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37632. */
  37633. keysRight: number[];
  37634. /**
  37635. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37636. */
  37637. wheelPrecision: number;
  37638. /**
  37639. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37640. * It will be used instead of pinchDeltaPrecision if different from 0.
  37641. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37642. */
  37643. wheelDeltaPercentage: number;
  37644. /**
  37645. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37646. */
  37647. zoomOnFactor: number;
  37648. /**
  37649. * Defines a screen offset for the camera position.
  37650. */
  37651. targetScreenOffset: Vector2;
  37652. /**
  37653. * Allows the camera to be completely reversed.
  37654. * If false the camera can not arrive upside down.
  37655. */
  37656. allowUpsideDown: boolean;
  37657. /**
  37658. * Define if double tap/click is used to restore the previously saved state of the camera.
  37659. */
  37660. useInputToRestoreState: boolean;
  37661. /** @hidden */
  37662. _viewMatrix: Matrix;
  37663. /** @hidden */
  37664. _useCtrlForPanning: boolean;
  37665. /** @hidden */
  37666. _panningMouseButton: number;
  37667. /**
  37668. * Defines the input associated to the camera.
  37669. */
  37670. inputs: ArcRotateCameraInputsManager;
  37671. /** @hidden */
  37672. _reset: () => void;
  37673. /**
  37674. * Defines the allowed panning axis.
  37675. */
  37676. panningAxis: Vector3;
  37677. protected _localDirection: Vector3;
  37678. protected _transformedDirection: Vector3;
  37679. private _bouncingBehavior;
  37680. /**
  37681. * Gets the bouncing behavior of the camera if it has been enabled.
  37682. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37683. */
  37684. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37685. /**
  37686. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37687. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37688. */
  37689. useBouncingBehavior: boolean;
  37690. private _framingBehavior;
  37691. /**
  37692. * Gets the framing behavior of the camera if it has been enabled.
  37693. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37694. */
  37695. readonly framingBehavior: Nullable<FramingBehavior>;
  37696. /**
  37697. * Defines if the framing behavior of the camera is enabled on the camera.
  37698. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37699. */
  37700. useFramingBehavior: boolean;
  37701. private _autoRotationBehavior;
  37702. /**
  37703. * Gets the auto rotation behavior of the camera if it has been enabled.
  37704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37705. */
  37706. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37707. /**
  37708. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37709. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37710. */
  37711. useAutoRotationBehavior: boolean;
  37712. /**
  37713. * Observable triggered when the mesh target has been changed on the camera.
  37714. */
  37715. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37716. /**
  37717. * Event raised when the camera is colliding with a mesh.
  37718. */
  37719. onCollide: (collidedMesh: AbstractMesh) => void;
  37720. /**
  37721. * Defines whether the camera should check collision with the objects oh the scene.
  37722. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37723. */
  37724. checkCollisions: boolean;
  37725. /**
  37726. * Defines the collision radius of the camera.
  37727. * This simulates a sphere around the camera.
  37728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37729. */
  37730. collisionRadius: Vector3;
  37731. protected _collider: Collider;
  37732. protected _previousPosition: Vector3;
  37733. protected _collisionVelocity: Vector3;
  37734. protected _newPosition: Vector3;
  37735. protected _previousAlpha: number;
  37736. protected _previousBeta: number;
  37737. protected _previousRadius: number;
  37738. protected _collisionTriggered: boolean;
  37739. protected _targetBoundingCenter: Nullable<Vector3>;
  37740. private _computationVector;
  37741. /**
  37742. * Instantiates a new ArcRotateCamera in a given scene
  37743. * @param name Defines the name of the camera
  37744. * @param alpha Defines the camera rotation along the logitudinal axis
  37745. * @param beta Defines the camera rotation along the latitudinal axis
  37746. * @param radius Defines the camera distance from its target
  37747. * @param target Defines the camera target
  37748. * @param scene Defines the scene the camera belongs to
  37749. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37750. */
  37751. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37752. /** @hidden */
  37753. _initCache(): void;
  37754. /** @hidden */
  37755. _updateCache(ignoreParentClass?: boolean): void;
  37756. protected _getTargetPosition(): Vector3;
  37757. private _storedAlpha;
  37758. private _storedBeta;
  37759. private _storedRadius;
  37760. private _storedTarget;
  37761. private _storedTargetScreenOffset;
  37762. /**
  37763. * Stores the current state of the camera (alpha, beta, radius and target)
  37764. * @returns the camera itself
  37765. */
  37766. storeState(): Camera;
  37767. /**
  37768. * @hidden
  37769. * Restored camera state. You must call storeState() first
  37770. */
  37771. _restoreStateValues(): boolean;
  37772. /** @hidden */
  37773. _isSynchronizedViewMatrix(): boolean;
  37774. /**
  37775. * Attached controls to the current camera.
  37776. * @param element Defines the element the controls should be listened from
  37777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37778. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37779. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37780. */
  37781. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37782. /**
  37783. * Detach the current controls from the camera.
  37784. * The camera will stop reacting to inputs.
  37785. * @param element Defines the element to stop listening the inputs from
  37786. */
  37787. detachControl(element: HTMLElement): void;
  37788. /** @hidden */
  37789. _checkInputs(): void;
  37790. protected _checkLimits(): void;
  37791. /**
  37792. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37793. */
  37794. rebuildAnglesAndRadius(): void;
  37795. /**
  37796. * Use a position to define the current camera related information like alpha, beta and radius
  37797. * @param position Defines the position to set the camera at
  37798. */
  37799. setPosition(position: Vector3): void;
  37800. /**
  37801. * Defines the target the camera should look at.
  37802. * This will automatically adapt alpha beta and radius to fit within the new target.
  37803. * @param target Defines the new target as a Vector or a mesh
  37804. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37805. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37806. */
  37807. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37808. /** @hidden */
  37809. _getViewMatrix(): Matrix;
  37810. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37811. /**
  37812. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37813. * @param meshes Defines the mesh to zoom on
  37814. * @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)
  37815. */
  37816. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37817. /**
  37818. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37819. * The target will be changed but the radius
  37820. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37821. * @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)
  37822. */
  37823. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37824. min: Vector3;
  37825. max: Vector3;
  37826. distance: number;
  37827. }, doNotUpdateMaxZ?: boolean): void;
  37828. /**
  37829. * @override
  37830. * Override Camera.createRigCamera
  37831. */
  37832. createRigCamera(name: string, cameraIndex: number): Camera;
  37833. /**
  37834. * @hidden
  37835. * @override
  37836. * Override Camera._updateRigCameras
  37837. */
  37838. _updateRigCameras(): void;
  37839. /**
  37840. * Destroy the camera and release the current resources hold by it.
  37841. */
  37842. dispose(): void;
  37843. /**
  37844. * Gets the current object class name.
  37845. * @return the class name
  37846. */
  37847. getClassName(): string;
  37848. }
  37849. }
  37850. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37851. import { Behavior } from "babylonjs/Behaviors/behavior";
  37852. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37853. /**
  37854. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37855. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37856. */
  37857. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37858. /**
  37859. * Gets the name of the behavior.
  37860. */
  37861. readonly name: string;
  37862. private _zoomStopsAnimation;
  37863. private _idleRotationSpeed;
  37864. private _idleRotationWaitTime;
  37865. private _idleRotationSpinupTime;
  37866. /**
  37867. * Sets the flag that indicates if user zooming should stop animation.
  37868. */
  37869. /**
  37870. * Gets the flag that indicates if user zooming should stop animation.
  37871. */
  37872. zoomStopsAnimation: boolean;
  37873. /**
  37874. * Sets the default speed at which the camera rotates around the model.
  37875. */
  37876. /**
  37877. * Gets the default speed at which the camera rotates around the model.
  37878. */
  37879. idleRotationSpeed: number;
  37880. /**
  37881. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37882. */
  37883. /**
  37884. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37885. */
  37886. idleRotationWaitTime: number;
  37887. /**
  37888. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37889. */
  37890. /**
  37891. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37892. */
  37893. idleRotationSpinupTime: number;
  37894. /**
  37895. * Gets a value indicating if the camera is currently rotating because of this behavior
  37896. */
  37897. readonly rotationInProgress: boolean;
  37898. private _onPrePointerObservableObserver;
  37899. private _onAfterCheckInputsObserver;
  37900. private _attachedCamera;
  37901. private _isPointerDown;
  37902. private _lastFrameTime;
  37903. private _lastInteractionTime;
  37904. private _cameraRotationSpeed;
  37905. /**
  37906. * Initializes the behavior.
  37907. */
  37908. init(): void;
  37909. /**
  37910. * Attaches the behavior to its arc rotate camera.
  37911. * @param camera Defines the camera to attach the behavior to
  37912. */
  37913. attach(camera: ArcRotateCamera): void;
  37914. /**
  37915. * Detaches the behavior from its current arc rotate camera.
  37916. */
  37917. detach(): void;
  37918. /**
  37919. * Returns true if user is scrolling.
  37920. * @return true if user is scrolling.
  37921. */
  37922. private _userIsZooming;
  37923. private _lastFrameRadius;
  37924. private _shouldAnimationStopForInteraction;
  37925. /**
  37926. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37927. */
  37928. private _applyUserInteraction;
  37929. private _userIsMoving;
  37930. }
  37931. }
  37932. declare module "babylonjs/Behaviors/Cameras/index" {
  37933. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37934. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37935. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37936. }
  37937. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37938. import { Mesh } from "babylonjs/Meshes/mesh";
  37939. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37940. import { Behavior } from "babylonjs/Behaviors/behavior";
  37941. /**
  37942. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37943. */
  37944. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37945. private ui;
  37946. /**
  37947. * The name of the behavior
  37948. */
  37949. name: string;
  37950. /**
  37951. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37952. */
  37953. distanceAwayFromFace: number;
  37954. /**
  37955. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37956. */
  37957. distanceAwayFromBottomOfFace: number;
  37958. private _faceVectors;
  37959. private _target;
  37960. private _scene;
  37961. private _onRenderObserver;
  37962. private _tmpMatrix;
  37963. private _tmpVector;
  37964. /**
  37965. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37966. * @param ui The transform node that should be attched to the mesh
  37967. */
  37968. constructor(ui: TransformNode);
  37969. /**
  37970. * Initializes the behavior
  37971. */
  37972. init(): void;
  37973. private _closestFace;
  37974. private _zeroVector;
  37975. private _lookAtTmpMatrix;
  37976. private _lookAtToRef;
  37977. /**
  37978. * Attaches the AttachToBoxBehavior to the passed in mesh
  37979. * @param target The mesh that the specified node will be attached to
  37980. */
  37981. attach(target: Mesh): void;
  37982. /**
  37983. * Detaches the behavior from the mesh
  37984. */
  37985. detach(): void;
  37986. }
  37987. }
  37988. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37989. import { Behavior } from "babylonjs/Behaviors/behavior";
  37990. import { Mesh } from "babylonjs/Meshes/mesh";
  37991. /**
  37992. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37993. */
  37994. export class FadeInOutBehavior implements Behavior<Mesh> {
  37995. /**
  37996. * Time in milliseconds to delay before fading in (Default: 0)
  37997. */
  37998. delay: number;
  37999. /**
  38000. * Time in milliseconds for the mesh to fade in (Default: 300)
  38001. */
  38002. fadeInTime: number;
  38003. private _millisecondsPerFrame;
  38004. private _hovered;
  38005. private _hoverValue;
  38006. private _ownerNode;
  38007. /**
  38008. * Instatiates the FadeInOutBehavior
  38009. */
  38010. constructor();
  38011. /**
  38012. * The name of the behavior
  38013. */
  38014. readonly name: string;
  38015. /**
  38016. * Initializes the behavior
  38017. */
  38018. init(): void;
  38019. /**
  38020. * Attaches the fade behavior on the passed in mesh
  38021. * @param ownerNode The mesh that will be faded in/out once attached
  38022. */
  38023. attach(ownerNode: Mesh): void;
  38024. /**
  38025. * Detaches the behavior from the mesh
  38026. */
  38027. detach(): void;
  38028. /**
  38029. * Triggers the mesh to begin fading in or out
  38030. * @param value if the object should fade in or out (true to fade in)
  38031. */
  38032. fadeIn(value: boolean): void;
  38033. private _update;
  38034. private _setAllVisibility;
  38035. }
  38036. }
  38037. declare module "babylonjs/Misc/pivotTools" {
  38038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38039. /**
  38040. * Class containing a set of static utilities functions for managing Pivots
  38041. * @hidden
  38042. */
  38043. export class PivotTools {
  38044. private static _PivotCached;
  38045. private static _OldPivotPoint;
  38046. private static _PivotTranslation;
  38047. private static _PivotTmpVector;
  38048. /** @hidden */
  38049. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38050. /** @hidden */
  38051. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38052. }
  38053. }
  38054. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38055. import { Scene } from "babylonjs/scene";
  38056. import { Vector4 } from "babylonjs/Maths/math.vector";
  38057. import { Mesh } from "babylonjs/Meshes/mesh";
  38058. import { Nullable } from "babylonjs/types";
  38059. import { Plane } from "babylonjs/Maths/math.plane";
  38060. /**
  38061. * Class containing static functions to help procedurally build meshes
  38062. */
  38063. export class PlaneBuilder {
  38064. /**
  38065. * Creates a plane mesh
  38066. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38067. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38068. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38072. * @param name defines the name of the mesh
  38073. * @param options defines the options used to create the mesh
  38074. * @param scene defines the hosting scene
  38075. * @returns the plane mesh
  38076. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38077. */
  38078. static CreatePlane(name: string, options: {
  38079. size?: number;
  38080. width?: number;
  38081. height?: number;
  38082. sideOrientation?: number;
  38083. frontUVs?: Vector4;
  38084. backUVs?: Vector4;
  38085. updatable?: boolean;
  38086. sourcePlane?: Plane;
  38087. }, scene?: Nullable<Scene>): Mesh;
  38088. }
  38089. }
  38090. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38091. import { Behavior } from "babylonjs/Behaviors/behavior";
  38092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38093. import { Observable } from "babylonjs/Misc/observable";
  38094. import { Vector3 } from "babylonjs/Maths/math.vector";
  38095. import { Ray } from "babylonjs/Culling/ray";
  38096. import "babylonjs/Meshes/Builders/planeBuilder";
  38097. /**
  38098. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38099. */
  38100. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38101. private static _AnyMouseID;
  38102. /**
  38103. * Abstract mesh the behavior is set on
  38104. */
  38105. attachedNode: AbstractMesh;
  38106. private _dragPlane;
  38107. private _scene;
  38108. private _pointerObserver;
  38109. private _beforeRenderObserver;
  38110. private static _planeScene;
  38111. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38112. /**
  38113. * 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)
  38114. */
  38115. maxDragAngle: number;
  38116. /**
  38117. * @hidden
  38118. */
  38119. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38120. /**
  38121. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38122. */
  38123. currentDraggingPointerID: number;
  38124. /**
  38125. * The last position where the pointer hit the drag plane in world space
  38126. */
  38127. lastDragPosition: Vector3;
  38128. /**
  38129. * If the behavior is currently in a dragging state
  38130. */
  38131. dragging: boolean;
  38132. /**
  38133. * 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)
  38134. */
  38135. dragDeltaRatio: number;
  38136. /**
  38137. * If the drag plane orientation should be updated during the dragging (Default: true)
  38138. */
  38139. updateDragPlane: boolean;
  38140. private _debugMode;
  38141. private _moving;
  38142. /**
  38143. * Fires each time the attached mesh is dragged with the pointer
  38144. * * delta between last drag position and current drag position in world space
  38145. * * dragDistance along the drag axis
  38146. * * dragPlaneNormal normal of the current drag plane used during the drag
  38147. * * dragPlanePoint in world space where the drag intersects the drag plane
  38148. */
  38149. onDragObservable: Observable<{
  38150. delta: Vector3;
  38151. dragPlanePoint: Vector3;
  38152. dragPlaneNormal: Vector3;
  38153. dragDistance: number;
  38154. pointerId: number;
  38155. }>;
  38156. /**
  38157. * Fires each time a drag begins (eg. mouse down on mesh)
  38158. */
  38159. onDragStartObservable: Observable<{
  38160. dragPlanePoint: Vector3;
  38161. pointerId: number;
  38162. }>;
  38163. /**
  38164. * Fires each time a drag ends (eg. mouse release after drag)
  38165. */
  38166. onDragEndObservable: Observable<{
  38167. dragPlanePoint: Vector3;
  38168. pointerId: number;
  38169. }>;
  38170. /**
  38171. * If the attached mesh should be moved when dragged
  38172. */
  38173. moveAttached: boolean;
  38174. /**
  38175. * If the drag behavior will react to drag events (Default: true)
  38176. */
  38177. enabled: boolean;
  38178. /**
  38179. * If pointer events should start and release the drag (Default: true)
  38180. */
  38181. startAndReleaseDragOnPointerEvents: boolean;
  38182. /**
  38183. * If camera controls should be detached during the drag
  38184. */
  38185. detachCameraControls: boolean;
  38186. /**
  38187. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38188. */
  38189. useObjectOrienationForDragging: boolean;
  38190. private _options;
  38191. /**
  38192. * Creates a pointer drag behavior that can be attached to a mesh
  38193. * @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)
  38194. */
  38195. constructor(options?: {
  38196. dragAxis?: Vector3;
  38197. dragPlaneNormal?: Vector3;
  38198. });
  38199. /**
  38200. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38201. */
  38202. validateDrag: (targetPosition: Vector3) => boolean;
  38203. /**
  38204. * The name of the behavior
  38205. */
  38206. readonly name: string;
  38207. /**
  38208. * Initializes the behavior
  38209. */
  38210. init(): void;
  38211. private _tmpVector;
  38212. private _alternatePickedPoint;
  38213. private _worldDragAxis;
  38214. private _targetPosition;
  38215. private _attachedElement;
  38216. /**
  38217. * Attaches the drag behavior the passed in mesh
  38218. * @param ownerNode The mesh that will be dragged around once attached
  38219. * @param predicate Predicate to use for pick filtering
  38220. */
  38221. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38222. /**
  38223. * Force relase the drag action by code.
  38224. */
  38225. releaseDrag(): void;
  38226. private _startDragRay;
  38227. private _lastPointerRay;
  38228. /**
  38229. * Simulates the start of a pointer drag event on the behavior
  38230. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38231. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38232. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38233. */
  38234. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38235. private _startDrag;
  38236. private _dragDelta;
  38237. private _moveDrag;
  38238. private _pickWithRayOnDragPlane;
  38239. private _pointA;
  38240. private _pointB;
  38241. private _pointC;
  38242. private _lineA;
  38243. private _lineB;
  38244. private _localAxis;
  38245. private _lookAt;
  38246. private _updateDragPlanePosition;
  38247. /**
  38248. * Detaches the behavior from the mesh
  38249. */
  38250. detach(): void;
  38251. }
  38252. }
  38253. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38254. import { Mesh } from "babylonjs/Meshes/mesh";
  38255. import { Behavior } from "babylonjs/Behaviors/behavior";
  38256. /**
  38257. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38258. */
  38259. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38260. private _dragBehaviorA;
  38261. private _dragBehaviorB;
  38262. private _startDistance;
  38263. private _initialScale;
  38264. private _targetScale;
  38265. private _ownerNode;
  38266. private _sceneRenderObserver;
  38267. /**
  38268. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38269. */
  38270. constructor();
  38271. /**
  38272. * The name of the behavior
  38273. */
  38274. readonly name: string;
  38275. /**
  38276. * Initializes the behavior
  38277. */
  38278. init(): void;
  38279. private _getCurrentDistance;
  38280. /**
  38281. * Attaches the scale behavior the passed in mesh
  38282. * @param ownerNode The mesh that will be scaled around once attached
  38283. */
  38284. attach(ownerNode: Mesh): void;
  38285. /**
  38286. * Detaches the behavior from the mesh
  38287. */
  38288. detach(): void;
  38289. }
  38290. }
  38291. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38292. import { Behavior } from "babylonjs/Behaviors/behavior";
  38293. import { Mesh } from "babylonjs/Meshes/mesh";
  38294. import { Observable } from "babylonjs/Misc/observable";
  38295. /**
  38296. * 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
  38297. */
  38298. export class SixDofDragBehavior implements Behavior<Mesh> {
  38299. private static _virtualScene;
  38300. private _ownerNode;
  38301. private _sceneRenderObserver;
  38302. private _scene;
  38303. private _targetPosition;
  38304. private _virtualOriginMesh;
  38305. private _virtualDragMesh;
  38306. private _pointerObserver;
  38307. private _moving;
  38308. private _startingOrientation;
  38309. /**
  38310. * 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)
  38311. */
  38312. private zDragFactor;
  38313. /**
  38314. * If the object should rotate to face the drag origin
  38315. */
  38316. rotateDraggedObject: boolean;
  38317. /**
  38318. * If the behavior is currently in a dragging state
  38319. */
  38320. dragging: boolean;
  38321. /**
  38322. * 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)
  38323. */
  38324. dragDeltaRatio: number;
  38325. /**
  38326. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38327. */
  38328. currentDraggingPointerID: number;
  38329. /**
  38330. * If camera controls should be detached during the drag
  38331. */
  38332. detachCameraControls: boolean;
  38333. /**
  38334. * Fires each time a drag starts
  38335. */
  38336. onDragStartObservable: Observable<{}>;
  38337. /**
  38338. * Fires each time a drag ends (eg. mouse release after drag)
  38339. */
  38340. onDragEndObservable: Observable<{}>;
  38341. /**
  38342. * 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
  38343. */
  38344. constructor();
  38345. /**
  38346. * The name of the behavior
  38347. */
  38348. readonly name: string;
  38349. /**
  38350. * Initializes the behavior
  38351. */
  38352. init(): void;
  38353. /**
  38354. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38355. */
  38356. private readonly _pointerCamera;
  38357. /**
  38358. * Attaches the scale behavior the passed in mesh
  38359. * @param ownerNode The mesh that will be scaled around once attached
  38360. */
  38361. attach(ownerNode: Mesh): void;
  38362. /**
  38363. * Detaches the behavior from the mesh
  38364. */
  38365. detach(): void;
  38366. }
  38367. }
  38368. declare module "babylonjs/Behaviors/Meshes/index" {
  38369. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38370. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38371. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38372. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38373. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38374. }
  38375. declare module "babylonjs/Behaviors/index" {
  38376. export * from "babylonjs/Behaviors/behavior";
  38377. export * from "babylonjs/Behaviors/Cameras/index";
  38378. export * from "babylonjs/Behaviors/Meshes/index";
  38379. }
  38380. declare module "babylonjs/Bones/boneIKController" {
  38381. import { Bone } from "babylonjs/Bones/bone";
  38382. import { Vector3 } from "babylonjs/Maths/math.vector";
  38383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38384. import { Nullable } from "babylonjs/types";
  38385. /**
  38386. * Class used to apply inverse kinematics to bones
  38387. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38388. */
  38389. export class BoneIKController {
  38390. private static _tmpVecs;
  38391. private static _tmpQuat;
  38392. private static _tmpMats;
  38393. /**
  38394. * Gets or sets the target mesh
  38395. */
  38396. targetMesh: AbstractMesh;
  38397. /** Gets or sets the mesh used as pole */
  38398. poleTargetMesh: AbstractMesh;
  38399. /**
  38400. * Gets or sets the bone used as pole
  38401. */
  38402. poleTargetBone: Nullable<Bone>;
  38403. /**
  38404. * Gets or sets the target position
  38405. */
  38406. targetPosition: Vector3;
  38407. /**
  38408. * Gets or sets the pole target position
  38409. */
  38410. poleTargetPosition: Vector3;
  38411. /**
  38412. * Gets or sets the pole target local offset
  38413. */
  38414. poleTargetLocalOffset: Vector3;
  38415. /**
  38416. * Gets or sets the pole angle
  38417. */
  38418. poleAngle: number;
  38419. /**
  38420. * Gets or sets the mesh associated with the controller
  38421. */
  38422. mesh: AbstractMesh;
  38423. /**
  38424. * 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)
  38425. */
  38426. slerpAmount: number;
  38427. private _bone1Quat;
  38428. private _bone1Mat;
  38429. private _bone2Ang;
  38430. private _bone1;
  38431. private _bone2;
  38432. private _bone1Length;
  38433. private _bone2Length;
  38434. private _maxAngle;
  38435. private _maxReach;
  38436. private _rightHandedSystem;
  38437. private _bendAxis;
  38438. private _slerping;
  38439. private _adjustRoll;
  38440. /**
  38441. * Gets or sets maximum allowed angle
  38442. */
  38443. maxAngle: number;
  38444. /**
  38445. * Creates a new BoneIKController
  38446. * @param mesh defines the mesh to control
  38447. * @param bone defines the bone to control
  38448. * @param options defines options to set up the controller
  38449. */
  38450. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38451. targetMesh?: AbstractMesh;
  38452. poleTargetMesh?: AbstractMesh;
  38453. poleTargetBone?: Bone;
  38454. poleTargetLocalOffset?: Vector3;
  38455. poleAngle?: number;
  38456. bendAxis?: Vector3;
  38457. maxAngle?: number;
  38458. slerpAmount?: number;
  38459. });
  38460. private _setMaxAngle;
  38461. /**
  38462. * Force the controller to update the bones
  38463. */
  38464. update(): void;
  38465. }
  38466. }
  38467. declare module "babylonjs/Bones/boneLookController" {
  38468. import { Vector3 } from "babylonjs/Maths/math.vector";
  38469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38470. import { Bone } from "babylonjs/Bones/bone";
  38471. import { Space } from "babylonjs/Maths/math.axis";
  38472. /**
  38473. * Class used to make a bone look toward a point in space
  38474. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38475. */
  38476. export class BoneLookController {
  38477. private static _tmpVecs;
  38478. private static _tmpQuat;
  38479. private static _tmpMats;
  38480. /**
  38481. * The target Vector3 that the bone will look at
  38482. */
  38483. target: Vector3;
  38484. /**
  38485. * The mesh that the bone is attached to
  38486. */
  38487. mesh: AbstractMesh;
  38488. /**
  38489. * The bone that will be looking to the target
  38490. */
  38491. bone: Bone;
  38492. /**
  38493. * The up axis of the coordinate system that is used when the bone is rotated
  38494. */
  38495. upAxis: Vector3;
  38496. /**
  38497. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38498. */
  38499. upAxisSpace: Space;
  38500. /**
  38501. * Used to make an adjustment to the yaw of the bone
  38502. */
  38503. adjustYaw: number;
  38504. /**
  38505. * Used to make an adjustment to the pitch of the bone
  38506. */
  38507. adjustPitch: number;
  38508. /**
  38509. * Used to make an adjustment to the roll of the bone
  38510. */
  38511. adjustRoll: number;
  38512. /**
  38513. * 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)
  38514. */
  38515. slerpAmount: number;
  38516. private _minYaw;
  38517. private _maxYaw;
  38518. private _minPitch;
  38519. private _maxPitch;
  38520. private _minYawSin;
  38521. private _minYawCos;
  38522. private _maxYawSin;
  38523. private _maxYawCos;
  38524. private _midYawConstraint;
  38525. private _minPitchTan;
  38526. private _maxPitchTan;
  38527. private _boneQuat;
  38528. private _slerping;
  38529. private _transformYawPitch;
  38530. private _transformYawPitchInv;
  38531. private _firstFrameSkipped;
  38532. private _yawRange;
  38533. private _fowardAxis;
  38534. /**
  38535. * Gets or sets the minimum yaw angle that the bone can look to
  38536. */
  38537. minYaw: number;
  38538. /**
  38539. * Gets or sets the maximum yaw angle that the bone can look to
  38540. */
  38541. maxYaw: number;
  38542. /**
  38543. * Gets or sets the minimum pitch angle that the bone can look to
  38544. */
  38545. minPitch: number;
  38546. /**
  38547. * Gets or sets the maximum pitch angle that the bone can look to
  38548. */
  38549. maxPitch: number;
  38550. /**
  38551. * Create a BoneLookController
  38552. * @param mesh the mesh that the bone belongs to
  38553. * @param bone the bone that will be looking to the target
  38554. * @param target the target Vector3 to look at
  38555. * @param options optional settings:
  38556. * * maxYaw: the maximum angle the bone will yaw to
  38557. * * minYaw: the minimum angle the bone will yaw to
  38558. * * maxPitch: the maximum angle the bone will pitch to
  38559. * * minPitch: the minimum angle the bone will yaw to
  38560. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38561. * * upAxis: the up axis of the coordinate system
  38562. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38563. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38564. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38565. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38566. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38567. * * adjustRoll: used to make an adjustment to the roll of the bone
  38568. **/
  38569. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38570. maxYaw?: number;
  38571. minYaw?: number;
  38572. maxPitch?: number;
  38573. minPitch?: number;
  38574. slerpAmount?: number;
  38575. upAxis?: Vector3;
  38576. upAxisSpace?: Space;
  38577. yawAxis?: Vector3;
  38578. pitchAxis?: Vector3;
  38579. adjustYaw?: number;
  38580. adjustPitch?: number;
  38581. adjustRoll?: number;
  38582. });
  38583. /**
  38584. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38585. */
  38586. update(): void;
  38587. private _getAngleDiff;
  38588. private _getAngleBetween;
  38589. private _isAngleBetween;
  38590. }
  38591. }
  38592. declare module "babylonjs/Bones/index" {
  38593. export * from "babylonjs/Bones/bone";
  38594. export * from "babylonjs/Bones/boneIKController";
  38595. export * from "babylonjs/Bones/boneLookController";
  38596. export * from "babylonjs/Bones/skeleton";
  38597. }
  38598. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38599. import { Nullable } from "babylonjs/types";
  38600. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38601. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38602. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38603. /**
  38604. * Manage the gamepad inputs to control an arc rotate camera.
  38605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38606. */
  38607. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38608. /**
  38609. * Defines the camera the input is attached to.
  38610. */
  38611. camera: ArcRotateCamera;
  38612. /**
  38613. * Defines the gamepad the input is gathering event from.
  38614. */
  38615. gamepad: Nullable<Gamepad>;
  38616. /**
  38617. * Defines the gamepad rotation sensiblity.
  38618. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38619. */
  38620. gamepadRotationSensibility: number;
  38621. /**
  38622. * Defines the gamepad move sensiblity.
  38623. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38624. */
  38625. gamepadMoveSensibility: number;
  38626. private _yAxisScale;
  38627. /**
  38628. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38629. */
  38630. invertYAxis: boolean;
  38631. private _onGamepadConnectedObserver;
  38632. private _onGamepadDisconnectedObserver;
  38633. /**
  38634. * Attach the input controls to a specific dom element to get the input from.
  38635. * @param element Defines the element the controls should be listened from
  38636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38637. */
  38638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38639. /**
  38640. * Detach the current controls from the specified dom element.
  38641. * @param element Defines the element to stop listening the inputs from
  38642. */
  38643. detachControl(element: Nullable<HTMLElement>): void;
  38644. /**
  38645. * Update the current camera state depending on the inputs that have been used this frame.
  38646. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38647. */
  38648. checkInputs(): void;
  38649. /**
  38650. * Gets the class name of the current intput.
  38651. * @returns the class name
  38652. */
  38653. getClassName(): string;
  38654. /**
  38655. * Get the friendly name associated with the input class.
  38656. * @returns the input friendly name
  38657. */
  38658. getSimpleName(): string;
  38659. }
  38660. }
  38661. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38662. import { Nullable } from "babylonjs/types";
  38663. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38664. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38665. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38666. interface ArcRotateCameraInputsManager {
  38667. /**
  38668. * Add orientation input support to the input manager.
  38669. * @returns the current input manager
  38670. */
  38671. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38672. }
  38673. }
  38674. /**
  38675. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38677. */
  38678. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38679. /**
  38680. * Defines the camera the input is attached to.
  38681. */
  38682. camera: ArcRotateCamera;
  38683. /**
  38684. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38685. */
  38686. alphaCorrection: number;
  38687. /**
  38688. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38689. */
  38690. gammaCorrection: number;
  38691. private _alpha;
  38692. private _gamma;
  38693. private _dirty;
  38694. private _deviceOrientationHandler;
  38695. /**
  38696. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38697. */
  38698. constructor();
  38699. /**
  38700. * Attach the input controls to a specific dom element to get the input from.
  38701. * @param element Defines the element the controls should be listened from
  38702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38703. */
  38704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38705. /** @hidden */
  38706. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38707. /**
  38708. * Update the current camera state depending on the inputs that have been used this frame.
  38709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38710. */
  38711. checkInputs(): void;
  38712. /**
  38713. * Detach the current controls from the specified dom element.
  38714. * @param element Defines the element to stop listening the inputs from
  38715. */
  38716. detachControl(element: Nullable<HTMLElement>): void;
  38717. /**
  38718. * Gets the class name of the current intput.
  38719. * @returns the class name
  38720. */
  38721. getClassName(): string;
  38722. /**
  38723. * Get the friendly name associated with the input class.
  38724. * @returns the input friendly name
  38725. */
  38726. getSimpleName(): string;
  38727. }
  38728. }
  38729. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38730. import { Nullable } from "babylonjs/types";
  38731. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38732. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38733. /**
  38734. * Listen to mouse events to control the camera.
  38735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38736. */
  38737. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38738. /**
  38739. * Defines the camera the input is attached to.
  38740. */
  38741. camera: FlyCamera;
  38742. /**
  38743. * Defines if touch is enabled. (Default is true.)
  38744. */
  38745. touchEnabled: boolean;
  38746. /**
  38747. * Defines the buttons associated with the input to handle camera rotation.
  38748. */
  38749. buttons: number[];
  38750. /**
  38751. * Assign buttons for Yaw control.
  38752. */
  38753. buttonsYaw: number[];
  38754. /**
  38755. * Assign buttons for Pitch control.
  38756. */
  38757. buttonsPitch: number[];
  38758. /**
  38759. * Assign buttons for Roll control.
  38760. */
  38761. buttonsRoll: number[];
  38762. /**
  38763. * Detect if any button is being pressed while mouse is moved.
  38764. * -1 = Mouse locked.
  38765. * 0 = Left button.
  38766. * 1 = Middle Button.
  38767. * 2 = Right Button.
  38768. */
  38769. activeButton: number;
  38770. /**
  38771. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38772. * Higher values reduce its sensitivity.
  38773. */
  38774. angularSensibility: number;
  38775. private _mousemoveCallback;
  38776. private _observer;
  38777. private _rollObserver;
  38778. private previousPosition;
  38779. private noPreventDefault;
  38780. private element;
  38781. /**
  38782. * Listen to mouse events to control the camera.
  38783. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38785. */
  38786. constructor(touchEnabled?: boolean);
  38787. /**
  38788. * Attach the mouse control to the HTML DOM element.
  38789. * @param element Defines the element that listens to the input events.
  38790. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38791. */
  38792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38793. /**
  38794. * Detach the current controls from the specified dom element.
  38795. * @param element Defines the element to stop listening the inputs from
  38796. */
  38797. detachControl(element: Nullable<HTMLElement>): void;
  38798. /**
  38799. * Gets the class name of the current input.
  38800. * @returns the class name.
  38801. */
  38802. getClassName(): string;
  38803. /**
  38804. * Get the friendly name associated with the input class.
  38805. * @returns the input's friendly name.
  38806. */
  38807. getSimpleName(): string;
  38808. private _pointerInput;
  38809. private _onMouseMove;
  38810. /**
  38811. * Rotate camera by mouse offset.
  38812. */
  38813. private rotateCamera;
  38814. }
  38815. }
  38816. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38817. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38818. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38819. /**
  38820. * Default Inputs manager for the FlyCamera.
  38821. * It groups all the default supported inputs for ease of use.
  38822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38823. */
  38824. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38825. /**
  38826. * Instantiates a new FlyCameraInputsManager.
  38827. * @param camera Defines the camera the inputs belong to.
  38828. */
  38829. constructor(camera: FlyCamera);
  38830. /**
  38831. * Add keyboard input support to the input manager.
  38832. * @returns the new FlyCameraKeyboardMoveInput().
  38833. */
  38834. addKeyboard(): FlyCameraInputsManager;
  38835. /**
  38836. * Add mouse input support to the input manager.
  38837. * @param touchEnabled Enable touch screen support.
  38838. * @returns the new FlyCameraMouseInput().
  38839. */
  38840. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38841. }
  38842. }
  38843. declare module "babylonjs/Cameras/flyCamera" {
  38844. import { Scene } from "babylonjs/scene";
  38845. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38847. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38848. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38849. /**
  38850. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38851. * such as in a 3D Space Shooter or a Flight Simulator.
  38852. */
  38853. export class FlyCamera extends TargetCamera {
  38854. /**
  38855. * Define the collision ellipsoid of the camera.
  38856. * This is helpful for simulating a camera body, like a player's body.
  38857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38858. */
  38859. ellipsoid: Vector3;
  38860. /**
  38861. * Define an offset for the position of the ellipsoid around the camera.
  38862. * This can be helpful if the camera is attached away from the player's body center,
  38863. * such as at its head.
  38864. */
  38865. ellipsoidOffset: Vector3;
  38866. /**
  38867. * Enable or disable collisions of the camera with the rest of the scene objects.
  38868. */
  38869. checkCollisions: boolean;
  38870. /**
  38871. * Enable or disable gravity on the camera.
  38872. */
  38873. applyGravity: boolean;
  38874. /**
  38875. * Define the current direction the camera is moving to.
  38876. */
  38877. cameraDirection: Vector3;
  38878. /**
  38879. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38880. * This overrides and empties cameraRotation.
  38881. */
  38882. rotationQuaternion: Quaternion;
  38883. /**
  38884. * Track Roll to maintain the wanted Rolling when looking around.
  38885. */
  38886. _trackRoll: number;
  38887. /**
  38888. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38889. */
  38890. rollCorrect: number;
  38891. /**
  38892. * Mimic a banked turn, Rolling the camera when Yawing.
  38893. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38894. */
  38895. bankedTurn: boolean;
  38896. /**
  38897. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38898. */
  38899. bankedTurnLimit: number;
  38900. /**
  38901. * Value of 0 disables the banked Roll.
  38902. * Value of 1 is equal to the Yaw angle in radians.
  38903. */
  38904. bankedTurnMultiplier: number;
  38905. /**
  38906. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38907. */
  38908. inputs: FlyCameraInputsManager;
  38909. /**
  38910. * Gets the input sensibility for mouse input.
  38911. * Higher values reduce sensitivity.
  38912. */
  38913. /**
  38914. * Sets the input sensibility for a mouse input.
  38915. * Higher values reduce sensitivity.
  38916. */
  38917. angularSensibility: number;
  38918. /**
  38919. * Get the keys for camera movement forward.
  38920. */
  38921. /**
  38922. * Set the keys for camera movement forward.
  38923. */
  38924. keysForward: number[];
  38925. /**
  38926. * Get the keys for camera movement backward.
  38927. */
  38928. keysBackward: number[];
  38929. /**
  38930. * Get the keys for camera movement up.
  38931. */
  38932. /**
  38933. * Set the keys for camera movement up.
  38934. */
  38935. keysUp: number[];
  38936. /**
  38937. * Get the keys for camera movement down.
  38938. */
  38939. /**
  38940. * Set the keys for camera movement down.
  38941. */
  38942. keysDown: number[];
  38943. /**
  38944. * Get the keys for camera movement left.
  38945. */
  38946. /**
  38947. * Set the keys for camera movement left.
  38948. */
  38949. keysLeft: number[];
  38950. /**
  38951. * Set the keys for camera movement right.
  38952. */
  38953. /**
  38954. * Set the keys for camera movement right.
  38955. */
  38956. keysRight: number[];
  38957. /**
  38958. * Event raised when the camera collides with a mesh in the scene.
  38959. */
  38960. onCollide: (collidedMesh: AbstractMesh) => void;
  38961. private _collider;
  38962. private _needMoveForGravity;
  38963. private _oldPosition;
  38964. private _diffPosition;
  38965. private _newPosition;
  38966. /** @hidden */
  38967. _localDirection: Vector3;
  38968. /** @hidden */
  38969. _transformedDirection: Vector3;
  38970. /**
  38971. * Instantiates a FlyCamera.
  38972. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38973. * such as in a 3D Space Shooter or a Flight Simulator.
  38974. * @param name Define the name of the camera in the scene.
  38975. * @param position Define the starting position of the camera in the scene.
  38976. * @param scene Define the scene the camera belongs to.
  38977. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38978. */
  38979. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38980. /**
  38981. * Attach a control to the HTML DOM element.
  38982. * @param element Defines the element that listens to the input events.
  38983. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38984. */
  38985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38986. /**
  38987. * Detach a control from the HTML DOM element.
  38988. * The camera will stop reacting to that input.
  38989. * @param element Defines the element that listens to the input events.
  38990. */
  38991. detachControl(element: HTMLElement): void;
  38992. private _collisionMask;
  38993. /**
  38994. * Get the mask that the camera ignores in collision events.
  38995. */
  38996. /**
  38997. * Set the mask that the camera ignores in collision events.
  38998. */
  38999. collisionMask: number;
  39000. /** @hidden */
  39001. _collideWithWorld(displacement: Vector3): void;
  39002. /** @hidden */
  39003. private _onCollisionPositionChange;
  39004. /** @hidden */
  39005. _checkInputs(): void;
  39006. /** @hidden */
  39007. _decideIfNeedsToMove(): boolean;
  39008. /** @hidden */
  39009. _updatePosition(): void;
  39010. /**
  39011. * Restore the Roll to its target value at the rate specified.
  39012. * @param rate - Higher means slower restoring.
  39013. * @hidden
  39014. */
  39015. restoreRoll(rate: number): void;
  39016. /**
  39017. * Destroy the camera and release the current resources held by it.
  39018. */
  39019. dispose(): void;
  39020. /**
  39021. * Get the current object class name.
  39022. * @returns the class name.
  39023. */
  39024. getClassName(): string;
  39025. }
  39026. }
  39027. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39028. import { Nullable } from "babylonjs/types";
  39029. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39030. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39031. /**
  39032. * Listen to keyboard events to control the camera.
  39033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39034. */
  39035. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39036. /**
  39037. * Defines the camera the input is attached to.
  39038. */
  39039. camera: FlyCamera;
  39040. /**
  39041. * The list of keyboard keys used to control the forward move of the camera.
  39042. */
  39043. keysForward: number[];
  39044. /**
  39045. * The list of keyboard keys used to control the backward move of the camera.
  39046. */
  39047. keysBackward: number[];
  39048. /**
  39049. * The list of keyboard keys used to control the forward move of the camera.
  39050. */
  39051. keysUp: number[];
  39052. /**
  39053. * The list of keyboard keys used to control the backward move of the camera.
  39054. */
  39055. keysDown: number[];
  39056. /**
  39057. * The list of keyboard keys used to control the right strafe move of the camera.
  39058. */
  39059. keysRight: number[];
  39060. /**
  39061. * The list of keyboard keys used to control the left strafe move of the camera.
  39062. */
  39063. keysLeft: number[];
  39064. private _keys;
  39065. private _onCanvasBlurObserver;
  39066. private _onKeyboardObserver;
  39067. private _engine;
  39068. private _scene;
  39069. /**
  39070. * Attach the input controls to a specific dom element to get the input from.
  39071. * @param element Defines the element the controls should be listened from
  39072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39073. */
  39074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39075. /**
  39076. * Detach the current controls from the specified dom element.
  39077. * @param element Defines the element to stop listening the inputs from
  39078. */
  39079. detachControl(element: Nullable<HTMLElement>): void;
  39080. /**
  39081. * Gets the class name of the current intput.
  39082. * @returns the class name
  39083. */
  39084. getClassName(): string;
  39085. /** @hidden */
  39086. _onLostFocus(e: FocusEvent): void;
  39087. /**
  39088. * Get the friendly name associated with the input class.
  39089. * @returns the input friendly name
  39090. */
  39091. getSimpleName(): string;
  39092. /**
  39093. * Update the current camera state depending on the inputs that have been used this frame.
  39094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39095. */
  39096. checkInputs(): void;
  39097. }
  39098. }
  39099. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39100. import { Nullable } from "babylonjs/types";
  39101. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39102. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39103. /**
  39104. * Manage the mouse wheel inputs to control a follow camera.
  39105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39106. */
  39107. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39108. /**
  39109. * Defines the camera the input is attached to.
  39110. */
  39111. camera: FollowCamera;
  39112. /**
  39113. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39114. */
  39115. axisControlRadius: boolean;
  39116. /**
  39117. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39118. */
  39119. axisControlHeight: boolean;
  39120. /**
  39121. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39122. */
  39123. axisControlRotation: boolean;
  39124. /**
  39125. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39126. * relation to mouseWheel events.
  39127. */
  39128. wheelPrecision: number;
  39129. /**
  39130. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39131. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39132. */
  39133. wheelDeltaPercentage: number;
  39134. private _wheel;
  39135. private _observer;
  39136. /**
  39137. * Attach the input controls to a specific dom element to get the input from.
  39138. * @param element Defines the element the controls should be listened from
  39139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39140. */
  39141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39142. /**
  39143. * Detach the current controls from the specified dom element.
  39144. * @param element Defines the element to stop listening the inputs from
  39145. */
  39146. detachControl(element: Nullable<HTMLElement>): void;
  39147. /**
  39148. * Gets the class name of the current intput.
  39149. * @returns the class name
  39150. */
  39151. getClassName(): string;
  39152. /**
  39153. * Get the friendly name associated with the input class.
  39154. * @returns the input friendly name
  39155. */
  39156. getSimpleName(): string;
  39157. }
  39158. }
  39159. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39160. import { Nullable } from "babylonjs/types";
  39161. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39162. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39163. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39164. /**
  39165. * Manage the pointers inputs to control an follow camera.
  39166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39167. */
  39168. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39169. /**
  39170. * Defines the camera the input is attached to.
  39171. */
  39172. camera: FollowCamera;
  39173. /**
  39174. * Gets the class name of the current input.
  39175. * @returns the class name
  39176. */
  39177. getClassName(): string;
  39178. /**
  39179. * Defines the pointer angular sensibility along the X axis or how fast is
  39180. * the camera rotating.
  39181. * A negative number will reverse the axis direction.
  39182. */
  39183. angularSensibilityX: number;
  39184. /**
  39185. * Defines the pointer angular sensibility along the Y axis or how fast is
  39186. * the camera rotating.
  39187. * A negative number will reverse the axis direction.
  39188. */
  39189. angularSensibilityY: number;
  39190. /**
  39191. * Defines the pointer pinch precision or how fast is the camera zooming.
  39192. * A negative number will reverse the axis direction.
  39193. */
  39194. pinchPrecision: number;
  39195. /**
  39196. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39197. * from 0.
  39198. * It defines the percentage of current camera.radius to use as delta when
  39199. * pinch zoom is used.
  39200. */
  39201. pinchDeltaPercentage: number;
  39202. /**
  39203. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39204. */
  39205. axisXControlRadius: boolean;
  39206. /**
  39207. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39208. */
  39209. axisXControlHeight: boolean;
  39210. /**
  39211. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39212. */
  39213. axisXControlRotation: boolean;
  39214. /**
  39215. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39216. */
  39217. axisYControlRadius: boolean;
  39218. /**
  39219. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39220. */
  39221. axisYControlHeight: boolean;
  39222. /**
  39223. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39224. */
  39225. axisYControlRotation: boolean;
  39226. /**
  39227. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39228. */
  39229. axisPinchControlRadius: boolean;
  39230. /**
  39231. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39232. */
  39233. axisPinchControlHeight: boolean;
  39234. /**
  39235. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39236. */
  39237. axisPinchControlRotation: boolean;
  39238. /**
  39239. * Log error messages if basic misconfiguration has occurred.
  39240. */
  39241. warningEnable: boolean;
  39242. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39243. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39244. private _warningCounter;
  39245. private _warning;
  39246. }
  39247. }
  39248. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39249. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39250. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39251. /**
  39252. * Default Inputs manager for the FollowCamera.
  39253. * It groups all the default supported inputs for ease of use.
  39254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39255. */
  39256. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39257. /**
  39258. * Instantiates a new FollowCameraInputsManager.
  39259. * @param camera Defines the camera the inputs belong to
  39260. */
  39261. constructor(camera: FollowCamera);
  39262. /**
  39263. * Add keyboard input support to the input manager.
  39264. * @returns the current input manager
  39265. */
  39266. addKeyboard(): FollowCameraInputsManager;
  39267. /**
  39268. * Add mouse wheel input support to the input manager.
  39269. * @returns the current input manager
  39270. */
  39271. addMouseWheel(): FollowCameraInputsManager;
  39272. /**
  39273. * Add pointers input support to the input manager.
  39274. * @returns the current input manager
  39275. */
  39276. addPointers(): FollowCameraInputsManager;
  39277. /**
  39278. * Add orientation input support to the input manager.
  39279. * @returns the current input manager
  39280. */
  39281. addVRDeviceOrientation(): FollowCameraInputsManager;
  39282. }
  39283. }
  39284. declare module "babylonjs/Cameras/followCamera" {
  39285. import { Nullable } from "babylonjs/types";
  39286. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39287. import { Scene } from "babylonjs/scene";
  39288. import { Vector3 } from "babylonjs/Maths/math.vector";
  39289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39290. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39291. /**
  39292. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39293. * an arc rotate version arcFollowCamera are available.
  39294. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39295. */
  39296. export class FollowCamera extends TargetCamera {
  39297. /**
  39298. * Distance the follow camera should follow an object at
  39299. */
  39300. radius: number;
  39301. /**
  39302. * Minimum allowed distance of the camera to the axis of rotation
  39303. * (The camera can not get closer).
  39304. * This can help limiting how the Camera is able to move in the scene.
  39305. */
  39306. lowerRadiusLimit: Nullable<number>;
  39307. /**
  39308. * Maximum allowed distance of the camera to the axis of rotation
  39309. * (The camera can not get further).
  39310. * This can help limiting how the Camera is able to move in the scene.
  39311. */
  39312. upperRadiusLimit: Nullable<number>;
  39313. /**
  39314. * Define a rotation offset between the camera and the object it follows
  39315. */
  39316. rotationOffset: number;
  39317. /**
  39318. * Minimum allowed angle to camera position relative to target object.
  39319. * This can help limiting how the Camera is able to move in the scene.
  39320. */
  39321. lowerRotationOffsetLimit: Nullable<number>;
  39322. /**
  39323. * Maximum allowed angle to camera position relative to target object.
  39324. * This can help limiting how the Camera is able to move in the scene.
  39325. */
  39326. upperRotationOffsetLimit: Nullable<number>;
  39327. /**
  39328. * Define a height offset between the camera and the object it follows.
  39329. * It can help following an object from the top (like a car chaing a plane)
  39330. */
  39331. heightOffset: number;
  39332. /**
  39333. * Minimum allowed height of camera position relative to target object.
  39334. * This can help limiting how the Camera is able to move in the scene.
  39335. */
  39336. lowerHeightOffsetLimit: Nullable<number>;
  39337. /**
  39338. * Maximum allowed height of camera position relative to target object.
  39339. * This can help limiting how the Camera is able to move in the scene.
  39340. */
  39341. upperHeightOffsetLimit: Nullable<number>;
  39342. /**
  39343. * Define how fast the camera can accelerate to follow it s target.
  39344. */
  39345. cameraAcceleration: number;
  39346. /**
  39347. * Define the speed limit of the camera following an object.
  39348. */
  39349. maxCameraSpeed: number;
  39350. /**
  39351. * Define the target of the camera.
  39352. */
  39353. lockedTarget: Nullable<AbstractMesh>;
  39354. /**
  39355. * Defines the input associated with the camera.
  39356. */
  39357. inputs: FollowCameraInputsManager;
  39358. /**
  39359. * Instantiates the follow camera.
  39360. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39361. * @param name Define the name of the camera in the scene
  39362. * @param position Define the position of the camera
  39363. * @param scene Define the scene the camera belong to
  39364. * @param lockedTarget Define the target of the camera
  39365. */
  39366. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39367. private _follow;
  39368. /**
  39369. * Attached controls to the current camera.
  39370. * @param element Defines the element the controls should be listened from
  39371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39372. */
  39373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39374. /**
  39375. * Detach the current controls from the camera.
  39376. * The camera will stop reacting to inputs.
  39377. * @param element Defines the element to stop listening the inputs from
  39378. */
  39379. detachControl(element: HTMLElement): void;
  39380. /** @hidden */
  39381. _checkInputs(): void;
  39382. private _checkLimits;
  39383. /**
  39384. * Gets the camera class name.
  39385. * @returns the class name
  39386. */
  39387. getClassName(): string;
  39388. }
  39389. /**
  39390. * Arc Rotate version of the follow camera.
  39391. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39392. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39393. */
  39394. export class ArcFollowCamera extends TargetCamera {
  39395. /** The longitudinal angle of the camera */
  39396. alpha: number;
  39397. /** The latitudinal angle of the camera */
  39398. beta: number;
  39399. /** The radius of the camera from its target */
  39400. radius: number;
  39401. /** Define the camera target (the messh it should follow) */
  39402. target: Nullable<AbstractMesh>;
  39403. private _cartesianCoordinates;
  39404. /**
  39405. * Instantiates a new ArcFollowCamera
  39406. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39407. * @param name Define the name of the camera
  39408. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39409. * @param beta Define the rotation angle of the camera around the elevation axis
  39410. * @param radius Define the radius of the camera from its target point
  39411. * @param target Define the target of the camera
  39412. * @param scene Define the scene the camera belongs to
  39413. */
  39414. constructor(name: string,
  39415. /** The longitudinal angle of the camera */
  39416. alpha: number,
  39417. /** The latitudinal angle of the camera */
  39418. beta: number,
  39419. /** The radius of the camera from its target */
  39420. radius: number,
  39421. /** Define the camera target (the messh it should follow) */
  39422. target: Nullable<AbstractMesh>, scene: Scene);
  39423. private _follow;
  39424. /** @hidden */
  39425. _checkInputs(): void;
  39426. /**
  39427. * Returns the class name of the object.
  39428. * It is mostly used internally for serialization purposes.
  39429. */
  39430. getClassName(): string;
  39431. }
  39432. }
  39433. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39434. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39435. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39436. import { Nullable } from "babylonjs/types";
  39437. /**
  39438. * Manage the keyboard inputs to control the movement of a follow camera.
  39439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39440. */
  39441. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39442. /**
  39443. * Defines the camera the input is attached to.
  39444. */
  39445. camera: FollowCamera;
  39446. /**
  39447. * Defines the list of key codes associated with the up action (increase heightOffset)
  39448. */
  39449. keysHeightOffsetIncr: number[];
  39450. /**
  39451. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39452. */
  39453. keysHeightOffsetDecr: number[];
  39454. /**
  39455. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39456. */
  39457. keysHeightOffsetModifierAlt: boolean;
  39458. /**
  39459. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39460. */
  39461. keysHeightOffsetModifierCtrl: boolean;
  39462. /**
  39463. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39464. */
  39465. keysHeightOffsetModifierShift: boolean;
  39466. /**
  39467. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39468. */
  39469. keysRotationOffsetIncr: number[];
  39470. /**
  39471. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39472. */
  39473. keysRotationOffsetDecr: number[];
  39474. /**
  39475. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39476. */
  39477. keysRotationOffsetModifierAlt: boolean;
  39478. /**
  39479. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39480. */
  39481. keysRotationOffsetModifierCtrl: boolean;
  39482. /**
  39483. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39484. */
  39485. keysRotationOffsetModifierShift: boolean;
  39486. /**
  39487. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39488. */
  39489. keysRadiusIncr: number[];
  39490. /**
  39491. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39492. */
  39493. keysRadiusDecr: number[];
  39494. /**
  39495. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39496. */
  39497. keysRadiusModifierAlt: boolean;
  39498. /**
  39499. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39500. */
  39501. keysRadiusModifierCtrl: boolean;
  39502. /**
  39503. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39504. */
  39505. keysRadiusModifierShift: boolean;
  39506. /**
  39507. * Defines the rate of change of heightOffset.
  39508. */
  39509. heightSensibility: number;
  39510. /**
  39511. * Defines the rate of change of rotationOffset.
  39512. */
  39513. rotationSensibility: number;
  39514. /**
  39515. * Defines the rate of change of radius.
  39516. */
  39517. radiusSensibility: number;
  39518. private _keys;
  39519. private _ctrlPressed;
  39520. private _altPressed;
  39521. private _shiftPressed;
  39522. private _onCanvasBlurObserver;
  39523. private _onKeyboardObserver;
  39524. private _engine;
  39525. private _scene;
  39526. /**
  39527. * Attach the input controls to a specific dom element to get the input from.
  39528. * @param element Defines the element the controls should be listened from
  39529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39530. */
  39531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39532. /**
  39533. * Detach the current controls from the specified dom element.
  39534. * @param element Defines the element to stop listening the inputs from
  39535. */
  39536. detachControl(element: Nullable<HTMLElement>): void;
  39537. /**
  39538. * Update the current camera state depending on the inputs that have been used this frame.
  39539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39540. */
  39541. checkInputs(): void;
  39542. /**
  39543. * Gets the class name of the current input.
  39544. * @returns the class name
  39545. */
  39546. getClassName(): string;
  39547. /**
  39548. * Get the friendly name associated with the input class.
  39549. * @returns the input friendly name
  39550. */
  39551. getSimpleName(): string;
  39552. /**
  39553. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39554. * allow modification of the heightOffset value.
  39555. */
  39556. private _modifierHeightOffset;
  39557. /**
  39558. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39559. * allow modification of the rotationOffset value.
  39560. */
  39561. private _modifierRotationOffset;
  39562. /**
  39563. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39564. * allow modification of the radius value.
  39565. */
  39566. private _modifierRadius;
  39567. }
  39568. }
  39569. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39570. import { Nullable } from "babylonjs/types";
  39571. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39572. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39573. import { Observable } from "babylonjs/Misc/observable";
  39574. module "babylonjs/Cameras/freeCameraInputsManager" {
  39575. interface FreeCameraInputsManager {
  39576. /**
  39577. * @hidden
  39578. */
  39579. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39580. /**
  39581. * Add orientation input support to the input manager.
  39582. * @returns the current input manager
  39583. */
  39584. addDeviceOrientation(): FreeCameraInputsManager;
  39585. }
  39586. }
  39587. /**
  39588. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39589. * Screen rotation is taken into account.
  39590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39591. */
  39592. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39593. private _camera;
  39594. private _screenOrientationAngle;
  39595. private _constantTranform;
  39596. private _screenQuaternion;
  39597. private _alpha;
  39598. private _beta;
  39599. private _gamma;
  39600. /**
  39601. * Can be used to detect if a device orientation sensor is availible on a device
  39602. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39603. * @returns a promise that will resolve on orientation change
  39604. */
  39605. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39606. /**
  39607. * @hidden
  39608. */
  39609. _onDeviceOrientationChangedObservable: Observable<void>;
  39610. /**
  39611. * Instantiates a new input
  39612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39613. */
  39614. constructor();
  39615. /**
  39616. * Define the camera controlled by the input.
  39617. */
  39618. camera: FreeCamera;
  39619. /**
  39620. * Attach the input controls to a specific dom element to get the input from.
  39621. * @param element Defines the element the controls should be listened from
  39622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39623. */
  39624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39625. private _orientationChanged;
  39626. private _deviceOrientation;
  39627. /**
  39628. * Detach the current controls from the specified dom element.
  39629. * @param element Defines the element to stop listening the inputs from
  39630. */
  39631. detachControl(element: Nullable<HTMLElement>): void;
  39632. /**
  39633. * Update the current camera state depending on the inputs that have been used this frame.
  39634. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39635. */
  39636. checkInputs(): void;
  39637. /**
  39638. * Gets the class name of the current intput.
  39639. * @returns the class name
  39640. */
  39641. getClassName(): string;
  39642. /**
  39643. * Get the friendly name associated with the input class.
  39644. * @returns the input friendly name
  39645. */
  39646. getSimpleName(): string;
  39647. }
  39648. }
  39649. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39650. import { Nullable } from "babylonjs/types";
  39651. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39652. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39653. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39654. /**
  39655. * Manage the gamepad inputs to control a free camera.
  39656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39657. */
  39658. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39659. /**
  39660. * Define the camera the input is attached to.
  39661. */
  39662. camera: FreeCamera;
  39663. /**
  39664. * Define the Gamepad controlling the input
  39665. */
  39666. gamepad: Nullable<Gamepad>;
  39667. /**
  39668. * Defines the gamepad rotation sensiblity.
  39669. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39670. */
  39671. gamepadAngularSensibility: number;
  39672. /**
  39673. * Defines the gamepad move sensiblity.
  39674. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39675. */
  39676. gamepadMoveSensibility: number;
  39677. private _yAxisScale;
  39678. /**
  39679. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39680. */
  39681. invertYAxis: boolean;
  39682. private _onGamepadConnectedObserver;
  39683. private _onGamepadDisconnectedObserver;
  39684. private _cameraTransform;
  39685. private _deltaTransform;
  39686. private _vector3;
  39687. private _vector2;
  39688. /**
  39689. * Attach the input controls to a specific dom element to get the input from.
  39690. * @param element Defines the element the controls should be listened from
  39691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39692. */
  39693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39694. /**
  39695. * Detach the current controls from the specified dom element.
  39696. * @param element Defines the element to stop listening the inputs from
  39697. */
  39698. detachControl(element: Nullable<HTMLElement>): void;
  39699. /**
  39700. * Update the current camera state depending on the inputs that have been used this frame.
  39701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39702. */
  39703. checkInputs(): void;
  39704. /**
  39705. * Gets the class name of the current intput.
  39706. * @returns the class name
  39707. */
  39708. getClassName(): string;
  39709. /**
  39710. * Get the friendly name associated with the input class.
  39711. * @returns the input friendly name
  39712. */
  39713. getSimpleName(): string;
  39714. }
  39715. }
  39716. declare module "babylonjs/Misc/virtualJoystick" {
  39717. import { Nullable } from "babylonjs/types";
  39718. import { Vector3 } from "babylonjs/Maths/math.vector";
  39719. /**
  39720. * Defines the potential axis of a Joystick
  39721. */
  39722. export enum JoystickAxis {
  39723. /** X axis */
  39724. X = 0,
  39725. /** Y axis */
  39726. Y = 1,
  39727. /** Z axis */
  39728. Z = 2
  39729. }
  39730. /**
  39731. * Class used to define virtual joystick (used in touch mode)
  39732. */
  39733. export class VirtualJoystick {
  39734. /**
  39735. * Gets or sets a boolean indicating that left and right values must be inverted
  39736. */
  39737. reverseLeftRight: boolean;
  39738. /**
  39739. * Gets or sets a boolean indicating that up and down values must be inverted
  39740. */
  39741. reverseUpDown: boolean;
  39742. /**
  39743. * Gets the offset value for the position (ie. the change of the position value)
  39744. */
  39745. deltaPosition: Vector3;
  39746. /**
  39747. * Gets a boolean indicating if the virtual joystick was pressed
  39748. */
  39749. pressed: boolean;
  39750. /**
  39751. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39752. */
  39753. static Canvas: Nullable<HTMLCanvasElement>;
  39754. private static _globalJoystickIndex;
  39755. private static vjCanvasContext;
  39756. private static vjCanvasWidth;
  39757. private static vjCanvasHeight;
  39758. private static halfWidth;
  39759. private _action;
  39760. private _axisTargetedByLeftAndRight;
  39761. private _axisTargetedByUpAndDown;
  39762. private _joystickSensibility;
  39763. private _inversedSensibility;
  39764. private _joystickPointerID;
  39765. private _joystickColor;
  39766. private _joystickPointerPos;
  39767. private _joystickPreviousPointerPos;
  39768. private _joystickPointerStartPos;
  39769. private _deltaJoystickVector;
  39770. private _leftJoystick;
  39771. private _touches;
  39772. private _onPointerDownHandlerRef;
  39773. private _onPointerMoveHandlerRef;
  39774. private _onPointerUpHandlerRef;
  39775. private _onResize;
  39776. /**
  39777. * Creates a new virtual joystick
  39778. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39779. */
  39780. constructor(leftJoystick?: boolean);
  39781. /**
  39782. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39783. * @param newJoystickSensibility defines the new sensibility
  39784. */
  39785. setJoystickSensibility(newJoystickSensibility: number): void;
  39786. private _onPointerDown;
  39787. private _onPointerMove;
  39788. private _onPointerUp;
  39789. /**
  39790. * Change the color of the virtual joystick
  39791. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39792. */
  39793. setJoystickColor(newColor: string): void;
  39794. /**
  39795. * Defines a callback to call when the joystick is touched
  39796. * @param action defines the callback
  39797. */
  39798. setActionOnTouch(action: () => any): void;
  39799. /**
  39800. * Defines which axis you'd like to control for left & right
  39801. * @param axis defines the axis to use
  39802. */
  39803. setAxisForLeftRight(axis: JoystickAxis): void;
  39804. /**
  39805. * Defines which axis you'd like to control for up & down
  39806. * @param axis defines the axis to use
  39807. */
  39808. setAxisForUpDown(axis: JoystickAxis): void;
  39809. private _drawVirtualJoystick;
  39810. /**
  39811. * Release internal HTML canvas
  39812. */
  39813. releaseCanvas(): void;
  39814. }
  39815. }
  39816. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39817. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39818. import { Nullable } from "babylonjs/types";
  39819. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39820. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39821. module "babylonjs/Cameras/freeCameraInputsManager" {
  39822. interface FreeCameraInputsManager {
  39823. /**
  39824. * Add virtual joystick input support to the input manager.
  39825. * @returns the current input manager
  39826. */
  39827. addVirtualJoystick(): FreeCameraInputsManager;
  39828. }
  39829. }
  39830. /**
  39831. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39833. */
  39834. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39835. /**
  39836. * Defines the camera the input is attached to.
  39837. */
  39838. camera: FreeCamera;
  39839. private _leftjoystick;
  39840. private _rightjoystick;
  39841. /**
  39842. * Gets the left stick of the virtual joystick.
  39843. * @returns The virtual Joystick
  39844. */
  39845. getLeftJoystick(): VirtualJoystick;
  39846. /**
  39847. * Gets the right stick of the virtual joystick.
  39848. * @returns The virtual Joystick
  39849. */
  39850. getRightJoystick(): VirtualJoystick;
  39851. /**
  39852. * Update the current camera state depending on the inputs that have been used this frame.
  39853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39854. */
  39855. checkInputs(): void;
  39856. /**
  39857. * Attach the input controls to a specific dom element to get the input from.
  39858. * @param element Defines the element the controls should be listened from
  39859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39860. */
  39861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39862. /**
  39863. * Detach the current controls from the specified dom element.
  39864. * @param element Defines the element to stop listening the inputs from
  39865. */
  39866. detachControl(element: Nullable<HTMLElement>): void;
  39867. /**
  39868. * Gets the class name of the current intput.
  39869. * @returns the class name
  39870. */
  39871. getClassName(): string;
  39872. /**
  39873. * Get the friendly name associated with the input class.
  39874. * @returns the input friendly name
  39875. */
  39876. getSimpleName(): string;
  39877. }
  39878. }
  39879. declare module "babylonjs/Cameras/Inputs/index" {
  39880. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39881. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39882. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39883. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39884. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39885. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39886. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39887. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39888. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39889. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39890. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39891. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39892. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39893. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39894. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39895. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39896. }
  39897. declare module "babylonjs/Cameras/touchCamera" {
  39898. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39899. import { Scene } from "babylonjs/scene";
  39900. import { Vector3 } from "babylonjs/Maths/math.vector";
  39901. /**
  39902. * This represents a FPS type of camera controlled by touch.
  39903. * This is like a universal camera minus the Gamepad controls.
  39904. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39905. */
  39906. export class TouchCamera extends FreeCamera {
  39907. /**
  39908. * Defines the touch sensibility for rotation.
  39909. * The higher the faster.
  39910. */
  39911. touchAngularSensibility: number;
  39912. /**
  39913. * Defines the touch sensibility for move.
  39914. * The higher the faster.
  39915. */
  39916. touchMoveSensibility: number;
  39917. /**
  39918. * Instantiates a new touch camera.
  39919. * This represents a FPS type of camera controlled by touch.
  39920. * This is like a universal camera minus the Gamepad controls.
  39921. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39922. * @param name Define the name of the camera in the scene
  39923. * @param position Define the start position of the camera in the scene
  39924. * @param scene Define the scene the camera belongs to
  39925. */
  39926. constructor(name: string, position: Vector3, scene: Scene);
  39927. /**
  39928. * Gets the current object class name.
  39929. * @return the class name
  39930. */
  39931. getClassName(): string;
  39932. /** @hidden */
  39933. _setupInputs(): void;
  39934. }
  39935. }
  39936. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39938. import { Scene } from "babylonjs/scene";
  39939. import { Vector3 } from "babylonjs/Maths/math.vector";
  39940. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39941. import { Axis } from "babylonjs/Maths/math.axis";
  39942. /**
  39943. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39944. * being tilted forward or back and left or right.
  39945. */
  39946. export class DeviceOrientationCamera extends FreeCamera {
  39947. private _initialQuaternion;
  39948. private _quaternionCache;
  39949. private _tmpDragQuaternion;
  39950. private _disablePointerInputWhenUsingDeviceOrientation;
  39951. /**
  39952. * Creates a new device orientation camera
  39953. * @param name The name of the camera
  39954. * @param position The start position camera
  39955. * @param scene The scene the camera belongs to
  39956. */
  39957. constructor(name: string, position: Vector3, scene: Scene);
  39958. /**
  39959. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39960. */
  39961. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39962. private _dragFactor;
  39963. /**
  39964. * Enabled turning on the y axis when the orientation sensor is active
  39965. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39966. */
  39967. enableHorizontalDragging(dragFactor?: number): void;
  39968. /**
  39969. * Gets the current instance class name ("DeviceOrientationCamera").
  39970. * This helps avoiding instanceof at run time.
  39971. * @returns the class name
  39972. */
  39973. getClassName(): string;
  39974. /**
  39975. * @hidden
  39976. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39977. */
  39978. _checkInputs(): void;
  39979. /**
  39980. * Reset the camera to its default orientation on the specified axis only.
  39981. * @param axis The axis to reset
  39982. */
  39983. resetToCurrentRotation(axis?: Axis): void;
  39984. }
  39985. }
  39986. declare module "babylonjs/Gamepads/xboxGamepad" {
  39987. import { Observable } from "babylonjs/Misc/observable";
  39988. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39989. /**
  39990. * Defines supported buttons for XBox360 compatible gamepads
  39991. */
  39992. export enum Xbox360Button {
  39993. /** A */
  39994. A = 0,
  39995. /** B */
  39996. B = 1,
  39997. /** X */
  39998. X = 2,
  39999. /** Y */
  40000. Y = 3,
  40001. /** Start */
  40002. Start = 4,
  40003. /** Back */
  40004. Back = 5,
  40005. /** Left button */
  40006. LB = 6,
  40007. /** Right button */
  40008. RB = 7,
  40009. /** Left stick */
  40010. LeftStick = 8,
  40011. /** Right stick */
  40012. RightStick = 9
  40013. }
  40014. /** Defines values for XBox360 DPad */
  40015. export enum Xbox360Dpad {
  40016. /** Up */
  40017. Up = 0,
  40018. /** Down */
  40019. Down = 1,
  40020. /** Left */
  40021. Left = 2,
  40022. /** Right */
  40023. Right = 3
  40024. }
  40025. /**
  40026. * Defines a XBox360 gamepad
  40027. */
  40028. export class Xbox360Pad extends Gamepad {
  40029. private _leftTrigger;
  40030. private _rightTrigger;
  40031. private _onlefttriggerchanged;
  40032. private _onrighttriggerchanged;
  40033. private _onbuttondown;
  40034. private _onbuttonup;
  40035. private _ondpaddown;
  40036. private _ondpadup;
  40037. /** Observable raised when a button is pressed */
  40038. onButtonDownObservable: Observable<Xbox360Button>;
  40039. /** Observable raised when a button is released */
  40040. onButtonUpObservable: Observable<Xbox360Button>;
  40041. /** Observable raised when a pad is pressed */
  40042. onPadDownObservable: Observable<Xbox360Dpad>;
  40043. /** Observable raised when a pad is released */
  40044. onPadUpObservable: Observable<Xbox360Dpad>;
  40045. private _buttonA;
  40046. private _buttonB;
  40047. private _buttonX;
  40048. private _buttonY;
  40049. private _buttonBack;
  40050. private _buttonStart;
  40051. private _buttonLB;
  40052. private _buttonRB;
  40053. private _buttonLeftStick;
  40054. private _buttonRightStick;
  40055. private _dPadUp;
  40056. private _dPadDown;
  40057. private _dPadLeft;
  40058. private _dPadRight;
  40059. private _isXboxOnePad;
  40060. /**
  40061. * Creates a new XBox360 gamepad object
  40062. * @param id defines the id of this gamepad
  40063. * @param index defines its index
  40064. * @param gamepad defines the internal HTML gamepad object
  40065. * @param xboxOne defines if it is a XBox One gamepad
  40066. */
  40067. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40068. /**
  40069. * Defines the callback to call when left trigger is pressed
  40070. * @param callback defines the callback to use
  40071. */
  40072. onlefttriggerchanged(callback: (value: number) => void): void;
  40073. /**
  40074. * Defines the callback to call when right trigger is pressed
  40075. * @param callback defines the callback to use
  40076. */
  40077. onrighttriggerchanged(callback: (value: number) => void): void;
  40078. /**
  40079. * Gets the left trigger value
  40080. */
  40081. /**
  40082. * Sets the left trigger value
  40083. */
  40084. leftTrigger: number;
  40085. /**
  40086. * Gets the right trigger value
  40087. */
  40088. /**
  40089. * Sets the right trigger value
  40090. */
  40091. rightTrigger: number;
  40092. /**
  40093. * Defines the callback to call when a button is pressed
  40094. * @param callback defines the callback to use
  40095. */
  40096. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40097. /**
  40098. * Defines the callback to call when a button is released
  40099. * @param callback defines the callback to use
  40100. */
  40101. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40102. /**
  40103. * Defines the callback to call when a pad is pressed
  40104. * @param callback defines the callback to use
  40105. */
  40106. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40107. /**
  40108. * Defines the callback to call when a pad is released
  40109. * @param callback defines the callback to use
  40110. */
  40111. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40112. private _setButtonValue;
  40113. private _setDPadValue;
  40114. /**
  40115. * Gets the value of the `A` button
  40116. */
  40117. /**
  40118. * Sets the value of the `A` button
  40119. */
  40120. buttonA: number;
  40121. /**
  40122. * Gets the value of the `B` button
  40123. */
  40124. /**
  40125. * Sets the value of the `B` button
  40126. */
  40127. buttonB: number;
  40128. /**
  40129. * Gets the value of the `X` button
  40130. */
  40131. /**
  40132. * Sets the value of the `X` button
  40133. */
  40134. buttonX: number;
  40135. /**
  40136. * Gets the value of the `Y` button
  40137. */
  40138. /**
  40139. * Sets the value of the `Y` button
  40140. */
  40141. buttonY: number;
  40142. /**
  40143. * Gets the value of the `Start` button
  40144. */
  40145. /**
  40146. * Sets the value of the `Start` button
  40147. */
  40148. buttonStart: number;
  40149. /**
  40150. * Gets the value of the `Back` button
  40151. */
  40152. /**
  40153. * Sets the value of the `Back` button
  40154. */
  40155. buttonBack: number;
  40156. /**
  40157. * Gets the value of the `Left` button
  40158. */
  40159. /**
  40160. * Sets the value of the `Left` button
  40161. */
  40162. buttonLB: number;
  40163. /**
  40164. * Gets the value of the `Right` button
  40165. */
  40166. /**
  40167. * Sets the value of the `Right` button
  40168. */
  40169. buttonRB: number;
  40170. /**
  40171. * Gets the value of the Left joystick
  40172. */
  40173. /**
  40174. * Sets the value of the Left joystick
  40175. */
  40176. buttonLeftStick: number;
  40177. /**
  40178. * Gets the value of the Right joystick
  40179. */
  40180. /**
  40181. * Sets the value of the Right joystick
  40182. */
  40183. buttonRightStick: number;
  40184. /**
  40185. * Gets the value of D-pad up
  40186. */
  40187. /**
  40188. * Sets the value of D-pad up
  40189. */
  40190. dPadUp: number;
  40191. /**
  40192. * Gets the value of D-pad down
  40193. */
  40194. /**
  40195. * Sets the value of D-pad down
  40196. */
  40197. dPadDown: number;
  40198. /**
  40199. * Gets the value of D-pad left
  40200. */
  40201. /**
  40202. * Sets the value of D-pad left
  40203. */
  40204. dPadLeft: number;
  40205. /**
  40206. * Gets the value of D-pad right
  40207. */
  40208. /**
  40209. * Sets the value of D-pad right
  40210. */
  40211. dPadRight: number;
  40212. /**
  40213. * Force the gamepad to synchronize with device values
  40214. */
  40215. update(): void;
  40216. /**
  40217. * Disposes the gamepad
  40218. */
  40219. dispose(): void;
  40220. }
  40221. }
  40222. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40223. import { Observable } from "babylonjs/Misc/observable";
  40224. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40225. /**
  40226. * Defines supported buttons for DualShock compatible gamepads
  40227. */
  40228. export enum DualShockButton {
  40229. /** Cross */
  40230. Cross = 0,
  40231. /** Circle */
  40232. Circle = 1,
  40233. /** Square */
  40234. Square = 2,
  40235. /** Triangle */
  40236. Triangle = 3,
  40237. /** Options */
  40238. Options = 4,
  40239. /** Share */
  40240. Share = 5,
  40241. /** L1 */
  40242. L1 = 6,
  40243. /** R1 */
  40244. R1 = 7,
  40245. /** Left stick */
  40246. LeftStick = 8,
  40247. /** Right stick */
  40248. RightStick = 9
  40249. }
  40250. /** Defines values for DualShock DPad */
  40251. export enum DualShockDpad {
  40252. /** Up */
  40253. Up = 0,
  40254. /** Down */
  40255. Down = 1,
  40256. /** Left */
  40257. Left = 2,
  40258. /** Right */
  40259. Right = 3
  40260. }
  40261. /**
  40262. * Defines a DualShock gamepad
  40263. */
  40264. export class DualShockPad extends Gamepad {
  40265. private _leftTrigger;
  40266. private _rightTrigger;
  40267. private _onlefttriggerchanged;
  40268. private _onrighttriggerchanged;
  40269. private _onbuttondown;
  40270. private _onbuttonup;
  40271. private _ondpaddown;
  40272. private _ondpadup;
  40273. /** Observable raised when a button is pressed */
  40274. onButtonDownObservable: Observable<DualShockButton>;
  40275. /** Observable raised when a button is released */
  40276. onButtonUpObservable: Observable<DualShockButton>;
  40277. /** Observable raised when a pad is pressed */
  40278. onPadDownObservable: Observable<DualShockDpad>;
  40279. /** Observable raised when a pad is released */
  40280. onPadUpObservable: Observable<DualShockDpad>;
  40281. private _buttonCross;
  40282. private _buttonCircle;
  40283. private _buttonSquare;
  40284. private _buttonTriangle;
  40285. private _buttonShare;
  40286. private _buttonOptions;
  40287. private _buttonL1;
  40288. private _buttonR1;
  40289. private _buttonLeftStick;
  40290. private _buttonRightStick;
  40291. private _dPadUp;
  40292. private _dPadDown;
  40293. private _dPadLeft;
  40294. private _dPadRight;
  40295. /**
  40296. * Creates a new DualShock gamepad object
  40297. * @param id defines the id of this gamepad
  40298. * @param index defines its index
  40299. * @param gamepad defines the internal HTML gamepad object
  40300. */
  40301. constructor(id: string, index: number, gamepad: any);
  40302. /**
  40303. * Defines the callback to call when left trigger is pressed
  40304. * @param callback defines the callback to use
  40305. */
  40306. onlefttriggerchanged(callback: (value: number) => void): void;
  40307. /**
  40308. * Defines the callback to call when right trigger is pressed
  40309. * @param callback defines the callback to use
  40310. */
  40311. onrighttriggerchanged(callback: (value: number) => void): void;
  40312. /**
  40313. * Gets the left trigger value
  40314. */
  40315. /**
  40316. * Sets the left trigger value
  40317. */
  40318. leftTrigger: number;
  40319. /**
  40320. * Gets the right trigger value
  40321. */
  40322. /**
  40323. * Sets the right trigger value
  40324. */
  40325. rightTrigger: number;
  40326. /**
  40327. * Defines the callback to call when a button is pressed
  40328. * @param callback defines the callback to use
  40329. */
  40330. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40331. /**
  40332. * Defines the callback to call when a button is released
  40333. * @param callback defines the callback to use
  40334. */
  40335. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40336. /**
  40337. * Defines the callback to call when a pad is pressed
  40338. * @param callback defines the callback to use
  40339. */
  40340. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40341. /**
  40342. * Defines the callback to call when a pad is released
  40343. * @param callback defines the callback to use
  40344. */
  40345. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40346. private _setButtonValue;
  40347. private _setDPadValue;
  40348. /**
  40349. * Gets the value of the `Cross` button
  40350. */
  40351. /**
  40352. * Sets the value of the `Cross` button
  40353. */
  40354. buttonCross: number;
  40355. /**
  40356. * Gets the value of the `Circle` button
  40357. */
  40358. /**
  40359. * Sets the value of the `Circle` button
  40360. */
  40361. buttonCircle: number;
  40362. /**
  40363. * Gets the value of the `Square` button
  40364. */
  40365. /**
  40366. * Sets the value of the `Square` button
  40367. */
  40368. buttonSquare: number;
  40369. /**
  40370. * Gets the value of the `Triangle` button
  40371. */
  40372. /**
  40373. * Sets the value of the `Triangle` button
  40374. */
  40375. buttonTriangle: number;
  40376. /**
  40377. * Gets the value of the `Options` button
  40378. */
  40379. /**
  40380. * Sets the value of the `Options` button
  40381. */
  40382. buttonOptions: number;
  40383. /**
  40384. * Gets the value of the `Share` button
  40385. */
  40386. /**
  40387. * Sets the value of the `Share` button
  40388. */
  40389. buttonShare: number;
  40390. /**
  40391. * Gets the value of the `L1` button
  40392. */
  40393. /**
  40394. * Sets the value of the `L1` button
  40395. */
  40396. buttonL1: number;
  40397. /**
  40398. * Gets the value of the `R1` button
  40399. */
  40400. /**
  40401. * Sets the value of the `R1` button
  40402. */
  40403. buttonR1: number;
  40404. /**
  40405. * Gets the value of the Left joystick
  40406. */
  40407. /**
  40408. * Sets the value of the Left joystick
  40409. */
  40410. buttonLeftStick: number;
  40411. /**
  40412. * Gets the value of the Right joystick
  40413. */
  40414. /**
  40415. * Sets the value of the Right joystick
  40416. */
  40417. buttonRightStick: number;
  40418. /**
  40419. * Gets the value of D-pad up
  40420. */
  40421. /**
  40422. * Sets the value of D-pad up
  40423. */
  40424. dPadUp: number;
  40425. /**
  40426. * Gets the value of D-pad down
  40427. */
  40428. /**
  40429. * Sets the value of D-pad down
  40430. */
  40431. dPadDown: number;
  40432. /**
  40433. * Gets the value of D-pad left
  40434. */
  40435. /**
  40436. * Sets the value of D-pad left
  40437. */
  40438. dPadLeft: number;
  40439. /**
  40440. * Gets the value of D-pad right
  40441. */
  40442. /**
  40443. * Sets the value of D-pad right
  40444. */
  40445. dPadRight: number;
  40446. /**
  40447. * Force the gamepad to synchronize with device values
  40448. */
  40449. update(): void;
  40450. /**
  40451. * Disposes the gamepad
  40452. */
  40453. dispose(): void;
  40454. }
  40455. }
  40456. declare module "babylonjs/Gamepads/gamepadManager" {
  40457. import { Observable } from "babylonjs/Misc/observable";
  40458. import { Nullable } from "babylonjs/types";
  40459. import { Scene } from "babylonjs/scene";
  40460. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40461. /**
  40462. * Manager for handling gamepads
  40463. */
  40464. export class GamepadManager {
  40465. private _scene?;
  40466. private _babylonGamepads;
  40467. private _oneGamepadConnected;
  40468. /** @hidden */
  40469. _isMonitoring: boolean;
  40470. private _gamepadEventSupported;
  40471. private _gamepadSupport;
  40472. /**
  40473. * observable to be triggered when the gamepad controller has been connected
  40474. */
  40475. onGamepadConnectedObservable: Observable<Gamepad>;
  40476. /**
  40477. * observable to be triggered when the gamepad controller has been disconnected
  40478. */
  40479. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40480. private _onGamepadConnectedEvent;
  40481. private _onGamepadDisconnectedEvent;
  40482. /**
  40483. * Initializes the gamepad manager
  40484. * @param _scene BabylonJS scene
  40485. */
  40486. constructor(_scene?: Scene | undefined);
  40487. /**
  40488. * The gamepads in the game pad manager
  40489. */
  40490. readonly gamepads: Gamepad[];
  40491. /**
  40492. * Get the gamepad controllers based on type
  40493. * @param type The type of gamepad controller
  40494. * @returns Nullable gamepad
  40495. */
  40496. getGamepadByType(type?: number): Nullable<Gamepad>;
  40497. /**
  40498. * Disposes the gamepad manager
  40499. */
  40500. dispose(): void;
  40501. private _addNewGamepad;
  40502. private _startMonitoringGamepads;
  40503. private _stopMonitoringGamepads;
  40504. /** @hidden */
  40505. _checkGamepadsStatus(): void;
  40506. private _updateGamepadObjects;
  40507. }
  40508. }
  40509. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40510. import { Nullable } from "babylonjs/types";
  40511. import { Scene } from "babylonjs/scene";
  40512. import { ISceneComponent } from "babylonjs/sceneComponent";
  40513. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40514. module "babylonjs/scene" {
  40515. interface Scene {
  40516. /** @hidden */
  40517. _gamepadManager: Nullable<GamepadManager>;
  40518. /**
  40519. * Gets the gamepad manager associated with the scene
  40520. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40521. */
  40522. gamepadManager: GamepadManager;
  40523. }
  40524. }
  40525. module "babylonjs/Cameras/freeCameraInputsManager" {
  40526. /**
  40527. * Interface representing a free camera inputs manager
  40528. */
  40529. interface FreeCameraInputsManager {
  40530. /**
  40531. * Adds gamepad input support to the FreeCameraInputsManager.
  40532. * @returns the FreeCameraInputsManager
  40533. */
  40534. addGamepad(): FreeCameraInputsManager;
  40535. }
  40536. }
  40537. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40538. /**
  40539. * Interface representing an arc rotate camera inputs manager
  40540. */
  40541. interface ArcRotateCameraInputsManager {
  40542. /**
  40543. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40544. * @returns the camera inputs manager
  40545. */
  40546. addGamepad(): ArcRotateCameraInputsManager;
  40547. }
  40548. }
  40549. /**
  40550. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40551. */
  40552. export class GamepadSystemSceneComponent implements ISceneComponent {
  40553. /**
  40554. * The component name helpfull to identify the component in the list of scene components.
  40555. */
  40556. readonly name: string;
  40557. /**
  40558. * The scene the component belongs to.
  40559. */
  40560. scene: Scene;
  40561. /**
  40562. * Creates a new instance of the component for the given scene
  40563. * @param scene Defines the scene to register the component in
  40564. */
  40565. constructor(scene: Scene);
  40566. /**
  40567. * Registers the component in a given scene
  40568. */
  40569. register(): void;
  40570. /**
  40571. * Rebuilds the elements related to this component in case of
  40572. * context lost for instance.
  40573. */
  40574. rebuild(): void;
  40575. /**
  40576. * Disposes the component and the associated ressources
  40577. */
  40578. dispose(): void;
  40579. private _beforeCameraUpdate;
  40580. }
  40581. }
  40582. declare module "babylonjs/Cameras/universalCamera" {
  40583. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40584. import { Scene } from "babylonjs/scene";
  40585. import { Vector3 } from "babylonjs/Maths/math.vector";
  40586. import "babylonjs/Gamepads/gamepadSceneComponent";
  40587. /**
  40588. * 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,
  40589. * which still works and will still be found in many Playgrounds.
  40590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40591. */
  40592. export class UniversalCamera extends TouchCamera {
  40593. /**
  40594. * Defines the gamepad rotation sensiblity.
  40595. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40596. */
  40597. gamepadAngularSensibility: number;
  40598. /**
  40599. * Defines the gamepad move sensiblity.
  40600. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40601. */
  40602. gamepadMoveSensibility: number;
  40603. /**
  40604. * 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,
  40605. * which still works and will still be found in many Playgrounds.
  40606. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40607. * @param name Define the name of the camera in the scene
  40608. * @param position Define the start position of the camera in the scene
  40609. * @param scene Define the scene the camera belongs to
  40610. */
  40611. constructor(name: string, position: Vector3, scene: Scene);
  40612. /**
  40613. * Gets the current object class name.
  40614. * @return the class name
  40615. */
  40616. getClassName(): string;
  40617. }
  40618. }
  40619. declare module "babylonjs/Cameras/gamepadCamera" {
  40620. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40621. import { Scene } from "babylonjs/scene";
  40622. import { Vector3 } from "babylonjs/Maths/math.vector";
  40623. /**
  40624. * This represents a FPS type of camera. This is only here for back compat purpose.
  40625. * Please use the UniversalCamera instead as both are identical.
  40626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40627. */
  40628. export class GamepadCamera extends UniversalCamera {
  40629. /**
  40630. * Instantiates a new Gamepad Camera
  40631. * This represents a FPS type of camera. This is only here for back compat purpose.
  40632. * Please use the UniversalCamera instead as both are identical.
  40633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40634. * @param name Define the name of the camera in the scene
  40635. * @param position Define the start position of the camera in the scene
  40636. * @param scene Define the scene the camera belongs to
  40637. */
  40638. constructor(name: string, position: Vector3, scene: Scene);
  40639. /**
  40640. * Gets the current object class name.
  40641. * @return the class name
  40642. */
  40643. getClassName(): string;
  40644. }
  40645. }
  40646. declare module "babylonjs/Shaders/pass.fragment" {
  40647. /** @hidden */
  40648. export var passPixelShader: {
  40649. name: string;
  40650. shader: string;
  40651. };
  40652. }
  40653. declare module "babylonjs/Shaders/passCube.fragment" {
  40654. /** @hidden */
  40655. export var passCubePixelShader: {
  40656. name: string;
  40657. shader: string;
  40658. };
  40659. }
  40660. declare module "babylonjs/PostProcesses/passPostProcess" {
  40661. import { Nullable } from "babylonjs/types";
  40662. import { Camera } from "babylonjs/Cameras/camera";
  40663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40664. import { Engine } from "babylonjs/Engines/engine";
  40665. import "babylonjs/Shaders/pass.fragment";
  40666. import "babylonjs/Shaders/passCube.fragment";
  40667. /**
  40668. * PassPostProcess which produces an output the same as it's input
  40669. */
  40670. export class PassPostProcess extends PostProcess {
  40671. /**
  40672. * Creates the PassPostProcess
  40673. * @param name The name of the effect.
  40674. * @param options The required width/height ratio to downsize to before computing the render pass.
  40675. * @param camera The camera to apply the render pass to.
  40676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40677. * @param engine The engine which the post process will be applied. (default: current engine)
  40678. * @param reusable If the post process can be reused on the same frame. (default: false)
  40679. * @param textureType The type of texture to be used when performing the post processing.
  40680. * @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)
  40681. */
  40682. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40683. }
  40684. /**
  40685. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40686. */
  40687. export class PassCubePostProcess extends PostProcess {
  40688. private _face;
  40689. /**
  40690. * Gets or sets the cube face to display.
  40691. * * 0 is +X
  40692. * * 1 is -X
  40693. * * 2 is +Y
  40694. * * 3 is -Y
  40695. * * 4 is +Z
  40696. * * 5 is -Z
  40697. */
  40698. face: number;
  40699. /**
  40700. * Creates the PassCubePostProcess
  40701. * @param name The name of the effect.
  40702. * @param options The required width/height ratio to downsize to before computing the render pass.
  40703. * @param camera The camera to apply the render pass to.
  40704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40705. * @param engine The engine which the post process will be applied. (default: current engine)
  40706. * @param reusable If the post process can be reused on the same frame. (default: false)
  40707. * @param textureType The type of texture to be used when performing the post processing.
  40708. * @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)
  40709. */
  40710. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40711. }
  40712. }
  40713. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40714. /** @hidden */
  40715. export var anaglyphPixelShader: {
  40716. name: string;
  40717. shader: string;
  40718. };
  40719. }
  40720. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40721. import { Engine } from "babylonjs/Engines/engine";
  40722. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40723. import { Camera } from "babylonjs/Cameras/camera";
  40724. import "babylonjs/Shaders/anaglyph.fragment";
  40725. /**
  40726. * Postprocess used to generate anaglyphic rendering
  40727. */
  40728. export class AnaglyphPostProcess extends PostProcess {
  40729. private _passedProcess;
  40730. /**
  40731. * Creates a new AnaglyphPostProcess
  40732. * @param name defines postprocess name
  40733. * @param options defines creation options or target ratio scale
  40734. * @param rigCameras defines cameras using this postprocess
  40735. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40736. * @param engine defines hosting engine
  40737. * @param reusable defines if the postprocess will be reused multiple times per frame
  40738. */
  40739. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40740. }
  40741. }
  40742. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40743. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40744. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40745. import { Scene } from "babylonjs/scene";
  40746. import { Vector3 } from "babylonjs/Maths/math.vector";
  40747. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40748. /**
  40749. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40750. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40751. */
  40752. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40753. /**
  40754. * Creates a new AnaglyphArcRotateCamera
  40755. * @param name defines camera name
  40756. * @param alpha defines alpha angle (in radians)
  40757. * @param beta defines beta angle (in radians)
  40758. * @param radius defines radius
  40759. * @param target defines camera target
  40760. * @param interaxialDistance defines distance between each color axis
  40761. * @param scene defines the hosting scene
  40762. */
  40763. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40764. /**
  40765. * Gets camera class name
  40766. * @returns AnaglyphArcRotateCamera
  40767. */
  40768. getClassName(): string;
  40769. }
  40770. }
  40771. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40772. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40773. import { Scene } from "babylonjs/scene";
  40774. import { Vector3 } from "babylonjs/Maths/math.vector";
  40775. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40776. /**
  40777. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40778. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40779. */
  40780. export class AnaglyphFreeCamera extends FreeCamera {
  40781. /**
  40782. * Creates a new AnaglyphFreeCamera
  40783. * @param name defines camera name
  40784. * @param position defines initial position
  40785. * @param interaxialDistance defines distance between each color axis
  40786. * @param scene defines the hosting scene
  40787. */
  40788. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40789. /**
  40790. * Gets camera class name
  40791. * @returns AnaglyphFreeCamera
  40792. */
  40793. getClassName(): string;
  40794. }
  40795. }
  40796. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40797. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40798. import { Scene } from "babylonjs/scene";
  40799. import { Vector3 } from "babylonjs/Maths/math.vector";
  40800. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40801. /**
  40802. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40803. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40804. */
  40805. export class AnaglyphGamepadCamera extends GamepadCamera {
  40806. /**
  40807. * Creates a new AnaglyphGamepadCamera
  40808. * @param name defines camera name
  40809. * @param position defines initial position
  40810. * @param interaxialDistance defines distance between each color axis
  40811. * @param scene defines the hosting scene
  40812. */
  40813. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40814. /**
  40815. * Gets camera class name
  40816. * @returns AnaglyphGamepadCamera
  40817. */
  40818. getClassName(): string;
  40819. }
  40820. }
  40821. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40822. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40823. import { Scene } from "babylonjs/scene";
  40824. import { Vector3 } from "babylonjs/Maths/math.vector";
  40825. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40826. /**
  40827. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40828. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40829. */
  40830. export class AnaglyphUniversalCamera extends UniversalCamera {
  40831. /**
  40832. * Creates a new AnaglyphUniversalCamera
  40833. * @param name defines camera name
  40834. * @param position defines initial position
  40835. * @param interaxialDistance defines distance between each color axis
  40836. * @param scene defines the hosting scene
  40837. */
  40838. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40839. /**
  40840. * Gets camera class name
  40841. * @returns AnaglyphUniversalCamera
  40842. */
  40843. getClassName(): string;
  40844. }
  40845. }
  40846. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40847. /** @hidden */
  40848. export var stereoscopicInterlacePixelShader: {
  40849. name: string;
  40850. shader: string;
  40851. };
  40852. }
  40853. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40854. import { Camera } from "babylonjs/Cameras/camera";
  40855. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40856. import { Engine } from "babylonjs/Engines/engine";
  40857. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40858. /**
  40859. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40860. */
  40861. export class StereoscopicInterlacePostProcess extends PostProcess {
  40862. private _stepSize;
  40863. private _passedProcess;
  40864. /**
  40865. * Initializes a StereoscopicInterlacePostProcess
  40866. * @param name The name of the effect.
  40867. * @param rigCameras The rig cameras to be appled to the post process
  40868. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40870. * @param engine The engine which the post process will be applied. (default: current engine)
  40871. * @param reusable If the post process can be reused on the same frame. (default: false)
  40872. */
  40873. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40874. }
  40875. }
  40876. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40877. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40878. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40879. import { Scene } from "babylonjs/scene";
  40880. import { Vector3 } from "babylonjs/Maths/math.vector";
  40881. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40882. /**
  40883. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40884. * @see http://doc.babylonjs.com/features/cameras
  40885. */
  40886. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40887. /**
  40888. * Creates a new StereoscopicArcRotateCamera
  40889. * @param name defines camera name
  40890. * @param alpha defines alpha angle (in radians)
  40891. * @param beta defines beta angle (in radians)
  40892. * @param radius defines radius
  40893. * @param target defines camera target
  40894. * @param interaxialDistance defines distance between each color axis
  40895. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40896. * @param scene defines the hosting scene
  40897. */
  40898. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40899. /**
  40900. * Gets camera class name
  40901. * @returns StereoscopicArcRotateCamera
  40902. */
  40903. getClassName(): string;
  40904. }
  40905. }
  40906. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40907. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40908. import { Scene } from "babylonjs/scene";
  40909. import { Vector3 } from "babylonjs/Maths/math.vector";
  40910. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40911. /**
  40912. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40913. * @see http://doc.babylonjs.com/features/cameras
  40914. */
  40915. export class StereoscopicFreeCamera extends FreeCamera {
  40916. /**
  40917. * Creates a new StereoscopicFreeCamera
  40918. * @param name defines camera name
  40919. * @param position defines initial position
  40920. * @param interaxialDistance defines distance between each color axis
  40921. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40922. * @param scene defines the hosting scene
  40923. */
  40924. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40925. /**
  40926. * Gets camera class name
  40927. * @returns StereoscopicFreeCamera
  40928. */
  40929. getClassName(): string;
  40930. }
  40931. }
  40932. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40933. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40934. import { Scene } from "babylonjs/scene";
  40935. import { Vector3 } from "babylonjs/Maths/math.vector";
  40936. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40937. /**
  40938. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40939. * @see http://doc.babylonjs.com/features/cameras
  40940. */
  40941. export class StereoscopicGamepadCamera extends GamepadCamera {
  40942. /**
  40943. * Creates a new StereoscopicGamepadCamera
  40944. * @param name defines camera name
  40945. * @param position defines initial position
  40946. * @param interaxialDistance defines distance between each color axis
  40947. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40948. * @param scene defines the hosting scene
  40949. */
  40950. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40951. /**
  40952. * Gets camera class name
  40953. * @returns StereoscopicGamepadCamera
  40954. */
  40955. getClassName(): string;
  40956. }
  40957. }
  40958. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40959. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40960. import { Scene } from "babylonjs/scene";
  40961. import { Vector3 } from "babylonjs/Maths/math.vector";
  40962. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40963. /**
  40964. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40965. * @see http://doc.babylonjs.com/features/cameras
  40966. */
  40967. export class StereoscopicUniversalCamera extends UniversalCamera {
  40968. /**
  40969. * Creates a new StereoscopicUniversalCamera
  40970. * @param name defines camera name
  40971. * @param position defines initial position
  40972. * @param interaxialDistance defines distance between each color axis
  40973. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40974. * @param scene defines the hosting scene
  40975. */
  40976. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40977. /**
  40978. * Gets camera class name
  40979. * @returns StereoscopicUniversalCamera
  40980. */
  40981. getClassName(): string;
  40982. }
  40983. }
  40984. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40985. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40986. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40987. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40988. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40989. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40990. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40991. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40992. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40993. }
  40994. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40995. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40996. import { Scene } from "babylonjs/scene";
  40997. import { Vector3 } from "babylonjs/Maths/math.vector";
  40998. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40999. /**
  41000. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41001. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41002. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41003. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41004. */
  41005. export class VirtualJoysticksCamera extends FreeCamera {
  41006. /**
  41007. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41008. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41009. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41010. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41011. * @param name Define the name of the camera in the scene
  41012. * @param position Define the start position of the camera in the scene
  41013. * @param scene Define the scene the camera belongs to
  41014. */
  41015. constructor(name: string, position: Vector3, scene: Scene);
  41016. /**
  41017. * Gets the current object class name.
  41018. * @return the class name
  41019. */
  41020. getClassName(): string;
  41021. }
  41022. }
  41023. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41024. import { Matrix } from "babylonjs/Maths/math.vector";
  41025. /**
  41026. * This represents all the required metrics to create a VR camera.
  41027. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41028. */
  41029. export class VRCameraMetrics {
  41030. /**
  41031. * Define the horizontal resolution off the screen.
  41032. */
  41033. hResolution: number;
  41034. /**
  41035. * Define the vertical resolution off the screen.
  41036. */
  41037. vResolution: number;
  41038. /**
  41039. * Define the horizontal screen size.
  41040. */
  41041. hScreenSize: number;
  41042. /**
  41043. * Define the vertical screen size.
  41044. */
  41045. vScreenSize: number;
  41046. /**
  41047. * Define the vertical screen center position.
  41048. */
  41049. vScreenCenter: number;
  41050. /**
  41051. * Define the distance of the eyes to the screen.
  41052. */
  41053. eyeToScreenDistance: number;
  41054. /**
  41055. * Define the distance between both lenses
  41056. */
  41057. lensSeparationDistance: number;
  41058. /**
  41059. * Define the distance between both viewer's eyes.
  41060. */
  41061. interpupillaryDistance: number;
  41062. /**
  41063. * Define the distortion factor of the VR postprocess.
  41064. * Please, touch with care.
  41065. */
  41066. distortionK: number[];
  41067. /**
  41068. * Define the chromatic aberration correction factors for the VR post process.
  41069. */
  41070. chromaAbCorrection: number[];
  41071. /**
  41072. * Define the scale factor of the post process.
  41073. * The smaller the better but the slower.
  41074. */
  41075. postProcessScaleFactor: number;
  41076. /**
  41077. * Define an offset for the lens center.
  41078. */
  41079. lensCenterOffset: number;
  41080. /**
  41081. * Define if the current vr camera should compensate the distortion of the lense or not.
  41082. */
  41083. compensateDistortion: boolean;
  41084. /**
  41085. * Defines if multiview should be enabled when rendering (Default: false)
  41086. */
  41087. multiviewEnabled: boolean;
  41088. /**
  41089. * Gets the rendering aspect ratio based on the provided resolutions.
  41090. */
  41091. readonly aspectRatio: number;
  41092. /**
  41093. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41094. */
  41095. readonly aspectRatioFov: number;
  41096. /**
  41097. * @hidden
  41098. */
  41099. readonly leftHMatrix: Matrix;
  41100. /**
  41101. * @hidden
  41102. */
  41103. readonly rightHMatrix: Matrix;
  41104. /**
  41105. * @hidden
  41106. */
  41107. readonly leftPreViewMatrix: Matrix;
  41108. /**
  41109. * @hidden
  41110. */
  41111. readonly rightPreViewMatrix: Matrix;
  41112. /**
  41113. * Get the default VRMetrics based on the most generic setup.
  41114. * @returns the default vr metrics
  41115. */
  41116. static GetDefault(): VRCameraMetrics;
  41117. }
  41118. }
  41119. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41120. /** @hidden */
  41121. export var vrDistortionCorrectionPixelShader: {
  41122. name: string;
  41123. shader: string;
  41124. };
  41125. }
  41126. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41127. import { Camera } from "babylonjs/Cameras/camera";
  41128. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41129. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41130. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41131. /**
  41132. * VRDistortionCorrectionPostProcess used for mobile VR
  41133. */
  41134. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41135. private _isRightEye;
  41136. private _distortionFactors;
  41137. private _postProcessScaleFactor;
  41138. private _lensCenterOffset;
  41139. private _scaleIn;
  41140. private _scaleFactor;
  41141. private _lensCenter;
  41142. /**
  41143. * Initializes the VRDistortionCorrectionPostProcess
  41144. * @param name The name of the effect.
  41145. * @param camera The camera to apply the render pass to.
  41146. * @param isRightEye If this is for the right eye distortion
  41147. * @param vrMetrics All the required metrics for the VR camera
  41148. */
  41149. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41150. }
  41151. }
  41152. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41153. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41154. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41155. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41156. import { Scene } from "babylonjs/scene";
  41157. import { Vector3 } from "babylonjs/Maths/math.vector";
  41158. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41159. import "babylonjs/Cameras/RigModes/vrRigMode";
  41160. /**
  41161. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41162. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41163. */
  41164. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41165. /**
  41166. * Creates a new VRDeviceOrientationArcRotateCamera
  41167. * @param name defines camera name
  41168. * @param alpha defines the camera rotation along the logitudinal axis
  41169. * @param beta defines the camera rotation along the latitudinal axis
  41170. * @param radius defines the camera distance from its target
  41171. * @param target defines the camera target
  41172. * @param scene defines the scene the camera belongs to
  41173. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41174. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41175. */
  41176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41177. /**
  41178. * Gets camera class name
  41179. * @returns VRDeviceOrientationArcRotateCamera
  41180. */
  41181. getClassName(): string;
  41182. }
  41183. }
  41184. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41185. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41186. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41187. import { Scene } from "babylonjs/scene";
  41188. import { Vector3 } from "babylonjs/Maths/math.vector";
  41189. import "babylonjs/Cameras/RigModes/vrRigMode";
  41190. /**
  41191. * Camera used to simulate VR rendering (based on FreeCamera)
  41192. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41193. */
  41194. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41195. /**
  41196. * Creates a new VRDeviceOrientationFreeCamera
  41197. * @param name defines camera name
  41198. * @param position defines the start position of the camera
  41199. * @param scene defines the scene the camera belongs to
  41200. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41201. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41202. */
  41203. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41204. /**
  41205. * Gets camera class name
  41206. * @returns VRDeviceOrientationFreeCamera
  41207. */
  41208. getClassName(): string;
  41209. }
  41210. }
  41211. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41212. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41213. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41214. import { Scene } from "babylonjs/scene";
  41215. import { Vector3 } from "babylonjs/Maths/math.vector";
  41216. import "babylonjs/Gamepads/gamepadSceneComponent";
  41217. /**
  41218. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41219. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41220. */
  41221. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41222. /**
  41223. * Creates a new VRDeviceOrientationGamepadCamera
  41224. * @param name defines camera name
  41225. * @param position defines the start position of the camera
  41226. * @param scene defines the scene the camera belongs to
  41227. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41228. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41229. */
  41230. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41231. /**
  41232. * Gets camera class name
  41233. * @returns VRDeviceOrientationGamepadCamera
  41234. */
  41235. getClassName(): string;
  41236. }
  41237. }
  41238. declare module "babylonjs/Materials/pushMaterial" {
  41239. import { Nullable } from "babylonjs/types";
  41240. import { Scene } from "babylonjs/scene";
  41241. import { Matrix } from "babylonjs/Maths/math.vector";
  41242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41243. import { Mesh } from "babylonjs/Meshes/mesh";
  41244. import { Material } from "babylonjs/Materials/material";
  41245. import { Effect } from "babylonjs/Materials/effect";
  41246. /**
  41247. * Base class of materials working in push mode in babylon JS
  41248. * @hidden
  41249. */
  41250. export class PushMaterial extends Material {
  41251. protected _activeEffect: Effect;
  41252. protected _normalMatrix: Matrix;
  41253. /**
  41254. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41255. * This means that the material can keep using a previous shader while a new one is being compiled.
  41256. * This is mostly used when shader parallel compilation is supported (true by default)
  41257. */
  41258. allowShaderHotSwapping: boolean;
  41259. constructor(name: string, scene: Scene);
  41260. getEffect(): Effect;
  41261. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41262. /**
  41263. * Binds the given world matrix to the active effect
  41264. *
  41265. * @param world the matrix to bind
  41266. */
  41267. bindOnlyWorldMatrix(world: Matrix): void;
  41268. /**
  41269. * Binds the given normal matrix to the active effect
  41270. *
  41271. * @param normalMatrix the matrix to bind
  41272. */
  41273. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41274. bind(world: Matrix, mesh?: Mesh): void;
  41275. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41276. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41277. }
  41278. }
  41279. declare module "babylonjs/Materials/materialFlags" {
  41280. /**
  41281. * This groups all the flags used to control the materials channel.
  41282. */
  41283. export class MaterialFlags {
  41284. private static _DiffuseTextureEnabled;
  41285. /**
  41286. * Are diffuse textures enabled in the application.
  41287. */
  41288. static DiffuseTextureEnabled: boolean;
  41289. private static _AmbientTextureEnabled;
  41290. /**
  41291. * Are ambient textures enabled in the application.
  41292. */
  41293. static AmbientTextureEnabled: boolean;
  41294. private static _OpacityTextureEnabled;
  41295. /**
  41296. * Are opacity textures enabled in the application.
  41297. */
  41298. static OpacityTextureEnabled: boolean;
  41299. private static _ReflectionTextureEnabled;
  41300. /**
  41301. * Are reflection textures enabled in the application.
  41302. */
  41303. static ReflectionTextureEnabled: boolean;
  41304. private static _EmissiveTextureEnabled;
  41305. /**
  41306. * Are emissive textures enabled in the application.
  41307. */
  41308. static EmissiveTextureEnabled: boolean;
  41309. private static _SpecularTextureEnabled;
  41310. /**
  41311. * Are specular textures enabled in the application.
  41312. */
  41313. static SpecularTextureEnabled: boolean;
  41314. private static _BumpTextureEnabled;
  41315. /**
  41316. * Are bump textures enabled in the application.
  41317. */
  41318. static BumpTextureEnabled: boolean;
  41319. private static _LightmapTextureEnabled;
  41320. /**
  41321. * Are lightmap textures enabled in the application.
  41322. */
  41323. static LightmapTextureEnabled: boolean;
  41324. private static _RefractionTextureEnabled;
  41325. /**
  41326. * Are refraction textures enabled in the application.
  41327. */
  41328. static RefractionTextureEnabled: boolean;
  41329. private static _ColorGradingTextureEnabled;
  41330. /**
  41331. * Are color grading textures enabled in the application.
  41332. */
  41333. static ColorGradingTextureEnabled: boolean;
  41334. private static _FresnelEnabled;
  41335. /**
  41336. * Are fresnels enabled in the application.
  41337. */
  41338. static FresnelEnabled: boolean;
  41339. private static _ClearCoatTextureEnabled;
  41340. /**
  41341. * Are clear coat textures enabled in the application.
  41342. */
  41343. static ClearCoatTextureEnabled: boolean;
  41344. private static _ClearCoatBumpTextureEnabled;
  41345. /**
  41346. * Are clear coat bump textures enabled in the application.
  41347. */
  41348. static ClearCoatBumpTextureEnabled: boolean;
  41349. private static _ClearCoatTintTextureEnabled;
  41350. /**
  41351. * Are clear coat tint textures enabled in the application.
  41352. */
  41353. static ClearCoatTintTextureEnabled: boolean;
  41354. private static _SheenTextureEnabled;
  41355. /**
  41356. * Are sheen textures enabled in the application.
  41357. */
  41358. static SheenTextureEnabled: boolean;
  41359. private static _AnisotropicTextureEnabled;
  41360. /**
  41361. * Are anisotropic textures enabled in the application.
  41362. */
  41363. static AnisotropicTextureEnabled: boolean;
  41364. private static _ThicknessTextureEnabled;
  41365. /**
  41366. * Are thickness textures enabled in the application.
  41367. */
  41368. static ThicknessTextureEnabled: boolean;
  41369. }
  41370. }
  41371. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41372. /** @hidden */
  41373. export var defaultFragmentDeclaration: {
  41374. name: string;
  41375. shader: string;
  41376. };
  41377. }
  41378. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41379. /** @hidden */
  41380. export var defaultUboDeclaration: {
  41381. name: string;
  41382. shader: string;
  41383. };
  41384. }
  41385. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41386. /** @hidden */
  41387. export var lightFragmentDeclaration: {
  41388. name: string;
  41389. shader: string;
  41390. };
  41391. }
  41392. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41393. /** @hidden */
  41394. export var lightUboDeclaration: {
  41395. name: string;
  41396. shader: string;
  41397. };
  41398. }
  41399. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41400. /** @hidden */
  41401. export var lightsFragmentFunctions: {
  41402. name: string;
  41403. shader: string;
  41404. };
  41405. }
  41406. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41407. /** @hidden */
  41408. export var shadowsFragmentFunctions: {
  41409. name: string;
  41410. shader: string;
  41411. };
  41412. }
  41413. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41414. /** @hidden */
  41415. export var fresnelFunction: {
  41416. name: string;
  41417. shader: string;
  41418. };
  41419. }
  41420. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41421. /** @hidden */
  41422. export var reflectionFunction: {
  41423. name: string;
  41424. shader: string;
  41425. };
  41426. }
  41427. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41428. /** @hidden */
  41429. export var bumpFragmentFunctions: {
  41430. name: string;
  41431. shader: string;
  41432. };
  41433. }
  41434. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41435. /** @hidden */
  41436. export var logDepthDeclaration: {
  41437. name: string;
  41438. shader: string;
  41439. };
  41440. }
  41441. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41442. /** @hidden */
  41443. export var bumpFragment: {
  41444. name: string;
  41445. shader: string;
  41446. };
  41447. }
  41448. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41449. /** @hidden */
  41450. export var depthPrePass: {
  41451. name: string;
  41452. shader: string;
  41453. };
  41454. }
  41455. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41456. /** @hidden */
  41457. export var lightFragment: {
  41458. name: string;
  41459. shader: string;
  41460. };
  41461. }
  41462. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41463. /** @hidden */
  41464. export var logDepthFragment: {
  41465. name: string;
  41466. shader: string;
  41467. };
  41468. }
  41469. declare module "babylonjs/Shaders/default.fragment" {
  41470. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41471. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41472. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41473. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41474. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41475. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41476. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41477. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41478. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41479. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41480. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41481. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41483. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41484. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41485. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41486. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41487. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41488. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41489. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41490. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41491. /** @hidden */
  41492. export var defaultPixelShader: {
  41493. name: string;
  41494. shader: string;
  41495. };
  41496. }
  41497. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41498. /** @hidden */
  41499. export var defaultVertexDeclaration: {
  41500. name: string;
  41501. shader: string;
  41502. };
  41503. }
  41504. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41505. /** @hidden */
  41506. export var bumpVertexDeclaration: {
  41507. name: string;
  41508. shader: string;
  41509. };
  41510. }
  41511. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41512. /** @hidden */
  41513. export var bumpVertex: {
  41514. name: string;
  41515. shader: string;
  41516. };
  41517. }
  41518. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41519. /** @hidden */
  41520. export var fogVertex: {
  41521. name: string;
  41522. shader: string;
  41523. };
  41524. }
  41525. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41526. /** @hidden */
  41527. export var shadowsVertex: {
  41528. name: string;
  41529. shader: string;
  41530. };
  41531. }
  41532. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41533. /** @hidden */
  41534. export var pointCloudVertex: {
  41535. name: string;
  41536. shader: string;
  41537. };
  41538. }
  41539. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41540. /** @hidden */
  41541. export var logDepthVertex: {
  41542. name: string;
  41543. shader: string;
  41544. };
  41545. }
  41546. declare module "babylonjs/Shaders/default.vertex" {
  41547. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41548. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41550. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41551. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41552. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41553. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41554. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41555. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41556. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41557. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41558. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41559. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41561. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41562. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41563. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41564. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41565. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41566. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41567. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41568. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41569. /** @hidden */
  41570. export var defaultVertexShader: {
  41571. name: string;
  41572. shader: string;
  41573. };
  41574. }
  41575. declare module "babylonjs/Materials/standardMaterial" {
  41576. import { SmartArray } from "babylonjs/Misc/smartArray";
  41577. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41578. import { Nullable } from "babylonjs/types";
  41579. import { Scene } from "babylonjs/scene";
  41580. import { Matrix } from "babylonjs/Maths/math.vector";
  41581. import { Color3 } from "babylonjs/Maths/math.color";
  41582. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41584. import { Mesh } from "babylonjs/Meshes/mesh";
  41585. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41586. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41587. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41588. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41589. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41591. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41592. import "babylonjs/Shaders/default.fragment";
  41593. import "babylonjs/Shaders/default.vertex";
  41594. /** @hidden */
  41595. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41596. MAINUV1: boolean;
  41597. MAINUV2: boolean;
  41598. DIFFUSE: boolean;
  41599. DIFFUSEDIRECTUV: number;
  41600. AMBIENT: boolean;
  41601. AMBIENTDIRECTUV: number;
  41602. OPACITY: boolean;
  41603. OPACITYDIRECTUV: number;
  41604. OPACITYRGB: boolean;
  41605. REFLECTION: boolean;
  41606. EMISSIVE: boolean;
  41607. EMISSIVEDIRECTUV: number;
  41608. SPECULAR: boolean;
  41609. SPECULARDIRECTUV: number;
  41610. BUMP: boolean;
  41611. BUMPDIRECTUV: number;
  41612. PARALLAX: boolean;
  41613. PARALLAXOCCLUSION: boolean;
  41614. SPECULAROVERALPHA: boolean;
  41615. CLIPPLANE: boolean;
  41616. CLIPPLANE2: boolean;
  41617. CLIPPLANE3: boolean;
  41618. CLIPPLANE4: boolean;
  41619. ALPHATEST: boolean;
  41620. DEPTHPREPASS: boolean;
  41621. ALPHAFROMDIFFUSE: boolean;
  41622. POINTSIZE: boolean;
  41623. FOG: boolean;
  41624. SPECULARTERM: boolean;
  41625. DIFFUSEFRESNEL: boolean;
  41626. OPACITYFRESNEL: boolean;
  41627. REFLECTIONFRESNEL: boolean;
  41628. REFRACTIONFRESNEL: boolean;
  41629. EMISSIVEFRESNEL: boolean;
  41630. FRESNEL: boolean;
  41631. NORMAL: boolean;
  41632. UV1: boolean;
  41633. UV2: boolean;
  41634. VERTEXCOLOR: boolean;
  41635. VERTEXALPHA: boolean;
  41636. NUM_BONE_INFLUENCERS: number;
  41637. BonesPerMesh: number;
  41638. BONETEXTURE: boolean;
  41639. INSTANCES: boolean;
  41640. GLOSSINESS: boolean;
  41641. ROUGHNESS: boolean;
  41642. EMISSIVEASILLUMINATION: boolean;
  41643. LINKEMISSIVEWITHDIFFUSE: boolean;
  41644. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41645. LIGHTMAP: boolean;
  41646. LIGHTMAPDIRECTUV: number;
  41647. OBJECTSPACE_NORMALMAP: boolean;
  41648. USELIGHTMAPASSHADOWMAP: boolean;
  41649. REFLECTIONMAP_3D: boolean;
  41650. REFLECTIONMAP_SPHERICAL: boolean;
  41651. REFLECTIONMAP_PLANAR: boolean;
  41652. REFLECTIONMAP_CUBIC: boolean;
  41653. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41654. REFLECTIONMAP_PROJECTION: boolean;
  41655. REFLECTIONMAP_SKYBOX: boolean;
  41656. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41657. REFLECTIONMAP_EXPLICIT: boolean;
  41658. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41659. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41660. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41661. INVERTCUBICMAP: boolean;
  41662. LOGARITHMICDEPTH: boolean;
  41663. REFRACTION: boolean;
  41664. REFRACTIONMAP_3D: boolean;
  41665. REFLECTIONOVERALPHA: boolean;
  41666. TWOSIDEDLIGHTING: boolean;
  41667. SHADOWFLOAT: boolean;
  41668. MORPHTARGETS: boolean;
  41669. MORPHTARGETS_NORMAL: boolean;
  41670. MORPHTARGETS_TANGENT: boolean;
  41671. MORPHTARGETS_UV: boolean;
  41672. NUM_MORPH_INFLUENCERS: number;
  41673. NONUNIFORMSCALING: boolean;
  41674. PREMULTIPLYALPHA: boolean;
  41675. IMAGEPROCESSING: boolean;
  41676. VIGNETTE: boolean;
  41677. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41678. VIGNETTEBLENDMODEOPAQUE: boolean;
  41679. TONEMAPPING: boolean;
  41680. TONEMAPPING_ACES: boolean;
  41681. CONTRAST: boolean;
  41682. COLORCURVES: boolean;
  41683. COLORGRADING: boolean;
  41684. COLORGRADING3D: boolean;
  41685. SAMPLER3DGREENDEPTH: boolean;
  41686. SAMPLER3DBGRMAP: boolean;
  41687. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41688. MULTIVIEW: boolean;
  41689. /**
  41690. * If the reflection texture on this material is in linear color space
  41691. * @hidden
  41692. */
  41693. IS_REFLECTION_LINEAR: boolean;
  41694. /**
  41695. * If the refraction texture on this material is in linear color space
  41696. * @hidden
  41697. */
  41698. IS_REFRACTION_LINEAR: boolean;
  41699. EXPOSURE: boolean;
  41700. constructor();
  41701. setReflectionMode(modeToEnable: string): void;
  41702. }
  41703. /**
  41704. * This is the default material used in Babylon. It is the best trade off between quality
  41705. * and performances.
  41706. * @see http://doc.babylonjs.com/babylon101/materials
  41707. */
  41708. export class StandardMaterial extends PushMaterial {
  41709. private _diffuseTexture;
  41710. /**
  41711. * The basic texture of the material as viewed under a light.
  41712. */
  41713. diffuseTexture: Nullable<BaseTexture>;
  41714. private _ambientTexture;
  41715. /**
  41716. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41717. */
  41718. ambientTexture: Nullable<BaseTexture>;
  41719. private _opacityTexture;
  41720. /**
  41721. * Define the transparency of the material from a texture.
  41722. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41723. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41724. */
  41725. opacityTexture: Nullable<BaseTexture>;
  41726. private _reflectionTexture;
  41727. /**
  41728. * Define the texture used to display the reflection.
  41729. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41730. */
  41731. reflectionTexture: Nullable<BaseTexture>;
  41732. private _emissiveTexture;
  41733. /**
  41734. * Define texture of the material as if self lit.
  41735. * This will be mixed in the final result even in the absence of light.
  41736. */
  41737. emissiveTexture: Nullable<BaseTexture>;
  41738. private _specularTexture;
  41739. /**
  41740. * Define how the color and intensity of the highlight given by the light in the material.
  41741. */
  41742. specularTexture: Nullable<BaseTexture>;
  41743. private _bumpTexture;
  41744. /**
  41745. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41746. * 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.
  41747. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41748. */
  41749. bumpTexture: Nullable<BaseTexture>;
  41750. private _lightmapTexture;
  41751. /**
  41752. * Complex lighting can be computationally expensive to compute at runtime.
  41753. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41754. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41755. */
  41756. lightmapTexture: Nullable<BaseTexture>;
  41757. private _refractionTexture;
  41758. /**
  41759. * Define the texture used to display the refraction.
  41760. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41761. */
  41762. refractionTexture: Nullable<BaseTexture>;
  41763. /**
  41764. * The color of the material lit by the environmental background lighting.
  41765. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41766. */
  41767. ambientColor: Color3;
  41768. /**
  41769. * The basic color of the material as viewed under a light.
  41770. */
  41771. diffuseColor: Color3;
  41772. /**
  41773. * Define how the color and intensity of the highlight given by the light in the material.
  41774. */
  41775. specularColor: Color3;
  41776. /**
  41777. * Define the color of the material as if self lit.
  41778. * This will be mixed in the final result even in the absence of light.
  41779. */
  41780. emissiveColor: Color3;
  41781. /**
  41782. * Defines how sharp are the highlights in the material.
  41783. * The bigger the value the sharper giving a more glossy feeling to the result.
  41784. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41785. */
  41786. specularPower: number;
  41787. private _useAlphaFromDiffuseTexture;
  41788. /**
  41789. * Does the transparency come from the diffuse texture alpha channel.
  41790. */
  41791. useAlphaFromDiffuseTexture: boolean;
  41792. private _useEmissiveAsIllumination;
  41793. /**
  41794. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41795. */
  41796. useEmissiveAsIllumination: boolean;
  41797. private _linkEmissiveWithDiffuse;
  41798. /**
  41799. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41800. * the emissive level when the final color is close to one.
  41801. */
  41802. linkEmissiveWithDiffuse: boolean;
  41803. private _useSpecularOverAlpha;
  41804. /**
  41805. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41806. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41807. */
  41808. useSpecularOverAlpha: boolean;
  41809. private _useReflectionOverAlpha;
  41810. /**
  41811. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41812. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41813. */
  41814. useReflectionOverAlpha: boolean;
  41815. private _disableLighting;
  41816. /**
  41817. * Does lights from the scene impacts this material.
  41818. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41819. */
  41820. disableLighting: boolean;
  41821. private _useObjectSpaceNormalMap;
  41822. /**
  41823. * Allows using an object space normal map (instead of tangent space).
  41824. */
  41825. useObjectSpaceNormalMap: boolean;
  41826. private _useParallax;
  41827. /**
  41828. * Is parallax enabled or not.
  41829. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41830. */
  41831. useParallax: boolean;
  41832. private _useParallaxOcclusion;
  41833. /**
  41834. * Is parallax occlusion enabled or not.
  41835. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41836. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41837. */
  41838. useParallaxOcclusion: boolean;
  41839. /**
  41840. * 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.
  41841. */
  41842. parallaxScaleBias: number;
  41843. private _roughness;
  41844. /**
  41845. * Helps to define how blurry the reflections should appears in the material.
  41846. */
  41847. roughness: number;
  41848. /**
  41849. * In case of refraction, define the value of the index of refraction.
  41850. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41851. */
  41852. indexOfRefraction: number;
  41853. /**
  41854. * Invert the refraction texture alongside the y axis.
  41855. * It can be useful with procedural textures or probe for instance.
  41856. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41857. */
  41858. invertRefractionY: boolean;
  41859. /**
  41860. * Defines the alpha limits in alpha test mode.
  41861. */
  41862. alphaCutOff: number;
  41863. private _useLightmapAsShadowmap;
  41864. /**
  41865. * In case of light mapping, define whether the map contains light or shadow informations.
  41866. */
  41867. useLightmapAsShadowmap: boolean;
  41868. private _diffuseFresnelParameters;
  41869. /**
  41870. * Define the diffuse fresnel parameters of the material.
  41871. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41872. */
  41873. diffuseFresnelParameters: FresnelParameters;
  41874. private _opacityFresnelParameters;
  41875. /**
  41876. * Define the opacity fresnel parameters of the material.
  41877. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41878. */
  41879. opacityFresnelParameters: FresnelParameters;
  41880. private _reflectionFresnelParameters;
  41881. /**
  41882. * Define the reflection fresnel parameters of the material.
  41883. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41884. */
  41885. reflectionFresnelParameters: FresnelParameters;
  41886. private _refractionFresnelParameters;
  41887. /**
  41888. * Define the refraction fresnel parameters of the material.
  41889. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41890. */
  41891. refractionFresnelParameters: FresnelParameters;
  41892. private _emissiveFresnelParameters;
  41893. /**
  41894. * Define the emissive fresnel parameters of the material.
  41895. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41896. */
  41897. emissiveFresnelParameters: FresnelParameters;
  41898. private _useReflectionFresnelFromSpecular;
  41899. /**
  41900. * If true automatically deducts the fresnels values from the material specularity.
  41901. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41902. */
  41903. useReflectionFresnelFromSpecular: boolean;
  41904. private _useGlossinessFromSpecularMapAlpha;
  41905. /**
  41906. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41907. */
  41908. useGlossinessFromSpecularMapAlpha: boolean;
  41909. private _maxSimultaneousLights;
  41910. /**
  41911. * Defines the maximum number of lights that can be used in the material
  41912. */
  41913. maxSimultaneousLights: number;
  41914. private _invertNormalMapX;
  41915. /**
  41916. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41917. */
  41918. invertNormalMapX: boolean;
  41919. private _invertNormalMapY;
  41920. /**
  41921. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41922. */
  41923. invertNormalMapY: boolean;
  41924. private _twoSidedLighting;
  41925. /**
  41926. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41927. */
  41928. twoSidedLighting: boolean;
  41929. /**
  41930. * Default configuration related to image processing available in the standard Material.
  41931. */
  41932. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41933. /**
  41934. * Gets the image processing configuration used either in this material.
  41935. */
  41936. /**
  41937. * Sets the Default image processing configuration used either in the this material.
  41938. *
  41939. * If sets to null, the scene one is in use.
  41940. */
  41941. imageProcessingConfiguration: ImageProcessingConfiguration;
  41942. /**
  41943. * Keep track of the image processing observer to allow dispose and replace.
  41944. */
  41945. private _imageProcessingObserver;
  41946. /**
  41947. * Attaches a new image processing configuration to the Standard Material.
  41948. * @param configuration
  41949. */
  41950. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41951. /**
  41952. * Gets wether the color curves effect is enabled.
  41953. */
  41954. /**
  41955. * Sets wether the color curves effect is enabled.
  41956. */
  41957. cameraColorCurvesEnabled: boolean;
  41958. /**
  41959. * Gets wether the color grading effect is enabled.
  41960. */
  41961. /**
  41962. * Gets wether the color grading effect is enabled.
  41963. */
  41964. cameraColorGradingEnabled: boolean;
  41965. /**
  41966. * Gets wether tonemapping is enabled or not.
  41967. */
  41968. /**
  41969. * Sets wether tonemapping is enabled or not
  41970. */
  41971. cameraToneMappingEnabled: boolean;
  41972. /**
  41973. * The camera exposure used on this material.
  41974. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41975. * This corresponds to a photographic exposure.
  41976. */
  41977. /**
  41978. * The camera exposure used on this material.
  41979. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41980. * This corresponds to a photographic exposure.
  41981. */
  41982. cameraExposure: number;
  41983. /**
  41984. * Gets The camera contrast used on this material.
  41985. */
  41986. /**
  41987. * Sets The camera contrast used on this material.
  41988. */
  41989. cameraContrast: number;
  41990. /**
  41991. * Gets the Color Grading 2D Lookup Texture.
  41992. */
  41993. /**
  41994. * Sets the Color Grading 2D Lookup Texture.
  41995. */
  41996. cameraColorGradingTexture: Nullable<BaseTexture>;
  41997. /**
  41998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42000. * 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;
  42001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42002. */
  42003. /**
  42004. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42005. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42006. * 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;
  42007. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42008. */
  42009. cameraColorCurves: Nullable<ColorCurves>;
  42010. /**
  42011. * Custom callback helping to override the default shader used in the material.
  42012. */
  42013. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42014. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42015. protected _worldViewProjectionMatrix: Matrix;
  42016. protected _globalAmbientColor: Color3;
  42017. protected _useLogarithmicDepth: boolean;
  42018. protected _rebuildInParallel: boolean;
  42019. /**
  42020. * Instantiates a new standard material.
  42021. * This is the default material used in Babylon. It is the best trade off between quality
  42022. * and performances.
  42023. * @see http://doc.babylonjs.com/babylon101/materials
  42024. * @param name Define the name of the material in the scene
  42025. * @param scene Define the scene the material belong to
  42026. */
  42027. constructor(name: string, scene: Scene);
  42028. /**
  42029. * Gets a boolean indicating that current material needs to register RTT
  42030. */
  42031. readonly hasRenderTargetTextures: boolean;
  42032. /**
  42033. * Gets the current class name of the material e.g. "StandardMaterial"
  42034. * Mainly use in serialization.
  42035. * @returns the class name
  42036. */
  42037. getClassName(): string;
  42038. /**
  42039. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42040. * You can try switching to logarithmic depth.
  42041. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42042. */
  42043. useLogarithmicDepth: boolean;
  42044. /**
  42045. * Specifies if the material will require alpha blending
  42046. * @returns a boolean specifying if alpha blending is needed
  42047. */
  42048. needAlphaBlending(): boolean;
  42049. /**
  42050. * Specifies if this material should be rendered in alpha test mode
  42051. * @returns a boolean specifying if an alpha test is needed.
  42052. */
  42053. needAlphaTesting(): boolean;
  42054. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42055. /**
  42056. * Get the texture used for alpha test purpose.
  42057. * @returns the diffuse texture in case of the standard material.
  42058. */
  42059. getAlphaTestTexture(): Nullable<BaseTexture>;
  42060. /**
  42061. * Get if the submesh is ready to be used and all its information available.
  42062. * Child classes can use it to update shaders
  42063. * @param mesh defines the mesh to check
  42064. * @param subMesh defines which submesh to check
  42065. * @param useInstances specifies that instances should be used
  42066. * @returns a boolean indicating that the submesh is ready or not
  42067. */
  42068. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42069. /**
  42070. * Builds the material UBO layouts.
  42071. * Used internally during the effect preparation.
  42072. */
  42073. buildUniformLayout(): void;
  42074. /**
  42075. * Unbinds the material from the mesh
  42076. */
  42077. unbind(): void;
  42078. /**
  42079. * Binds the submesh to this material by preparing the effect and shader to draw
  42080. * @param world defines the world transformation matrix
  42081. * @param mesh defines the mesh containing the submesh
  42082. * @param subMesh defines the submesh to bind the material to
  42083. */
  42084. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42085. /**
  42086. * Get the list of animatables in the material.
  42087. * @returns the list of animatables object used in the material
  42088. */
  42089. getAnimatables(): IAnimatable[];
  42090. /**
  42091. * Gets the active textures from the material
  42092. * @returns an array of textures
  42093. */
  42094. getActiveTextures(): BaseTexture[];
  42095. /**
  42096. * Specifies if the material uses a texture
  42097. * @param texture defines the texture to check against the material
  42098. * @returns a boolean specifying if the material uses the texture
  42099. */
  42100. hasTexture(texture: BaseTexture): boolean;
  42101. /**
  42102. * Disposes the material
  42103. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42104. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42105. */
  42106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42107. /**
  42108. * Makes a duplicate of the material, and gives it a new name
  42109. * @param name defines the new name for the duplicated material
  42110. * @returns the cloned material
  42111. */
  42112. clone(name: string): StandardMaterial;
  42113. /**
  42114. * Serializes this material in a JSON representation
  42115. * @returns the serialized material object
  42116. */
  42117. serialize(): any;
  42118. /**
  42119. * Creates a standard material from parsed material data
  42120. * @param source defines the JSON representation of the material
  42121. * @param scene defines the hosting scene
  42122. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42123. * @returns a new standard material
  42124. */
  42125. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42126. /**
  42127. * Are diffuse textures enabled in the application.
  42128. */
  42129. static DiffuseTextureEnabled: boolean;
  42130. /**
  42131. * Are ambient textures enabled in the application.
  42132. */
  42133. static AmbientTextureEnabled: boolean;
  42134. /**
  42135. * Are opacity textures enabled in the application.
  42136. */
  42137. static OpacityTextureEnabled: boolean;
  42138. /**
  42139. * Are reflection textures enabled in the application.
  42140. */
  42141. static ReflectionTextureEnabled: boolean;
  42142. /**
  42143. * Are emissive textures enabled in the application.
  42144. */
  42145. static EmissiveTextureEnabled: boolean;
  42146. /**
  42147. * Are specular textures enabled in the application.
  42148. */
  42149. static SpecularTextureEnabled: boolean;
  42150. /**
  42151. * Are bump textures enabled in the application.
  42152. */
  42153. static BumpTextureEnabled: boolean;
  42154. /**
  42155. * Are lightmap textures enabled in the application.
  42156. */
  42157. static LightmapTextureEnabled: boolean;
  42158. /**
  42159. * Are refraction textures enabled in the application.
  42160. */
  42161. static RefractionTextureEnabled: boolean;
  42162. /**
  42163. * Are color grading textures enabled in the application.
  42164. */
  42165. static ColorGradingTextureEnabled: boolean;
  42166. /**
  42167. * Are fresnels enabled in the application.
  42168. */
  42169. static FresnelEnabled: boolean;
  42170. }
  42171. }
  42172. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42173. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42174. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42175. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42176. /** @hidden */
  42177. export var imageProcessingPixelShader: {
  42178. name: string;
  42179. shader: string;
  42180. };
  42181. }
  42182. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42183. import { Nullable } from "babylonjs/types";
  42184. import { Color4 } from "babylonjs/Maths/math.color";
  42185. import { Camera } from "babylonjs/Cameras/camera";
  42186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42187. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42188. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42189. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42190. import { Engine } from "babylonjs/Engines/engine";
  42191. import "babylonjs/Shaders/imageProcessing.fragment";
  42192. import "babylonjs/Shaders/postprocess.vertex";
  42193. /**
  42194. * ImageProcessingPostProcess
  42195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42196. */
  42197. export class ImageProcessingPostProcess extends PostProcess {
  42198. /**
  42199. * Default configuration related to image processing available in the PBR Material.
  42200. */
  42201. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42202. /**
  42203. * Gets the image processing configuration used either in this material.
  42204. */
  42205. /**
  42206. * Sets the Default image processing configuration used either in the this material.
  42207. *
  42208. * If sets to null, the scene one is in use.
  42209. */
  42210. imageProcessingConfiguration: ImageProcessingConfiguration;
  42211. /**
  42212. * Keep track of the image processing observer to allow dispose and replace.
  42213. */
  42214. private _imageProcessingObserver;
  42215. /**
  42216. * Attaches a new image processing configuration to the PBR Material.
  42217. * @param configuration
  42218. */
  42219. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42220. /**
  42221. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42222. */
  42223. /**
  42224. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42225. */
  42226. colorCurves: Nullable<ColorCurves>;
  42227. /**
  42228. * Gets wether the color curves effect is enabled.
  42229. */
  42230. /**
  42231. * Sets wether the color curves effect is enabled.
  42232. */
  42233. colorCurvesEnabled: boolean;
  42234. /**
  42235. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42236. */
  42237. /**
  42238. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42239. */
  42240. colorGradingTexture: Nullable<BaseTexture>;
  42241. /**
  42242. * Gets wether the color grading effect is enabled.
  42243. */
  42244. /**
  42245. * Gets wether the color grading effect is enabled.
  42246. */
  42247. colorGradingEnabled: boolean;
  42248. /**
  42249. * Gets exposure used in the effect.
  42250. */
  42251. /**
  42252. * Sets exposure used in the effect.
  42253. */
  42254. exposure: number;
  42255. /**
  42256. * Gets wether tonemapping is enabled or not.
  42257. */
  42258. /**
  42259. * Sets wether tonemapping is enabled or not
  42260. */
  42261. toneMappingEnabled: boolean;
  42262. /**
  42263. * Gets the type of tone mapping effect.
  42264. */
  42265. /**
  42266. * Sets the type of tone mapping effect.
  42267. */
  42268. toneMappingType: number;
  42269. /**
  42270. * Gets contrast used in the effect.
  42271. */
  42272. /**
  42273. * Sets contrast used in the effect.
  42274. */
  42275. contrast: number;
  42276. /**
  42277. * Gets Vignette stretch size.
  42278. */
  42279. /**
  42280. * Sets Vignette stretch size.
  42281. */
  42282. vignetteStretch: number;
  42283. /**
  42284. * Gets Vignette centre X Offset.
  42285. */
  42286. /**
  42287. * Sets Vignette centre X Offset.
  42288. */
  42289. vignetteCentreX: number;
  42290. /**
  42291. * Gets Vignette centre Y Offset.
  42292. */
  42293. /**
  42294. * Sets Vignette centre Y Offset.
  42295. */
  42296. vignetteCentreY: number;
  42297. /**
  42298. * Gets Vignette weight or intensity of the vignette effect.
  42299. */
  42300. /**
  42301. * Sets Vignette weight or intensity of the vignette effect.
  42302. */
  42303. vignetteWeight: number;
  42304. /**
  42305. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42306. * if vignetteEnabled is set to true.
  42307. */
  42308. /**
  42309. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42310. * if vignetteEnabled is set to true.
  42311. */
  42312. vignetteColor: Color4;
  42313. /**
  42314. * Gets Camera field of view used by the Vignette effect.
  42315. */
  42316. /**
  42317. * Sets Camera field of view used by the Vignette effect.
  42318. */
  42319. vignetteCameraFov: number;
  42320. /**
  42321. * Gets the vignette blend mode allowing different kind of effect.
  42322. */
  42323. /**
  42324. * Sets the vignette blend mode allowing different kind of effect.
  42325. */
  42326. vignetteBlendMode: number;
  42327. /**
  42328. * Gets wether the vignette effect is enabled.
  42329. */
  42330. /**
  42331. * Sets wether the vignette effect is enabled.
  42332. */
  42333. vignetteEnabled: boolean;
  42334. private _fromLinearSpace;
  42335. /**
  42336. * Gets wether the input of the processing is in Gamma or Linear Space.
  42337. */
  42338. /**
  42339. * Sets wether the input of the processing is in Gamma or Linear Space.
  42340. */
  42341. fromLinearSpace: boolean;
  42342. /**
  42343. * Defines cache preventing GC.
  42344. */
  42345. private _defines;
  42346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42347. /**
  42348. * "ImageProcessingPostProcess"
  42349. * @returns "ImageProcessingPostProcess"
  42350. */
  42351. getClassName(): string;
  42352. protected _updateParameters(): void;
  42353. dispose(camera?: Camera): void;
  42354. }
  42355. }
  42356. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42357. import { Scene } from "babylonjs/scene";
  42358. import { Color3 } from "babylonjs/Maths/math.color";
  42359. import { Mesh } from "babylonjs/Meshes/mesh";
  42360. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42361. import { Nullable } from "babylonjs/types";
  42362. /**
  42363. * Class containing static functions to help procedurally build meshes
  42364. */
  42365. export class GroundBuilder {
  42366. /**
  42367. * Creates a ground mesh
  42368. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42369. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42371. * @param name defines the name of the mesh
  42372. * @param options defines the options used to create the mesh
  42373. * @param scene defines the hosting scene
  42374. * @returns the ground mesh
  42375. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42376. */
  42377. static CreateGround(name: string, options: {
  42378. width?: number;
  42379. height?: number;
  42380. subdivisions?: number;
  42381. subdivisionsX?: number;
  42382. subdivisionsY?: number;
  42383. updatable?: boolean;
  42384. }, scene: any): Mesh;
  42385. /**
  42386. * Creates a tiled ground mesh
  42387. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42388. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42389. * * 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
  42390. * * 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
  42391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42392. * @param name defines the name of the mesh
  42393. * @param options defines the options used to create the mesh
  42394. * @param scene defines the hosting scene
  42395. * @returns the tiled ground mesh
  42396. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42397. */
  42398. static CreateTiledGround(name: string, options: {
  42399. xmin: number;
  42400. zmin: number;
  42401. xmax: number;
  42402. zmax: number;
  42403. subdivisions?: {
  42404. w: number;
  42405. h: number;
  42406. };
  42407. precision?: {
  42408. w: number;
  42409. h: number;
  42410. };
  42411. updatable?: boolean;
  42412. }, scene?: Nullable<Scene>): Mesh;
  42413. /**
  42414. * Creates a ground mesh from a height map
  42415. * * The parameter `url` sets the URL of the height map image resource.
  42416. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42417. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42418. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42419. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42420. * * 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.
  42421. * * 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).
  42422. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42424. * @param name defines the name of the mesh
  42425. * @param url defines the url to the height map
  42426. * @param options defines the options used to create the mesh
  42427. * @param scene defines the hosting scene
  42428. * @returns the ground mesh
  42429. * @see https://doc.babylonjs.com/babylon101/height_map
  42430. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42431. */
  42432. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42433. width?: number;
  42434. height?: number;
  42435. subdivisions?: number;
  42436. minHeight?: number;
  42437. maxHeight?: number;
  42438. colorFilter?: Color3;
  42439. alphaFilter?: number;
  42440. updatable?: boolean;
  42441. onReady?: (mesh: GroundMesh) => void;
  42442. }, scene?: Nullable<Scene>): GroundMesh;
  42443. }
  42444. }
  42445. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42446. import { Vector4 } from "babylonjs/Maths/math.vector";
  42447. import { Mesh } from "babylonjs/Meshes/mesh";
  42448. /**
  42449. * Class containing static functions to help procedurally build meshes
  42450. */
  42451. export class TorusBuilder {
  42452. /**
  42453. * Creates a torus mesh
  42454. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42455. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42456. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42460. * @param name defines the name of the mesh
  42461. * @param options defines the options used to create the mesh
  42462. * @param scene defines the hosting scene
  42463. * @returns the torus mesh
  42464. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42465. */
  42466. static CreateTorus(name: string, options: {
  42467. diameter?: number;
  42468. thickness?: number;
  42469. tessellation?: number;
  42470. updatable?: boolean;
  42471. sideOrientation?: number;
  42472. frontUVs?: Vector4;
  42473. backUVs?: Vector4;
  42474. }, scene: any): Mesh;
  42475. }
  42476. }
  42477. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42478. import { Vector4 } from "babylonjs/Maths/math.vector";
  42479. import { Color4 } from "babylonjs/Maths/math.color";
  42480. import { Mesh } from "babylonjs/Meshes/mesh";
  42481. /**
  42482. * Class containing static functions to help procedurally build meshes
  42483. */
  42484. export class CylinderBuilder {
  42485. /**
  42486. * Creates a cylinder or a cone mesh
  42487. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42488. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42489. * * 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.
  42490. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42491. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42492. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42493. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42494. * * 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).
  42495. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42496. * * 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).
  42497. * * 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
  42498. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42499. * * 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
  42500. * * 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.
  42501. * * If `enclose` is false, a ring surface is one element.
  42502. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42503. * * 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
  42504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42507. * @param name defines the name of the mesh
  42508. * @param options defines the options used to create the mesh
  42509. * @param scene defines the hosting scene
  42510. * @returns the cylinder mesh
  42511. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42512. */
  42513. static CreateCylinder(name: string, options: {
  42514. height?: number;
  42515. diameterTop?: number;
  42516. diameterBottom?: number;
  42517. diameter?: number;
  42518. tessellation?: number;
  42519. subdivisions?: number;
  42520. arc?: number;
  42521. faceColors?: Color4[];
  42522. faceUV?: Vector4[];
  42523. updatable?: boolean;
  42524. hasRings?: boolean;
  42525. enclose?: boolean;
  42526. cap?: number;
  42527. sideOrientation?: number;
  42528. frontUVs?: Vector4;
  42529. backUVs?: Vector4;
  42530. }, scene: any): Mesh;
  42531. }
  42532. }
  42533. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42534. import { Observable } from "babylonjs/Misc/observable";
  42535. import { Nullable } from "babylonjs/types";
  42536. import { Camera } from "babylonjs/Cameras/camera";
  42537. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42538. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42539. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42540. import { Scene } from "babylonjs/scene";
  42541. import { Vector3 } from "babylonjs/Maths/math.vector";
  42542. import { Color3 } from "babylonjs/Maths/math.color";
  42543. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42545. import { Mesh } from "babylonjs/Meshes/mesh";
  42546. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42547. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42548. import "babylonjs/Meshes/Builders/groundBuilder";
  42549. import "babylonjs/Meshes/Builders/torusBuilder";
  42550. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42551. import "babylonjs/Gamepads/gamepadSceneComponent";
  42552. import "babylonjs/Animations/animatable";
  42553. /**
  42554. * Options to modify the vr teleportation behavior.
  42555. */
  42556. export interface VRTeleportationOptions {
  42557. /**
  42558. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42559. */
  42560. floorMeshName?: string;
  42561. /**
  42562. * A list of meshes to be used as the teleportation floor. (default: empty)
  42563. */
  42564. floorMeshes?: Mesh[];
  42565. }
  42566. /**
  42567. * Options to modify the vr experience helper's behavior.
  42568. */
  42569. export interface VRExperienceHelperOptions extends WebVROptions {
  42570. /**
  42571. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42572. */
  42573. createDeviceOrientationCamera?: boolean;
  42574. /**
  42575. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42576. */
  42577. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42578. /**
  42579. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42580. */
  42581. laserToggle?: boolean;
  42582. /**
  42583. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42584. */
  42585. floorMeshes?: Mesh[];
  42586. /**
  42587. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42588. */
  42589. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42590. }
  42591. /**
  42592. * Event containing information after VR has been entered
  42593. */
  42594. export class OnAfterEnteringVRObservableEvent {
  42595. /**
  42596. * If entering vr was successful
  42597. */
  42598. success: boolean;
  42599. }
  42600. /**
  42601. * Helps to quickly add VR support to an existing scene.
  42602. * See http://doc.babylonjs.com/how_to/webvr_helper
  42603. */
  42604. export class VRExperienceHelper {
  42605. /** Options to modify the vr experience helper's behavior. */
  42606. webVROptions: VRExperienceHelperOptions;
  42607. private _scene;
  42608. private _position;
  42609. private _btnVR;
  42610. private _btnVRDisplayed;
  42611. private _webVRsupported;
  42612. private _webVRready;
  42613. private _webVRrequesting;
  42614. private _webVRpresenting;
  42615. private _hasEnteredVR;
  42616. private _fullscreenVRpresenting;
  42617. private _canvas;
  42618. private _webVRCamera;
  42619. private _vrDeviceOrientationCamera;
  42620. private _deviceOrientationCamera;
  42621. private _existingCamera;
  42622. private _onKeyDown;
  42623. private _onVrDisplayPresentChange;
  42624. private _onVRDisplayChanged;
  42625. private _onVRRequestPresentStart;
  42626. private _onVRRequestPresentComplete;
  42627. /**
  42628. * 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)
  42629. */
  42630. enableGazeEvenWhenNoPointerLock: boolean;
  42631. /**
  42632. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42633. */
  42634. exitVROnDoubleTap: boolean;
  42635. /**
  42636. * Observable raised right before entering VR.
  42637. */
  42638. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42639. /**
  42640. * Observable raised when entering VR has completed.
  42641. */
  42642. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42643. /**
  42644. * Observable raised when exiting VR.
  42645. */
  42646. onExitingVRObservable: Observable<VRExperienceHelper>;
  42647. /**
  42648. * Observable raised when controller mesh is loaded.
  42649. */
  42650. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42651. /** Return this.onEnteringVRObservable
  42652. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42653. */
  42654. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42655. /** Return this.onExitingVRObservable
  42656. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42657. */
  42658. readonly onExitingVR: Observable<VRExperienceHelper>;
  42659. /** Return this.onControllerMeshLoadedObservable
  42660. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42661. */
  42662. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42663. private _rayLength;
  42664. private _useCustomVRButton;
  42665. private _teleportationRequested;
  42666. private _teleportActive;
  42667. private _floorMeshName;
  42668. private _floorMeshesCollection;
  42669. private _rotationAllowed;
  42670. private _teleportBackwardsVector;
  42671. private _teleportationTarget;
  42672. private _isDefaultTeleportationTarget;
  42673. private _postProcessMove;
  42674. private _teleportationFillColor;
  42675. private _teleportationBorderColor;
  42676. private _rotationAngle;
  42677. private _haloCenter;
  42678. private _cameraGazer;
  42679. private _padSensibilityUp;
  42680. private _padSensibilityDown;
  42681. private _leftController;
  42682. private _rightController;
  42683. /**
  42684. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42685. */
  42686. onNewMeshSelected: Observable<AbstractMesh>;
  42687. /**
  42688. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42689. * This observable will provide the mesh and the controller used to select the mesh
  42690. */
  42691. onMeshSelectedWithController: Observable<{
  42692. mesh: AbstractMesh;
  42693. controller: WebVRController;
  42694. }>;
  42695. /**
  42696. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42697. */
  42698. onNewMeshPicked: Observable<PickingInfo>;
  42699. private _circleEase;
  42700. /**
  42701. * Observable raised before camera teleportation
  42702. */
  42703. onBeforeCameraTeleport: Observable<Vector3>;
  42704. /**
  42705. * Observable raised after camera teleportation
  42706. */
  42707. onAfterCameraTeleport: Observable<Vector3>;
  42708. /**
  42709. * Observable raised when current selected mesh gets unselected
  42710. */
  42711. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42712. private _raySelectionPredicate;
  42713. /**
  42714. * To be optionaly changed by user to define custom ray selection
  42715. */
  42716. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42717. /**
  42718. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42719. */
  42720. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42721. /**
  42722. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42723. */
  42724. teleportationEnabled: boolean;
  42725. private _defaultHeight;
  42726. private _teleportationInitialized;
  42727. private _interactionsEnabled;
  42728. private _interactionsRequested;
  42729. private _displayGaze;
  42730. private _displayLaserPointer;
  42731. /**
  42732. * The mesh used to display where the user is going to teleport.
  42733. */
  42734. /**
  42735. * Sets the mesh to be used to display where the user is going to teleport.
  42736. */
  42737. teleportationTarget: Mesh;
  42738. /**
  42739. * 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
  42740. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42741. * See http://doc.babylonjs.com/resources/baking_transformations
  42742. */
  42743. gazeTrackerMesh: Mesh;
  42744. /**
  42745. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42746. */
  42747. updateGazeTrackerScale: boolean;
  42748. /**
  42749. * If the gaze trackers color should be updated when selecting meshes
  42750. */
  42751. updateGazeTrackerColor: boolean;
  42752. /**
  42753. * If the controller laser color should be updated when selecting meshes
  42754. */
  42755. updateControllerLaserColor: boolean;
  42756. /**
  42757. * The gaze tracking mesh corresponding to the left controller
  42758. */
  42759. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42760. /**
  42761. * The gaze tracking mesh corresponding to the right controller
  42762. */
  42763. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42764. /**
  42765. * If the ray of the gaze should be displayed.
  42766. */
  42767. /**
  42768. * Sets if the ray of the gaze should be displayed.
  42769. */
  42770. displayGaze: boolean;
  42771. /**
  42772. * If the ray of the LaserPointer should be displayed.
  42773. */
  42774. /**
  42775. * Sets if the ray of the LaserPointer should be displayed.
  42776. */
  42777. displayLaserPointer: boolean;
  42778. /**
  42779. * The deviceOrientationCamera used as the camera when not in VR.
  42780. */
  42781. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42782. /**
  42783. * Based on the current WebVR support, returns the current VR camera used.
  42784. */
  42785. readonly currentVRCamera: Nullable<Camera>;
  42786. /**
  42787. * The webVRCamera which is used when in VR.
  42788. */
  42789. readonly webVRCamera: WebVRFreeCamera;
  42790. /**
  42791. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42792. */
  42793. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42794. /**
  42795. * The html button that is used to trigger entering into VR.
  42796. */
  42797. readonly vrButton: Nullable<HTMLButtonElement>;
  42798. private readonly _teleportationRequestInitiated;
  42799. /**
  42800. * Defines wether or not Pointer lock should be requested when switching to
  42801. * full screen.
  42802. */
  42803. requestPointerLockOnFullScreen: boolean;
  42804. /**
  42805. * Instantiates a VRExperienceHelper.
  42806. * Helps to quickly add VR support to an existing scene.
  42807. * @param scene The scene the VRExperienceHelper belongs to.
  42808. * @param webVROptions Options to modify the vr experience helper's behavior.
  42809. */
  42810. constructor(scene: Scene,
  42811. /** Options to modify the vr experience helper's behavior. */
  42812. webVROptions?: VRExperienceHelperOptions);
  42813. private _onDefaultMeshLoaded;
  42814. private _onResize;
  42815. private _onFullscreenChange;
  42816. /**
  42817. * Gets a value indicating if we are currently in VR mode.
  42818. */
  42819. readonly isInVRMode: boolean;
  42820. private onVrDisplayPresentChange;
  42821. private onVRDisplayChanged;
  42822. private moveButtonToBottomRight;
  42823. private displayVRButton;
  42824. private updateButtonVisibility;
  42825. private _cachedAngularSensibility;
  42826. /**
  42827. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42828. * Otherwise, will use the fullscreen API.
  42829. */
  42830. enterVR(): void;
  42831. /**
  42832. * Attempt to exit VR, or fullscreen.
  42833. */
  42834. exitVR(): void;
  42835. /**
  42836. * The position of the vr experience helper.
  42837. */
  42838. /**
  42839. * Sets the position of the vr experience helper.
  42840. */
  42841. position: Vector3;
  42842. /**
  42843. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42844. */
  42845. enableInteractions(): void;
  42846. private readonly _noControllerIsActive;
  42847. private beforeRender;
  42848. private _isTeleportationFloor;
  42849. /**
  42850. * Adds a floor mesh to be used for teleportation.
  42851. * @param floorMesh the mesh to be used for teleportation.
  42852. */
  42853. addFloorMesh(floorMesh: Mesh): void;
  42854. /**
  42855. * Removes a floor mesh from being used for teleportation.
  42856. * @param floorMesh the mesh to be removed.
  42857. */
  42858. removeFloorMesh(floorMesh: Mesh): void;
  42859. /**
  42860. * Enables interactions and teleportation using the VR controllers and gaze.
  42861. * @param vrTeleportationOptions options to modify teleportation behavior.
  42862. */
  42863. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42864. private _onNewGamepadConnected;
  42865. private _tryEnableInteractionOnController;
  42866. private _onNewGamepadDisconnected;
  42867. private _enableInteractionOnController;
  42868. private _checkTeleportWithRay;
  42869. private _checkRotate;
  42870. private _checkTeleportBackwards;
  42871. private _enableTeleportationOnController;
  42872. private _createTeleportationCircles;
  42873. private _displayTeleportationTarget;
  42874. private _hideTeleportationTarget;
  42875. private _rotateCamera;
  42876. private _moveTeleportationSelectorTo;
  42877. private _workingVector;
  42878. private _workingQuaternion;
  42879. private _workingMatrix;
  42880. /**
  42881. * Teleports the users feet to the desired location
  42882. * @param location The location where the user's feet should be placed
  42883. */
  42884. teleportCamera(location: Vector3): void;
  42885. private _convertNormalToDirectionOfRay;
  42886. private _castRayAndSelectObject;
  42887. private _notifySelectedMeshUnselected;
  42888. /**
  42889. * Sets the color of the laser ray from the vr controllers.
  42890. * @param color new color for the ray.
  42891. */
  42892. changeLaserColor(color: Color3): void;
  42893. /**
  42894. * Sets the color of the ray from the vr headsets gaze.
  42895. * @param color new color for the ray.
  42896. */
  42897. changeGazeColor(color: Color3): void;
  42898. /**
  42899. * Exits VR and disposes of the vr experience helper
  42900. */
  42901. dispose(): void;
  42902. /**
  42903. * Gets the name of the VRExperienceHelper class
  42904. * @returns "VRExperienceHelper"
  42905. */
  42906. getClassName(): string;
  42907. }
  42908. }
  42909. declare module "babylonjs/Cameras/VR/index" {
  42910. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42911. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42912. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42913. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42914. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42915. export * from "babylonjs/Cameras/VR/webVRCamera";
  42916. }
  42917. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42918. import { Observable } from "babylonjs/Misc/observable";
  42919. import { Nullable } from "babylonjs/types";
  42920. import { IDisposable, Scene } from "babylonjs/scene";
  42921. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42922. /**
  42923. * Manages an XRSession to work with Babylon's engine
  42924. * @see https://doc.babylonjs.com/how_to/webxr
  42925. */
  42926. export class WebXRSessionManager implements IDisposable {
  42927. private scene;
  42928. /**
  42929. * Fires every time a new xrFrame arrives which can be used to update the camera
  42930. */
  42931. onXRFrameObservable: Observable<any>;
  42932. /**
  42933. * Fires when the xr session is ended either by the device or manually done
  42934. */
  42935. onXRSessionEnded: Observable<any>;
  42936. /**
  42937. * Underlying xr session
  42938. */
  42939. session: XRSession;
  42940. /**
  42941. * Type of reference space used when creating the session
  42942. */
  42943. referenceSpace: XRReferenceSpace;
  42944. /** @hidden */
  42945. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42946. /**
  42947. * Current XR frame
  42948. */
  42949. currentFrame: Nullable<XRFrame>;
  42950. private _xrNavigator;
  42951. private baseLayer;
  42952. private _sessionEnded;
  42953. /**
  42954. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42955. * @param scene The scene which the session should be created for
  42956. */
  42957. constructor(scene: Scene);
  42958. /**
  42959. * Initializes the manager
  42960. * After initialization enterXR can be called to start an XR session
  42961. * @returns Promise which resolves after it is initialized
  42962. */
  42963. initializeAsync(): Promise<void>;
  42964. /**
  42965. * Initializes an xr session
  42966. * @param xrSessionMode mode to initialize
  42967. * @returns a promise which will resolve once the session has been initialized
  42968. */
  42969. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42970. /**
  42971. * Sets the reference space on the xr session
  42972. * @param referenceSpace space to set
  42973. * @returns a promise that will resolve once the reference space has been set
  42974. */
  42975. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42976. /**
  42977. * Updates the render state of the session
  42978. * @param state state to set
  42979. * @returns a promise that resolves once the render state has been updated
  42980. */
  42981. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42982. /**
  42983. * Starts rendering to the xr layer
  42984. * @returns a promise that will resolve once rendering has started
  42985. */
  42986. startRenderingToXRAsync(): Promise<void>;
  42987. /**
  42988. * Stops the xrSession and restores the renderloop
  42989. * @returns Promise which resolves after it exits XR
  42990. */
  42991. exitXRAsync(): Promise<unknown>;
  42992. /**
  42993. * Checks if a session would be supported for the creation options specified
  42994. * @param sessionMode session mode to check if supported eg. immersive-vr
  42995. * @returns true if supported
  42996. */
  42997. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42998. /**
  42999. * @hidden
  43000. * Converts the render layer of xrSession to a render target
  43001. * @param session session to create render target for
  43002. * @param scene scene the new render target should be created for
  43003. */
  43004. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43005. /**
  43006. * Disposes of the session manager
  43007. */
  43008. dispose(): void;
  43009. }
  43010. }
  43011. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43012. import { Scene } from "babylonjs/scene";
  43013. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43014. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43015. /**
  43016. * WebXR Camera which holds the views for the xrSession
  43017. * @see https://doc.babylonjs.com/how_to/webxr
  43018. */
  43019. export class WebXRCamera extends FreeCamera {
  43020. private static _TmpMatrix;
  43021. /**
  43022. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43023. * @param name the name of the camera
  43024. * @param scene the scene to add the camera to
  43025. */
  43026. constructor(name: string, scene: Scene);
  43027. private _updateNumberOfRigCameras;
  43028. /** @hidden */
  43029. _updateForDualEyeDebugging(): void;
  43030. /**
  43031. * Updates the cameras position from the current pose information of the XR session
  43032. * @param xrSessionManager the session containing pose information
  43033. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43034. */
  43035. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43036. }
  43037. }
  43038. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43039. import { Nullable } from "babylonjs/types";
  43040. import { IDisposable } from "babylonjs/scene";
  43041. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43042. /**
  43043. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43044. */
  43045. export class WebXRManagedOutputCanvas implements IDisposable {
  43046. private helper;
  43047. private _canvas;
  43048. /**
  43049. * xrpresent context of the canvas which can be used to display/mirror xr content
  43050. */
  43051. canvasContext: WebGLRenderingContext;
  43052. /**
  43053. * xr layer for the canvas
  43054. */
  43055. xrLayer: Nullable<XRWebGLLayer>;
  43056. /**
  43057. * Initializes the xr layer for the session
  43058. * @param xrSession xr session
  43059. * @returns a promise that will resolve once the XR Layer has been created
  43060. */
  43061. initializeXRLayerAsync(xrSession: any): any;
  43062. /**
  43063. * Initializes the canvas to be added/removed upon entering/exiting xr
  43064. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43065. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43066. */
  43067. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43068. /**
  43069. * Disposes of the object
  43070. */
  43071. dispose(): void;
  43072. private _setManagedOutputCanvas;
  43073. private _addCanvas;
  43074. private _removeCanvas;
  43075. }
  43076. }
  43077. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43078. import { Observable } from "babylonjs/Misc/observable";
  43079. import { IDisposable, Scene } from "babylonjs/scene";
  43080. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43082. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43083. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43084. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43085. /**
  43086. * States of the webXR experience
  43087. */
  43088. export enum WebXRState {
  43089. /**
  43090. * Transitioning to being in XR mode
  43091. */
  43092. ENTERING_XR = 0,
  43093. /**
  43094. * Transitioning to non XR mode
  43095. */
  43096. EXITING_XR = 1,
  43097. /**
  43098. * In XR mode and presenting
  43099. */
  43100. IN_XR = 2,
  43101. /**
  43102. * Not entered XR mode
  43103. */
  43104. NOT_IN_XR = 3
  43105. }
  43106. /**
  43107. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43108. * @see https://doc.babylonjs.com/how_to/webxr
  43109. */
  43110. export class WebXRExperienceHelper implements IDisposable {
  43111. private scene;
  43112. /**
  43113. * 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
  43114. */
  43115. container: AbstractMesh;
  43116. /**
  43117. * Camera used to render xr content
  43118. */
  43119. camera: WebXRCamera;
  43120. /**
  43121. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43122. */
  43123. state: WebXRState;
  43124. private _setState;
  43125. private static _TmpVector;
  43126. /**
  43127. * Fires when the state of the experience helper has changed
  43128. */
  43129. onStateChangedObservable: Observable<WebXRState>;
  43130. /** Session manager used to keep track of xr session */
  43131. sessionManager: WebXRSessionManager;
  43132. private _nonVRCamera;
  43133. private _originalSceneAutoClear;
  43134. private _supported;
  43135. /**
  43136. * Creates the experience helper
  43137. * @param scene the scene to attach the experience helper to
  43138. * @returns a promise for the experience helper
  43139. */
  43140. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43141. /**
  43142. * Creates a WebXRExperienceHelper
  43143. * @param scene The scene the helper should be created in
  43144. */
  43145. private constructor();
  43146. /**
  43147. * Exits XR mode and returns the scene to its original state
  43148. * @returns promise that resolves after xr mode has exited
  43149. */
  43150. exitXRAsync(): Promise<unknown>;
  43151. /**
  43152. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43153. * @param sessionCreationOptions options for the XR session
  43154. * @param referenceSpaceType frame of reference of the XR session
  43155. * @param outputCanvas the output canvas that will be used to enter XR mode
  43156. * @returns promise that resolves after xr mode has entered
  43157. */
  43158. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43159. /**
  43160. * Updates the global position of the camera by moving the camera's container
  43161. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43162. * @param position The desired global position of the camera
  43163. */
  43164. setPositionOfCameraUsingContainer(position: Vector3): void;
  43165. /**
  43166. * Rotates the xr camera by rotating the camera's container around the camera's position
  43167. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43168. * @param rotation the desired quaternion rotation to apply to the camera
  43169. */
  43170. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43171. /**
  43172. * Disposes of the experience helper
  43173. */
  43174. dispose(): void;
  43175. }
  43176. }
  43177. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43178. import { Nullable } from "babylonjs/types";
  43179. import { Observable } from "babylonjs/Misc/observable";
  43180. import { IDisposable, Scene } from "babylonjs/scene";
  43181. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43182. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43183. /**
  43184. * Button which can be used to enter a different mode of XR
  43185. */
  43186. export class WebXREnterExitUIButton {
  43187. /** button element */
  43188. element: HTMLElement;
  43189. /** XR initialization options for the button */
  43190. sessionMode: XRSessionMode;
  43191. /** Reference space type */
  43192. referenceSpaceType: XRReferenceSpaceType;
  43193. /**
  43194. * Creates a WebXREnterExitUIButton
  43195. * @param element button element
  43196. * @param sessionMode XR initialization session mode
  43197. * @param referenceSpaceType the type of reference space to be used
  43198. */
  43199. constructor(
  43200. /** button element */
  43201. element: HTMLElement,
  43202. /** XR initialization options for the button */
  43203. sessionMode: XRSessionMode,
  43204. /** Reference space type */
  43205. referenceSpaceType: XRReferenceSpaceType);
  43206. /**
  43207. * Overwritable function which can be used to update the button's visuals when the state changes
  43208. * @param activeButton the current active button in the UI
  43209. */
  43210. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43211. }
  43212. /**
  43213. * Options to create the webXR UI
  43214. */
  43215. export class WebXREnterExitUIOptions {
  43216. /**
  43217. * Context to enter xr with
  43218. */
  43219. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43220. /**
  43221. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43222. */
  43223. customButtons?: Array<WebXREnterExitUIButton>;
  43224. }
  43225. /**
  43226. * UI to allow the user to enter/exit XR mode
  43227. */
  43228. export class WebXREnterExitUI implements IDisposable {
  43229. private scene;
  43230. private _overlay;
  43231. private _buttons;
  43232. private _activeButton;
  43233. /**
  43234. * Fired every time the active button is changed.
  43235. *
  43236. * When xr is entered via a button that launches xr that button will be the callback parameter
  43237. *
  43238. * When exiting xr the callback parameter will be null)
  43239. */
  43240. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43241. /**
  43242. * Creates UI to allow the user to enter/exit XR mode
  43243. * @param scene the scene to add the ui to
  43244. * @param helper the xr experience helper to enter/exit xr with
  43245. * @param options options to configure the UI
  43246. * @returns the created ui
  43247. */
  43248. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43249. private constructor();
  43250. private _updateButtons;
  43251. /**
  43252. * Disposes of the object
  43253. */
  43254. dispose(): void;
  43255. }
  43256. }
  43257. declare module "babylonjs/Cameras/XR/webXRController" {
  43258. import { Nullable } from "babylonjs/types";
  43259. import { Observable } from "babylonjs/Misc/observable";
  43260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43261. import { Ray } from "babylonjs/Culling/ray";
  43262. import { Scene } from "babylonjs/scene";
  43263. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43264. /**
  43265. * Represents an XR input
  43266. */
  43267. export class WebXRController {
  43268. private scene;
  43269. /** The underlying input source for the controller */
  43270. inputSource: XRInputSource;
  43271. private parentContainer;
  43272. /**
  43273. * 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
  43274. */
  43275. grip?: AbstractMesh;
  43276. /**
  43277. * Pointer which can be used to select objects or attach a visible laser to
  43278. */
  43279. pointer: AbstractMesh;
  43280. private _gamepadMode;
  43281. /**
  43282. * If available, this is the gamepad object related to this controller.
  43283. * Using this object it is possible to get click events and trackpad changes of the
  43284. * webxr controller that is currently being used.
  43285. */
  43286. gamepadController?: WebVRController;
  43287. /**
  43288. * Event that fires when the controller is removed/disposed
  43289. */
  43290. onDisposeObservable: Observable<{}>;
  43291. private _tmpMatrix;
  43292. private _tmpQuaternion;
  43293. private _tmpVector;
  43294. /**
  43295. * Creates the controller
  43296. * @see https://doc.babylonjs.com/how_to/webxr
  43297. * @param scene the scene which the controller should be associated to
  43298. * @param inputSource the underlying input source for the controller
  43299. * @param parentContainer parent that the controller meshes should be children of
  43300. */
  43301. constructor(scene: Scene,
  43302. /** The underlying input source for the controller */
  43303. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43304. /**
  43305. * Updates the controller pose based on the given XRFrame
  43306. * @param xrFrame xr frame to update the pose with
  43307. * @param referenceSpace reference space to use
  43308. */
  43309. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43310. /**
  43311. * Gets a world space ray coming from the controller
  43312. * @param result the resulting ray
  43313. */
  43314. getWorldPointerRayToRef(result: Ray): void;
  43315. /**
  43316. * Get the scene associated with this controller
  43317. * @returns the scene object
  43318. */
  43319. getScene(): Scene;
  43320. /**
  43321. * Disposes of the object
  43322. */
  43323. dispose(): void;
  43324. }
  43325. }
  43326. declare module "babylonjs/Cameras/XR/webXRInput" {
  43327. import { Observable } from "babylonjs/Misc/observable";
  43328. import { IDisposable } from "babylonjs/scene";
  43329. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43330. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43331. /**
  43332. * XR input used to track XR inputs such as controllers/rays
  43333. */
  43334. export class WebXRInput implements IDisposable {
  43335. /**
  43336. * Base experience the input listens to
  43337. */
  43338. baseExperience: WebXRExperienceHelper;
  43339. /**
  43340. * XR controllers being tracked
  43341. */
  43342. controllers: Array<WebXRController>;
  43343. private _frameObserver;
  43344. private _stateObserver;
  43345. /**
  43346. * Event when a controller has been connected/added
  43347. */
  43348. onControllerAddedObservable: Observable<WebXRController>;
  43349. /**
  43350. * Event when a controller has been removed/disconnected
  43351. */
  43352. onControllerRemovedObservable: Observable<WebXRController>;
  43353. /**
  43354. * Initializes the WebXRInput
  43355. * @param baseExperience experience helper which the input should be created for
  43356. */
  43357. constructor(
  43358. /**
  43359. * Base experience the input listens to
  43360. */
  43361. baseExperience: WebXRExperienceHelper);
  43362. private _onInputSourcesChange;
  43363. private _addAndRemoveControllers;
  43364. /**
  43365. * Disposes of the object
  43366. */
  43367. dispose(): void;
  43368. }
  43369. }
  43370. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43372. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43373. /**
  43374. * Enables teleportation
  43375. */
  43376. export class WebXRControllerTeleportation {
  43377. private _teleportationFillColor;
  43378. private _teleportationBorderColor;
  43379. private _tmpRay;
  43380. private _tmpVector;
  43381. /**
  43382. * Creates a WebXRControllerTeleportation
  43383. * @param input input manager to add teleportation to
  43384. * @param floorMeshes floormeshes which can be teleported to
  43385. */
  43386. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43387. }
  43388. }
  43389. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43390. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43391. /**
  43392. * Handles pointer input automatically for the pointer of XR controllers
  43393. */
  43394. export class WebXRControllerPointerSelection {
  43395. private static _idCounter;
  43396. private _tmpRay;
  43397. /**
  43398. * Creates a WebXRControllerPointerSelection
  43399. * @param input input manager to setup pointer selection
  43400. */
  43401. constructor(input: WebXRInput);
  43402. private _convertNormalToDirectionOfRay;
  43403. private _updatePointerDistance;
  43404. }
  43405. }
  43406. declare module "babylonjs/Loading/sceneLoader" {
  43407. import { Observable } from "babylonjs/Misc/observable";
  43408. import { Nullable } from "babylonjs/types";
  43409. import { Scene } from "babylonjs/scene";
  43410. import { Engine } from "babylonjs/Engines/engine";
  43411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43412. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43413. import { AssetContainer } from "babylonjs/assetContainer";
  43414. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43415. import { Skeleton } from "babylonjs/Bones/skeleton";
  43416. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43417. import { WebRequest } from "babylonjs/Misc/webRequest";
  43418. /**
  43419. * Class used to represent data loading progression
  43420. */
  43421. export class SceneLoaderProgressEvent {
  43422. /** defines if data length to load can be evaluated */
  43423. readonly lengthComputable: boolean;
  43424. /** defines the loaded data length */
  43425. readonly loaded: number;
  43426. /** defines the data length to load */
  43427. readonly total: number;
  43428. /**
  43429. * Create a new progress event
  43430. * @param lengthComputable defines if data length to load can be evaluated
  43431. * @param loaded defines the loaded data length
  43432. * @param total defines the data length to load
  43433. */
  43434. constructor(
  43435. /** defines if data length to load can be evaluated */
  43436. lengthComputable: boolean,
  43437. /** defines the loaded data length */
  43438. loaded: number,
  43439. /** defines the data length to load */
  43440. total: number);
  43441. /**
  43442. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43443. * @param event defines the source event
  43444. * @returns a new SceneLoaderProgressEvent
  43445. */
  43446. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43447. }
  43448. /**
  43449. * Interface used by SceneLoader plugins to define supported file extensions
  43450. */
  43451. export interface ISceneLoaderPluginExtensions {
  43452. /**
  43453. * Defines the list of supported extensions
  43454. */
  43455. [extension: string]: {
  43456. isBinary: boolean;
  43457. };
  43458. }
  43459. /**
  43460. * Interface used by SceneLoader plugin factory
  43461. */
  43462. export interface ISceneLoaderPluginFactory {
  43463. /**
  43464. * Defines the name of the factory
  43465. */
  43466. name: string;
  43467. /**
  43468. * Function called to create a new plugin
  43469. * @return the new plugin
  43470. */
  43471. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43472. /**
  43473. * The callback that returns true if the data can be directly loaded.
  43474. * @param data string containing the file data
  43475. * @returns if the data can be loaded directly
  43476. */
  43477. canDirectLoad?(data: string): boolean;
  43478. }
  43479. /**
  43480. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43481. */
  43482. export interface ISceneLoaderPluginBase {
  43483. /**
  43484. * The friendly name of this plugin.
  43485. */
  43486. name: string;
  43487. /**
  43488. * The file extensions supported by this plugin.
  43489. */
  43490. extensions: string | ISceneLoaderPluginExtensions;
  43491. /**
  43492. * The callback called when loading from a url.
  43493. * @param scene scene loading this url
  43494. * @param url url to load
  43495. * @param onSuccess callback called when the file successfully loads
  43496. * @param onProgress callback called while file is loading (if the server supports this mode)
  43497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43498. * @param onError callback called when the file fails to load
  43499. * @returns a file request object
  43500. */
  43501. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43502. /**
  43503. * The callback called when loading from a file object.
  43504. * @param scene scene loading this file
  43505. * @param file defines the file to load
  43506. * @param onSuccess defines the callback to call when data is loaded
  43507. * @param onProgress defines the callback to call during loading process
  43508. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43509. * @param onError defines the callback to call when an error occurs
  43510. * @returns a file request object
  43511. */
  43512. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43513. /**
  43514. * The callback that returns true if the data can be directly loaded.
  43515. * @param data string containing the file data
  43516. * @returns if the data can be loaded directly
  43517. */
  43518. canDirectLoad?(data: string): boolean;
  43519. /**
  43520. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43521. * @param scene scene loading this data
  43522. * @param data string containing the data
  43523. * @returns data to pass to the plugin
  43524. */
  43525. directLoad?(scene: Scene, data: string): any;
  43526. /**
  43527. * The callback that allows custom handling of the root url based on the response url.
  43528. * @param rootUrl the original root url
  43529. * @param responseURL the response url if available
  43530. * @returns the new root url
  43531. */
  43532. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43533. }
  43534. /**
  43535. * Interface used to define a SceneLoader plugin
  43536. */
  43537. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43538. /**
  43539. * Import meshes into a scene.
  43540. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43541. * @param scene The scene to import into
  43542. * @param data The data to import
  43543. * @param rootUrl The root url for scene and resources
  43544. * @param meshes The meshes array to import into
  43545. * @param particleSystems The particle systems array to import into
  43546. * @param skeletons The skeletons array to import into
  43547. * @param onError The callback when import fails
  43548. * @returns True if successful or false otherwise
  43549. */
  43550. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43551. /**
  43552. * Load into a scene.
  43553. * @param scene The scene to load into
  43554. * @param data The data to import
  43555. * @param rootUrl The root url for scene and resources
  43556. * @param onError The callback when import fails
  43557. * @returns True if successful or false otherwise
  43558. */
  43559. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43560. /**
  43561. * Load into an asset container.
  43562. * @param scene The scene to load into
  43563. * @param data The data to import
  43564. * @param rootUrl The root url for scene and resources
  43565. * @param onError The callback when import fails
  43566. * @returns The loaded asset container
  43567. */
  43568. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43569. }
  43570. /**
  43571. * Interface used to define an async SceneLoader plugin
  43572. */
  43573. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43574. /**
  43575. * Import meshes into a scene.
  43576. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43577. * @param scene The scene to import into
  43578. * @param data The data to import
  43579. * @param rootUrl The root url for scene and resources
  43580. * @param onProgress The callback when the load progresses
  43581. * @param fileName Defines the name of the file to load
  43582. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43583. */
  43584. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43585. meshes: AbstractMesh[];
  43586. particleSystems: IParticleSystem[];
  43587. skeletons: Skeleton[];
  43588. animationGroups: AnimationGroup[];
  43589. }>;
  43590. /**
  43591. * Load into a scene.
  43592. * @param scene The scene to load into
  43593. * @param data The data to import
  43594. * @param rootUrl The root url for scene and resources
  43595. * @param onProgress The callback when the load progresses
  43596. * @param fileName Defines the name of the file to load
  43597. * @returns Nothing
  43598. */
  43599. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43600. /**
  43601. * Load into an asset container.
  43602. * @param scene The scene to load into
  43603. * @param data The data to import
  43604. * @param rootUrl The root url for scene and resources
  43605. * @param onProgress The callback when the load progresses
  43606. * @param fileName Defines the name of the file to load
  43607. * @returns The loaded asset container
  43608. */
  43609. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43610. }
  43611. /**
  43612. * Class used to load scene from various file formats using registered plugins
  43613. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43614. */
  43615. export class SceneLoader {
  43616. /**
  43617. * No logging while loading
  43618. */
  43619. static readonly NO_LOGGING: number;
  43620. /**
  43621. * Minimal logging while loading
  43622. */
  43623. static readonly MINIMAL_LOGGING: number;
  43624. /**
  43625. * Summary logging while loading
  43626. */
  43627. static readonly SUMMARY_LOGGING: number;
  43628. /**
  43629. * Detailled logging while loading
  43630. */
  43631. static readonly DETAILED_LOGGING: number;
  43632. /**
  43633. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43634. */
  43635. static ForceFullSceneLoadingForIncremental: boolean;
  43636. /**
  43637. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43638. */
  43639. static ShowLoadingScreen: boolean;
  43640. /**
  43641. * Defines the current logging level (while loading the scene)
  43642. * @ignorenaming
  43643. */
  43644. static loggingLevel: number;
  43645. /**
  43646. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43647. */
  43648. static CleanBoneMatrixWeights: boolean;
  43649. /**
  43650. * Event raised when a plugin is used to load a scene
  43651. */
  43652. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43653. private static _registeredPlugins;
  43654. private static _getDefaultPlugin;
  43655. private static _getPluginForExtension;
  43656. private static _getPluginForDirectLoad;
  43657. private static _getPluginForFilename;
  43658. private static _getDirectLoad;
  43659. private static _loadData;
  43660. private static _getFileInfo;
  43661. /**
  43662. * Gets a plugin that can load the given extension
  43663. * @param extension defines the extension to load
  43664. * @returns a plugin or null if none works
  43665. */
  43666. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43667. /**
  43668. * Gets a boolean indicating that the given extension can be loaded
  43669. * @param extension defines the extension to load
  43670. * @returns true if the extension is supported
  43671. */
  43672. static IsPluginForExtensionAvailable(extension: string): boolean;
  43673. /**
  43674. * Adds a new plugin to the list of registered plugins
  43675. * @param plugin defines the plugin to add
  43676. */
  43677. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43678. /**
  43679. * Import meshes into a scene
  43680. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43681. * @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)
  43682. * @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)
  43683. * @param scene the instance of BABYLON.Scene to append to
  43684. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43685. * @param onProgress a callback with a progress event for each file being loaded
  43686. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43687. * @param pluginExtension the extension used to determine the plugin
  43688. * @returns The loaded plugin
  43689. */
  43690. 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>;
  43691. /**
  43692. * Import meshes into a scene
  43693. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43694. * @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)
  43695. * @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)
  43696. * @param scene the instance of BABYLON.Scene to append to
  43697. * @param onProgress a callback with a progress event for each file being loaded
  43698. * @param pluginExtension the extension used to determine the plugin
  43699. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43700. */
  43701. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43702. meshes: AbstractMesh[];
  43703. particleSystems: IParticleSystem[];
  43704. skeletons: Skeleton[];
  43705. animationGroups: AnimationGroup[];
  43706. }>;
  43707. /**
  43708. * Load a scene
  43709. * @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)
  43710. * @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)
  43711. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43712. * @param onSuccess a callback with the scene when import succeeds
  43713. * @param onProgress a callback with a progress event for each file being loaded
  43714. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43715. * @param pluginExtension the extension used to determine the plugin
  43716. * @returns The loaded plugin
  43717. */
  43718. 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>;
  43719. /**
  43720. * Load a scene
  43721. * @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)
  43722. * @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)
  43723. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43724. * @param onProgress a callback with a progress event for each file being loaded
  43725. * @param pluginExtension the extension used to determine the plugin
  43726. * @returns The loaded scene
  43727. */
  43728. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43729. /**
  43730. * Append a scene
  43731. * @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)
  43732. * @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)
  43733. * @param scene is the instance of BABYLON.Scene to append to
  43734. * @param onSuccess a callback with the scene when import succeeds
  43735. * @param onProgress a callback with a progress event for each file being loaded
  43736. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43737. * @param pluginExtension the extension used to determine the plugin
  43738. * @returns The loaded plugin
  43739. */
  43740. 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>;
  43741. /**
  43742. * Append a scene
  43743. * @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)
  43744. * @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)
  43745. * @param scene is the instance of BABYLON.Scene to append to
  43746. * @param onProgress a callback with a progress event for each file being loaded
  43747. * @param pluginExtension the extension used to determine the plugin
  43748. * @returns The given scene
  43749. */
  43750. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43751. /**
  43752. * Load a scene into an asset container
  43753. * @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)
  43754. * @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)
  43755. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43756. * @param onSuccess a callback with the scene when import succeeds
  43757. * @param onProgress a callback with a progress event for each file being loaded
  43758. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43759. * @param pluginExtension the extension used to determine the plugin
  43760. * @returns The loaded plugin
  43761. */
  43762. 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>;
  43763. /**
  43764. * Load a scene into an asset container
  43765. * @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)
  43766. * @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)
  43767. * @param scene is the instance of Scene to append to
  43768. * @param onProgress a callback with a progress event for each file being loaded
  43769. * @param pluginExtension the extension used to determine the plugin
  43770. * @returns The loaded asset container
  43771. */
  43772. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43773. }
  43774. }
  43775. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43776. import { Scene } from "babylonjs/scene";
  43777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43778. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43779. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43780. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43781. /**
  43782. * Generic Controller
  43783. */
  43784. export class GenericController extends WebVRController {
  43785. /**
  43786. * Base Url for the controller model.
  43787. */
  43788. static readonly MODEL_BASE_URL: string;
  43789. /**
  43790. * File name for the controller model.
  43791. */
  43792. static readonly MODEL_FILENAME: string;
  43793. /**
  43794. * Creates a new GenericController from a gamepad
  43795. * @param vrGamepad the gamepad that the controller should be created from
  43796. */
  43797. constructor(vrGamepad: any);
  43798. /**
  43799. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43800. * @param scene scene in which to add meshes
  43801. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43802. */
  43803. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43804. /**
  43805. * Called once for each button that changed state since the last frame
  43806. * @param buttonIdx Which button index changed
  43807. * @param state New state of the button
  43808. * @param changes Which properties on the state changed since last frame
  43809. */
  43810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43811. }
  43812. }
  43813. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43814. import { Observable } from "babylonjs/Misc/observable";
  43815. import { Scene } from "babylonjs/scene";
  43816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43817. import { Ray } from "babylonjs/Culling/ray";
  43818. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43819. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43820. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43821. /**
  43822. * Defines the WindowsMotionController object that the state of the windows motion controller
  43823. */
  43824. export class WindowsMotionController extends WebVRController {
  43825. /**
  43826. * The base url used to load the left and right controller models
  43827. */
  43828. static MODEL_BASE_URL: string;
  43829. /**
  43830. * The name of the left controller model file
  43831. */
  43832. static MODEL_LEFT_FILENAME: string;
  43833. /**
  43834. * The name of the right controller model file
  43835. */
  43836. static MODEL_RIGHT_FILENAME: string;
  43837. /**
  43838. * The controller name prefix for this controller type
  43839. */
  43840. static readonly GAMEPAD_ID_PREFIX: string;
  43841. /**
  43842. * The controller id pattern for this controller type
  43843. */
  43844. private static readonly GAMEPAD_ID_PATTERN;
  43845. private _loadedMeshInfo;
  43846. private readonly _mapping;
  43847. /**
  43848. * Fired when the trackpad on this controller is clicked
  43849. */
  43850. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43851. /**
  43852. * Fired when the trackpad on this controller is modified
  43853. */
  43854. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43855. /**
  43856. * The current x and y values of this controller's trackpad
  43857. */
  43858. trackpad: StickValues;
  43859. /**
  43860. * Creates a new WindowsMotionController from a gamepad
  43861. * @param vrGamepad the gamepad that the controller should be created from
  43862. */
  43863. constructor(vrGamepad: any);
  43864. /**
  43865. * Fired when the trigger on this controller is modified
  43866. */
  43867. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43868. /**
  43869. * Fired when the menu button on this controller is modified
  43870. */
  43871. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43872. /**
  43873. * Fired when the grip button on this controller is modified
  43874. */
  43875. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43876. /**
  43877. * Fired when the thumbstick button on this controller is modified
  43878. */
  43879. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43880. /**
  43881. * Fired when the touchpad button on this controller is modified
  43882. */
  43883. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43884. /**
  43885. * Fired when the touchpad values on this controller are modified
  43886. */
  43887. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43888. private _updateTrackpad;
  43889. /**
  43890. * Called once per frame by the engine.
  43891. */
  43892. update(): void;
  43893. /**
  43894. * Called once for each button that changed state since the last frame
  43895. * @param buttonIdx Which button index changed
  43896. * @param state New state of the button
  43897. * @param changes Which properties on the state changed since last frame
  43898. */
  43899. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43900. /**
  43901. * Moves the buttons on the controller mesh based on their current state
  43902. * @param buttonName the name of the button to move
  43903. * @param buttonValue the value of the button which determines the buttons new position
  43904. */
  43905. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43906. /**
  43907. * Moves the axis on the controller mesh based on its current state
  43908. * @param axis the index of the axis
  43909. * @param axisValue the value of the axis which determines the meshes new position
  43910. * @hidden
  43911. */
  43912. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43913. /**
  43914. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43915. * @param scene scene in which to add meshes
  43916. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43917. */
  43918. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43919. /**
  43920. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43921. * can be transformed by button presses and axes values, based on this._mapping.
  43922. *
  43923. * @param scene scene in which the meshes exist
  43924. * @param meshes list of meshes that make up the controller model to process
  43925. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43926. */
  43927. private processModel;
  43928. private createMeshInfo;
  43929. /**
  43930. * Gets the ray of the controller in the direction the controller is pointing
  43931. * @param length the length the resulting ray should be
  43932. * @returns a ray in the direction the controller is pointing
  43933. */
  43934. getForwardRay(length?: number): Ray;
  43935. /**
  43936. * Disposes of the controller
  43937. */
  43938. dispose(): void;
  43939. }
  43940. }
  43941. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43942. import { Observable } from "babylonjs/Misc/observable";
  43943. import { Scene } from "babylonjs/scene";
  43944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43945. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43946. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43947. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43948. /**
  43949. * Oculus Touch Controller
  43950. */
  43951. export class OculusTouchController extends WebVRController {
  43952. /**
  43953. * Base Url for the controller model.
  43954. */
  43955. static MODEL_BASE_URL: string;
  43956. /**
  43957. * File name for the left controller model.
  43958. */
  43959. static MODEL_LEFT_FILENAME: string;
  43960. /**
  43961. * File name for the right controller model.
  43962. */
  43963. static MODEL_RIGHT_FILENAME: string;
  43964. /**
  43965. * Base Url for the Quest controller model.
  43966. */
  43967. static QUEST_MODEL_BASE_URL: string;
  43968. /**
  43969. * @hidden
  43970. * If the controllers are running on a device that needs the updated Quest controller models
  43971. */
  43972. static _IsQuest: boolean;
  43973. /**
  43974. * Fired when the secondary trigger on this controller is modified
  43975. */
  43976. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43977. /**
  43978. * Fired when the thumb rest on this controller is modified
  43979. */
  43980. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43981. /**
  43982. * Creates a new OculusTouchController from a gamepad
  43983. * @param vrGamepad the gamepad that the controller should be created from
  43984. */
  43985. constructor(vrGamepad: any);
  43986. /**
  43987. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43988. * @param scene scene in which to add meshes
  43989. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43990. */
  43991. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43992. /**
  43993. * Fired when the A button on this controller is modified
  43994. */
  43995. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43996. /**
  43997. * Fired when the B button on this controller is modified
  43998. */
  43999. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44000. /**
  44001. * Fired when the X button on this controller is modified
  44002. */
  44003. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44004. /**
  44005. * Fired when the Y button on this controller is modified
  44006. */
  44007. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44008. /**
  44009. * Called once for each button that changed state since the last frame
  44010. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44011. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44012. * 2) secondary trigger (same)
  44013. * 3) A (right) X (left), touch, pressed = value
  44014. * 4) B / Y
  44015. * 5) thumb rest
  44016. * @param buttonIdx Which button index changed
  44017. * @param state New state of the button
  44018. * @param changes Which properties on the state changed since last frame
  44019. */
  44020. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44021. }
  44022. }
  44023. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44024. import { Scene } from "babylonjs/scene";
  44025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44026. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44027. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44028. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44029. import { Observable } from "babylonjs/Misc/observable";
  44030. /**
  44031. * Vive Controller
  44032. */
  44033. export class ViveController extends WebVRController {
  44034. /**
  44035. * Base Url for the controller model.
  44036. */
  44037. static MODEL_BASE_URL: string;
  44038. /**
  44039. * File name for the controller model.
  44040. */
  44041. static MODEL_FILENAME: string;
  44042. /**
  44043. * Creates a new ViveController from a gamepad
  44044. * @param vrGamepad the gamepad that the controller should be created from
  44045. */
  44046. constructor(vrGamepad: any);
  44047. /**
  44048. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44049. * @param scene scene in which to add meshes
  44050. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44051. */
  44052. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44053. /**
  44054. * Fired when the left button on this controller is modified
  44055. */
  44056. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44057. /**
  44058. * Fired when the right button on this controller is modified
  44059. */
  44060. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44061. /**
  44062. * Fired when the menu button on this controller is modified
  44063. */
  44064. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44065. /**
  44066. * Called once for each button that changed state since the last frame
  44067. * Vive mapping:
  44068. * 0: touchpad
  44069. * 1: trigger
  44070. * 2: left AND right buttons
  44071. * 3: menu button
  44072. * @param buttonIdx Which button index changed
  44073. * @param state New state of the button
  44074. * @param changes Which properties on the state changed since last frame
  44075. */
  44076. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44077. }
  44078. }
  44079. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44080. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44081. /**
  44082. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44083. */
  44084. export class WebXRControllerModelLoader {
  44085. /**
  44086. * Creates the WebXRControllerModelLoader
  44087. * @param input xr input that creates the controllers
  44088. */
  44089. constructor(input: WebXRInput);
  44090. }
  44091. }
  44092. declare module "babylonjs/Cameras/XR/index" {
  44093. export * from "babylonjs/Cameras/XR/webXRCamera";
  44094. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44095. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44096. export * from "babylonjs/Cameras/XR/webXRInput";
  44097. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44098. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44099. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44100. export * from "babylonjs/Cameras/XR/webXRController";
  44101. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44102. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44103. }
  44104. declare module "babylonjs/Cameras/RigModes/index" {
  44105. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44106. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44107. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44108. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44109. }
  44110. declare module "babylonjs/Cameras/index" {
  44111. export * from "babylonjs/Cameras/Inputs/index";
  44112. export * from "babylonjs/Cameras/cameraInputsManager";
  44113. export * from "babylonjs/Cameras/camera";
  44114. export * from "babylonjs/Cameras/targetCamera";
  44115. export * from "babylonjs/Cameras/freeCamera";
  44116. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44117. export * from "babylonjs/Cameras/touchCamera";
  44118. export * from "babylonjs/Cameras/arcRotateCamera";
  44119. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44120. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44121. export * from "babylonjs/Cameras/flyCamera";
  44122. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44123. export * from "babylonjs/Cameras/followCamera";
  44124. export * from "babylonjs/Cameras/followCameraInputsManager";
  44125. export * from "babylonjs/Cameras/gamepadCamera";
  44126. export * from "babylonjs/Cameras/Stereoscopic/index";
  44127. export * from "babylonjs/Cameras/universalCamera";
  44128. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44129. export * from "babylonjs/Cameras/VR/index";
  44130. export * from "babylonjs/Cameras/XR/index";
  44131. export * from "babylonjs/Cameras/RigModes/index";
  44132. }
  44133. declare module "babylonjs/Collisions/index" {
  44134. export * from "babylonjs/Collisions/collider";
  44135. export * from "babylonjs/Collisions/collisionCoordinator";
  44136. export * from "babylonjs/Collisions/pickingInfo";
  44137. export * from "babylonjs/Collisions/intersectionInfo";
  44138. export * from "babylonjs/Collisions/meshCollisionData";
  44139. }
  44140. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44141. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44142. import { Vector3 } from "babylonjs/Maths/math.vector";
  44143. import { Ray } from "babylonjs/Culling/ray";
  44144. import { Plane } from "babylonjs/Maths/math.plane";
  44145. /**
  44146. * Contains an array of blocks representing the octree
  44147. */
  44148. export interface IOctreeContainer<T> {
  44149. /**
  44150. * Blocks within the octree
  44151. */
  44152. blocks: Array<OctreeBlock<T>>;
  44153. }
  44154. /**
  44155. * Class used to store a cell in an octree
  44156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44157. */
  44158. export class OctreeBlock<T> {
  44159. /**
  44160. * Gets the content of the current block
  44161. */
  44162. entries: T[];
  44163. /**
  44164. * Gets the list of block children
  44165. */
  44166. blocks: Array<OctreeBlock<T>>;
  44167. private _depth;
  44168. private _maxDepth;
  44169. private _capacity;
  44170. private _minPoint;
  44171. private _maxPoint;
  44172. private _boundingVectors;
  44173. private _creationFunc;
  44174. /**
  44175. * Creates a new block
  44176. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44177. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44178. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44179. * @param depth defines the current depth of this block in the octree
  44180. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44181. * @param creationFunc defines a callback to call when an element is added to the block
  44182. */
  44183. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44184. /**
  44185. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44186. */
  44187. readonly capacity: number;
  44188. /**
  44189. * Gets the minimum vector (in world space) of the block's bounding box
  44190. */
  44191. readonly minPoint: Vector3;
  44192. /**
  44193. * Gets the maximum vector (in world space) of the block's bounding box
  44194. */
  44195. readonly maxPoint: Vector3;
  44196. /**
  44197. * Add a new element to this block
  44198. * @param entry defines the element to add
  44199. */
  44200. addEntry(entry: T): void;
  44201. /**
  44202. * Remove an element from this block
  44203. * @param entry defines the element to remove
  44204. */
  44205. removeEntry(entry: T): void;
  44206. /**
  44207. * Add an array of elements to this block
  44208. * @param entries defines the array of elements to add
  44209. */
  44210. addEntries(entries: T[]): void;
  44211. /**
  44212. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44213. * @param frustumPlanes defines the frustum planes to test
  44214. * @param selection defines the array to store current content if selection is positive
  44215. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44216. */
  44217. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44218. /**
  44219. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44220. * @param sphereCenter defines the bounding sphere center
  44221. * @param sphereRadius defines the bounding sphere radius
  44222. * @param selection defines the array to store current content if selection is positive
  44223. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44224. */
  44225. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44226. /**
  44227. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44228. * @param ray defines the ray to test with
  44229. * @param selection defines the array to store current content if selection is positive
  44230. */
  44231. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44232. /**
  44233. * Subdivide the content into child blocks (this block will then be empty)
  44234. */
  44235. createInnerBlocks(): void;
  44236. /**
  44237. * @hidden
  44238. */
  44239. 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;
  44240. }
  44241. }
  44242. declare module "babylonjs/Culling/Octrees/octree" {
  44243. import { SmartArray } from "babylonjs/Misc/smartArray";
  44244. import { Vector3 } from "babylonjs/Maths/math.vector";
  44245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44247. import { Ray } from "babylonjs/Culling/ray";
  44248. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44249. import { Plane } from "babylonjs/Maths/math.plane";
  44250. /**
  44251. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44252. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44253. */
  44254. export class Octree<T> {
  44255. /** 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.) */
  44256. maxDepth: number;
  44257. /**
  44258. * Blocks within the octree containing objects
  44259. */
  44260. blocks: Array<OctreeBlock<T>>;
  44261. /**
  44262. * Content stored in the octree
  44263. */
  44264. dynamicContent: T[];
  44265. private _maxBlockCapacity;
  44266. private _selectionContent;
  44267. private _creationFunc;
  44268. /**
  44269. * Creates a octree
  44270. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44271. * @param creationFunc function to be used to instatiate the octree
  44272. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44273. * @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.)
  44274. */
  44275. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44276. /** 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.) */
  44277. maxDepth?: number);
  44278. /**
  44279. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44280. * @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);
  44281. * @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);
  44282. * @param entries meshes to be added to the octree blocks
  44283. */
  44284. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44285. /**
  44286. * Adds a mesh to the octree
  44287. * @param entry Mesh to add to the octree
  44288. */
  44289. addMesh(entry: T): void;
  44290. /**
  44291. * Remove an element from the octree
  44292. * @param entry defines the element to remove
  44293. */
  44294. removeMesh(entry: T): void;
  44295. /**
  44296. * Selects an array of meshes within the frustum
  44297. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44298. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44299. * @returns array of meshes within the frustum
  44300. */
  44301. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44302. /**
  44303. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44304. * @param sphereCenter defines the bounding sphere center
  44305. * @param sphereRadius defines the bounding sphere radius
  44306. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44307. * @returns an array of objects that intersect the sphere
  44308. */
  44309. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44310. /**
  44311. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44312. * @param ray defines the ray to test with
  44313. * @returns array of intersected objects
  44314. */
  44315. intersectsRay(ray: Ray): SmartArray<T>;
  44316. /**
  44317. * Adds a mesh into the octree block if it intersects the block
  44318. */
  44319. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44320. /**
  44321. * Adds a submesh into the octree block if it intersects the block
  44322. */
  44323. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44324. }
  44325. }
  44326. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44327. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44328. import { Scene } from "babylonjs/scene";
  44329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44331. import { Ray } from "babylonjs/Culling/ray";
  44332. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44333. import { Collider } from "babylonjs/Collisions/collider";
  44334. module "babylonjs/scene" {
  44335. interface Scene {
  44336. /**
  44337. * @hidden
  44338. * Backing Filed
  44339. */
  44340. _selectionOctree: Octree<AbstractMesh>;
  44341. /**
  44342. * Gets the octree used to boost mesh selection (picking)
  44343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44344. */
  44345. selectionOctree: Octree<AbstractMesh>;
  44346. /**
  44347. * Creates or updates the octree used to boost selection (picking)
  44348. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44349. * @param maxCapacity defines the maximum capacity per leaf
  44350. * @param maxDepth defines the maximum depth of the octree
  44351. * @returns an octree of AbstractMesh
  44352. */
  44353. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44354. }
  44355. }
  44356. module "babylonjs/Meshes/abstractMesh" {
  44357. interface AbstractMesh {
  44358. /**
  44359. * @hidden
  44360. * Backing Field
  44361. */
  44362. _submeshesOctree: Octree<SubMesh>;
  44363. /**
  44364. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44365. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44366. * @param maxCapacity defines the maximum size of each block (64 by default)
  44367. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44368. * @returns the new octree
  44369. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44371. */
  44372. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44373. }
  44374. }
  44375. /**
  44376. * Defines the octree scene component responsible to manage any octrees
  44377. * in a given scene.
  44378. */
  44379. export class OctreeSceneComponent {
  44380. /**
  44381. * The component name help to identify the component in the list of scene components.
  44382. */
  44383. readonly name: string;
  44384. /**
  44385. * The scene the component belongs to.
  44386. */
  44387. scene: Scene;
  44388. /**
  44389. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44390. */
  44391. readonly checksIsEnabled: boolean;
  44392. /**
  44393. * Creates a new instance of the component for the given scene
  44394. * @param scene Defines the scene to register the component in
  44395. */
  44396. constructor(scene: Scene);
  44397. /**
  44398. * Registers the component in a given scene
  44399. */
  44400. register(): void;
  44401. /**
  44402. * Return the list of active meshes
  44403. * @returns the list of active meshes
  44404. */
  44405. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44406. /**
  44407. * Return the list of active sub meshes
  44408. * @param mesh The mesh to get the candidates sub meshes from
  44409. * @returns the list of active sub meshes
  44410. */
  44411. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44412. private _tempRay;
  44413. /**
  44414. * Return the list of sub meshes intersecting with a given local ray
  44415. * @param mesh defines the mesh to find the submesh for
  44416. * @param localRay defines the ray in local space
  44417. * @returns the list of intersecting sub meshes
  44418. */
  44419. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44420. /**
  44421. * Return the list of sub meshes colliding with a collider
  44422. * @param mesh defines the mesh to find the submesh for
  44423. * @param collider defines the collider to evaluate the collision against
  44424. * @returns the list of colliding sub meshes
  44425. */
  44426. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44427. /**
  44428. * Rebuilds the elements related to this component in case of
  44429. * context lost for instance.
  44430. */
  44431. rebuild(): void;
  44432. /**
  44433. * Disposes the component and the associated ressources.
  44434. */
  44435. dispose(): void;
  44436. }
  44437. }
  44438. declare module "babylonjs/Culling/Octrees/index" {
  44439. export * from "babylonjs/Culling/Octrees/octree";
  44440. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44441. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44442. }
  44443. declare module "babylonjs/Culling/index" {
  44444. export * from "babylonjs/Culling/boundingBox";
  44445. export * from "babylonjs/Culling/boundingInfo";
  44446. export * from "babylonjs/Culling/boundingSphere";
  44447. export * from "babylonjs/Culling/Octrees/index";
  44448. export * from "babylonjs/Culling/ray";
  44449. }
  44450. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44451. import { IDisposable, Scene } from "babylonjs/scene";
  44452. import { Nullable } from "babylonjs/types";
  44453. import { Observable } from "babylonjs/Misc/observable";
  44454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44455. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44456. import { Camera } from "babylonjs/Cameras/camera";
  44457. /**
  44458. * Renders a layer on top of an existing scene
  44459. */
  44460. export class UtilityLayerRenderer implements IDisposable {
  44461. /** the original scene that will be rendered on top of */
  44462. originalScene: Scene;
  44463. private _pointerCaptures;
  44464. private _lastPointerEvents;
  44465. private static _DefaultUtilityLayer;
  44466. private static _DefaultKeepDepthUtilityLayer;
  44467. private _sharedGizmoLight;
  44468. private _renderCamera;
  44469. /**
  44470. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44471. * @returns the camera that is used when rendering the utility layer
  44472. */
  44473. getRenderCamera(): Nullable<Camera>;
  44474. /**
  44475. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44476. * @param cam the camera that should be used when rendering the utility layer
  44477. */
  44478. setRenderCamera(cam: Nullable<Camera>): void;
  44479. /**
  44480. * @hidden
  44481. * Light which used by gizmos to get light shading
  44482. */
  44483. _getSharedGizmoLight(): HemisphericLight;
  44484. /**
  44485. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44486. */
  44487. pickUtilitySceneFirst: boolean;
  44488. /**
  44489. * 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)
  44490. */
  44491. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44492. /**
  44493. * 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)
  44494. */
  44495. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44496. /**
  44497. * The scene that is rendered on top of the original scene
  44498. */
  44499. utilityLayerScene: Scene;
  44500. /**
  44501. * If the utility layer should automatically be rendered on top of existing scene
  44502. */
  44503. shouldRender: boolean;
  44504. /**
  44505. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44506. */
  44507. onlyCheckPointerDownEvents: boolean;
  44508. /**
  44509. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44510. */
  44511. processAllEvents: boolean;
  44512. /**
  44513. * Observable raised when the pointer move from the utility layer scene to the main scene
  44514. */
  44515. onPointerOutObservable: Observable<number>;
  44516. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44517. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44518. private _afterRenderObserver;
  44519. private _sceneDisposeObserver;
  44520. private _originalPointerObserver;
  44521. /**
  44522. * Instantiates a UtilityLayerRenderer
  44523. * @param originalScene the original scene that will be rendered on top of
  44524. * @param handleEvents boolean indicating if the utility layer should handle events
  44525. */
  44526. constructor(
  44527. /** the original scene that will be rendered on top of */
  44528. originalScene: Scene, handleEvents?: boolean);
  44529. private _notifyObservers;
  44530. /**
  44531. * Renders the utility layers scene on top of the original scene
  44532. */
  44533. render(): void;
  44534. /**
  44535. * Disposes of the renderer
  44536. */
  44537. dispose(): void;
  44538. private _updateCamera;
  44539. }
  44540. }
  44541. declare module "babylonjs/Gizmos/gizmo" {
  44542. import { Nullable } from "babylonjs/types";
  44543. import { IDisposable } from "babylonjs/scene";
  44544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44545. import { Mesh } from "babylonjs/Meshes/mesh";
  44546. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44547. /**
  44548. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44549. */
  44550. export class Gizmo implements IDisposable {
  44551. /** The utility layer the gizmo will be added to */
  44552. gizmoLayer: UtilityLayerRenderer;
  44553. /**
  44554. * The root mesh of the gizmo
  44555. */
  44556. _rootMesh: Mesh;
  44557. private _attachedMesh;
  44558. /**
  44559. * Ratio for the scale of the gizmo (Default: 1)
  44560. */
  44561. scaleRatio: number;
  44562. /**
  44563. * If a custom mesh has been set (Default: false)
  44564. */
  44565. protected _customMeshSet: boolean;
  44566. /**
  44567. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44568. * * When set, interactions will be enabled
  44569. */
  44570. attachedMesh: Nullable<AbstractMesh>;
  44571. /**
  44572. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44573. * @param mesh The mesh to replace the default mesh of the gizmo
  44574. */
  44575. setCustomMesh(mesh: Mesh): void;
  44576. /**
  44577. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44578. */
  44579. updateGizmoRotationToMatchAttachedMesh: boolean;
  44580. /**
  44581. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44582. */
  44583. updateGizmoPositionToMatchAttachedMesh: boolean;
  44584. /**
  44585. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44586. */
  44587. updateScale: boolean;
  44588. protected _interactionsEnabled: boolean;
  44589. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44590. private _beforeRenderObserver;
  44591. private _tempVector;
  44592. /**
  44593. * Creates a gizmo
  44594. * @param gizmoLayer The utility layer the gizmo will be added to
  44595. */
  44596. constructor(
  44597. /** The utility layer the gizmo will be added to */
  44598. gizmoLayer?: UtilityLayerRenderer);
  44599. /**
  44600. * Updates the gizmo to match the attached mesh's position/rotation
  44601. */
  44602. protected _update(): void;
  44603. /**
  44604. * Disposes of the gizmo
  44605. */
  44606. dispose(): void;
  44607. }
  44608. }
  44609. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44610. import { Observable } from "babylonjs/Misc/observable";
  44611. import { Nullable } from "babylonjs/types";
  44612. import { Vector3 } from "babylonjs/Maths/math.vector";
  44613. import { Color3 } from "babylonjs/Maths/math.color";
  44614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44616. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44617. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44618. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44619. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44620. import { Scene } from "babylonjs/scene";
  44621. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44622. /**
  44623. * Single plane drag gizmo
  44624. */
  44625. export class PlaneDragGizmo extends Gizmo {
  44626. /**
  44627. * Drag behavior responsible for the gizmos dragging interactions
  44628. */
  44629. dragBehavior: PointerDragBehavior;
  44630. private _pointerObserver;
  44631. /**
  44632. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44633. */
  44634. snapDistance: number;
  44635. /**
  44636. * Event that fires each time the gizmo snaps to a new location.
  44637. * * snapDistance is the the change in distance
  44638. */
  44639. onSnapObservable: Observable<{
  44640. snapDistance: number;
  44641. }>;
  44642. private _plane;
  44643. private _coloredMaterial;
  44644. private _hoverMaterial;
  44645. private _isEnabled;
  44646. private _parent;
  44647. /** @hidden */
  44648. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44649. /** @hidden */
  44650. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44651. /**
  44652. * Creates a PlaneDragGizmo
  44653. * @param gizmoLayer The utility layer the gizmo will be added to
  44654. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44655. * @param color The color of the gizmo
  44656. */
  44657. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44658. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44659. /**
  44660. * If the gizmo is enabled
  44661. */
  44662. isEnabled: boolean;
  44663. /**
  44664. * Disposes of the gizmo
  44665. */
  44666. dispose(): void;
  44667. }
  44668. }
  44669. declare module "babylonjs/Gizmos/positionGizmo" {
  44670. import { Observable } from "babylonjs/Misc/observable";
  44671. import { Nullable } from "babylonjs/types";
  44672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44673. import { Mesh } from "babylonjs/Meshes/mesh";
  44674. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44675. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44676. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44677. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44678. /**
  44679. * Gizmo that enables dragging a mesh along 3 axis
  44680. */
  44681. export class PositionGizmo extends Gizmo {
  44682. /**
  44683. * Internal gizmo used for interactions on the x axis
  44684. */
  44685. xGizmo: AxisDragGizmo;
  44686. /**
  44687. * Internal gizmo used for interactions on the y axis
  44688. */
  44689. yGizmo: AxisDragGizmo;
  44690. /**
  44691. * Internal gizmo used for interactions on the z axis
  44692. */
  44693. zGizmo: AxisDragGizmo;
  44694. /**
  44695. * Internal gizmo used for interactions on the yz plane
  44696. */
  44697. xPlaneGizmo: PlaneDragGizmo;
  44698. /**
  44699. * Internal gizmo used for interactions on the xz plane
  44700. */
  44701. yPlaneGizmo: PlaneDragGizmo;
  44702. /**
  44703. * Internal gizmo used for interactions on the xy plane
  44704. */
  44705. zPlaneGizmo: PlaneDragGizmo;
  44706. /**
  44707. * private variables
  44708. */
  44709. private _meshAttached;
  44710. private _updateGizmoRotationToMatchAttachedMesh;
  44711. private _snapDistance;
  44712. private _scaleRatio;
  44713. /** Fires an event when any of it's sub gizmos are dragged */
  44714. onDragStartObservable: Observable<unknown>;
  44715. /** Fires an event when any of it's sub gizmos are released from dragging */
  44716. onDragEndObservable: Observable<unknown>;
  44717. /**
  44718. * If set to true, planar drag is enabled
  44719. */
  44720. private _planarGizmoEnabled;
  44721. attachedMesh: Nullable<AbstractMesh>;
  44722. /**
  44723. * Creates a PositionGizmo
  44724. * @param gizmoLayer The utility layer the gizmo will be added to
  44725. */
  44726. constructor(gizmoLayer?: UtilityLayerRenderer);
  44727. /**
  44728. * If the planar drag gizmo is enabled
  44729. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44730. */
  44731. planarGizmoEnabled: boolean;
  44732. updateGizmoRotationToMatchAttachedMesh: boolean;
  44733. /**
  44734. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44735. */
  44736. snapDistance: number;
  44737. /**
  44738. * Ratio for the scale of the gizmo (Default: 1)
  44739. */
  44740. scaleRatio: number;
  44741. /**
  44742. * Disposes of the gizmo
  44743. */
  44744. dispose(): void;
  44745. /**
  44746. * CustomMeshes are not supported by this gizmo
  44747. * @param mesh The mesh to replace the default mesh of the gizmo
  44748. */
  44749. setCustomMesh(mesh: Mesh): void;
  44750. }
  44751. }
  44752. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44753. import { Observable } from "babylonjs/Misc/observable";
  44754. import { Nullable } from "babylonjs/types";
  44755. import { Vector3 } from "babylonjs/Maths/math.vector";
  44756. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44758. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44759. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44760. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44761. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44762. import { Scene } from "babylonjs/scene";
  44763. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44764. import { Color3 } from "babylonjs/Maths/math.color";
  44765. /**
  44766. * Single axis drag gizmo
  44767. */
  44768. export class AxisDragGizmo extends Gizmo {
  44769. /**
  44770. * Drag behavior responsible for the gizmos dragging interactions
  44771. */
  44772. dragBehavior: PointerDragBehavior;
  44773. private _pointerObserver;
  44774. /**
  44775. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44776. */
  44777. snapDistance: number;
  44778. /**
  44779. * Event that fires each time the gizmo snaps to a new location.
  44780. * * snapDistance is the the change in distance
  44781. */
  44782. onSnapObservable: Observable<{
  44783. snapDistance: number;
  44784. }>;
  44785. private _isEnabled;
  44786. private _parent;
  44787. private _arrow;
  44788. private _coloredMaterial;
  44789. private _hoverMaterial;
  44790. /** @hidden */
  44791. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44792. /** @hidden */
  44793. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44794. /**
  44795. * Creates an AxisDragGizmo
  44796. * @param gizmoLayer The utility layer the gizmo will be added to
  44797. * @param dragAxis The axis which the gizmo will be able to drag on
  44798. * @param color The color of the gizmo
  44799. */
  44800. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44801. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44802. /**
  44803. * If the gizmo is enabled
  44804. */
  44805. isEnabled: boolean;
  44806. /**
  44807. * Disposes of the gizmo
  44808. */
  44809. dispose(): void;
  44810. }
  44811. }
  44812. declare module "babylonjs/Debug/axesViewer" {
  44813. import { Vector3 } from "babylonjs/Maths/math.vector";
  44814. import { Nullable } from "babylonjs/types";
  44815. import { Scene } from "babylonjs/scene";
  44816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44817. /**
  44818. * The Axes viewer will show 3 axes in a specific point in space
  44819. */
  44820. export class AxesViewer {
  44821. private _xAxis;
  44822. private _yAxis;
  44823. private _zAxis;
  44824. private _scaleLinesFactor;
  44825. private _instanced;
  44826. /**
  44827. * Gets the hosting scene
  44828. */
  44829. scene: Scene;
  44830. /**
  44831. * Gets or sets a number used to scale line length
  44832. */
  44833. scaleLines: number;
  44834. /** Gets the node hierarchy used to render x-axis */
  44835. readonly xAxis: TransformNode;
  44836. /** Gets the node hierarchy used to render y-axis */
  44837. readonly yAxis: TransformNode;
  44838. /** Gets the node hierarchy used to render z-axis */
  44839. readonly zAxis: TransformNode;
  44840. /**
  44841. * Creates a new AxesViewer
  44842. * @param scene defines the hosting scene
  44843. * @param scaleLines defines a number used to scale line length (1 by default)
  44844. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44845. * @param xAxis defines the node hierarchy used to render the x-axis
  44846. * @param yAxis defines the node hierarchy used to render the y-axis
  44847. * @param zAxis defines the node hierarchy used to render the z-axis
  44848. */
  44849. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44850. /**
  44851. * Force the viewer to update
  44852. * @param position defines the position of the viewer
  44853. * @param xaxis defines the x axis of the viewer
  44854. * @param yaxis defines the y axis of the viewer
  44855. * @param zaxis defines the z axis of the viewer
  44856. */
  44857. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44858. /**
  44859. * Creates an instance of this axes viewer.
  44860. * @returns a new axes viewer with instanced meshes
  44861. */
  44862. createInstance(): AxesViewer;
  44863. /** Releases resources */
  44864. dispose(): void;
  44865. private static _SetRenderingGroupId;
  44866. }
  44867. }
  44868. declare module "babylonjs/Debug/boneAxesViewer" {
  44869. import { Nullable } from "babylonjs/types";
  44870. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44871. import { Vector3 } from "babylonjs/Maths/math.vector";
  44872. import { Mesh } from "babylonjs/Meshes/mesh";
  44873. import { Bone } from "babylonjs/Bones/bone";
  44874. import { Scene } from "babylonjs/scene";
  44875. /**
  44876. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44877. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44878. */
  44879. export class BoneAxesViewer extends AxesViewer {
  44880. /**
  44881. * Gets or sets the target mesh where to display the axes viewer
  44882. */
  44883. mesh: Nullable<Mesh>;
  44884. /**
  44885. * Gets or sets the target bone where to display the axes viewer
  44886. */
  44887. bone: Nullable<Bone>;
  44888. /** Gets current position */
  44889. pos: Vector3;
  44890. /** Gets direction of X axis */
  44891. xaxis: Vector3;
  44892. /** Gets direction of Y axis */
  44893. yaxis: Vector3;
  44894. /** Gets direction of Z axis */
  44895. zaxis: Vector3;
  44896. /**
  44897. * Creates a new BoneAxesViewer
  44898. * @param scene defines the hosting scene
  44899. * @param bone defines the target bone
  44900. * @param mesh defines the target mesh
  44901. * @param scaleLines defines a scaling factor for line length (1 by default)
  44902. */
  44903. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44904. /**
  44905. * Force the viewer to update
  44906. */
  44907. update(): void;
  44908. /** Releases resources */
  44909. dispose(): void;
  44910. }
  44911. }
  44912. declare module "babylonjs/Debug/debugLayer" {
  44913. import { Scene } from "babylonjs/scene";
  44914. /**
  44915. * Interface used to define scene explorer extensibility option
  44916. */
  44917. export interface IExplorerExtensibilityOption {
  44918. /**
  44919. * Define the option label
  44920. */
  44921. label: string;
  44922. /**
  44923. * Defines the action to execute on click
  44924. */
  44925. action: (entity: any) => void;
  44926. }
  44927. /**
  44928. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44929. */
  44930. export interface IExplorerExtensibilityGroup {
  44931. /**
  44932. * Defines a predicate to test if a given type mut be extended
  44933. */
  44934. predicate: (entity: any) => boolean;
  44935. /**
  44936. * Gets the list of options added to a type
  44937. */
  44938. entries: IExplorerExtensibilityOption[];
  44939. }
  44940. /**
  44941. * Interface used to define the options to use to create the Inspector
  44942. */
  44943. export interface IInspectorOptions {
  44944. /**
  44945. * Display in overlay mode (default: false)
  44946. */
  44947. overlay?: boolean;
  44948. /**
  44949. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44950. */
  44951. globalRoot?: HTMLElement;
  44952. /**
  44953. * Display the Scene explorer
  44954. */
  44955. showExplorer?: boolean;
  44956. /**
  44957. * Display the property inspector
  44958. */
  44959. showInspector?: boolean;
  44960. /**
  44961. * Display in embed mode (both panes on the right)
  44962. */
  44963. embedMode?: boolean;
  44964. /**
  44965. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44966. */
  44967. handleResize?: boolean;
  44968. /**
  44969. * Allow the panes to popup (default: true)
  44970. */
  44971. enablePopup?: boolean;
  44972. /**
  44973. * Allow the panes to be closed by users (default: true)
  44974. */
  44975. enableClose?: boolean;
  44976. /**
  44977. * Optional list of extensibility entries
  44978. */
  44979. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44980. /**
  44981. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44982. */
  44983. inspectorURL?: string;
  44984. }
  44985. module "babylonjs/scene" {
  44986. interface Scene {
  44987. /**
  44988. * @hidden
  44989. * Backing field
  44990. */
  44991. _debugLayer: DebugLayer;
  44992. /**
  44993. * Gets the debug layer (aka Inspector) associated with the scene
  44994. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44995. */
  44996. debugLayer: DebugLayer;
  44997. }
  44998. }
  44999. /**
  45000. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45001. * what is happening in your scene
  45002. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45003. */
  45004. export class DebugLayer {
  45005. /**
  45006. * Define the url to get the inspector script from.
  45007. * By default it uses the babylonjs CDN.
  45008. * @ignoreNaming
  45009. */
  45010. static InspectorURL: string;
  45011. private _scene;
  45012. private BJSINSPECTOR;
  45013. private _onPropertyChangedObservable?;
  45014. /**
  45015. * Observable triggered when a property is changed through the inspector.
  45016. */
  45017. readonly onPropertyChangedObservable: any;
  45018. /**
  45019. * Instantiates a new debug layer.
  45020. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45021. * what is happening in your scene
  45022. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45023. * @param scene Defines the scene to inspect
  45024. */
  45025. constructor(scene: Scene);
  45026. /** Creates the inspector window. */
  45027. private _createInspector;
  45028. /**
  45029. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45030. * @param entity defines the entity to select
  45031. * @param lineContainerTitle defines the specific block to highlight
  45032. */
  45033. select(entity: any, lineContainerTitle?: string): void;
  45034. /** Get the inspector from bundle or global */
  45035. private _getGlobalInspector;
  45036. /**
  45037. * Get if the inspector is visible or not.
  45038. * @returns true if visible otherwise, false
  45039. */
  45040. isVisible(): boolean;
  45041. /**
  45042. * Hide the inspector and close its window.
  45043. */
  45044. hide(): void;
  45045. /**
  45046. * Launch the debugLayer.
  45047. * @param config Define the configuration of the inspector
  45048. * @return a promise fulfilled when the debug layer is visible
  45049. */
  45050. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45051. }
  45052. }
  45053. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45054. import { Nullable } from "babylonjs/types";
  45055. import { Scene } from "babylonjs/scene";
  45056. import { Vector4 } from "babylonjs/Maths/math.vector";
  45057. import { Color4 } from "babylonjs/Maths/math.color";
  45058. import { Mesh } from "babylonjs/Meshes/mesh";
  45059. /**
  45060. * Class containing static functions to help procedurally build meshes
  45061. */
  45062. export class BoxBuilder {
  45063. /**
  45064. * Creates a box mesh
  45065. * * The parameter `size` sets the size (float) of each box side (default 1)
  45066. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45067. * * 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)
  45068. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45072. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45073. * @param name defines the name of the mesh
  45074. * @param options defines the options used to create the mesh
  45075. * @param scene defines the hosting scene
  45076. * @returns the box mesh
  45077. */
  45078. static CreateBox(name: string, options: {
  45079. size?: number;
  45080. width?: number;
  45081. height?: number;
  45082. depth?: number;
  45083. faceUV?: Vector4[];
  45084. faceColors?: Color4[];
  45085. sideOrientation?: number;
  45086. frontUVs?: Vector4;
  45087. backUVs?: Vector4;
  45088. wrap?: boolean;
  45089. topBaseAt?: number;
  45090. bottomBaseAt?: number;
  45091. updatable?: boolean;
  45092. }, scene?: Nullable<Scene>): Mesh;
  45093. }
  45094. }
  45095. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45096. import { Vector4 } from "babylonjs/Maths/math.vector";
  45097. import { Mesh } from "babylonjs/Meshes/mesh";
  45098. import { Scene } from "babylonjs/scene";
  45099. import { Nullable } from "babylonjs/types";
  45100. /**
  45101. * Class containing static functions to help procedurally build meshes
  45102. */
  45103. export class SphereBuilder {
  45104. /**
  45105. * Creates a sphere mesh
  45106. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45107. * * 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`)
  45108. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45109. * * 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
  45110. * * 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)
  45111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45114. * @param name defines the name of the mesh
  45115. * @param options defines the options used to create the mesh
  45116. * @param scene defines the hosting scene
  45117. * @returns the sphere mesh
  45118. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45119. */
  45120. static CreateSphere(name: string, options: {
  45121. segments?: number;
  45122. diameter?: number;
  45123. diameterX?: number;
  45124. diameterY?: number;
  45125. diameterZ?: number;
  45126. arc?: number;
  45127. slice?: number;
  45128. sideOrientation?: number;
  45129. frontUVs?: Vector4;
  45130. backUVs?: Vector4;
  45131. updatable?: boolean;
  45132. }, scene?: Nullable<Scene>): Mesh;
  45133. }
  45134. }
  45135. declare module "babylonjs/Debug/physicsViewer" {
  45136. import { Nullable } from "babylonjs/types";
  45137. import { Scene } from "babylonjs/scene";
  45138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45139. import { Mesh } from "babylonjs/Meshes/mesh";
  45140. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45141. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45142. /**
  45143. * Used to show the physics impostor around the specific mesh
  45144. */
  45145. export class PhysicsViewer {
  45146. /** @hidden */
  45147. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45148. /** @hidden */
  45149. protected _meshes: Array<Nullable<AbstractMesh>>;
  45150. /** @hidden */
  45151. protected _scene: Nullable<Scene>;
  45152. /** @hidden */
  45153. protected _numMeshes: number;
  45154. /** @hidden */
  45155. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45156. private _renderFunction;
  45157. private _utilityLayer;
  45158. private _debugBoxMesh;
  45159. private _debugSphereMesh;
  45160. private _debugCylinderMesh;
  45161. private _debugMaterial;
  45162. private _debugMeshMeshes;
  45163. /**
  45164. * Creates a new PhysicsViewer
  45165. * @param scene defines the hosting scene
  45166. */
  45167. constructor(scene: Scene);
  45168. /** @hidden */
  45169. protected _updateDebugMeshes(): void;
  45170. /**
  45171. * Renders a specified physic impostor
  45172. * @param impostor defines the impostor to render
  45173. * @param targetMesh defines the mesh represented by the impostor
  45174. * @returns the new debug mesh used to render the impostor
  45175. */
  45176. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45177. /**
  45178. * Hides a specified physic impostor
  45179. * @param impostor defines the impostor to hide
  45180. */
  45181. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45182. private _getDebugMaterial;
  45183. private _getDebugBoxMesh;
  45184. private _getDebugSphereMesh;
  45185. private _getDebugCylinderMesh;
  45186. private _getDebugMeshMesh;
  45187. private _getDebugMesh;
  45188. /** Releases all resources */
  45189. dispose(): void;
  45190. }
  45191. }
  45192. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45193. import { Vector3 } from "babylonjs/Maths/math.vector";
  45194. import { Color4 } from "babylonjs/Maths/math.color";
  45195. import { Nullable } from "babylonjs/types";
  45196. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45197. import { Scene } from "babylonjs/scene";
  45198. /**
  45199. * Class containing static functions to help procedurally build meshes
  45200. */
  45201. export class LinesBuilder {
  45202. /**
  45203. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45204. * * 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
  45205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45206. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45207. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45208. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45209. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45210. * * 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
  45211. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45214. * @param name defines the name of the new line system
  45215. * @param options defines the options used to create the line system
  45216. * @param scene defines the hosting scene
  45217. * @returns a new line system mesh
  45218. */
  45219. static CreateLineSystem(name: string, options: {
  45220. lines: Vector3[][];
  45221. updatable?: boolean;
  45222. instance?: Nullable<LinesMesh>;
  45223. colors?: Nullable<Color4[][]>;
  45224. useVertexAlpha?: boolean;
  45225. }, scene: Nullable<Scene>): LinesMesh;
  45226. /**
  45227. * Creates a line mesh
  45228. * 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
  45229. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45230. * * The parameter `points` is an array successive Vector3
  45231. * * 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
  45232. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45233. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45234. * * When updating an instance, remember that only point positions can change, not the number of points
  45235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45237. * @param name defines the name of the new line system
  45238. * @param options defines the options used to create the line system
  45239. * @param scene defines the hosting scene
  45240. * @returns a new line mesh
  45241. */
  45242. static CreateLines(name: string, options: {
  45243. points: Vector3[];
  45244. updatable?: boolean;
  45245. instance?: Nullable<LinesMesh>;
  45246. colors?: Color4[];
  45247. useVertexAlpha?: boolean;
  45248. }, scene?: Nullable<Scene>): LinesMesh;
  45249. /**
  45250. * Creates a dashed line mesh
  45251. * * 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
  45252. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45253. * * The parameter `points` is an array successive Vector3
  45254. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45255. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45256. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45257. * * 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
  45258. * * When updating an instance, remember that only point positions can change, not the number of points
  45259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45260. * @param name defines the name of the mesh
  45261. * @param options defines the options used to create the mesh
  45262. * @param scene defines the hosting scene
  45263. * @returns the dashed line mesh
  45264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45265. */
  45266. static CreateDashedLines(name: string, options: {
  45267. points: Vector3[];
  45268. dashSize?: number;
  45269. gapSize?: number;
  45270. dashNb?: number;
  45271. updatable?: boolean;
  45272. instance?: LinesMesh;
  45273. }, scene?: Nullable<Scene>): LinesMesh;
  45274. }
  45275. }
  45276. declare module "babylonjs/Debug/rayHelper" {
  45277. import { Nullable } from "babylonjs/types";
  45278. import { Ray } from "babylonjs/Culling/ray";
  45279. import { Vector3 } from "babylonjs/Maths/math.vector";
  45280. import { Color3 } from "babylonjs/Maths/math.color";
  45281. import { Scene } from "babylonjs/scene";
  45282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45283. import "babylonjs/Meshes/Builders/linesBuilder";
  45284. /**
  45285. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45286. * in order to better appreciate the issue one might have.
  45287. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45288. */
  45289. export class RayHelper {
  45290. /**
  45291. * Defines the ray we are currently tryin to visualize.
  45292. */
  45293. ray: Nullable<Ray>;
  45294. private _renderPoints;
  45295. private _renderLine;
  45296. private _renderFunction;
  45297. private _scene;
  45298. private _updateToMeshFunction;
  45299. private _attachedToMesh;
  45300. private _meshSpaceDirection;
  45301. private _meshSpaceOrigin;
  45302. /**
  45303. * Helper function to create a colored helper in a scene in one line.
  45304. * @param ray Defines the ray we are currently tryin to visualize
  45305. * @param scene Defines the scene the ray is used in
  45306. * @param color Defines the color we want to see the ray in
  45307. * @returns The newly created ray helper.
  45308. */
  45309. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45310. /**
  45311. * Instantiate a new ray helper.
  45312. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45313. * in order to better appreciate the issue one might have.
  45314. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45315. * @param ray Defines the ray we are currently tryin to visualize
  45316. */
  45317. constructor(ray: Ray);
  45318. /**
  45319. * Shows the ray we are willing to debug.
  45320. * @param scene Defines the scene the ray needs to be rendered in
  45321. * @param color Defines the color the ray needs to be rendered in
  45322. */
  45323. show(scene: Scene, color?: Color3): void;
  45324. /**
  45325. * Hides the ray we are debugging.
  45326. */
  45327. hide(): void;
  45328. private _render;
  45329. /**
  45330. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45331. * @param mesh Defines the mesh we want the helper attached to
  45332. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45333. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45334. * @param length Defines the length of the ray
  45335. */
  45336. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45337. /**
  45338. * Detach the ray helper from the mesh it has previously been attached to.
  45339. */
  45340. detachFromMesh(): void;
  45341. private _updateToMesh;
  45342. /**
  45343. * Dispose the helper and release its associated resources.
  45344. */
  45345. dispose(): void;
  45346. }
  45347. }
  45348. declare module "babylonjs/Debug/skeletonViewer" {
  45349. import { Color3 } from "babylonjs/Maths/math.color";
  45350. import { Scene } from "babylonjs/scene";
  45351. import { Nullable } from "babylonjs/types";
  45352. import { Skeleton } from "babylonjs/Bones/skeleton";
  45353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45354. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45355. /**
  45356. * Class used to render a debug view of a given skeleton
  45357. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45358. */
  45359. export class SkeletonViewer {
  45360. /** defines the skeleton to render */
  45361. skeleton: Skeleton;
  45362. /** defines the mesh attached to the skeleton */
  45363. mesh: AbstractMesh;
  45364. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45365. autoUpdateBonesMatrices: boolean;
  45366. /** defines the rendering group id to use with the viewer */
  45367. renderingGroupId: number;
  45368. /** Gets or sets the color used to render the skeleton */
  45369. color: Color3;
  45370. private _scene;
  45371. private _debugLines;
  45372. private _debugMesh;
  45373. private _isEnabled;
  45374. private _renderFunction;
  45375. private _utilityLayer;
  45376. /**
  45377. * Returns the mesh used to render the bones
  45378. */
  45379. readonly debugMesh: Nullable<LinesMesh>;
  45380. /**
  45381. * Creates a new SkeletonViewer
  45382. * @param skeleton defines the skeleton to render
  45383. * @param mesh defines the mesh attached to the skeleton
  45384. * @param scene defines the hosting scene
  45385. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45386. * @param renderingGroupId defines the rendering group id to use with the viewer
  45387. */
  45388. constructor(
  45389. /** defines the skeleton to render */
  45390. skeleton: Skeleton,
  45391. /** defines the mesh attached to the skeleton */
  45392. mesh: AbstractMesh, scene: Scene,
  45393. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45394. autoUpdateBonesMatrices?: boolean,
  45395. /** defines the rendering group id to use with the viewer */
  45396. renderingGroupId?: number);
  45397. /** Gets or sets a boolean indicating if the viewer is enabled */
  45398. isEnabled: boolean;
  45399. private _getBonePosition;
  45400. private _getLinesForBonesWithLength;
  45401. private _getLinesForBonesNoLength;
  45402. /** Update the viewer to sync with current skeleton state */
  45403. update(): void;
  45404. /** Release associated resources */
  45405. dispose(): void;
  45406. }
  45407. }
  45408. declare module "babylonjs/Debug/index" {
  45409. export * from "babylonjs/Debug/axesViewer";
  45410. export * from "babylonjs/Debug/boneAxesViewer";
  45411. export * from "babylonjs/Debug/debugLayer";
  45412. export * from "babylonjs/Debug/physicsViewer";
  45413. export * from "babylonjs/Debug/rayHelper";
  45414. export * from "babylonjs/Debug/skeletonViewer";
  45415. }
  45416. declare module "babylonjs/Engines/nullEngine" {
  45417. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45418. import { Scene } from "babylonjs/scene";
  45419. import { Engine } from "babylonjs/Engines/engine";
  45420. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45421. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45423. import { Effect } from "babylonjs/Materials/effect";
  45424. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45425. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45426. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45427. /**
  45428. * Options to create the null engine
  45429. */
  45430. export class NullEngineOptions {
  45431. /**
  45432. * Render width (Default: 512)
  45433. */
  45434. renderWidth: number;
  45435. /**
  45436. * Render height (Default: 256)
  45437. */
  45438. renderHeight: number;
  45439. /**
  45440. * Texture size (Default: 512)
  45441. */
  45442. textureSize: number;
  45443. /**
  45444. * If delta time between frames should be constant
  45445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45446. */
  45447. deterministicLockstep: boolean;
  45448. /**
  45449. * Maximum about of steps between frames (Default: 4)
  45450. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45451. */
  45452. lockstepMaxSteps: number;
  45453. }
  45454. /**
  45455. * The null engine class provides support for headless version of babylon.js.
  45456. * This can be used in server side scenario or for testing purposes
  45457. */
  45458. export class NullEngine extends Engine {
  45459. private _options;
  45460. /**
  45461. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45463. * @returns true if engine is in deterministic lock step mode
  45464. */
  45465. isDeterministicLockStep(): boolean;
  45466. /**
  45467. * Gets the max steps when engine is running in deterministic lock step
  45468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45469. * @returns the max steps
  45470. */
  45471. getLockstepMaxSteps(): number;
  45472. /**
  45473. * Gets the current hardware scaling level.
  45474. * By default the hardware scaling level is computed from the window device ratio.
  45475. * 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.
  45476. * @returns a number indicating the current hardware scaling level
  45477. */
  45478. getHardwareScalingLevel(): number;
  45479. constructor(options?: NullEngineOptions);
  45480. /**
  45481. * Creates a vertex buffer
  45482. * @param vertices the data for the vertex buffer
  45483. * @returns the new WebGL static buffer
  45484. */
  45485. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45486. /**
  45487. * Creates a new index buffer
  45488. * @param indices defines the content of the index buffer
  45489. * @param updatable defines if the index buffer must be updatable
  45490. * @returns a new webGL buffer
  45491. */
  45492. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45493. /**
  45494. * Clear the current render buffer or the current render target (if any is set up)
  45495. * @param color defines the color to use
  45496. * @param backBuffer defines if the back buffer must be cleared
  45497. * @param depth defines if the depth buffer must be cleared
  45498. * @param stencil defines if the stencil buffer must be cleared
  45499. */
  45500. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45501. /**
  45502. * Gets the current render width
  45503. * @param useScreen defines if screen size must be used (or the current render target if any)
  45504. * @returns a number defining the current render width
  45505. */
  45506. getRenderWidth(useScreen?: boolean): number;
  45507. /**
  45508. * Gets the current render height
  45509. * @param useScreen defines if screen size must be used (or the current render target if any)
  45510. * @returns a number defining the current render height
  45511. */
  45512. getRenderHeight(useScreen?: boolean): number;
  45513. /**
  45514. * Set the WebGL's viewport
  45515. * @param viewport defines the viewport element to be used
  45516. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45517. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45518. */
  45519. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45520. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45521. /**
  45522. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45523. * @param pipelineContext defines the pipeline context to use
  45524. * @param uniformsNames defines the list of uniform names
  45525. * @returns an array of webGL uniform locations
  45526. */
  45527. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45528. /**
  45529. * Gets the lsit of active attributes for a given webGL program
  45530. * @param pipelineContext defines the pipeline context to use
  45531. * @param attributesNames defines the list of attribute names to get
  45532. * @returns an array of indices indicating the offset of each attribute
  45533. */
  45534. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45535. /**
  45536. * Binds an effect to the webGL context
  45537. * @param effect defines the effect to bind
  45538. */
  45539. bindSamplers(effect: Effect): void;
  45540. /**
  45541. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45542. * @param effect defines the effect to activate
  45543. */
  45544. enableEffect(effect: Effect): void;
  45545. /**
  45546. * Set various states to the webGL context
  45547. * @param culling defines backface culling state
  45548. * @param zOffset defines the value to apply to zOffset (0 by default)
  45549. * @param force defines if states must be applied even if cache is up to date
  45550. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45551. */
  45552. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45553. /**
  45554. * Set the value of an uniform to an array of int32
  45555. * @param uniform defines the webGL uniform location where to store the value
  45556. * @param array defines the array of int32 to store
  45557. */
  45558. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45559. /**
  45560. * Set the value of an uniform to an array of int32 (stored as vec2)
  45561. * @param uniform defines the webGL uniform location where to store the value
  45562. * @param array defines the array of int32 to store
  45563. */
  45564. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45565. /**
  45566. * Set the value of an uniform to an array of int32 (stored as vec3)
  45567. * @param uniform defines the webGL uniform location where to store the value
  45568. * @param array defines the array of int32 to store
  45569. */
  45570. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45571. /**
  45572. * Set the value of an uniform to an array of int32 (stored as vec4)
  45573. * @param uniform defines the webGL uniform location where to store the value
  45574. * @param array defines the array of int32 to store
  45575. */
  45576. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45577. /**
  45578. * Set the value of an uniform to an array of float32
  45579. * @param uniform defines the webGL uniform location where to store the value
  45580. * @param array defines the array of float32 to store
  45581. */
  45582. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45583. /**
  45584. * Set the value of an uniform to an array of float32 (stored as vec2)
  45585. * @param uniform defines the webGL uniform location where to store the value
  45586. * @param array defines the array of float32 to store
  45587. */
  45588. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45589. /**
  45590. * Set the value of an uniform to an array of float32 (stored as vec3)
  45591. * @param uniform defines the webGL uniform location where to store the value
  45592. * @param array defines the array of float32 to store
  45593. */
  45594. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45595. /**
  45596. * Set the value of an uniform to an array of float32 (stored as vec4)
  45597. * @param uniform defines the webGL uniform location where to store the value
  45598. * @param array defines the array of float32 to store
  45599. */
  45600. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45601. /**
  45602. * Set the value of an uniform to an array of number
  45603. * @param uniform defines the webGL uniform location where to store the value
  45604. * @param array defines the array of number to store
  45605. */
  45606. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45607. /**
  45608. * Set the value of an uniform to an array of number (stored as vec2)
  45609. * @param uniform defines the webGL uniform location where to store the value
  45610. * @param array defines the array of number to store
  45611. */
  45612. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45613. /**
  45614. * Set the value of an uniform to an array of number (stored as vec3)
  45615. * @param uniform defines the webGL uniform location where to store the value
  45616. * @param array defines the array of number to store
  45617. */
  45618. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45619. /**
  45620. * Set the value of an uniform to an array of number (stored as vec4)
  45621. * @param uniform defines the webGL uniform location where to store the value
  45622. * @param array defines the array of number to store
  45623. */
  45624. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45625. /**
  45626. * Set the value of an uniform to an array of float32 (stored as matrices)
  45627. * @param uniform defines the webGL uniform location where to store the value
  45628. * @param matrices defines the array of float32 to store
  45629. */
  45630. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45631. /**
  45632. * Set the value of an uniform to a matrix (3x3)
  45633. * @param uniform defines the webGL uniform location where to store the value
  45634. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45635. */
  45636. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45637. /**
  45638. * Set the value of an uniform to a matrix (2x2)
  45639. * @param uniform defines the webGL uniform location where to store the value
  45640. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45641. */
  45642. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45643. /**
  45644. * Set the value of an uniform to a number (float)
  45645. * @param uniform defines the webGL uniform location where to store the value
  45646. * @param value defines the float number to store
  45647. */
  45648. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45649. /**
  45650. * Set the value of an uniform to a vec2
  45651. * @param uniform defines the webGL uniform location where to store the value
  45652. * @param x defines the 1st component of the value
  45653. * @param y defines the 2nd component of the value
  45654. */
  45655. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45656. /**
  45657. * Set the value of an uniform to a vec3
  45658. * @param uniform defines the webGL uniform location where to store the value
  45659. * @param x defines the 1st component of the value
  45660. * @param y defines the 2nd component of the value
  45661. * @param z defines the 3rd component of the value
  45662. */
  45663. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45664. /**
  45665. * Set the value of an uniform to a boolean
  45666. * @param uniform defines the webGL uniform location where to store the value
  45667. * @param bool defines the boolean to store
  45668. */
  45669. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45670. /**
  45671. * Set the value of an uniform to a vec4
  45672. * @param uniform defines the webGL uniform location where to store the value
  45673. * @param x defines the 1st component of the value
  45674. * @param y defines the 2nd component of the value
  45675. * @param z defines the 3rd component of the value
  45676. * @param w defines the 4th component of the value
  45677. */
  45678. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45679. /**
  45680. * Sets the current alpha mode
  45681. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45682. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45684. */
  45685. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45686. /**
  45687. * Bind webGl buffers directly to the webGL context
  45688. * @param vertexBuffers defines the vertex buffer to bind
  45689. * @param indexBuffer defines the index buffer to bind
  45690. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45691. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45692. * @param effect defines the effect associated with the vertex buffer
  45693. */
  45694. bindBuffers(vertexBuffers: {
  45695. [key: string]: VertexBuffer;
  45696. }, indexBuffer: DataBuffer, effect: Effect): void;
  45697. /**
  45698. * Force the entire cache to be cleared
  45699. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45700. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45701. */
  45702. wipeCaches(bruteForce?: boolean): void;
  45703. /**
  45704. * Send a draw order
  45705. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45706. * @param indexStart defines the starting index
  45707. * @param indexCount defines the number of index to draw
  45708. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45709. */
  45710. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45711. /**
  45712. * Draw a list of indexed primitives
  45713. * @param fillMode defines the primitive to use
  45714. * @param indexStart defines the starting index
  45715. * @param indexCount defines the number of index to draw
  45716. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45717. */
  45718. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45719. /**
  45720. * Draw a list of unindexed primitives
  45721. * @param fillMode defines the primitive to use
  45722. * @param verticesStart defines the index of first vertex to draw
  45723. * @param verticesCount defines the count of vertices to draw
  45724. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45725. */
  45726. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45727. /** @hidden */
  45728. _createTexture(): WebGLTexture;
  45729. /** @hidden */
  45730. _releaseTexture(texture: InternalTexture): void;
  45731. /**
  45732. * Usually called from Texture.ts.
  45733. * Passed information to create a WebGLTexture
  45734. * @param urlArg defines a value which contains one of the following:
  45735. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45736. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45737. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45738. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45739. * @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)
  45740. * @param scene needed for loading to the correct scene
  45741. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45742. * @param onLoad optional callback to be called upon successful completion
  45743. * @param onError optional callback to be called upon failure
  45744. * @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
  45745. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45746. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45747. * @param forcedExtension defines the extension to use to pick the right loader
  45748. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45749. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45750. */
  45751. 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;
  45752. /**
  45753. * Creates a new render target texture
  45754. * @param size defines the size of the texture
  45755. * @param options defines the options used to create the texture
  45756. * @returns a new render target texture stored in an InternalTexture
  45757. */
  45758. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45759. /**
  45760. * Update the sampling mode of a given texture
  45761. * @param samplingMode defines the required sampling mode
  45762. * @param texture defines the texture to update
  45763. */
  45764. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45765. /**
  45766. * Binds the frame buffer to the specified texture.
  45767. * @param texture The texture to render to or null for the default canvas
  45768. * @param faceIndex The face of the texture to render to in case of cube texture
  45769. * @param requiredWidth The width of the target to render to
  45770. * @param requiredHeight The height of the target to render to
  45771. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45772. * @param depthStencilTexture The depth stencil texture to use to render
  45773. * @param lodLevel defines le lod level to bind to the frame buffer
  45774. */
  45775. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45776. /**
  45777. * Unbind the current render target texture from the webGL context
  45778. * @param texture defines the render target texture to unbind
  45779. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45780. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45781. */
  45782. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45783. /**
  45784. * Creates a dynamic vertex buffer
  45785. * @param vertices the data for the dynamic vertex buffer
  45786. * @returns the new WebGL dynamic buffer
  45787. */
  45788. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45789. /**
  45790. * Update the content of a dynamic texture
  45791. * @param texture defines the texture to update
  45792. * @param canvas defines the canvas containing the source
  45793. * @param invertY defines if data must be stored with Y axis inverted
  45794. * @param premulAlpha defines if alpha is stored as premultiplied
  45795. * @param format defines the format of the data
  45796. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45797. */
  45798. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45799. /**
  45800. * Gets a boolean indicating if all created effects are ready
  45801. * @returns true if all effects are ready
  45802. */
  45803. areAllEffectsReady(): boolean;
  45804. /**
  45805. * @hidden
  45806. * Get the current error code of the webGL context
  45807. * @returns the error code
  45808. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45809. */
  45810. getError(): number;
  45811. /** @hidden */
  45812. _getUnpackAlignement(): number;
  45813. /** @hidden */
  45814. _unpackFlipY(value: boolean): void;
  45815. /**
  45816. * Update a dynamic index buffer
  45817. * @param indexBuffer defines the target index buffer
  45818. * @param indices defines the data to update
  45819. * @param offset defines the offset in the target index buffer where update should start
  45820. */
  45821. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45822. /**
  45823. * Updates a dynamic vertex buffer.
  45824. * @param vertexBuffer the vertex buffer to update
  45825. * @param vertices the data used to update the vertex buffer
  45826. * @param byteOffset the byte offset of the data (optional)
  45827. * @param byteLength the byte length of the data (optional)
  45828. */
  45829. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45830. /** @hidden */
  45831. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45832. /** @hidden */
  45833. _bindTexture(channel: number, texture: InternalTexture): void;
  45834. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45835. /**
  45836. * 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
  45837. */
  45838. releaseEffects(): void;
  45839. displayLoadingUI(): void;
  45840. hideLoadingUI(): void;
  45841. /** @hidden */
  45842. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45843. /** @hidden */
  45844. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45845. /** @hidden */
  45846. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45847. /** @hidden */
  45848. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45849. }
  45850. }
  45851. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45852. import { Nullable, int } from "babylonjs/types";
  45853. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45854. /** @hidden */
  45855. export class _OcclusionDataStorage {
  45856. /** @hidden */
  45857. occlusionInternalRetryCounter: number;
  45858. /** @hidden */
  45859. isOcclusionQueryInProgress: boolean;
  45860. /** @hidden */
  45861. isOccluded: boolean;
  45862. /** @hidden */
  45863. occlusionRetryCount: number;
  45864. /** @hidden */
  45865. occlusionType: number;
  45866. /** @hidden */
  45867. occlusionQueryAlgorithmType: number;
  45868. }
  45869. module "babylonjs/Engines/engine" {
  45870. interface Engine {
  45871. /**
  45872. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45873. * @return the new query
  45874. */
  45875. createQuery(): WebGLQuery;
  45876. /**
  45877. * Delete and release a webGL query
  45878. * @param query defines the query to delete
  45879. * @return the current engine
  45880. */
  45881. deleteQuery(query: WebGLQuery): Engine;
  45882. /**
  45883. * Check if a given query has resolved and got its value
  45884. * @param query defines the query to check
  45885. * @returns true if the query got its value
  45886. */
  45887. isQueryResultAvailable(query: WebGLQuery): boolean;
  45888. /**
  45889. * Gets the value of a given query
  45890. * @param query defines the query to check
  45891. * @returns the value of the query
  45892. */
  45893. getQueryResult(query: WebGLQuery): number;
  45894. /**
  45895. * Initiates an occlusion query
  45896. * @param algorithmType defines the algorithm to use
  45897. * @param query defines the query to use
  45898. * @returns the current engine
  45899. * @see http://doc.babylonjs.com/features/occlusionquery
  45900. */
  45901. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45902. /**
  45903. * Ends an occlusion query
  45904. * @see http://doc.babylonjs.com/features/occlusionquery
  45905. * @param algorithmType defines the algorithm to use
  45906. * @returns the current engine
  45907. */
  45908. endOcclusionQuery(algorithmType: number): Engine;
  45909. /**
  45910. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45911. * Please note that only one query can be issued at a time
  45912. * @returns a time token used to track the time span
  45913. */
  45914. startTimeQuery(): Nullable<_TimeToken>;
  45915. /**
  45916. * Ends a time query
  45917. * @param token defines the token used to measure the time span
  45918. * @returns the time spent (in ns)
  45919. */
  45920. endTimeQuery(token: _TimeToken): int;
  45921. /** @hidden */
  45922. _currentNonTimestampToken: Nullable<_TimeToken>;
  45923. /** @hidden */
  45924. _createTimeQuery(): WebGLQuery;
  45925. /** @hidden */
  45926. _deleteTimeQuery(query: WebGLQuery): void;
  45927. /** @hidden */
  45928. _getGlAlgorithmType(algorithmType: number): number;
  45929. /** @hidden */
  45930. _getTimeQueryResult(query: WebGLQuery): any;
  45931. /** @hidden */
  45932. _getTimeQueryAvailability(query: WebGLQuery): any;
  45933. }
  45934. }
  45935. module "babylonjs/Meshes/abstractMesh" {
  45936. interface AbstractMesh {
  45937. /**
  45938. * Backing filed
  45939. * @hidden
  45940. */
  45941. __occlusionDataStorage: _OcclusionDataStorage;
  45942. /**
  45943. * Access property
  45944. * @hidden
  45945. */
  45946. _occlusionDataStorage: _OcclusionDataStorage;
  45947. /**
  45948. * 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.
  45949. * The default value is -1 which means don't break the query and wait till the result
  45950. * @see http://doc.babylonjs.com/features/occlusionquery
  45951. */
  45952. occlusionRetryCount: number;
  45953. /**
  45954. * 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:
  45955. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45956. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45957. * * 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.
  45958. * @see http://doc.babylonjs.com/features/occlusionquery
  45959. */
  45960. occlusionType: number;
  45961. /**
  45962. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45963. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45964. * * 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.
  45965. * @see http://doc.babylonjs.com/features/occlusionquery
  45966. */
  45967. occlusionQueryAlgorithmType: number;
  45968. /**
  45969. * 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
  45970. * @see http://doc.babylonjs.com/features/occlusionquery
  45971. */
  45972. isOccluded: boolean;
  45973. /**
  45974. * Flag to check the progress status of the query
  45975. * @see http://doc.babylonjs.com/features/occlusionquery
  45976. */
  45977. isOcclusionQueryInProgress: boolean;
  45978. }
  45979. }
  45980. }
  45981. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45982. import { Nullable } from "babylonjs/types";
  45983. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45984. /** @hidden */
  45985. export var _forceTransformFeedbackToBundle: boolean;
  45986. module "babylonjs/Engines/engine" {
  45987. interface Engine {
  45988. /**
  45989. * Creates a webGL transform feedback object
  45990. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45991. * @returns the webGL transform feedback object
  45992. */
  45993. createTransformFeedback(): WebGLTransformFeedback;
  45994. /**
  45995. * Delete a webGL transform feedback object
  45996. * @param value defines the webGL transform feedback object to delete
  45997. */
  45998. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45999. /**
  46000. * Bind a webGL transform feedback object to the webgl context
  46001. * @param value defines the webGL transform feedback object to bind
  46002. */
  46003. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46004. /**
  46005. * Begins a transform feedback operation
  46006. * @param usePoints defines if points or triangles must be used
  46007. */
  46008. beginTransformFeedback(usePoints: boolean): void;
  46009. /**
  46010. * Ends a transform feedback operation
  46011. */
  46012. endTransformFeedback(): void;
  46013. /**
  46014. * Specify the varyings to use with transform feedback
  46015. * @param program defines the associated webGL program
  46016. * @param value defines the list of strings representing the varying names
  46017. */
  46018. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46019. /**
  46020. * Bind a webGL buffer for a transform feedback operation
  46021. * @param value defines the webGL buffer to bind
  46022. */
  46023. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46024. }
  46025. }
  46026. }
  46027. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46028. import { Scene } from "babylonjs/scene";
  46029. import { Engine } from "babylonjs/Engines/engine";
  46030. import { Texture } from "babylonjs/Materials/Textures/texture";
  46031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46032. import "babylonjs/Engines/Extensions/engine.multiRender";
  46033. /**
  46034. * Creation options of the multi render target texture.
  46035. */
  46036. export interface IMultiRenderTargetOptions {
  46037. /**
  46038. * Define if the texture needs to create mip maps after render.
  46039. */
  46040. generateMipMaps?: boolean;
  46041. /**
  46042. * Define the types of all the draw buffers we want to create
  46043. */
  46044. types?: number[];
  46045. /**
  46046. * Define the sampling modes of all the draw buffers we want to create
  46047. */
  46048. samplingModes?: number[];
  46049. /**
  46050. * Define if a depth buffer is required
  46051. */
  46052. generateDepthBuffer?: boolean;
  46053. /**
  46054. * Define if a stencil buffer is required
  46055. */
  46056. generateStencilBuffer?: boolean;
  46057. /**
  46058. * Define if a depth texture is required instead of a depth buffer
  46059. */
  46060. generateDepthTexture?: boolean;
  46061. /**
  46062. * Define the number of desired draw buffers
  46063. */
  46064. textureCount?: number;
  46065. /**
  46066. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46067. */
  46068. doNotChangeAspectRatio?: boolean;
  46069. /**
  46070. * Define the default type of the buffers we are creating
  46071. */
  46072. defaultType?: number;
  46073. }
  46074. /**
  46075. * A multi render target, like a render target provides the ability to render to a texture.
  46076. * Unlike the render target, it can render to several draw buffers in one draw.
  46077. * This is specially interesting in deferred rendering or for any effects requiring more than
  46078. * just one color from a single pass.
  46079. */
  46080. export class MultiRenderTarget extends RenderTargetTexture {
  46081. private _internalTextures;
  46082. private _textures;
  46083. private _multiRenderTargetOptions;
  46084. /**
  46085. * Get if draw buffers are currently supported by the used hardware and browser.
  46086. */
  46087. readonly isSupported: boolean;
  46088. /**
  46089. * Get the list of textures generated by the multi render target.
  46090. */
  46091. readonly textures: Texture[];
  46092. /**
  46093. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46094. */
  46095. readonly depthTexture: Texture;
  46096. /**
  46097. * Set the wrapping mode on U of all the textures we are rendering to.
  46098. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46099. */
  46100. wrapU: number;
  46101. /**
  46102. * Set the wrapping mode on V of all the textures we are rendering to.
  46103. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46104. */
  46105. wrapV: number;
  46106. /**
  46107. * Instantiate a new multi render target texture.
  46108. * A multi render target, like a render target provides the ability to render to a texture.
  46109. * Unlike the render target, it can render to several draw buffers in one draw.
  46110. * This is specially interesting in deferred rendering or for any effects requiring more than
  46111. * just one color from a single pass.
  46112. * @param name Define the name of the texture
  46113. * @param size Define the size of the buffers to render to
  46114. * @param count Define the number of target we are rendering into
  46115. * @param scene Define the scene the texture belongs to
  46116. * @param options Define the options used to create the multi render target
  46117. */
  46118. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46119. /** @hidden */
  46120. _rebuild(): void;
  46121. private _createInternalTextures;
  46122. private _createTextures;
  46123. /**
  46124. * Define the number of samples used if MSAA is enabled.
  46125. */
  46126. samples: number;
  46127. /**
  46128. * Resize all the textures in the multi render target.
  46129. * Be carrefull as it will recreate all the data in the new texture.
  46130. * @param size Define the new size
  46131. */
  46132. resize(size: any): void;
  46133. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46134. /**
  46135. * Dispose the render targets and their associated resources
  46136. */
  46137. dispose(): void;
  46138. /**
  46139. * Release all the underlying texture used as draw buffers.
  46140. */
  46141. releaseInternalTextures(): void;
  46142. }
  46143. }
  46144. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46146. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46147. import { Nullable } from "babylonjs/types";
  46148. module "babylonjs/Engines/thinEngine" {
  46149. interface ThinEngine {
  46150. /**
  46151. * Unbind a list of render target textures from the webGL context
  46152. * This is used only when drawBuffer extension or webGL2 are active
  46153. * @param textures defines the render target textures to unbind
  46154. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46155. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46156. */
  46157. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46158. /**
  46159. * Create a multi render target texture
  46160. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46161. * @param size defines the size of the texture
  46162. * @param options defines the creation options
  46163. * @returns the cube texture as an InternalTexture
  46164. */
  46165. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46166. /**
  46167. * Update the sample count for a given multiple render target texture
  46168. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46169. * @param textures defines the textures to update
  46170. * @param samples defines the sample count to set
  46171. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46172. */
  46173. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46174. }
  46175. }
  46176. }
  46177. declare module "babylonjs/Engines/Extensions/index" {
  46178. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46179. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46180. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46181. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46182. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46183. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46184. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46185. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46186. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46187. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46188. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46189. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46190. }
  46191. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46192. import { Nullable } from "babylonjs/types";
  46193. /**
  46194. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46195. */
  46196. export interface CubeMapInfo {
  46197. /**
  46198. * The pixel array for the front face.
  46199. * This is stored in format, left to right, up to down format.
  46200. */
  46201. front: Nullable<ArrayBufferView>;
  46202. /**
  46203. * The pixel array for the back face.
  46204. * This is stored in format, left to right, up to down format.
  46205. */
  46206. back: Nullable<ArrayBufferView>;
  46207. /**
  46208. * The pixel array for the left face.
  46209. * This is stored in format, left to right, up to down format.
  46210. */
  46211. left: Nullable<ArrayBufferView>;
  46212. /**
  46213. * The pixel array for the right face.
  46214. * This is stored in format, left to right, up to down format.
  46215. */
  46216. right: Nullable<ArrayBufferView>;
  46217. /**
  46218. * The pixel array for the up face.
  46219. * This is stored in format, left to right, up to down format.
  46220. */
  46221. up: Nullable<ArrayBufferView>;
  46222. /**
  46223. * The pixel array for the down face.
  46224. * This is stored in format, left to right, up to down format.
  46225. */
  46226. down: Nullable<ArrayBufferView>;
  46227. /**
  46228. * The size of the cubemap stored.
  46229. *
  46230. * Each faces will be size * size pixels.
  46231. */
  46232. size: number;
  46233. /**
  46234. * The format of the texture.
  46235. *
  46236. * RGBA, RGB.
  46237. */
  46238. format: number;
  46239. /**
  46240. * The type of the texture data.
  46241. *
  46242. * UNSIGNED_INT, FLOAT.
  46243. */
  46244. type: number;
  46245. /**
  46246. * Specifies whether the texture is in gamma space.
  46247. */
  46248. gammaSpace: boolean;
  46249. }
  46250. /**
  46251. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46252. */
  46253. export class PanoramaToCubeMapTools {
  46254. private static FACE_FRONT;
  46255. private static FACE_BACK;
  46256. private static FACE_RIGHT;
  46257. private static FACE_LEFT;
  46258. private static FACE_DOWN;
  46259. private static FACE_UP;
  46260. /**
  46261. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46262. *
  46263. * @param float32Array The source data.
  46264. * @param inputWidth The width of the input panorama.
  46265. * @param inputHeight The height of the input panorama.
  46266. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46267. * @return The cubemap data
  46268. */
  46269. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46270. private static CreateCubemapTexture;
  46271. private static CalcProjectionSpherical;
  46272. }
  46273. }
  46274. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46275. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46277. import { Nullable } from "babylonjs/types";
  46278. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46279. /**
  46280. * Helper class dealing with the extraction of spherical polynomial dataArray
  46281. * from a cube map.
  46282. */
  46283. export class CubeMapToSphericalPolynomialTools {
  46284. private static FileFaces;
  46285. /**
  46286. * Converts a texture to the according Spherical Polynomial data.
  46287. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46288. *
  46289. * @param texture The texture to extract the information from.
  46290. * @return The Spherical Polynomial data.
  46291. */
  46292. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46293. /**
  46294. * Converts a cubemap to the according Spherical Polynomial data.
  46295. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46296. *
  46297. * @param cubeInfo The Cube map to extract the information from.
  46298. * @return The Spherical Polynomial data.
  46299. */
  46300. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46301. }
  46302. }
  46303. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46304. import { Nullable } from "babylonjs/types";
  46305. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46306. module "babylonjs/Materials/Textures/baseTexture" {
  46307. interface BaseTexture {
  46308. /**
  46309. * Get the polynomial representation of the texture data.
  46310. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46311. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46312. */
  46313. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46314. }
  46315. }
  46316. }
  46317. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46319. /** @hidden */
  46320. export var rgbdEncodePixelShader: {
  46321. name: string;
  46322. shader: string;
  46323. };
  46324. }
  46325. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46326. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46327. /** @hidden */
  46328. export var rgbdDecodePixelShader: {
  46329. name: string;
  46330. shader: string;
  46331. };
  46332. }
  46333. declare module "babylonjs/Misc/environmentTextureTools" {
  46334. import { Nullable } from "babylonjs/types";
  46335. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46337. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46338. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46339. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46340. import "babylonjs/Shaders/rgbdEncode.fragment";
  46341. import "babylonjs/Shaders/rgbdDecode.fragment";
  46342. /**
  46343. * Raw texture data and descriptor sufficient for WebGL texture upload
  46344. */
  46345. export interface EnvironmentTextureInfo {
  46346. /**
  46347. * Version of the environment map
  46348. */
  46349. version: number;
  46350. /**
  46351. * Width of image
  46352. */
  46353. width: number;
  46354. /**
  46355. * Irradiance information stored in the file.
  46356. */
  46357. irradiance: any;
  46358. /**
  46359. * Specular information stored in the file.
  46360. */
  46361. specular: any;
  46362. }
  46363. /**
  46364. * Defines One Image in the file. It requires only the position in the file
  46365. * as well as the length.
  46366. */
  46367. interface BufferImageData {
  46368. /**
  46369. * Length of the image data.
  46370. */
  46371. length: number;
  46372. /**
  46373. * Position of the data from the null terminator delimiting the end of the JSON.
  46374. */
  46375. position: number;
  46376. }
  46377. /**
  46378. * Defines the specular data enclosed in the file.
  46379. * This corresponds to the version 1 of the data.
  46380. */
  46381. export interface EnvironmentTextureSpecularInfoV1 {
  46382. /**
  46383. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46384. */
  46385. specularDataPosition?: number;
  46386. /**
  46387. * This contains all the images data needed to reconstruct the cubemap.
  46388. */
  46389. mipmaps: Array<BufferImageData>;
  46390. /**
  46391. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46392. */
  46393. lodGenerationScale: number;
  46394. }
  46395. /**
  46396. * Sets of helpers addressing the serialization and deserialization of environment texture
  46397. * stored in a BabylonJS env file.
  46398. * Those files are usually stored as .env files.
  46399. */
  46400. export class EnvironmentTextureTools {
  46401. /**
  46402. * Magic number identifying the env file.
  46403. */
  46404. private static _MagicBytes;
  46405. /**
  46406. * Gets the environment info from an env file.
  46407. * @param data The array buffer containing the .env bytes.
  46408. * @returns the environment file info (the json header) if successfully parsed.
  46409. */
  46410. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46411. /**
  46412. * Creates an environment texture from a loaded cube texture.
  46413. * @param texture defines the cube texture to convert in env file
  46414. * @return a promise containing the environment data if succesfull.
  46415. */
  46416. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46417. /**
  46418. * Creates a JSON representation of the spherical data.
  46419. * @param texture defines the texture containing the polynomials
  46420. * @return the JSON representation of the spherical info
  46421. */
  46422. private static _CreateEnvTextureIrradiance;
  46423. /**
  46424. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46425. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46426. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46427. * @return the views described by info providing access to the underlying buffer
  46428. */
  46429. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46430. /**
  46431. * Uploads the texture info contained in the env file to the GPU.
  46432. * @param texture defines the internal texture to upload to
  46433. * @param arrayBuffer defines the buffer cotaining the data to load
  46434. * @param info defines the texture info retrieved through the GetEnvInfo method
  46435. * @returns a promise
  46436. */
  46437. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46438. private static _OnImageReadyAsync;
  46439. /**
  46440. * Uploads the levels of image data to the GPU.
  46441. * @param texture defines the internal texture to upload to
  46442. * @param imageData defines the array buffer views of image data [mipmap][face]
  46443. * @returns a promise
  46444. */
  46445. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46446. /**
  46447. * Uploads spherical polynomials information to the texture.
  46448. * @param texture defines the texture we are trying to upload the information to
  46449. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46450. */
  46451. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46452. /** @hidden */
  46453. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46454. }
  46455. }
  46456. declare module "babylonjs/Maths/math.vertexFormat" {
  46457. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46458. /**
  46459. * Contains position and normal vectors for a vertex
  46460. */
  46461. export class PositionNormalVertex {
  46462. /** the position of the vertex (defaut: 0,0,0) */
  46463. position: Vector3;
  46464. /** the normal of the vertex (defaut: 0,1,0) */
  46465. normal: Vector3;
  46466. /**
  46467. * Creates a PositionNormalVertex
  46468. * @param position the position of the vertex (defaut: 0,0,0)
  46469. * @param normal the normal of the vertex (defaut: 0,1,0)
  46470. */
  46471. constructor(
  46472. /** the position of the vertex (defaut: 0,0,0) */
  46473. position?: Vector3,
  46474. /** the normal of the vertex (defaut: 0,1,0) */
  46475. normal?: Vector3);
  46476. /**
  46477. * Clones the PositionNormalVertex
  46478. * @returns the cloned PositionNormalVertex
  46479. */
  46480. clone(): PositionNormalVertex;
  46481. }
  46482. /**
  46483. * Contains position, normal and uv vectors for a vertex
  46484. */
  46485. export class PositionNormalTextureVertex {
  46486. /** the position of the vertex (defaut: 0,0,0) */
  46487. position: Vector3;
  46488. /** the normal of the vertex (defaut: 0,1,0) */
  46489. normal: Vector3;
  46490. /** the uv of the vertex (default: 0,0) */
  46491. uv: Vector2;
  46492. /**
  46493. * Creates a PositionNormalTextureVertex
  46494. * @param position the position of the vertex (defaut: 0,0,0)
  46495. * @param normal the normal of the vertex (defaut: 0,1,0)
  46496. * @param uv the uv of the vertex (default: 0,0)
  46497. */
  46498. constructor(
  46499. /** the position of the vertex (defaut: 0,0,0) */
  46500. position?: Vector3,
  46501. /** the normal of the vertex (defaut: 0,1,0) */
  46502. normal?: Vector3,
  46503. /** the uv of the vertex (default: 0,0) */
  46504. uv?: Vector2);
  46505. /**
  46506. * Clones the PositionNormalTextureVertex
  46507. * @returns the cloned PositionNormalTextureVertex
  46508. */
  46509. clone(): PositionNormalTextureVertex;
  46510. }
  46511. }
  46512. declare module "babylonjs/Maths/math" {
  46513. export * from "babylonjs/Maths/math.axis";
  46514. export * from "babylonjs/Maths/math.color";
  46515. export * from "babylonjs/Maths/math.constants";
  46516. export * from "babylonjs/Maths/math.frustum";
  46517. export * from "babylonjs/Maths/math.path";
  46518. export * from "babylonjs/Maths/math.plane";
  46519. export * from "babylonjs/Maths/math.size";
  46520. export * from "babylonjs/Maths/math.vector";
  46521. export * from "babylonjs/Maths/math.vertexFormat";
  46522. export * from "babylonjs/Maths/math.viewport";
  46523. }
  46524. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46525. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46526. /** @hidden */
  46527. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46528. private _genericAttributeLocation;
  46529. private _varyingLocationCount;
  46530. private _varyingLocationMap;
  46531. private _replacements;
  46532. private _textureCount;
  46533. private _uniforms;
  46534. lineProcessor(line: string): string;
  46535. attributeProcessor(attribute: string): string;
  46536. varyingProcessor(varying: string, isFragment: boolean): string;
  46537. uniformProcessor(uniform: string): string;
  46538. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46539. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46540. }
  46541. }
  46542. declare module "babylonjs/Engines/nativeEngine" {
  46543. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46544. import { Engine } from "babylonjs/Engines/engine";
  46545. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46548. import { Effect } from "babylonjs/Materials/effect";
  46549. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46550. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46551. import { Scene } from "babylonjs/scene";
  46552. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46553. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46554. /**
  46555. * Container for accessors for natively-stored mesh data buffers.
  46556. */
  46557. class NativeDataBuffer extends DataBuffer {
  46558. /**
  46559. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46560. */
  46561. nativeIndexBuffer?: any;
  46562. /**
  46563. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46564. */
  46565. nativeVertexBuffer?: any;
  46566. }
  46567. /** @hidden */
  46568. export class NativeEngine extends Engine {
  46569. private readonly _native;
  46570. getHardwareScalingLevel(): number;
  46571. constructor();
  46572. /**
  46573. * Can be used to override the current requestAnimationFrame requester.
  46574. * @hidden
  46575. */
  46576. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46577. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46578. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46579. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46580. recordVertexArrayObject(vertexBuffers: {
  46581. [key: string]: VertexBuffer;
  46582. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46583. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46584. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46585. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46586. /**
  46587. * Draw a list of indexed primitives
  46588. * @param fillMode defines the primitive to use
  46589. * @param indexStart defines the starting index
  46590. * @param indexCount defines the number of index to draw
  46591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46592. */
  46593. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46594. /**
  46595. * Draw a list of unindexed primitives
  46596. * @param fillMode defines the primitive to use
  46597. * @param verticesStart defines the index of first vertex to draw
  46598. * @param verticesCount defines the count of vertices to draw
  46599. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46600. */
  46601. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46602. createPipelineContext(): IPipelineContext;
  46603. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46604. /** @hidden */
  46605. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46606. /** @hidden */
  46607. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46608. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46609. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46610. protected _setProgram(program: WebGLProgram): void;
  46611. _releaseEffect(effect: Effect): void;
  46612. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46613. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46614. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46615. bindSamplers(effect: Effect): void;
  46616. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46617. getRenderWidth(useScreen?: boolean): number;
  46618. getRenderHeight(useScreen?: boolean): number;
  46619. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46620. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46621. /**
  46622. * Set the z offset to apply to current rendering
  46623. * @param value defines the offset to apply
  46624. */
  46625. setZOffset(value: number): void;
  46626. /**
  46627. * Gets the current value of the zOffset
  46628. * @returns the current zOffset state
  46629. */
  46630. getZOffset(): number;
  46631. /**
  46632. * Enable or disable depth buffering
  46633. * @param enable defines the state to set
  46634. */
  46635. setDepthBuffer(enable: boolean): void;
  46636. /**
  46637. * Gets a boolean indicating if depth writing is enabled
  46638. * @returns the current depth writing state
  46639. */
  46640. getDepthWrite(): boolean;
  46641. /**
  46642. * Enable or disable depth writing
  46643. * @param enable defines the state to set
  46644. */
  46645. setDepthWrite(enable: boolean): void;
  46646. /**
  46647. * Enable or disable color writing
  46648. * @param enable defines the state to set
  46649. */
  46650. setColorWrite(enable: boolean): void;
  46651. /**
  46652. * Gets a boolean indicating if color writing is enabled
  46653. * @returns the current color writing state
  46654. */
  46655. getColorWrite(): boolean;
  46656. /**
  46657. * Sets alpha constants used by some alpha blending modes
  46658. * @param r defines the red component
  46659. * @param g defines the green component
  46660. * @param b defines the blue component
  46661. * @param a defines the alpha component
  46662. */
  46663. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46664. /**
  46665. * Sets the current alpha mode
  46666. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46667. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46669. */
  46670. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46671. /**
  46672. * Gets the current alpha mode
  46673. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46674. * @returns the current alpha mode
  46675. */
  46676. getAlphaMode(): number;
  46677. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46678. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46679. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46680. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46681. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46682. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46683. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46684. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46685. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46686. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46687. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46688. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46689. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46690. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46691. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46692. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46693. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46694. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46695. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46696. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46697. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46698. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46699. wipeCaches(bruteForce?: boolean): void;
  46700. _createTexture(): WebGLTexture;
  46701. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46702. /**
  46703. * Usually called from BABYLON.Texture.ts.
  46704. * Passed information to create a WebGLTexture
  46705. * @param urlArg defines a value which contains one of the following:
  46706. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46707. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46708. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46709. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46710. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46711. * @param scene needed for loading to the correct scene
  46712. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46713. * @param onLoad optional callback to be called upon successful completion
  46714. * @param onError optional callback to be called upon failure
  46715. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46716. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46717. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46718. * @param forcedExtension defines the extension to use to pick the right loader
  46719. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46720. */
  46721. 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;
  46722. /**
  46723. * Creates a cube texture
  46724. * @param rootUrl defines the url where the files to load is located
  46725. * @param scene defines the current scene
  46726. * @param files defines the list of files to load (1 per face)
  46727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46728. * @param onLoad defines an optional callback raised when the texture is loaded
  46729. * @param onError defines an optional callback raised if there is an issue to load the texture
  46730. * @param format defines the format of the data
  46731. * @param forcedExtension defines the extension to use to pick the right loader
  46732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46736. * @returns the cube texture as an InternalTexture
  46737. */
  46738. 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;
  46739. private _getSamplingFilter;
  46740. private static _GetNativeTextureFormat;
  46741. createRenderTargetTexture(size: number | {
  46742. width: number;
  46743. height: number;
  46744. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46745. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46746. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46747. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46748. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46749. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46750. /**
  46751. * Updates a dynamic vertex buffer.
  46752. * @param vertexBuffer the vertex buffer to update
  46753. * @param data the data used to update the vertex buffer
  46754. * @param byteOffset the byte offset of the data (optional)
  46755. * @param byteLength the byte length of the data (optional)
  46756. */
  46757. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46758. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46759. private _updateAnisotropicLevel;
  46760. private _getAddressMode;
  46761. /** @hidden */
  46762. _bindTexture(channel: number, texture: InternalTexture): void;
  46763. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46764. releaseEffects(): void;
  46765. /** @hidden */
  46766. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46767. /** @hidden */
  46768. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46769. /** @hidden */
  46770. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46771. /** @hidden */
  46772. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46773. }
  46774. }
  46775. declare module "babylonjs/Engines/index" {
  46776. export * from "babylonjs/Engines/constants";
  46777. export * from "babylonjs/Engines/engineCapabilities";
  46778. export * from "babylonjs/Engines/instancingAttributeInfo";
  46779. export * from "babylonjs/Engines/thinEngine";
  46780. export * from "babylonjs/Engines/engine";
  46781. export * from "babylonjs/Engines/engineStore";
  46782. export * from "babylonjs/Engines/nullEngine";
  46783. export * from "babylonjs/Engines/Extensions/index";
  46784. export * from "babylonjs/Engines/IPipelineContext";
  46785. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46786. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46787. export * from "babylonjs/Engines/nativeEngine";
  46788. }
  46789. declare module "babylonjs/Events/clipboardEvents" {
  46790. /**
  46791. * Gather the list of clipboard event types as constants.
  46792. */
  46793. export class ClipboardEventTypes {
  46794. /**
  46795. * The clipboard event is fired when a copy command is active (pressed).
  46796. */
  46797. static readonly COPY: number;
  46798. /**
  46799. * The clipboard event is fired when a cut command is active (pressed).
  46800. */
  46801. static readonly CUT: number;
  46802. /**
  46803. * The clipboard event is fired when a paste command is active (pressed).
  46804. */
  46805. static readonly PASTE: number;
  46806. }
  46807. /**
  46808. * This class is used to store clipboard related info for the onClipboardObservable event.
  46809. */
  46810. export class ClipboardInfo {
  46811. /**
  46812. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46813. */
  46814. type: number;
  46815. /**
  46816. * Defines the related dom event
  46817. */
  46818. event: ClipboardEvent;
  46819. /**
  46820. *Creates an instance of ClipboardInfo.
  46821. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46822. * @param event Defines the related dom event
  46823. */
  46824. constructor(
  46825. /**
  46826. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46827. */
  46828. type: number,
  46829. /**
  46830. * Defines the related dom event
  46831. */
  46832. event: ClipboardEvent);
  46833. /**
  46834. * Get the clipboard event's type from the keycode.
  46835. * @param keyCode Defines the keyCode for the current keyboard event.
  46836. * @return {number}
  46837. */
  46838. static GetTypeFromCharacter(keyCode: number): number;
  46839. }
  46840. }
  46841. declare module "babylonjs/Events/index" {
  46842. export * from "babylonjs/Events/keyboardEvents";
  46843. export * from "babylonjs/Events/pointerEvents";
  46844. export * from "babylonjs/Events/clipboardEvents";
  46845. }
  46846. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46847. import { Scene } from "babylonjs/scene";
  46848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46849. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46850. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46851. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46852. /**
  46853. * Google Daydream controller
  46854. */
  46855. export class DaydreamController extends WebVRController {
  46856. /**
  46857. * Base Url for the controller model.
  46858. */
  46859. static MODEL_BASE_URL: string;
  46860. /**
  46861. * File name for the controller model.
  46862. */
  46863. static MODEL_FILENAME: string;
  46864. /**
  46865. * Gamepad Id prefix used to identify Daydream Controller.
  46866. */
  46867. static readonly GAMEPAD_ID_PREFIX: string;
  46868. /**
  46869. * Creates a new DaydreamController from a gamepad
  46870. * @param vrGamepad the gamepad that the controller should be created from
  46871. */
  46872. constructor(vrGamepad: any);
  46873. /**
  46874. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46875. * @param scene scene in which to add meshes
  46876. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46877. */
  46878. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46879. /**
  46880. * Called once for each button that changed state since the last frame
  46881. * @param buttonIdx Which button index changed
  46882. * @param state New state of the button
  46883. * @param changes Which properties on the state changed since last frame
  46884. */
  46885. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46886. }
  46887. }
  46888. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46889. import { Scene } from "babylonjs/scene";
  46890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46891. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46892. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46893. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46894. /**
  46895. * Gear VR Controller
  46896. */
  46897. export class GearVRController extends WebVRController {
  46898. /**
  46899. * Base Url for the controller model.
  46900. */
  46901. static MODEL_BASE_URL: string;
  46902. /**
  46903. * File name for the controller model.
  46904. */
  46905. static MODEL_FILENAME: string;
  46906. /**
  46907. * Gamepad Id prefix used to identify this controller.
  46908. */
  46909. static readonly GAMEPAD_ID_PREFIX: string;
  46910. private readonly _buttonIndexToObservableNameMap;
  46911. /**
  46912. * Creates a new GearVRController from a gamepad
  46913. * @param vrGamepad the gamepad that the controller should be created from
  46914. */
  46915. constructor(vrGamepad: any);
  46916. /**
  46917. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46918. * @param scene scene in which to add meshes
  46919. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46920. */
  46921. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46922. /**
  46923. * Called once for each button that changed state since the last frame
  46924. * @param buttonIdx Which button index changed
  46925. * @param state New state of the button
  46926. * @param changes Which properties on the state changed since last frame
  46927. */
  46928. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46929. }
  46930. }
  46931. declare module "babylonjs/Gamepads/Controllers/index" {
  46932. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46933. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46934. export * from "babylonjs/Gamepads/Controllers/genericController";
  46935. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46936. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46937. export * from "babylonjs/Gamepads/Controllers/viveController";
  46938. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46939. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46940. }
  46941. declare module "babylonjs/Gamepads/index" {
  46942. export * from "babylonjs/Gamepads/Controllers/index";
  46943. export * from "babylonjs/Gamepads/gamepad";
  46944. export * from "babylonjs/Gamepads/gamepadManager";
  46945. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46946. export * from "babylonjs/Gamepads/xboxGamepad";
  46947. export * from "babylonjs/Gamepads/dualShockGamepad";
  46948. }
  46949. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46950. import { Scene } from "babylonjs/scene";
  46951. import { Vector4 } from "babylonjs/Maths/math.vector";
  46952. import { Color4 } from "babylonjs/Maths/math.color";
  46953. import { Mesh } from "babylonjs/Meshes/mesh";
  46954. import { Nullable } from "babylonjs/types";
  46955. /**
  46956. * Class containing static functions to help procedurally build meshes
  46957. */
  46958. export class PolyhedronBuilder {
  46959. /**
  46960. * Creates a polyhedron mesh
  46961. * * 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
  46962. * * The parameter `size` (positive float, default 1) sets the polygon size
  46963. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46964. * * 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`
  46965. * * 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
  46966. * * 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)`)
  46967. * * 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
  46968. * * 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
  46969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46972. * @param name defines the name of the mesh
  46973. * @param options defines the options used to create the mesh
  46974. * @param scene defines the hosting scene
  46975. * @returns the polyhedron mesh
  46976. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46977. */
  46978. static CreatePolyhedron(name: string, options: {
  46979. type?: number;
  46980. size?: number;
  46981. sizeX?: number;
  46982. sizeY?: number;
  46983. sizeZ?: number;
  46984. custom?: any;
  46985. faceUV?: Vector4[];
  46986. faceColors?: Color4[];
  46987. flat?: boolean;
  46988. updatable?: boolean;
  46989. sideOrientation?: number;
  46990. frontUVs?: Vector4;
  46991. backUVs?: Vector4;
  46992. }, scene?: Nullable<Scene>): Mesh;
  46993. }
  46994. }
  46995. declare module "babylonjs/Gizmos/scaleGizmo" {
  46996. import { Observable } from "babylonjs/Misc/observable";
  46997. import { Nullable } from "babylonjs/types";
  46998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46999. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47000. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47001. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47002. /**
  47003. * Gizmo that enables scaling a mesh along 3 axis
  47004. */
  47005. export class ScaleGizmo extends Gizmo {
  47006. /**
  47007. * Internal gizmo used for interactions on the x axis
  47008. */
  47009. xGizmo: AxisScaleGizmo;
  47010. /**
  47011. * Internal gizmo used for interactions on the y axis
  47012. */
  47013. yGizmo: AxisScaleGizmo;
  47014. /**
  47015. * Internal gizmo used for interactions on the z axis
  47016. */
  47017. zGizmo: AxisScaleGizmo;
  47018. /**
  47019. * Internal gizmo used to scale all axis equally
  47020. */
  47021. uniformScaleGizmo: AxisScaleGizmo;
  47022. private _meshAttached;
  47023. private _updateGizmoRotationToMatchAttachedMesh;
  47024. private _snapDistance;
  47025. private _scaleRatio;
  47026. private _uniformScalingMesh;
  47027. private _octahedron;
  47028. /** Fires an event when any of it's sub gizmos are dragged */
  47029. onDragStartObservable: Observable<unknown>;
  47030. /** Fires an event when any of it's sub gizmos are released from dragging */
  47031. onDragEndObservable: Observable<unknown>;
  47032. attachedMesh: Nullable<AbstractMesh>;
  47033. /**
  47034. * Creates a ScaleGizmo
  47035. * @param gizmoLayer The utility layer the gizmo will be added to
  47036. */
  47037. constructor(gizmoLayer?: UtilityLayerRenderer);
  47038. updateGizmoRotationToMatchAttachedMesh: boolean;
  47039. /**
  47040. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47041. */
  47042. snapDistance: number;
  47043. /**
  47044. * Ratio for the scale of the gizmo (Default: 1)
  47045. */
  47046. scaleRatio: number;
  47047. /**
  47048. * Disposes of the gizmo
  47049. */
  47050. dispose(): void;
  47051. }
  47052. }
  47053. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47054. import { Observable } from "babylonjs/Misc/observable";
  47055. import { Nullable } from "babylonjs/types";
  47056. import { Vector3 } from "babylonjs/Maths/math.vector";
  47057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47058. import { Mesh } from "babylonjs/Meshes/mesh";
  47059. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47060. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47061. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47062. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47063. import { Color3 } from "babylonjs/Maths/math.color";
  47064. /**
  47065. * Single axis scale gizmo
  47066. */
  47067. export class AxisScaleGizmo extends Gizmo {
  47068. /**
  47069. * Drag behavior responsible for the gizmos dragging interactions
  47070. */
  47071. dragBehavior: PointerDragBehavior;
  47072. private _pointerObserver;
  47073. /**
  47074. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47075. */
  47076. snapDistance: number;
  47077. /**
  47078. * Event that fires each time the gizmo snaps to a new location.
  47079. * * snapDistance is the the change in distance
  47080. */
  47081. onSnapObservable: Observable<{
  47082. snapDistance: number;
  47083. }>;
  47084. /**
  47085. * If the scaling operation should be done on all axis (default: false)
  47086. */
  47087. uniformScaling: boolean;
  47088. private _isEnabled;
  47089. private _parent;
  47090. private _arrow;
  47091. private _coloredMaterial;
  47092. private _hoverMaterial;
  47093. /**
  47094. * Creates an AxisScaleGizmo
  47095. * @param gizmoLayer The utility layer the gizmo will be added to
  47096. * @param dragAxis The axis which the gizmo will be able to scale on
  47097. * @param color The color of the gizmo
  47098. */
  47099. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47100. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47101. /**
  47102. * If the gizmo is enabled
  47103. */
  47104. isEnabled: boolean;
  47105. /**
  47106. * Disposes of the gizmo
  47107. */
  47108. dispose(): void;
  47109. /**
  47110. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47111. * @param mesh The mesh to replace the default mesh of the gizmo
  47112. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47113. */
  47114. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47115. }
  47116. }
  47117. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47118. import { Observable } from "babylonjs/Misc/observable";
  47119. import { Nullable } from "babylonjs/types";
  47120. import { Vector3 } from "babylonjs/Maths/math.vector";
  47121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47122. import { Mesh } from "babylonjs/Meshes/mesh";
  47123. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47124. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47125. import { Color3 } from "babylonjs/Maths/math.color";
  47126. import "babylonjs/Meshes/Builders/boxBuilder";
  47127. /**
  47128. * Bounding box gizmo
  47129. */
  47130. export class BoundingBoxGizmo extends Gizmo {
  47131. private _lineBoundingBox;
  47132. private _rotateSpheresParent;
  47133. private _scaleBoxesParent;
  47134. private _boundingDimensions;
  47135. private _renderObserver;
  47136. private _pointerObserver;
  47137. private _scaleDragSpeed;
  47138. private _tmpQuaternion;
  47139. private _tmpVector;
  47140. private _tmpRotationMatrix;
  47141. /**
  47142. * 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)
  47143. */
  47144. ignoreChildren: boolean;
  47145. /**
  47146. * 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)
  47147. */
  47148. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47149. /**
  47150. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47151. */
  47152. rotationSphereSize: number;
  47153. /**
  47154. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47155. */
  47156. scaleBoxSize: number;
  47157. /**
  47158. * 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)
  47159. */
  47160. fixedDragMeshScreenSize: boolean;
  47161. /**
  47162. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47163. */
  47164. fixedDragMeshScreenSizeDistanceFactor: number;
  47165. /**
  47166. * Fired when a rotation sphere or scale box is dragged
  47167. */
  47168. onDragStartObservable: Observable<{}>;
  47169. /**
  47170. * Fired when a scale box is dragged
  47171. */
  47172. onScaleBoxDragObservable: Observable<{}>;
  47173. /**
  47174. * Fired when a scale box drag is ended
  47175. */
  47176. onScaleBoxDragEndObservable: Observable<{}>;
  47177. /**
  47178. * Fired when a rotation sphere is dragged
  47179. */
  47180. onRotationSphereDragObservable: Observable<{}>;
  47181. /**
  47182. * Fired when a rotation sphere drag is ended
  47183. */
  47184. onRotationSphereDragEndObservable: Observable<{}>;
  47185. /**
  47186. * 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)
  47187. */
  47188. scalePivot: Nullable<Vector3>;
  47189. /**
  47190. * Mesh used as a pivot to rotate the attached mesh
  47191. */
  47192. private _anchorMesh;
  47193. private _existingMeshScale;
  47194. private _dragMesh;
  47195. private pointerDragBehavior;
  47196. private coloredMaterial;
  47197. private hoverColoredMaterial;
  47198. /**
  47199. * Sets the color of the bounding box gizmo
  47200. * @param color the color to set
  47201. */
  47202. setColor(color: Color3): void;
  47203. /**
  47204. * Creates an BoundingBoxGizmo
  47205. * @param gizmoLayer The utility layer the gizmo will be added to
  47206. * @param color The color of the gizmo
  47207. */
  47208. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47210. private _selectNode;
  47211. /**
  47212. * Updates the bounding box information for the Gizmo
  47213. */
  47214. updateBoundingBox(): void;
  47215. private _updateRotationSpheres;
  47216. private _updateScaleBoxes;
  47217. /**
  47218. * Enables rotation on the specified axis and disables rotation on the others
  47219. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47220. */
  47221. setEnabledRotationAxis(axis: string): void;
  47222. /**
  47223. * Enables/disables scaling
  47224. * @param enable if scaling should be enabled
  47225. */
  47226. setEnabledScaling(enable: boolean): void;
  47227. private _updateDummy;
  47228. /**
  47229. * Enables a pointer drag behavior on the bounding box of the gizmo
  47230. */
  47231. enableDragBehavior(): void;
  47232. /**
  47233. * Disposes of the gizmo
  47234. */
  47235. dispose(): void;
  47236. /**
  47237. * 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)
  47238. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47239. * @returns the bounding box mesh with the passed in mesh as a child
  47240. */
  47241. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47242. /**
  47243. * CustomMeshes are not supported by this gizmo
  47244. * @param mesh The mesh to replace the default mesh of the gizmo
  47245. */
  47246. setCustomMesh(mesh: Mesh): void;
  47247. }
  47248. }
  47249. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47250. import { Observable } from "babylonjs/Misc/observable";
  47251. import { Nullable } from "babylonjs/types";
  47252. import { Vector3 } from "babylonjs/Maths/math.vector";
  47253. import { Color3 } from "babylonjs/Maths/math.color";
  47254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47255. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47256. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47257. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47258. import "babylonjs/Meshes/Builders/linesBuilder";
  47259. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47260. /**
  47261. * Single plane rotation gizmo
  47262. */
  47263. export class PlaneRotationGizmo extends Gizmo {
  47264. /**
  47265. * Drag behavior responsible for the gizmos dragging interactions
  47266. */
  47267. dragBehavior: PointerDragBehavior;
  47268. private _pointerObserver;
  47269. /**
  47270. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47271. */
  47272. snapDistance: number;
  47273. /**
  47274. * Event that fires each time the gizmo snaps to a new location.
  47275. * * snapDistance is the the change in distance
  47276. */
  47277. onSnapObservable: Observable<{
  47278. snapDistance: number;
  47279. }>;
  47280. private _isEnabled;
  47281. private _parent;
  47282. /**
  47283. * Creates a PlaneRotationGizmo
  47284. * @param gizmoLayer The utility layer the gizmo will be added to
  47285. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47286. * @param color The color of the gizmo
  47287. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47288. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47289. */
  47290. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47291. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47292. /**
  47293. * If the gizmo is enabled
  47294. */
  47295. isEnabled: boolean;
  47296. /**
  47297. * Disposes of the gizmo
  47298. */
  47299. dispose(): void;
  47300. }
  47301. }
  47302. declare module "babylonjs/Gizmos/rotationGizmo" {
  47303. import { Observable } from "babylonjs/Misc/observable";
  47304. import { Nullable } from "babylonjs/types";
  47305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47306. import { Mesh } from "babylonjs/Meshes/mesh";
  47307. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47308. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47309. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47310. /**
  47311. * Gizmo that enables rotating a mesh along 3 axis
  47312. */
  47313. export class RotationGizmo extends Gizmo {
  47314. /**
  47315. * Internal gizmo used for interactions on the x axis
  47316. */
  47317. xGizmo: PlaneRotationGizmo;
  47318. /**
  47319. * Internal gizmo used for interactions on the y axis
  47320. */
  47321. yGizmo: PlaneRotationGizmo;
  47322. /**
  47323. * Internal gizmo used for interactions on the z axis
  47324. */
  47325. zGizmo: PlaneRotationGizmo;
  47326. /** Fires an event when any of it's sub gizmos are dragged */
  47327. onDragStartObservable: Observable<unknown>;
  47328. /** Fires an event when any of it's sub gizmos are released from dragging */
  47329. onDragEndObservable: Observable<unknown>;
  47330. private _meshAttached;
  47331. attachedMesh: Nullable<AbstractMesh>;
  47332. /**
  47333. * Creates a RotationGizmo
  47334. * @param gizmoLayer The utility layer the gizmo will be added to
  47335. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47336. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47337. */
  47338. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47339. updateGizmoRotationToMatchAttachedMesh: boolean;
  47340. /**
  47341. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47342. */
  47343. snapDistance: number;
  47344. /**
  47345. * Ratio for the scale of the gizmo (Default: 1)
  47346. */
  47347. scaleRatio: number;
  47348. /**
  47349. * Disposes of the gizmo
  47350. */
  47351. dispose(): void;
  47352. /**
  47353. * CustomMeshes are not supported by this gizmo
  47354. * @param mesh The mesh to replace the default mesh of the gizmo
  47355. */
  47356. setCustomMesh(mesh: Mesh): void;
  47357. }
  47358. }
  47359. declare module "babylonjs/Gizmos/gizmoManager" {
  47360. import { Observable } from "babylonjs/Misc/observable";
  47361. import { Nullable } from "babylonjs/types";
  47362. import { Scene, IDisposable } from "babylonjs/scene";
  47363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47364. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47365. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47366. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47367. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47368. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47369. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47370. /**
  47371. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47372. */
  47373. export class GizmoManager implements IDisposable {
  47374. private scene;
  47375. /**
  47376. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47377. */
  47378. gizmos: {
  47379. positionGizmo: Nullable<PositionGizmo>;
  47380. rotationGizmo: Nullable<RotationGizmo>;
  47381. scaleGizmo: Nullable<ScaleGizmo>;
  47382. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47383. };
  47384. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47385. clearGizmoOnEmptyPointerEvent: boolean;
  47386. /** Fires an event when the manager is attached to a mesh */
  47387. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47388. private _gizmosEnabled;
  47389. private _pointerObserver;
  47390. private _attachedMesh;
  47391. private _boundingBoxColor;
  47392. private _defaultUtilityLayer;
  47393. private _defaultKeepDepthUtilityLayer;
  47394. /**
  47395. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47396. */
  47397. boundingBoxDragBehavior: SixDofDragBehavior;
  47398. /**
  47399. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47400. */
  47401. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47402. /**
  47403. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47404. */
  47405. usePointerToAttachGizmos: boolean;
  47406. /**
  47407. * Utility layer that the bounding box gizmo belongs to
  47408. */
  47409. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47410. /**
  47411. * Utility layer that all gizmos besides bounding box belong to
  47412. */
  47413. readonly utilityLayer: UtilityLayerRenderer;
  47414. /**
  47415. * Instatiates a gizmo manager
  47416. * @param scene the scene to overlay the gizmos on top of
  47417. */
  47418. constructor(scene: Scene);
  47419. /**
  47420. * Attaches a set of gizmos to the specified mesh
  47421. * @param mesh The mesh the gizmo's should be attached to
  47422. */
  47423. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47424. /**
  47425. * If the position gizmo is enabled
  47426. */
  47427. positionGizmoEnabled: boolean;
  47428. /**
  47429. * If the rotation gizmo is enabled
  47430. */
  47431. rotationGizmoEnabled: boolean;
  47432. /**
  47433. * If the scale gizmo is enabled
  47434. */
  47435. scaleGizmoEnabled: boolean;
  47436. /**
  47437. * If the boundingBox gizmo is enabled
  47438. */
  47439. boundingBoxGizmoEnabled: boolean;
  47440. /**
  47441. * Disposes of the gizmo manager
  47442. */
  47443. dispose(): void;
  47444. }
  47445. }
  47446. declare module "babylonjs/Lights/directionalLight" {
  47447. import { Camera } from "babylonjs/Cameras/camera";
  47448. import { Scene } from "babylonjs/scene";
  47449. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47451. import { Light } from "babylonjs/Lights/light";
  47452. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47453. import { Effect } from "babylonjs/Materials/effect";
  47454. /**
  47455. * A directional light is defined by a direction (what a surprise!).
  47456. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47457. * 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.
  47458. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47459. */
  47460. export class DirectionalLight extends ShadowLight {
  47461. private _shadowFrustumSize;
  47462. /**
  47463. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47464. */
  47465. /**
  47466. * Specifies a fix frustum size for the shadow generation.
  47467. */
  47468. shadowFrustumSize: number;
  47469. private _shadowOrthoScale;
  47470. /**
  47471. * Gets the shadow projection scale against the optimal computed one.
  47472. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47473. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47474. */
  47475. /**
  47476. * Sets the shadow projection scale against the optimal computed one.
  47477. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47478. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47479. */
  47480. shadowOrthoScale: number;
  47481. /**
  47482. * Automatically compute the projection matrix to best fit (including all the casters)
  47483. * on each frame.
  47484. */
  47485. autoUpdateExtends: boolean;
  47486. private _orthoLeft;
  47487. private _orthoRight;
  47488. private _orthoTop;
  47489. private _orthoBottom;
  47490. /**
  47491. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47492. * The directional light is emitted from everywhere in the given direction.
  47493. * It can cast shadows.
  47494. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47495. * @param name The friendly name of the light
  47496. * @param direction The direction of the light
  47497. * @param scene The scene the light belongs to
  47498. */
  47499. constructor(name: string, direction: Vector3, scene: Scene);
  47500. /**
  47501. * Returns the string "DirectionalLight".
  47502. * @return The class name
  47503. */
  47504. getClassName(): string;
  47505. /**
  47506. * Returns the integer 1.
  47507. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47508. */
  47509. getTypeID(): number;
  47510. /**
  47511. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47512. * Returns the DirectionalLight Shadow projection matrix.
  47513. */
  47514. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47515. /**
  47516. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47517. * Returns the DirectionalLight Shadow projection matrix.
  47518. */
  47519. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47520. /**
  47521. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47522. * Returns the DirectionalLight Shadow projection matrix.
  47523. */
  47524. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47525. protected _buildUniformLayout(): void;
  47526. /**
  47527. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47528. * @param effect The effect to update
  47529. * @param lightIndex The index of the light in the effect to update
  47530. * @returns The directional light
  47531. */
  47532. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47533. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47534. /**
  47535. * Gets the minZ used for shadow according to both the scene and the light.
  47536. *
  47537. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47538. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47539. * @param activeCamera The camera we are returning the min for
  47540. * @returns the depth min z
  47541. */
  47542. getDepthMinZ(activeCamera: Camera): number;
  47543. /**
  47544. * Gets the maxZ used for shadow according to both the scene and the light.
  47545. *
  47546. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47547. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47548. * @param activeCamera The camera we are returning the max for
  47549. * @returns the depth max z
  47550. */
  47551. getDepthMaxZ(activeCamera: Camera): number;
  47552. /**
  47553. * Prepares the list of defines specific to the light type.
  47554. * @param defines the list of defines
  47555. * @param lightIndex defines the index of the light for the effect
  47556. */
  47557. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47558. }
  47559. }
  47560. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47561. import { Mesh } from "babylonjs/Meshes/mesh";
  47562. /**
  47563. * Class containing static functions to help procedurally build meshes
  47564. */
  47565. export class HemisphereBuilder {
  47566. /**
  47567. * Creates a hemisphere mesh
  47568. * @param name defines the name of the mesh
  47569. * @param options defines the options used to create the mesh
  47570. * @param scene defines the hosting scene
  47571. * @returns the hemisphere mesh
  47572. */
  47573. static CreateHemisphere(name: string, options: {
  47574. segments?: number;
  47575. diameter?: number;
  47576. sideOrientation?: number;
  47577. }, scene: any): Mesh;
  47578. }
  47579. }
  47580. declare module "babylonjs/Lights/spotLight" {
  47581. import { Nullable } from "babylonjs/types";
  47582. import { Scene } from "babylonjs/scene";
  47583. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47585. import { Effect } from "babylonjs/Materials/effect";
  47586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47587. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47588. /**
  47589. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47590. * These values define a cone of light starting from the position, emitting toward the direction.
  47591. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47592. * and the exponent defines the speed of the decay of the light with distance (reach).
  47593. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47594. */
  47595. export class SpotLight extends ShadowLight {
  47596. private _angle;
  47597. private _innerAngle;
  47598. private _cosHalfAngle;
  47599. private _lightAngleScale;
  47600. private _lightAngleOffset;
  47601. /**
  47602. * Gets the cone angle of the spot light in Radians.
  47603. */
  47604. /**
  47605. * Sets the cone angle of the spot light in Radians.
  47606. */
  47607. angle: number;
  47608. /**
  47609. * Only used in gltf falloff mode, this defines the angle where
  47610. * the directional falloff will start before cutting at angle which could be seen
  47611. * as outer angle.
  47612. */
  47613. /**
  47614. * Only used in gltf falloff mode, this defines the angle where
  47615. * the directional falloff will start before cutting at angle which could be seen
  47616. * as outer angle.
  47617. */
  47618. innerAngle: number;
  47619. private _shadowAngleScale;
  47620. /**
  47621. * Allows scaling the angle of the light for shadow generation only.
  47622. */
  47623. /**
  47624. * Allows scaling the angle of the light for shadow generation only.
  47625. */
  47626. shadowAngleScale: number;
  47627. /**
  47628. * The light decay speed with the distance from the emission spot.
  47629. */
  47630. exponent: number;
  47631. private _projectionTextureMatrix;
  47632. /**
  47633. * Allows reading the projecton texture
  47634. */
  47635. readonly projectionTextureMatrix: Matrix;
  47636. protected _projectionTextureLightNear: number;
  47637. /**
  47638. * Gets the near clip of the Spotlight for texture projection.
  47639. */
  47640. /**
  47641. * Sets the near clip of the Spotlight for texture projection.
  47642. */
  47643. projectionTextureLightNear: number;
  47644. protected _projectionTextureLightFar: number;
  47645. /**
  47646. * Gets the far clip of the Spotlight for texture projection.
  47647. */
  47648. /**
  47649. * Sets the far clip of the Spotlight for texture projection.
  47650. */
  47651. projectionTextureLightFar: number;
  47652. protected _projectionTextureUpDirection: Vector3;
  47653. /**
  47654. * Gets the Up vector of the Spotlight for texture projection.
  47655. */
  47656. /**
  47657. * Sets the Up vector of the Spotlight for texture projection.
  47658. */
  47659. projectionTextureUpDirection: Vector3;
  47660. private _projectionTexture;
  47661. /**
  47662. * Gets the projection texture of the light.
  47663. */
  47664. /**
  47665. * Sets the projection texture of the light.
  47666. */
  47667. projectionTexture: Nullable<BaseTexture>;
  47668. private _projectionTextureViewLightDirty;
  47669. private _projectionTextureProjectionLightDirty;
  47670. private _projectionTextureDirty;
  47671. private _projectionTextureViewTargetVector;
  47672. private _projectionTextureViewLightMatrix;
  47673. private _projectionTextureProjectionLightMatrix;
  47674. private _projectionTextureScalingMatrix;
  47675. /**
  47676. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47677. * It can cast shadows.
  47678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47679. * @param name The light friendly name
  47680. * @param position The position of the spot light in the scene
  47681. * @param direction The direction of the light in the scene
  47682. * @param angle The cone angle of the light in Radians
  47683. * @param exponent The light decay speed with the distance from the emission spot
  47684. * @param scene The scene the lights belongs to
  47685. */
  47686. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47687. /**
  47688. * Returns the string "SpotLight".
  47689. * @returns the class name
  47690. */
  47691. getClassName(): string;
  47692. /**
  47693. * Returns the integer 2.
  47694. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47695. */
  47696. getTypeID(): number;
  47697. /**
  47698. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47699. */
  47700. protected _setDirection(value: Vector3): void;
  47701. /**
  47702. * Overrides the position setter to recompute the projection texture view light Matrix.
  47703. */
  47704. protected _setPosition(value: Vector3): void;
  47705. /**
  47706. * 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.
  47707. * Returns the SpotLight.
  47708. */
  47709. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47710. protected _computeProjectionTextureViewLightMatrix(): void;
  47711. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47712. /**
  47713. * Main function for light texture projection matrix computing.
  47714. */
  47715. protected _computeProjectionTextureMatrix(): void;
  47716. protected _buildUniformLayout(): void;
  47717. private _computeAngleValues;
  47718. /**
  47719. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47720. * @param effect The effect to update
  47721. * @param lightIndex The index of the light in the effect to update
  47722. * @returns The spot light
  47723. */
  47724. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47725. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47726. /**
  47727. * Disposes the light and the associated resources.
  47728. */
  47729. dispose(): void;
  47730. /**
  47731. * Prepares the list of defines specific to the light type.
  47732. * @param defines the list of defines
  47733. * @param lightIndex defines the index of the light for the effect
  47734. */
  47735. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47736. }
  47737. }
  47738. declare module "babylonjs/Gizmos/lightGizmo" {
  47739. import { Nullable } from "babylonjs/types";
  47740. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47741. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47742. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47743. import { Light } from "babylonjs/Lights/light";
  47744. /**
  47745. * Gizmo that enables viewing a light
  47746. */
  47747. export class LightGizmo extends Gizmo {
  47748. private _lightMesh;
  47749. private _material;
  47750. private cachedPosition;
  47751. private cachedForward;
  47752. /**
  47753. * Creates a LightGizmo
  47754. * @param gizmoLayer The utility layer the gizmo will be added to
  47755. */
  47756. constructor(gizmoLayer?: UtilityLayerRenderer);
  47757. private _light;
  47758. /**
  47759. * The light that the gizmo is attached to
  47760. */
  47761. light: Nullable<Light>;
  47762. /**
  47763. * Gets the material used to render the light gizmo
  47764. */
  47765. readonly material: StandardMaterial;
  47766. /**
  47767. * @hidden
  47768. * Updates the gizmo to match the attached mesh's position/rotation
  47769. */
  47770. protected _update(): void;
  47771. private static _Scale;
  47772. /**
  47773. * Creates the lines for a light mesh
  47774. */
  47775. private static _createLightLines;
  47776. /**
  47777. * Disposes of the light gizmo
  47778. */
  47779. dispose(): void;
  47780. private static _CreateHemisphericLightMesh;
  47781. private static _CreatePointLightMesh;
  47782. private static _CreateSpotLightMesh;
  47783. private static _CreateDirectionalLightMesh;
  47784. }
  47785. }
  47786. declare module "babylonjs/Gizmos/index" {
  47787. export * from "babylonjs/Gizmos/axisDragGizmo";
  47788. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47789. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47790. export * from "babylonjs/Gizmos/gizmo";
  47791. export * from "babylonjs/Gizmos/gizmoManager";
  47792. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47793. export * from "babylonjs/Gizmos/positionGizmo";
  47794. export * from "babylonjs/Gizmos/rotationGizmo";
  47795. export * from "babylonjs/Gizmos/scaleGizmo";
  47796. export * from "babylonjs/Gizmos/lightGizmo";
  47797. export * from "babylonjs/Gizmos/planeDragGizmo";
  47798. }
  47799. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47800. /** @hidden */
  47801. export var backgroundFragmentDeclaration: {
  47802. name: string;
  47803. shader: string;
  47804. };
  47805. }
  47806. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47807. /** @hidden */
  47808. export var backgroundUboDeclaration: {
  47809. name: string;
  47810. shader: string;
  47811. };
  47812. }
  47813. declare module "babylonjs/Shaders/background.fragment" {
  47814. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47815. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47816. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47817. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47818. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47819. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47821. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47822. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47823. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47824. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47825. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47826. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47827. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47828. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47829. /** @hidden */
  47830. export var backgroundPixelShader: {
  47831. name: string;
  47832. shader: string;
  47833. };
  47834. }
  47835. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47836. /** @hidden */
  47837. export var backgroundVertexDeclaration: {
  47838. name: string;
  47839. shader: string;
  47840. };
  47841. }
  47842. declare module "babylonjs/Shaders/background.vertex" {
  47843. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47844. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47845. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47846. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47847. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47848. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47849. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47850. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47851. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47852. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47853. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47854. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47855. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47856. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47857. /** @hidden */
  47858. export var backgroundVertexShader: {
  47859. name: string;
  47860. shader: string;
  47861. };
  47862. }
  47863. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47864. import { Nullable, int, float } from "babylonjs/types";
  47865. import { Scene } from "babylonjs/scene";
  47866. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47869. import { Mesh } from "babylonjs/Meshes/mesh";
  47870. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47871. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47872. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47874. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47875. import { Color3 } from "babylonjs/Maths/math.color";
  47876. import "babylonjs/Shaders/background.fragment";
  47877. import "babylonjs/Shaders/background.vertex";
  47878. /**
  47879. * Background material used to create an efficient environement around your scene.
  47880. */
  47881. export class BackgroundMaterial extends PushMaterial {
  47882. /**
  47883. * Standard reflectance value at parallel view angle.
  47884. */
  47885. static StandardReflectance0: number;
  47886. /**
  47887. * Standard reflectance value at grazing angle.
  47888. */
  47889. static StandardReflectance90: number;
  47890. protected _primaryColor: Color3;
  47891. /**
  47892. * Key light Color (multiply against the environement texture)
  47893. */
  47894. primaryColor: Color3;
  47895. protected __perceptualColor: Nullable<Color3>;
  47896. /**
  47897. * Experimental Internal Use Only.
  47898. *
  47899. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47900. * This acts as a helper to set the primary color to a more "human friendly" value.
  47901. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47902. * output color as close as possible from the chosen value.
  47903. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47904. * part of lighting setup.)
  47905. */
  47906. _perceptualColor: Nullable<Color3>;
  47907. protected _primaryColorShadowLevel: float;
  47908. /**
  47909. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47910. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47911. */
  47912. primaryColorShadowLevel: float;
  47913. protected _primaryColorHighlightLevel: float;
  47914. /**
  47915. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47916. * The primary color is used at the level chosen to define what the white area would look.
  47917. */
  47918. primaryColorHighlightLevel: float;
  47919. protected _reflectionTexture: Nullable<BaseTexture>;
  47920. /**
  47921. * Reflection Texture used in the material.
  47922. * Should be author in a specific way for the best result (refer to the documentation).
  47923. */
  47924. reflectionTexture: Nullable<BaseTexture>;
  47925. protected _reflectionBlur: float;
  47926. /**
  47927. * Reflection Texture level of blur.
  47928. *
  47929. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47930. * texture twice.
  47931. */
  47932. reflectionBlur: float;
  47933. protected _diffuseTexture: Nullable<BaseTexture>;
  47934. /**
  47935. * Diffuse Texture used in the material.
  47936. * Should be author in a specific way for the best result (refer to the documentation).
  47937. */
  47938. diffuseTexture: Nullable<BaseTexture>;
  47939. protected _shadowLights: Nullable<IShadowLight[]>;
  47940. /**
  47941. * Specify the list of lights casting shadow on the material.
  47942. * All scene shadow lights will be included if null.
  47943. */
  47944. shadowLights: Nullable<IShadowLight[]>;
  47945. protected _shadowLevel: float;
  47946. /**
  47947. * Helps adjusting the shadow to a softer level if required.
  47948. * 0 means black shadows and 1 means no shadows.
  47949. */
  47950. shadowLevel: float;
  47951. protected _sceneCenter: Vector3;
  47952. /**
  47953. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47954. * It is usually zero but might be interesting to modify according to your setup.
  47955. */
  47956. sceneCenter: Vector3;
  47957. protected _opacityFresnel: boolean;
  47958. /**
  47959. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47960. * This helps ensuring a nice transition when the camera goes under the ground.
  47961. */
  47962. opacityFresnel: boolean;
  47963. protected _reflectionFresnel: boolean;
  47964. /**
  47965. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47966. * This helps adding a mirror texture on the ground.
  47967. */
  47968. reflectionFresnel: boolean;
  47969. protected _reflectionFalloffDistance: number;
  47970. /**
  47971. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47972. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47973. */
  47974. reflectionFalloffDistance: number;
  47975. protected _reflectionAmount: number;
  47976. /**
  47977. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47978. */
  47979. reflectionAmount: number;
  47980. protected _reflectionReflectance0: number;
  47981. /**
  47982. * This specifies the weight of the reflection at grazing angle.
  47983. */
  47984. reflectionReflectance0: number;
  47985. protected _reflectionReflectance90: number;
  47986. /**
  47987. * This specifies the weight of the reflection at a perpendicular point of view.
  47988. */
  47989. reflectionReflectance90: number;
  47990. /**
  47991. * Sets the reflection reflectance fresnel values according to the default standard
  47992. * empirically know to work well :-)
  47993. */
  47994. reflectionStandardFresnelWeight: number;
  47995. protected _useRGBColor: boolean;
  47996. /**
  47997. * Helps to directly use the maps channels instead of their level.
  47998. */
  47999. useRGBColor: boolean;
  48000. protected _enableNoise: boolean;
  48001. /**
  48002. * This helps reducing the banding effect that could occur on the background.
  48003. */
  48004. enableNoise: boolean;
  48005. /**
  48006. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48007. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48008. * Recommended to be keep at 1.0 except for special cases.
  48009. */
  48010. fovMultiplier: number;
  48011. private _fovMultiplier;
  48012. /**
  48013. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48014. */
  48015. useEquirectangularFOV: boolean;
  48016. private _maxSimultaneousLights;
  48017. /**
  48018. * Number of Simultaneous lights allowed on the material.
  48019. */
  48020. maxSimultaneousLights: int;
  48021. /**
  48022. * Default configuration related to image processing available in the Background Material.
  48023. */
  48024. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48025. /**
  48026. * Keep track of the image processing observer to allow dispose and replace.
  48027. */
  48028. private _imageProcessingObserver;
  48029. /**
  48030. * Attaches a new image processing configuration to the PBR Material.
  48031. * @param configuration (if null the scene configuration will be use)
  48032. */
  48033. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48034. /**
  48035. * Gets the image processing configuration used either in this material.
  48036. */
  48037. /**
  48038. * Sets the Default image processing configuration used either in the this material.
  48039. *
  48040. * If sets to null, the scene one is in use.
  48041. */
  48042. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48043. /**
  48044. * Gets wether the color curves effect is enabled.
  48045. */
  48046. /**
  48047. * Sets wether the color curves effect is enabled.
  48048. */
  48049. cameraColorCurvesEnabled: boolean;
  48050. /**
  48051. * Gets wether the color grading effect is enabled.
  48052. */
  48053. /**
  48054. * Gets wether the color grading effect is enabled.
  48055. */
  48056. cameraColorGradingEnabled: boolean;
  48057. /**
  48058. * Gets wether tonemapping is enabled or not.
  48059. */
  48060. /**
  48061. * Sets wether tonemapping is enabled or not
  48062. */
  48063. cameraToneMappingEnabled: boolean;
  48064. /**
  48065. * The camera exposure used on this material.
  48066. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48067. * This corresponds to a photographic exposure.
  48068. */
  48069. /**
  48070. * The camera exposure used on this material.
  48071. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48072. * This corresponds to a photographic exposure.
  48073. */
  48074. cameraExposure: float;
  48075. /**
  48076. * Gets The camera contrast used on this material.
  48077. */
  48078. /**
  48079. * Sets The camera contrast used on this material.
  48080. */
  48081. cameraContrast: float;
  48082. /**
  48083. * Gets the Color Grading 2D Lookup Texture.
  48084. */
  48085. /**
  48086. * Sets the Color Grading 2D Lookup Texture.
  48087. */
  48088. cameraColorGradingTexture: Nullable<BaseTexture>;
  48089. /**
  48090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48092. * 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;
  48093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48094. */
  48095. /**
  48096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48098. * 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;
  48099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48100. */
  48101. cameraColorCurves: Nullable<ColorCurves>;
  48102. /**
  48103. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48104. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48105. */
  48106. switchToBGR: boolean;
  48107. private _renderTargets;
  48108. private _reflectionControls;
  48109. private _white;
  48110. private _primaryShadowColor;
  48111. private _primaryHighlightColor;
  48112. /**
  48113. * Instantiates a Background Material in the given scene
  48114. * @param name The friendly name of the material
  48115. * @param scene The scene to add the material to
  48116. */
  48117. constructor(name: string, scene: Scene);
  48118. /**
  48119. * Gets a boolean indicating that current material needs to register RTT
  48120. */
  48121. readonly hasRenderTargetTextures: boolean;
  48122. /**
  48123. * The entire material has been created in order to prevent overdraw.
  48124. * @returns false
  48125. */
  48126. needAlphaTesting(): boolean;
  48127. /**
  48128. * The entire material has been created in order to prevent overdraw.
  48129. * @returns true if blending is enable
  48130. */
  48131. needAlphaBlending(): boolean;
  48132. /**
  48133. * Checks wether the material is ready to be rendered for a given mesh.
  48134. * @param mesh The mesh to render
  48135. * @param subMesh The submesh to check against
  48136. * @param useInstances Specify wether or not the material is used with instances
  48137. * @returns true if all the dependencies are ready (Textures, Effects...)
  48138. */
  48139. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48140. /**
  48141. * Compute the primary color according to the chosen perceptual color.
  48142. */
  48143. private _computePrimaryColorFromPerceptualColor;
  48144. /**
  48145. * Compute the highlights and shadow colors according to their chosen levels.
  48146. */
  48147. private _computePrimaryColors;
  48148. /**
  48149. * Build the uniform buffer used in the material.
  48150. */
  48151. buildUniformLayout(): void;
  48152. /**
  48153. * Unbind the material.
  48154. */
  48155. unbind(): void;
  48156. /**
  48157. * Bind only the world matrix to the material.
  48158. * @param world The world matrix to bind.
  48159. */
  48160. bindOnlyWorldMatrix(world: Matrix): void;
  48161. /**
  48162. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48163. * @param world The world matrix to bind.
  48164. * @param subMesh The submesh to bind for.
  48165. */
  48166. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48167. /**
  48168. * Checks to see if a texture is used in the material.
  48169. * @param texture - Base texture to use.
  48170. * @returns - Boolean specifying if a texture is used in the material.
  48171. */
  48172. hasTexture(texture: BaseTexture): boolean;
  48173. /**
  48174. * Dispose the material.
  48175. * @param forceDisposeEffect Force disposal of the associated effect.
  48176. * @param forceDisposeTextures Force disposal of the associated textures.
  48177. */
  48178. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48179. /**
  48180. * Clones the material.
  48181. * @param name The cloned name.
  48182. * @returns The cloned material.
  48183. */
  48184. clone(name: string): BackgroundMaterial;
  48185. /**
  48186. * Serializes the current material to its JSON representation.
  48187. * @returns The JSON representation.
  48188. */
  48189. serialize(): any;
  48190. /**
  48191. * Gets the class name of the material
  48192. * @returns "BackgroundMaterial"
  48193. */
  48194. getClassName(): string;
  48195. /**
  48196. * Parse a JSON input to create back a background material.
  48197. * @param source The JSON data to parse
  48198. * @param scene The scene to create the parsed material in
  48199. * @param rootUrl The root url of the assets the material depends upon
  48200. * @returns the instantiated BackgroundMaterial.
  48201. */
  48202. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48203. }
  48204. }
  48205. declare module "babylonjs/Helpers/environmentHelper" {
  48206. import { Observable } from "babylonjs/Misc/observable";
  48207. import { Nullable } from "babylonjs/types";
  48208. import { Scene } from "babylonjs/scene";
  48209. import { Vector3 } from "babylonjs/Maths/math.vector";
  48210. import { Color3 } from "babylonjs/Maths/math.color";
  48211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48212. import { Mesh } from "babylonjs/Meshes/mesh";
  48213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48214. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48215. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48216. import "babylonjs/Meshes/Builders/planeBuilder";
  48217. import "babylonjs/Meshes/Builders/boxBuilder";
  48218. /**
  48219. * Represents the different options available during the creation of
  48220. * a Environment helper.
  48221. *
  48222. * This can control the default ground, skybox and image processing setup of your scene.
  48223. */
  48224. export interface IEnvironmentHelperOptions {
  48225. /**
  48226. * Specifies wether or not to create a ground.
  48227. * True by default.
  48228. */
  48229. createGround: boolean;
  48230. /**
  48231. * Specifies the ground size.
  48232. * 15 by default.
  48233. */
  48234. groundSize: number;
  48235. /**
  48236. * The texture used on the ground for the main color.
  48237. * Comes from the BabylonJS CDN by default.
  48238. *
  48239. * Remarks: Can be either a texture or a url.
  48240. */
  48241. groundTexture: string | BaseTexture;
  48242. /**
  48243. * The color mixed in the ground texture by default.
  48244. * BabylonJS clearColor by default.
  48245. */
  48246. groundColor: Color3;
  48247. /**
  48248. * Specifies the ground opacity.
  48249. * 1 by default.
  48250. */
  48251. groundOpacity: number;
  48252. /**
  48253. * Enables the ground to receive shadows.
  48254. * True by default.
  48255. */
  48256. enableGroundShadow: boolean;
  48257. /**
  48258. * Helps preventing the shadow to be fully black on the ground.
  48259. * 0.5 by default.
  48260. */
  48261. groundShadowLevel: number;
  48262. /**
  48263. * Creates a mirror texture attach to the ground.
  48264. * false by default.
  48265. */
  48266. enableGroundMirror: boolean;
  48267. /**
  48268. * Specifies the ground mirror size ratio.
  48269. * 0.3 by default as the default kernel is 64.
  48270. */
  48271. groundMirrorSizeRatio: number;
  48272. /**
  48273. * Specifies the ground mirror blur kernel size.
  48274. * 64 by default.
  48275. */
  48276. groundMirrorBlurKernel: number;
  48277. /**
  48278. * Specifies the ground mirror visibility amount.
  48279. * 1 by default
  48280. */
  48281. groundMirrorAmount: number;
  48282. /**
  48283. * Specifies the ground mirror reflectance weight.
  48284. * This uses the standard weight of the background material to setup the fresnel effect
  48285. * of the mirror.
  48286. * 1 by default.
  48287. */
  48288. groundMirrorFresnelWeight: number;
  48289. /**
  48290. * Specifies the ground mirror Falloff distance.
  48291. * This can helps reducing the size of the reflection.
  48292. * 0 by Default.
  48293. */
  48294. groundMirrorFallOffDistance: number;
  48295. /**
  48296. * Specifies the ground mirror texture type.
  48297. * Unsigned Int by Default.
  48298. */
  48299. groundMirrorTextureType: number;
  48300. /**
  48301. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48302. * the shown objects.
  48303. */
  48304. groundYBias: number;
  48305. /**
  48306. * Specifies wether or not to create a skybox.
  48307. * True by default.
  48308. */
  48309. createSkybox: boolean;
  48310. /**
  48311. * Specifies the skybox size.
  48312. * 20 by default.
  48313. */
  48314. skyboxSize: number;
  48315. /**
  48316. * The texture used on the skybox for the main color.
  48317. * Comes from the BabylonJS CDN by default.
  48318. *
  48319. * Remarks: Can be either a texture or a url.
  48320. */
  48321. skyboxTexture: string | BaseTexture;
  48322. /**
  48323. * The color mixed in the skybox texture by default.
  48324. * BabylonJS clearColor by default.
  48325. */
  48326. skyboxColor: Color3;
  48327. /**
  48328. * The background rotation around the Y axis of the scene.
  48329. * This helps aligning the key lights of your scene with the background.
  48330. * 0 by default.
  48331. */
  48332. backgroundYRotation: number;
  48333. /**
  48334. * Compute automatically the size of the elements to best fit with the scene.
  48335. */
  48336. sizeAuto: boolean;
  48337. /**
  48338. * Default position of the rootMesh if autoSize is not true.
  48339. */
  48340. rootPosition: Vector3;
  48341. /**
  48342. * Sets up the image processing in the scene.
  48343. * true by default.
  48344. */
  48345. setupImageProcessing: boolean;
  48346. /**
  48347. * The texture used as your environment texture in the scene.
  48348. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48349. *
  48350. * Remarks: Can be either a texture or a url.
  48351. */
  48352. environmentTexture: string | BaseTexture;
  48353. /**
  48354. * The value of the exposure to apply to the scene.
  48355. * 0.6 by default if setupImageProcessing is true.
  48356. */
  48357. cameraExposure: number;
  48358. /**
  48359. * The value of the contrast to apply to the scene.
  48360. * 1.6 by default if setupImageProcessing is true.
  48361. */
  48362. cameraContrast: number;
  48363. /**
  48364. * Specifies wether or not tonemapping should be enabled in the scene.
  48365. * true by default if setupImageProcessing is true.
  48366. */
  48367. toneMappingEnabled: boolean;
  48368. }
  48369. /**
  48370. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48371. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48372. * It also helps with the default setup of your imageProcessing configuration.
  48373. */
  48374. export class EnvironmentHelper {
  48375. /**
  48376. * Default ground texture URL.
  48377. */
  48378. private static _groundTextureCDNUrl;
  48379. /**
  48380. * Default skybox texture URL.
  48381. */
  48382. private static _skyboxTextureCDNUrl;
  48383. /**
  48384. * Default environment texture URL.
  48385. */
  48386. private static _environmentTextureCDNUrl;
  48387. /**
  48388. * Creates the default options for the helper.
  48389. */
  48390. private static _getDefaultOptions;
  48391. private _rootMesh;
  48392. /**
  48393. * Gets the root mesh created by the helper.
  48394. */
  48395. readonly rootMesh: Mesh;
  48396. private _skybox;
  48397. /**
  48398. * Gets the skybox created by the helper.
  48399. */
  48400. readonly skybox: Nullable<Mesh>;
  48401. private _skyboxTexture;
  48402. /**
  48403. * Gets the skybox texture created by the helper.
  48404. */
  48405. readonly skyboxTexture: Nullable<BaseTexture>;
  48406. private _skyboxMaterial;
  48407. /**
  48408. * Gets the skybox material created by the helper.
  48409. */
  48410. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48411. private _ground;
  48412. /**
  48413. * Gets the ground mesh created by the helper.
  48414. */
  48415. readonly ground: Nullable<Mesh>;
  48416. private _groundTexture;
  48417. /**
  48418. * Gets the ground texture created by the helper.
  48419. */
  48420. readonly groundTexture: Nullable<BaseTexture>;
  48421. private _groundMirror;
  48422. /**
  48423. * Gets the ground mirror created by the helper.
  48424. */
  48425. readonly groundMirror: Nullable<MirrorTexture>;
  48426. /**
  48427. * Gets the ground mirror render list to helps pushing the meshes
  48428. * you wish in the ground reflection.
  48429. */
  48430. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48431. private _groundMaterial;
  48432. /**
  48433. * Gets the ground material created by the helper.
  48434. */
  48435. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48436. /**
  48437. * Stores the creation options.
  48438. */
  48439. private readonly _scene;
  48440. private _options;
  48441. /**
  48442. * This observable will be notified with any error during the creation of the environment,
  48443. * mainly texture creation errors.
  48444. */
  48445. onErrorObservable: Observable<{
  48446. message?: string;
  48447. exception?: any;
  48448. }>;
  48449. /**
  48450. * constructor
  48451. * @param options Defines the options we want to customize the helper
  48452. * @param scene The scene to add the material to
  48453. */
  48454. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48455. /**
  48456. * Updates the background according to the new options
  48457. * @param options
  48458. */
  48459. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48460. /**
  48461. * Sets the primary color of all the available elements.
  48462. * @param color the main color to affect to the ground and the background
  48463. */
  48464. setMainColor(color: Color3): void;
  48465. /**
  48466. * Setup the image processing according to the specified options.
  48467. */
  48468. private _setupImageProcessing;
  48469. /**
  48470. * Setup the environment texture according to the specified options.
  48471. */
  48472. private _setupEnvironmentTexture;
  48473. /**
  48474. * Setup the background according to the specified options.
  48475. */
  48476. private _setupBackground;
  48477. /**
  48478. * Get the scene sizes according to the setup.
  48479. */
  48480. private _getSceneSize;
  48481. /**
  48482. * Setup the ground according to the specified options.
  48483. */
  48484. private _setupGround;
  48485. /**
  48486. * Setup the ground material according to the specified options.
  48487. */
  48488. private _setupGroundMaterial;
  48489. /**
  48490. * Setup the ground diffuse texture according to the specified options.
  48491. */
  48492. private _setupGroundDiffuseTexture;
  48493. /**
  48494. * Setup the ground mirror texture according to the specified options.
  48495. */
  48496. private _setupGroundMirrorTexture;
  48497. /**
  48498. * Setup the ground to receive the mirror texture.
  48499. */
  48500. private _setupMirrorInGroundMaterial;
  48501. /**
  48502. * Setup the skybox according to the specified options.
  48503. */
  48504. private _setupSkybox;
  48505. /**
  48506. * Setup the skybox material according to the specified options.
  48507. */
  48508. private _setupSkyboxMaterial;
  48509. /**
  48510. * Setup the skybox reflection texture according to the specified options.
  48511. */
  48512. private _setupSkyboxReflectionTexture;
  48513. private _errorHandler;
  48514. /**
  48515. * Dispose all the elements created by the Helper.
  48516. */
  48517. dispose(): void;
  48518. }
  48519. }
  48520. declare module "babylonjs/Helpers/photoDome" {
  48521. import { Observable } from "babylonjs/Misc/observable";
  48522. import { Nullable } from "babylonjs/types";
  48523. import { Scene } from "babylonjs/scene";
  48524. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48525. import { Mesh } from "babylonjs/Meshes/mesh";
  48526. import { Texture } from "babylonjs/Materials/Textures/texture";
  48527. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48528. import "babylonjs/Meshes/Builders/sphereBuilder";
  48529. /**
  48530. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48531. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48532. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48533. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48534. */
  48535. export class PhotoDome extends TransformNode {
  48536. /**
  48537. * Define the image as a Monoscopic panoramic 360 image.
  48538. */
  48539. static readonly MODE_MONOSCOPIC: number;
  48540. /**
  48541. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48542. */
  48543. static readonly MODE_TOPBOTTOM: number;
  48544. /**
  48545. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48546. */
  48547. static readonly MODE_SIDEBYSIDE: number;
  48548. private _useDirectMapping;
  48549. /**
  48550. * The texture being displayed on the sphere
  48551. */
  48552. protected _photoTexture: Texture;
  48553. /**
  48554. * Gets or sets the texture being displayed on the sphere
  48555. */
  48556. photoTexture: Texture;
  48557. /**
  48558. * Observable raised when an error occured while loading the 360 image
  48559. */
  48560. onLoadErrorObservable: Observable<string>;
  48561. /**
  48562. * The skybox material
  48563. */
  48564. protected _material: BackgroundMaterial;
  48565. /**
  48566. * The surface used for the skybox
  48567. */
  48568. protected _mesh: Mesh;
  48569. /**
  48570. * Gets the mesh used for the skybox.
  48571. */
  48572. readonly mesh: Mesh;
  48573. /**
  48574. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48575. * Also see the options.resolution property.
  48576. */
  48577. fovMultiplier: number;
  48578. private _imageMode;
  48579. /**
  48580. * Gets or set the current video mode for the video. It can be:
  48581. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48582. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48583. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48584. */
  48585. imageMode: number;
  48586. /**
  48587. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48588. * @param name Element's name, child elements will append suffixes for their own names.
  48589. * @param urlsOfPhoto defines the url of the photo to display
  48590. * @param options defines an object containing optional or exposed sub element properties
  48591. * @param onError defines a callback called when an error occured while loading the texture
  48592. */
  48593. constructor(name: string, urlOfPhoto: string, options: {
  48594. resolution?: number;
  48595. size?: number;
  48596. useDirectMapping?: boolean;
  48597. faceForward?: boolean;
  48598. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48599. private _onBeforeCameraRenderObserver;
  48600. private _changeImageMode;
  48601. /**
  48602. * Releases resources associated with this node.
  48603. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48604. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48605. */
  48606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48607. }
  48608. }
  48609. declare module "babylonjs/Misc/rgbdTextureTools" {
  48610. import "babylonjs/Shaders/rgbdDecode.fragment";
  48611. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48612. import { Texture } from "babylonjs/Materials/Textures/texture";
  48613. /**
  48614. * Class used to host RGBD texture specific utilities
  48615. */
  48616. export class RGBDTextureTools {
  48617. /**
  48618. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48619. * @param texture the texture to expand.
  48620. */
  48621. static ExpandRGBDTexture(texture: Texture): void;
  48622. }
  48623. }
  48624. declare module "babylonjs/Misc/brdfTextureTools" {
  48625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48626. import { Scene } from "babylonjs/scene";
  48627. /**
  48628. * Class used to host texture specific utilities
  48629. */
  48630. export class BRDFTextureTools {
  48631. /**
  48632. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48633. * @param scene defines the hosting scene
  48634. * @returns the environment BRDF texture
  48635. */
  48636. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48637. private static _environmentBRDFBase64Texture;
  48638. }
  48639. }
  48640. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48641. import { Nullable } from "babylonjs/types";
  48642. import { Color3 } from "babylonjs/Maths/math.color";
  48643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48644. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48645. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48646. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48647. import { Engine } from "babylonjs/Engines/engine";
  48648. import { Scene } from "babylonjs/scene";
  48649. /**
  48650. * @hidden
  48651. */
  48652. export interface IMaterialClearCoatDefines {
  48653. CLEARCOAT: boolean;
  48654. CLEARCOAT_DEFAULTIOR: boolean;
  48655. CLEARCOAT_TEXTURE: boolean;
  48656. CLEARCOAT_TEXTUREDIRECTUV: number;
  48657. CLEARCOAT_BUMP: boolean;
  48658. CLEARCOAT_BUMPDIRECTUV: number;
  48659. CLEARCOAT_TINT: boolean;
  48660. CLEARCOAT_TINT_TEXTURE: boolean;
  48661. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48662. /** @hidden */
  48663. _areTexturesDirty: boolean;
  48664. }
  48665. /**
  48666. * Define the code related to the clear coat parameters of the pbr material.
  48667. */
  48668. export class PBRClearCoatConfiguration {
  48669. /**
  48670. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48671. * The default fits with a polyurethane material.
  48672. */
  48673. private static readonly _DefaultIndexOfRefraction;
  48674. private _isEnabled;
  48675. /**
  48676. * Defines if the clear coat is enabled in the material.
  48677. */
  48678. isEnabled: boolean;
  48679. /**
  48680. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48681. */
  48682. intensity: number;
  48683. /**
  48684. * Defines the clear coat layer roughness.
  48685. */
  48686. roughness: number;
  48687. private _indexOfRefraction;
  48688. /**
  48689. * Defines the index of refraction of the clear coat.
  48690. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48691. * The default fits with a polyurethane material.
  48692. * Changing the default value is more performance intensive.
  48693. */
  48694. indexOfRefraction: number;
  48695. private _texture;
  48696. /**
  48697. * Stores the clear coat values in a texture.
  48698. */
  48699. texture: Nullable<BaseTexture>;
  48700. private _bumpTexture;
  48701. /**
  48702. * Define the clear coat specific bump texture.
  48703. */
  48704. bumpTexture: Nullable<BaseTexture>;
  48705. private _isTintEnabled;
  48706. /**
  48707. * Defines if the clear coat tint is enabled in the material.
  48708. */
  48709. isTintEnabled: boolean;
  48710. /**
  48711. * Defines the clear coat tint of the material.
  48712. * This is only use if tint is enabled
  48713. */
  48714. tintColor: Color3;
  48715. /**
  48716. * Defines the distance at which the tint color should be found in the
  48717. * clear coat media.
  48718. * This is only use if tint is enabled
  48719. */
  48720. tintColorAtDistance: number;
  48721. /**
  48722. * Defines the clear coat layer thickness.
  48723. * This is only use if tint is enabled
  48724. */
  48725. tintThickness: number;
  48726. private _tintTexture;
  48727. /**
  48728. * Stores the clear tint values in a texture.
  48729. * rgb is tint
  48730. * a is a thickness factor
  48731. */
  48732. tintTexture: Nullable<BaseTexture>;
  48733. /** @hidden */
  48734. private _internalMarkAllSubMeshesAsTexturesDirty;
  48735. /** @hidden */
  48736. _markAllSubMeshesAsTexturesDirty(): void;
  48737. /**
  48738. * Instantiate a new istance of clear coat configuration.
  48739. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48740. */
  48741. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48742. /**
  48743. * Gets wehter the submesh is ready to be used or not.
  48744. * @param defines the list of "defines" to update.
  48745. * @param scene defines the scene the material belongs to.
  48746. * @param engine defines the engine the material belongs to.
  48747. * @param disableBumpMap defines wether the material disables bump or not.
  48748. * @returns - boolean indicating that the submesh is ready or not.
  48749. */
  48750. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48751. /**
  48752. * Checks to see if a texture is used in the material.
  48753. * @param defines the list of "defines" to update.
  48754. * @param scene defines the scene to the material belongs to.
  48755. */
  48756. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48757. /**
  48758. * Binds the material data.
  48759. * @param uniformBuffer defines the Uniform buffer to fill in.
  48760. * @param scene defines the scene the material belongs to.
  48761. * @param engine defines the engine the material belongs to.
  48762. * @param disableBumpMap defines wether the material disables bump or not.
  48763. * @param isFrozen defines wether the material is frozen or not.
  48764. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48765. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48766. */
  48767. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48768. /**
  48769. * Checks to see if a texture is used in the material.
  48770. * @param texture - Base texture to use.
  48771. * @returns - Boolean specifying if a texture is used in the material.
  48772. */
  48773. hasTexture(texture: BaseTexture): boolean;
  48774. /**
  48775. * Returns an array of the actively used textures.
  48776. * @param activeTextures Array of BaseTextures
  48777. */
  48778. getActiveTextures(activeTextures: BaseTexture[]): void;
  48779. /**
  48780. * Returns the animatable textures.
  48781. * @param animatables Array of animatable textures.
  48782. */
  48783. getAnimatables(animatables: IAnimatable[]): void;
  48784. /**
  48785. * Disposes the resources of the material.
  48786. * @param forceDisposeTextures - Forces the disposal of all textures.
  48787. */
  48788. dispose(forceDisposeTextures?: boolean): void;
  48789. /**
  48790. * Get the current class name of the texture useful for serialization or dynamic coding.
  48791. * @returns "PBRClearCoatConfiguration"
  48792. */
  48793. getClassName(): string;
  48794. /**
  48795. * Add fallbacks to the effect fallbacks list.
  48796. * @param defines defines the Base texture to use.
  48797. * @param fallbacks defines the current fallback list.
  48798. * @param currentRank defines the current fallback rank.
  48799. * @returns the new fallback rank.
  48800. */
  48801. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48802. /**
  48803. * Add the required uniforms to the current list.
  48804. * @param uniforms defines the current uniform list.
  48805. */
  48806. static AddUniforms(uniforms: string[]): void;
  48807. /**
  48808. * Add the required samplers to the current list.
  48809. * @param samplers defines the current sampler list.
  48810. */
  48811. static AddSamplers(samplers: string[]): void;
  48812. /**
  48813. * Add the required uniforms to the current buffer.
  48814. * @param uniformBuffer defines the current uniform buffer.
  48815. */
  48816. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48817. /**
  48818. * Makes a duplicate of the current configuration into another one.
  48819. * @param clearCoatConfiguration define the config where to copy the info
  48820. */
  48821. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48822. /**
  48823. * Serializes this clear coat configuration.
  48824. * @returns - An object with the serialized config.
  48825. */
  48826. serialize(): any;
  48827. /**
  48828. * Parses a anisotropy Configuration from a serialized object.
  48829. * @param source - Serialized object.
  48830. * @param scene Defines the scene we are parsing for
  48831. * @param rootUrl Defines the rootUrl to load from
  48832. */
  48833. parse(source: any, scene: Scene, rootUrl: string): void;
  48834. }
  48835. }
  48836. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48837. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48839. import { Vector2 } from "babylonjs/Maths/math.vector";
  48840. import { Scene } from "babylonjs/scene";
  48841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48842. import { Nullable } from "babylonjs/types";
  48843. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48844. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48845. /**
  48846. * @hidden
  48847. */
  48848. export interface IMaterialAnisotropicDefines {
  48849. ANISOTROPIC: boolean;
  48850. ANISOTROPIC_TEXTURE: boolean;
  48851. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48852. MAINUV1: boolean;
  48853. _areTexturesDirty: boolean;
  48854. _needUVs: boolean;
  48855. }
  48856. /**
  48857. * Define the code related to the anisotropic parameters of the pbr material.
  48858. */
  48859. export class PBRAnisotropicConfiguration {
  48860. private _isEnabled;
  48861. /**
  48862. * Defines if the anisotropy is enabled in the material.
  48863. */
  48864. isEnabled: boolean;
  48865. /**
  48866. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48867. */
  48868. intensity: number;
  48869. /**
  48870. * Defines if the effect is along the tangents, bitangents or in between.
  48871. * By default, the effect is "strectching" the highlights along the tangents.
  48872. */
  48873. direction: Vector2;
  48874. private _texture;
  48875. /**
  48876. * Stores the anisotropy values in a texture.
  48877. * rg is direction (like normal from -1 to 1)
  48878. * b is a intensity
  48879. */
  48880. texture: Nullable<BaseTexture>;
  48881. /** @hidden */
  48882. private _internalMarkAllSubMeshesAsTexturesDirty;
  48883. /** @hidden */
  48884. _markAllSubMeshesAsTexturesDirty(): void;
  48885. /**
  48886. * Instantiate a new istance of anisotropy configuration.
  48887. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48888. */
  48889. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48890. /**
  48891. * Specifies that the submesh is ready to be used.
  48892. * @param defines the list of "defines" to update.
  48893. * @param scene defines the scene the material belongs to.
  48894. * @returns - boolean indicating that the submesh is ready or not.
  48895. */
  48896. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48897. /**
  48898. * Checks to see if a texture is used in the material.
  48899. * @param defines the list of "defines" to update.
  48900. * @param mesh the mesh we are preparing the defines for.
  48901. * @param scene defines the scene the material belongs to.
  48902. */
  48903. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48904. /**
  48905. * Binds the material data.
  48906. * @param uniformBuffer defines the Uniform buffer to fill in.
  48907. * @param scene defines the scene the material belongs to.
  48908. * @param isFrozen defines wether the material is frozen or not.
  48909. */
  48910. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48911. /**
  48912. * Checks to see if a texture is used in the material.
  48913. * @param texture - Base texture to use.
  48914. * @returns - Boolean specifying if a texture is used in the material.
  48915. */
  48916. hasTexture(texture: BaseTexture): boolean;
  48917. /**
  48918. * Returns an array of the actively used textures.
  48919. * @param activeTextures Array of BaseTextures
  48920. */
  48921. getActiveTextures(activeTextures: BaseTexture[]): void;
  48922. /**
  48923. * Returns the animatable textures.
  48924. * @param animatables Array of animatable textures.
  48925. */
  48926. getAnimatables(animatables: IAnimatable[]): void;
  48927. /**
  48928. * Disposes the resources of the material.
  48929. * @param forceDisposeTextures - Forces the disposal of all textures.
  48930. */
  48931. dispose(forceDisposeTextures?: boolean): void;
  48932. /**
  48933. * Get the current class name of the texture useful for serialization or dynamic coding.
  48934. * @returns "PBRAnisotropicConfiguration"
  48935. */
  48936. getClassName(): string;
  48937. /**
  48938. * Add fallbacks to the effect fallbacks list.
  48939. * @param defines defines the Base texture to use.
  48940. * @param fallbacks defines the current fallback list.
  48941. * @param currentRank defines the current fallback rank.
  48942. * @returns the new fallback rank.
  48943. */
  48944. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48945. /**
  48946. * Add the required uniforms to the current list.
  48947. * @param uniforms defines the current uniform list.
  48948. */
  48949. static AddUniforms(uniforms: string[]): void;
  48950. /**
  48951. * Add the required uniforms to the current buffer.
  48952. * @param uniformBuffer defines the current uniform buffer.
  48953. */
  48954. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48955. /**
  48956. * Add the required samplers to the current list.
  48957. * @param samplers defines the current sampler list.
  48958. */
  48959. static AddSamplers(samplers: string[]): void;
  48960. /**
  48961. * Makes a duplicate of the current configuration into another one.
  48962. * @param anisotropicConfiguration define the config where to copy the info
  48963. */
  48964. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48965. /**
  48966. * Serializes this anisotropy configuration.
  48967. * @returns - An object with the serialized config.
  48968. */
  48969. serialize(): any;
  48970. /**
  48971. * Parses a anisotropy Configuration from a serialized object.
  48972. * @param source - Serialized object.
  48973. * @param scene Defines the scene we are parsing for
  48974. * @param rootUrl Defines the rootUrl to load from
  48975. */
  48976. parse(source: any, scene: Scene, rootUrl: string): void;
  48977. }
  48978. }
  48979. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48980. import { Scene } from "babylonjs/scene";
  48981. /**
  48982. * @hidden
  48983. */
  48984. export interface IMaterialBRDFDefines {
  48985. BRDF_V_HEIGHT_CORRELATED: boolean;
  48986. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48987. SPHERICAL_HARMONICS: boolean;
  48988. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48989. /** @hidden */
  48990. _areMiscDirty: boolean;
  48991. }
  48992. /**
  48993. * Define the code related to the BRDF parameters of the pbr material.
  48994. */
  48995. export class PBRBRDFConfiguration {
  48996. /**
  48997. * Default value used for the energy conservation.
  48998. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48999. */
  49000. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49001. /**
  49002. * Default value used for the Smith Visibility Height Correlated mode.
  49003. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49004. */
  49005. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49006. /**
  49007. * Default value used for the IBL diffuse part.
  49008. * This can help switching back to the polynomials mode globally which is a tiny bit
  49009. * less GPU intensive at the drawback of a lower quality.
  49010. */
  49011. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49012. /**
  49013. * Default value used for activating energy conservation for the specular workflow.
  49014. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49015. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49016. */
  49017. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49018. private _useEnergyConservation;
  49019. /**
  49020. * Defines if the material uses energy conservation.
  49021. */
  49022. useEnergyConservation: boolean;
  49023. private _useSmithVisibilityHeightCorrelated;
  49024. /**
  49025. * LEGACY Mode set to false
  49026. * Defines if the material uses height smith correlated visibility term.
  49027. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49028. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49029. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49030. * Not relying on height correlated will also disable energy conservation.
  49031. */
  49032. useSmithVisibilityHeightCorrelated: boolean;
  49033. private _useSphericalHarmonics;
  49034. /**
  49035. * LEGACY Mode set to false
  49036. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49037. * diffuse part of the IBL.
  49038. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49039. * to the ground truth.
  49040. */
  49041. useSphericalHarmonics: boolean;
  49042. private _useSpecularGlossinessInputEnergyConservation;
  49043. /**
  49044. * Defines if the material uses energy conservation, when the specular workflow is active.
  49045. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49046. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49047. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49048. */
  49049. useSpecularGlossinessInputEnergyConservation: boolean;
  49050. /** @hidden */
  49051. private _internalMarkAllSubMeshesAsMiscDirty;
  49052. /** @hidden */
  49053. _markAllSubMeshesAsMiscDirty(): void;
  49054. /**
  49055. * Instantiate a new istance of clear coat configuration.
  49056. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49057. */
  49058. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49059. /**
  49060. * Checks to see if a texture is used in the material.
  49061. * @param defines the list of "defines" to update.
  49062. */
  49063. prepareDefines(defines: IMaterialBRDFDefines): void;
  49064. /**
  49065. * Get the current class name of the texture useful for serialization or dynamic coding.
  49066. * @returns "PBRClearCoatConfiguration"
  49067. */
  49068. getClassName(): string;
  49069. /**
  49070. * Makes a duplicate of the current configuration into another one.
  49071. * @param brdfConfiguration define the config where to copy the info
  49072. */
  49073. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49074. /**
  49075. * Serializes this BRDF configuration.
  49076. * @returns - An object with the serialized config.
  49077. */
  49078. serialize(): any;
  49079. /**
  49080. * Parses a anisotropy Configuration from a serialized object.
  49081. * @param source - Serialized object.
  49082. * @param scene Defines the scene we are parsing for
  49083. * @param rootUrl Defines the rootUrl to load from
  49084. */
  49085. parse(source: any, scene: Scene, rootUrl: string): void;
  49086. }
  49087. }
  49088. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49089. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49090. import { Color3 } from "babylonjs/Maths/math.color";
  49091. import { Scene } from "babylonjs/scene";
  49092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49093. import { Nullable } from "babylonjs/types";
  49094. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49095. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49096. /**
  49097. * @hidden
  49098. */
  49099. export interface IMaterialSheenDefines {
  49100. SHEEN: boolean;
  49101. SHEEN_TEXTURE: boolean;
  49102. SHEEN_TEXTUREDIRECTUV: number;
  49103. SHEEN_LINKWITHALBEDO: boolean;
  49104. /** @hidden */
  49105. _areTexturesDirty: boolean;
  49106. }
  49107. /**
  49108. * Define the code related to the Sheen parameters of the pbr material.
  49109. */
  49110. export class PBRSheenConfiguration {
  49111. private _isEnabled;
  49112. /**
  49113. * Defines if the material uses sheen.
  49114. */
  49115. isEnabled: boolean;
  49116. private _linkSheenWithAlbedo;
  49117. /**
  49118. * Defines if the sheen is linked to the sheen color.
  49119. */
  49120. linkSheenWithAlbedo: boolean;
  49121. /**
  49122. * Defines the sheen intensity.
  49123. */
  49124. intensity: number;
  49125. /**
  49126. * Defines the sheen color.
  49127. */
  49128. color: Color3;
  49129. private _texture;
  49130. /**
  49131. * Stores the sheen tint values in a texture.
  49132. * rgb is tint
  49133. * a is a intensity
  49134. */
  49135. texture: Nullable<BaseTexture>;
  49136. /** @hidden */
  49137. private _internalMarkAllSubMeshesAsTexturesDirty;
  49138. /** @hidden */
  49139. _markAllSubMeshesAsTexturesDirty(): void;
  49140. /**
  49141. * Instantiate a new istance of clear coat configuration.
  49142. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49143. */
  49144. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49145. /**
  49146. * Specifies that the submesh is ready to be used.
  49147. * @param defines the list of "defines" to update.
  49148. * @param scene defines the scene the material belongs to.
  49149. * @returns - boolean indicating that the submesh is ready or not.
  49150. */
  49151. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49152. /**
  49153. * Checks to see if a texture is used in the material.
  49154. * @param defines the list of "defines" to update.
  49155. * @param scene defines the scene the material belongs to.
  49156. */
  49157. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49158. /**
  49159. * Binds the material data.
  49160. * @param uniformBuffer defines the Uniform buffer to fill in.
  49161. * @param scene defines the scene the material belongs to.
  49162. * @param isFrozen defines wether the material is frozen or not.
  49163. */
  49164. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49165. /**
  49166. * Checks to see if a texture is used in the material.
  49167. * @param texture - Base texture to use.
  49168. * @returns - Boolean specifying if a texture is used in the material.
  49169. */
  49170. hasTexture(texture: BaseTexture): boolean;
  49171. /**
  49172. * Returns an array of the actively used textures.
  49173. * @param activeTextures Array of BaseTextures
  49174. */
  49175. getActiveTextures(activeTextures: BaseTexture[]): void;
  49176. /**
  49177. * Returns the animatable textures.
  49178. * @param animatables Array of animatable textures.
  49179. */
  49180. getAnimatables(animatables: IAnimatable[]): void;
  49181. /**
  49182. * Disposes the resources of the material.
  49183. * @param forceDisposeTextures - Forces the disposal of all textures.
  49184. */
  49185. dispose(forceDisposeTextures?: boolean): void;
  49186. /**
  49187. * Get the current class name of the texture useful for serialization or dynamic coding.
  49188. * @returns "PBRSheenConfiguration"
  49189. */
  49190. getClassName(): string;
  49191. /**
  49192. * Add fallbacks to the effect fallbacks list.
  49193. * @param defines defines the Base texture to use.
  49194. * @param fallbacks defines the current fallback list.
  49195. * @param currentRank defines the current fallback rank.
  49196. * @returns the new fallback rank.
  49197. */
  49198. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49199. /**
  49200. * Add the required uniforms to the current list.
  49201. * @param uniforms defines the current uniform list.
  49202. */
  49203. static AddUniforms(uniforms: string[]): void;
  49204. /**
  49205. * Add the required uniforms to the current buffer.
  49206. * @param uniformBuffer defines the current uniform buffer.
  49207. */
  49208. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49209. /**
  49210. * Add the required samplers to the current list.
  49211. * @param samplers defines the current sampler list.
  49212. */
  49213. static AddSamplers(samplers: string[]): void;
  49214. /**
  49215. * Makes a duplicate of the current configuration into another one.
  49216. * @param sheenConfiguration define the config where to copy the info
  49217. */
  49218. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49219. /**
  49220. * Serializes this BRDF configuration.
  49221. * @returns - An object with the serialized config.
  49222. */
  49223. serialize(): any;
  49224. /**
  49225. * Parses a anisotropy Configuration from a serialized object.
  49226. * @param source - Serialized object.
  49227. * @param scene Defines the scene we are parsing for
  49228. * @param rootUrl Defines the rootUrl to load from
  49229. */
  49230. parse(source: any, scene: Scene, rootUrl: string): void;
  49231. }
  49232. }
  49233. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49234. import { Nullable } from "babylonjs/types";
  49235. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49236. import { Color3 } from "babylonjs/Maths/math.color";
  49237. import { SmartArray } from "babylonjs/Misc/smartArray";
  49238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49240. import { Effect } from "babylonjs/Materials/effect";
  49241. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49242. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49243. import { Engine } from "babylonjs/Engines/engine";
  49244. import { Scene } from "babylonjs/scene";
  49245. /**
  49246. * @hidden
  49247. */
  49248. export interface IMaterialSubSurfaceDefines {
  49249. SUBSURFACE: boolean;
  49250. SS_REFRACTION: boolean;
  49251. SS_TRANSLUCENCY: boolean;
  49252. SS_SCATERRING: boolean;
  49253. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49254. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49255. SS_REFRACTIONMAP_3D: boolean;
  49256. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49257. SS_LODINREFRACTIONALPHA: boolean;
  49258. SS_GAMMAREFRACTION: boolean;
  49259. SS_RGBDREFRACTION: boolean;
  49260. SS_LINEARSPECULARREFRACTION: boolean;
  49261. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49262. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49263. /** @hidden */
  49264. _areTexturesDirty: boolean;
  49265. }
  49266. /**
  49267. * Define the code related to the sub surface parameters of the pbr material.
  49268. */
  49269. export class PBRSubSurfaceConfiguration {
  49270. private _isRefractionEnabled;
  49271. /**
  49272. * Defines if the refraction is enabled in the material.
  49273. */
  49274. isRefractionEnabled: boolean;
  49275. private _isTranslucencyEnabled;
  49276. /**
  49277. * Defines if the translucency is enabled in the material.
  49278. */
  49279. isTranslucencyEnabled: boolean;
  49280. private _isScatteringEnabled;
  49281. /**
  49282. * Defines the refraction intensity of the material.
  49283. * The refraction when enabled replaces the Diffuse part of the material.
  49284. * The intensity helps transitionning between diffuse and refraction.
  49285. */
  49286. refractionIntensity: number;
  49287. /**
  49288. * Defines the translucency intensity of the material.
  49289. * When translucency has been enabled, this defines how much of the "translucency"
  49290. * is addded to the diffuse part of the material.
  49291. */
  49292. translucencyIntensity: number;
  49293. /**
  49294. * Defines the scattering intensity of the material.
  49295. * When scattering has been enabled, this defines how much of the "scattered light"
  49296. * is addded to the diffuse part of the material.
  49297. */
  49298. scatteringIntensity: number;
  49299. private _thicknessTexture;
  49300. /**
  49301. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49302. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49303. * 0 would mean minimumThickness
  49304. * 1 would mean maximumThickness
  49305. * The other channels might be use as a mask to vary the different effects intensity.
  49306. */
  49307. thicknessTexture: Nullable<BaseTexture>;
  49308. private _refractionTexture;
  49309. /**
  49310. * Defines the texture to use for refraction.
  49311. */
  49312. refractionTexture: Nullable<BaseTexture>;
  49313. private _indexOfRefraction;
  49314. /**
  49315. * Defines the index of refraction used in the material.
  49316. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49317. */
  49318. indexOfRefraction: number;
  49319. private _invertRefractionY;
  49320. /**
  49321. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49322. */
  49323. invertRefractionY: boolean;
  49324. private _linkRefractionWithTransparency;
  49325. /**
  49326. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49327. * Materials half opaque for instance using refraction could benefit from this control.
  49328. */
  49329. linkRefractionWithTransparency: boolean;
  49330. /**
  49331. * Defines the minimum thickness stored in the thickness map.
  49332. * If no thickness map is defined, this value will be used to simulate thickness.
  49333. */
  49334. minimumThickness: number;
  49335. /**
  49336. * Defines the maximum thickness stored in the thickness map.
  49337. */
  49338. maximumThickness: number;
  49339. /**
  49340. * Defines the volume tint of the material.
  49341. * This is used for both translucency and scattering.
  49342. */
  49343. tintColor: Color3;
  49344. /**
  49345. * Defines the distance at which the tint color should be found in the media.
  49346. * This is used for refraction only.
  49347. */
  49348. tintColorAtDistance: number;
  49349. /**
  49350. * Defines how far each channel transmit through the media.
  49351. * It is defined as a color to simplify it selection.
  49352. */
  49353. diffusionDistance: Color3;
  49354. private _useMaskFromThicknessTexture;
  49355. /**
  49356. * Stores the intensity of the different subsurface effects in the thickness texture.
  49357. * * the green channel is the translucency intensity.
  49358. * * the blue channel is the scattering intensity.
  49359. * * the alpha channel is the refraction intensity.
  49360. */
  49361. useMaskFromThicknessTexture: boolean;
  49362. /** @hidden */
  49363. private _internalMarkAllSubMeshesAsTexturesDirty;
  49364. /** @hidden */
  49365. _markAllSubMeshesAsTexturesDirty(): void;
  49366. /**
  49367. * Instantiate a new istance of sub surface configuration.
  49368. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49369. */
  49370. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49371. /**
  49372. * Gets wehter the submesh is ready to be used or not.
  49373. * @param defines the list of "defines" to update.
  49374. * @param scene defines the scene the material belongs to.
  49375. * @returns - boolean indicating that the submesh is ready or not.
  49376. */
  49377. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49378. /**
  49379. * Checks to see if a texture is used in the material.
  49380. * @param defines the list of "defines" to update.
  49381. * @param scene defines the scene to the material belongs to.
  49382. */
  49383. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49384. /**
  49385. * Binds the material data.
  49386. * @param uniformBuffer defines the Uniform buffer to fill in.
  49387. * @param scene defines the scene the material belongs to.
  49388. * @param engine defines the engine the material belongs to.
  49389. * @param isFrozen defines wether the material is frozen or not.
  49390. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49391. */
  49392. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49393. /**
  49394. * Unbinds the material from the mesh.
  49395. * @param activeEffect defines the effect that should be unbound from.
  49396. * @returns true if unbound, otherwise false
  49397. */
  49398. unbind(activeEffect: Effect): boolean;
  49399. /**
  49400. * Returns the texture used for refraction or null if none is used.
  49401. * @param scene defines the scene the material belongs to.
  49402. * @returns - Refraction texture if present. If no refraction texture and refraction
  49403. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49404. */
  49405. private _getRefractionTexture;
  49406. /**
  49407. * Returns true if alpha blending should be disabled.
  49408. */
  49409. readonly disableAlphaBlending: boolean;
  49410. /**
  49411. * Fills the list of render target textures.
  49412. * @param renderTargets the list of render targets to update
  49413. */
  49414. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49415. /**
  49416. * Checks to see if a texture is used in the material.
  49417. * @param texture - Base texture to use.
  49418. * @returns - Boolean specifying if a texture is used in the material.
  49419. */
  49420. hasTexture(texture: BaseTexture): boolean;
  49421. /**
  49422. * Gets a boolean indicating that current material needs to register RTT
  49423. * @returns true if this uses a render target otherwise false.
  49424. */
  49425. hasRenderTargetTextures(): boolean;
  49426. /**
  49427. * Returns an array of the actively used textures.
  49428. * @param activeTextures Array of BaseTextures
  49429. */
  49430. getActiveTextures(activeTextures: BaseTexture[]): void;
  49431. /**
  49432. * Returns the animatable textures.
  49433. * @param animatables Array of animatable textures.
  49434. */
  49435. getAnimatables(animatables: IAnimatable[]): void;
  49436. /**
  49437. * Disposes the resources of the material.
  49438. * @param forceDisposeTextures - Forces the disposal of all textures.
  49439. */
  49440. dispose(forceDisposeTextures?: boolean): void;
  49441. /**
  49442. * Get the current class name of the texture useful for serialization or dynamic coding.
  49443. * @returns "PBRSubSurfaceConfiguration"
  49444. */
  49445. getClassName(): string;
  49446. /**
  49447. * Add fallbacks to the effect fallbacks list.
  49448. * @param defines defines the Base texture to use.
  49449. * @param fallbacks defines the current fallback list.
  49450. * @param currentRank defines the current fallback rank.
  49451. * @returns the new fallback rank.
  49452. */
  49453. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49454. /**
  49455. * Add the required uniforms to the current list.
  49456. * @param uniforms defines the current uniform list.
  49457. */
  49458. static AddUniforms(uniforms: string[]): void;
  49459. /**
  49460. * Add the required samplers to the current list.
  49461. * @param samplers defines the current sampler list.
  49462. */
  49463. static AddSamplers(samplers: string[]): void;
  49464. /**
  49465. * Add the required uniforms to the current buffer.
  49466. * @param uniformBuffer defines the current uniform buffer.
  49467. */
  49468. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49469. /**
  49470. * Makes a duplicate of the current configuration into another one.
  49471. * @param configuration define the config where to copy the info
  49472. */
  49473. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49474. /**
  49475. * Serializes this Sub Surface configuration.
  49476. * @returns - An object with the serialized config.
  49477. */
  49478. serialize(): any;
  49479. /**
  49480. * Parses a anisotropy Configuration from a serialized object.
  49481. * @param source - Serialized object.
  49482. * @param scene Defines the scene we are parsing for
  49483. * @param rootUrl Defines the rootUrl to load from
  49484. */
  49485. parse(source: any, scene: Scene, rootUrl: string): void;
  49486. }
  49487. }
  49488. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49489. /** @hidden */
  49490. export var pbrFragmentDeclaration: {
  49491. name: string;
  49492. shader: string;
  49493. };
  49494. }
  49495. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49496. /** @hidden */
  49497. export var pbrUboDeclaration: {
  49498. name: string;
  49499. shader: string;
  49500. };
  49501. }
  49502. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49503. /** @hidden */
  49504. export var pbrFragmentExtraDeclaration: {
  49505. name: string;
  49506. shader: string;
  49507. };
  49508. }
  49509. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49510. /** @hidden */
  49511. export var pbrFragmentSamplersDeclaration: {
  49512. name: string;
  49513. shader: string;
  49514. };
  49515. }
  49516. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49517. /** @hidden */
  49518. export var pbrHelperFunctions: {
  49519. name: string;
  49520. shader: string;
  49521. };
  49522. }
  49523. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49524. /** @hidden */
  49525. export var harmonicsFunctions: {
  49526. name: string;
  49527. shader: string;
  49528. };
  49529. }
  49530. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49531. /** @hidden */
  49532. export var pbrDirectLightingSetupFunctions: {
  49533. name: string;
  49534. shader: string;
  49535. };
  49536. }
  49537. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49538. /** @hidden */
  49539. export var pbrDirectLightingFalloffFunctions: {
  49540. name: string;
  49541. shader: string;
  49542. };
  49543. }
  49544. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49545. /** @hidden */
  49546. export var pbrBRDFFunctions: {
  49547. name: string;
  49548. shader: string;
  49549. };
  49550. }
  49551. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49552. /** @hidden */
  49553. export var pbrDirectLightingFunctions: {
  49554. name: string;
  49555. shader: string;
  49556. };
  49557. }
  49558. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49559. /** @hidden */
  49560. export var pbrIBLFunctions: {
  49561. name: string;
  49562. shader: string;
  49563. };
  49564. }
  49565. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49566. /** @hidden */
  49567. export var pbrDebug: {
  49568. name: string;
  49569. shader: string;
  49570. };
  49571. }
  49572. declare module "babylonjs/Shaders/pbr.fragment" {
  49573. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49574. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49575. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49576. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49577. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49578. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49579. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49580. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49581. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49582. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49583. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49584. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49585. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49586. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49587. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49588. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49589. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49590. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49591. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49592. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49593. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49594. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49595. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49596. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49597. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49598. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49599. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49600. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49601. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49602. /** @hidden */
  49603. export var pbrPixelShader: {
  49604. name: string;
  49605. shader: string;
  49606. };
  49607. }
  49608. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49609. /** @hidden */
  49610. export var pbrVertexDeclaration: {
  49611. name: string;
  49612. shader: string;
  49613. };
  49614. }
  49615. declare module "babylonjs/Shaders/pbr.vertex" {
  49616. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49617. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49618. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49619. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49620. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49621. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49622. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49623. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49624. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49625. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49626. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49627. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49629. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49631. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49632. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49633. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49634. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49635. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49636. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49637. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49638. /** @hidden */
  49639. export var pbrVertexShader: {
  49640. name: string;
  49641. shader: string;
  49642. };
  49643. }
  49644. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49645. import { Nullable } from "babylonjs/types";
  49646. import { Scene } from "babylonjs/scene";
  49647. import { Matrix } from "babylonjs/Maths/math.vector";
  49648. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49650. import { Mesh } from "babylonjs/Meshes/mesh";
  49651. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49652. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49653. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49654. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49655. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49656. import { Color3 } from "babylonjs/Maths/math.color";
  49657. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49658. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  49659. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49660. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49662. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49663. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49664. import "babylonjs/Shaders/pbr.fragment";
  49665. import "babylonjs/Shaders/pbr.vertex";
  49666. /**
  49667. * Manages the defines for the PBR Material.
  49668. * @hidden
  49669. */
  49670. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49671. PBR: boolean;
  49672. MAINUV1: boolean;
  49673. MAINUV2: boolean;
  49674. UV1: boolean;
  49675. UV2: boolean;
  49676. ALBEDO: boolean;
  49677. ALBEDODIRECTUV: number;
  49678. VERTEXCOLOR: boolean;
  49679. AMBIENT: boolean;
  49680. AMBIENTDIRECTUV: number;
  49681. AMBIENTINGRAYSCALE: boolean;
  49682. OPACITY: boolean;
  49683. VERTEXALPHA: boolean;
  49684. OPACITYDIRECTUV: number;
  49685. OPACITYRGB: boolean;
  49686. ALPHATEST: boolean;
  49687. DEPTHPREPASS: boolean;
  49688. ALPHABLEND: boolean;
  49689. ALPHAFROMALBEDO: boolean;
  49690. ALPHATESTVALUE: string;
  49691. SPECULAROVERALPHA: boolean;
  49692. RADIANCEOVERALPHA: boolean;
  49693. ALPHAFRESNEL: boolean;
  49694. LINEARALPHAFRESNEL: boolean;
  49695. PREMULTIPLYALPHA: boolean;
  49696. EMISSIVE: boolean;
  49697. EMISSIVEDIRECTUV: number;
  49698. REFLECTIVITY: boolean;
  49699. REFLECTIVITYDIRECTUV: number;
  49700. SPECULARTERM: boolean;
  49701. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49702. MICROSURFACEAUTOMATIC: boolean;
  49703. LODBASEDMICROSFURACE: boolean;
  49704. MICROSURFACEMAP: boolean;
  49705. MICROSURFACEMAPDIRECTUV: number;
  49706. METALLICWORKFLOW: boolean;
  49707. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49708. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49709. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49710. AOSTOREINMETALMAPRED: boolean;
  49711. ENVIRONMENTBRDF: boolean;
  49712. ENVIRONMENTBRDF_RGBD: boolean;
  49713. NORMAL: boolean;
  49714. TANGENT: boolean;
  49715. BUMP: boolean;
  49716. BUMPDIRECTUV: number;
  49717. OBJECTSPACE_NORMALMAP: boolean;
  49718. PARALLAX: boolean;
  49719. PARALLAXOCCLUSION: boolean;
  49720. NORMALXYSCALE: boolean;
  49721. LIGHTMAP: boolean;
  49722. LIGHTMAPDIRECTUV: number;
  49723. USELIGHTMAPASSHADOWMAP: boolean;
  49724. GAMMALIGHTMAP: boolean;
  49725. RGBDLIGHTMAP: boolean;
  49726. REFLECTION: boolean;
  49727. REFLECTIONMAP_3D: boolean;
  49728. REFLECTIONMAP_SPHERICAL: boolean;
  49729. REFLECTIONMAP_PLANAR: boolean;
  49730. REFLECTIONMAP_CUBIC: boolean;
  49731. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49732. REFLECTIONMAP_PROJECTION: boolean;
  49733. REFLECTIONMAP_SKYBOX: boolean;
  49734. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49735. REFLECTIONMAP_EXPLICIT: boolean;
  49736. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49737. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49738. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49739. INVERTCUBICMAP: boolean;
  49740. USESPHERICALFROMREFLECTIONMAP: boolean;
  49741. USEIRRADIANCEMAP: boolean;
  49742. SPHERICAL_HARMONICS: boolean;
  49743. USESPHERICALINVERTEX: boolean;
  49744. REFLECTIONMAP_OPPOSITEZ: boolean;
  49745. LODINREFLECTIONALPHA: boolean;
  49746. GAMMAREFLECTION: boolean;
  49747. RGBDREFLECTION: boolean;
  49748. LINEARSPECULARREFLECTION: boolean;
  49749. RADIANCEOCCLUSION: boolean;
  49750. HORIZONOCCLUSION: boolean;
  49751. INSTANCES: boolean;
  49752. NUM_BONE_INFLUENCERS: number;
  49753. BonesPerMesh: number;
  49754. BONETEXTURE: boolean;
  49755. NONUNIFORMSCALING: boolean;
  49756. MORPHTARGETS: boolean;
  49757. MORPHTARGETS_NORMAL: boolean;
  49758. MORPHTARGETS_TANGENT: boolean;
  49759. MORPHTARGETS_UV: boolean;
  49760. NUM_MORPH_INFLUENCERS: number;
  49761. IMAGEPROCESSING: boolean;
  49762. VIGNETTE: boolean;
  49763. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49764. VIGNETTEBLENDMODEOPAQUE: boolean;
  49765. TONEMAPPING: boolean;
  49766. TONEMAPPING_ACES: boolean;
  49767. CONTRAST: boolean;
  49768. COLORCURVES: boolean;
  49769. COLORGRADING: boolean;
  49770. COLORGRADING3D: boolean;
  49771. SAMPLER3DGREENDEPTH: boolean;
  49772. SAMPLER3DBGRMAP: boolean;
  49773. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49774. EXPOSURE: boolean;
  49775. MULTIVIEW: boolean;
  49776. USEPHYSICALLIGHTFALLOFF: boolean;
  49777. USEGLTFLIGHTFALLOFF: boolean;
  49778. TWOSIDEDLIGHTING: boolean;
  49779. SHADOWFLOAT: boolean;
  49780. CLIPPLANE: boolean;
  49781. CLIPPLANE2: boolean;
  49782. CLIPPLANE3: boolean;
  49783. CLIPPLANE4: boolean;
  49784. POINTSIZE: boolean;
  49785. FOG: boolean;
  49786. LOGARITHMICDEPTH: boolean;
  49787. FORCENORMALFORWARD: boolean;
  49788. SPECULARAA: boolean;
  49789. CLEARCOAT: boolean;
  49790. CLEARCOAT_DEFAULTIOR: boolean;
  49791. CLEARCOAT_TEXTURE: boolean;
  49792. CLEARCOAT_TEXTUREDIRECTUV: number;
  49793. CLEARCOAT_BUMP: boolean;
  49794. CLEARCOAT_BUMPDIRECTUV: number;
  49795. CLEARCOAT_TINT: boolean;
  49796. CLEARCOAT_TINT_TEXTURE: boolean;
  49797. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49798. ANISOTROPIC: boolean;
  49799. ANISOTROPIC_TEXTURE: boolean;
  49800. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49801. BRDF_V_HEIGHT_CORRELATED: boolean;
  49802. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49803. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49804. SHEEN: boolean;
  49805. SHEEN_TEXTURE: boolean;
  49806. SHEEN_TEXTUREDIRECTUV: number;
  49807. SHEEN_LINKWITHALBEDO: boolean;
  49808. SUBSURFACE: boolean;
  49809. SS_REFRACTION: boolean;
  49810. SS_TRANSLUCENCY: boolean;
  49811. SS_SCATERRING: boolean;
  49812. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49813. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49814. SS_REFRACTIONMAP_3D: boolean;
  49815. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49816. SS_LODINREFRACTIONALPHA: boolean;
  49817. SS_GAMMAREFRACTION: boolean;
  49818. SS_RGBDREFRACTION: boolean;
  49819. SS_LINEARSPECULARREFRACTION: boolean;
  49820. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49821. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49822. UNLIT: boolean;
  49823. DEBUGMODE: number;
  49824. /**
  49825. * Initializes the PBR Material defines.
  49826. */
  49827. constructor();
  49828. /**
  49829. * Resets the PBR Material defines.
  49830. */
  49831. reset(): void;
  49832. }
  49833. /**
  49834. * The Physically based material base class of BJS.
  49835. *
  49836. * This offers the main features of a standard PBR material.
  49837. * For more information, please refer to the documentation :
  49838. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49839. */
  49840. export abstract class PBRBaseMaterial extends PushMaterial {
  49841. /**
  49842. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49843. */
  49844. static readonly PBRMATERIAL_OPAQUE: number;
  49845. /**
  49846. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49847. */
  49848. static readonly PBRMATERIAL_ALPHATEST: number;
  49849. /**
  49850. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49851. */
  49852. static readonly PBRMATERIAL_ALPHABLEND: number;
  49853. /**
  49854. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49855. * They are also discarded below the alpha cutoff threshold to improve performances.
  49856. */
  49857. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49858. /**
  49859. * Defines the default value of how much AO map is occluding the analytical lights
  49860. * (point spot...).
  49861. */
  49862. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49863. /**
  49864. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49865. */
  49866. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49867. /**
  49868. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49869. * to enhance interoperability with other engines.
  49870. */
  49871. static readonly LIGHTFALLOFF_GLTF: number;
  49872. /**
  49873. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49874. * to enhance interoperability with other materials.
  49875. */
  49876. static readonly LIGHTFALLOFF_STANDARD: number;
  49877. /**
  49878. * Intensity of the direct lights e.g. the four lights available in your scene.
  49879. * This impacts both the direct diffuse and specular highlights.
  49880. */
  49881. protected _directIntensity: number;
  49882. /**
  49883. * Intensity of the emissive part of the material.
  49884. * This helps controlling the emissive effect without modifying the emissive color.
  49885. */
  49886. protected _emissiveIntensity: number;
  49887. /**
  49888. * Intensity of the environment e.g. how much the environment will light the object
  49889. * either through harmonics for rough material or through the refelction for shiny ones.
  49890. */
  49891. protected _environmentIntensity: number;
  49892. /**
  49893. * This is a special control allowing the reduction of the specular highlights coming from the
  49894. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49895. */
  49896. protected _specularIntensity: number;
  49897. /**
  49898. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49899. */
  49900. private _lightingInfos;
  49901. /**
  49902. * Debug Control allowing disabling the bump map on this material.
  49903. */
  49904. protected _disableBumpMap: boolean;
  49905. /**
  49906. * AKA Diffuse Texture in standard nomenclature.
  49907. */
  49908. protected _albedoTexture: Nullable<BaseTexture>;
  49909. /**
  49910. * AKA Occlusion Texture in other nomenclature.
  49911. */
  49912. protected _ambientTexture: Nullable<BaseTexture>;
  49913. /**
  49914. * AKA Occlusion Texture Intensity in other nomenclature.
  49915. */
  49916. protected _ambientTextureStrength: number;
  49917. /**
  49918. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49919. * 1 means it completely occludes it
  49920. * 0 mean it has no impact
  49921. */
  49922. protected _ambientTextureImpactOnAnalyticalLights: number;
  49923. /**
  49924. * Stores the alpha values in a texture.
  49925. */
  49926. protected _opacityTexture: Nullable<BaseTexture>;
  49927. /**
  49928. * Stores the reflection values in a texture.
  49929. */
  49930. protected _reflectionTexture: Nullable<BaseTexture>;
  49931. /**
  49932. * Stores the emissive values in a texture.
  49933. */
  49934. protected _emissiveTexture: Nullable<BaseTexture>;
  49935. /**
  49936. * AKA Specular texture in other nomenclature.
  49937. */
  49938. protected _reflectivityTexture: Nullable<BaseTexture>;
  49939. /**
  49940. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49941. */
  49942. protected _metallicTexture: Nullable<BaseTexture>;
  49943. /**
  49944. * Specifies the metallic scalar of the metallic/roughness workflow.
  49945. * Can also be used to scale the metalness values of the metallic texture.
  49946. */
  49947. protected _metallic: Nullable<number>;
  49948. /**
  49949. * Specifies the roughness scalar of the metallic/roughness workflow.
  49950. * Can also be used to scale the roughness values of the metallic texture.
  49951. */
  49952. protected _roughness: Nullable<number>;
  49953. /**
  49954. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49955. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49956. */
  49957. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49958. /**
  49959. * Stores surface normal data used to displace a mesh in a texture.
  49960. */
  49961. protected _bumpTexture: Nullable<BaseTexture>;
  49962. /**
  49963. * Stores the pre-calculated light information of a mesh in a texture.
  49964. */
  49965. protected _lightmapTexture: Nullable<BaseTexture>;
  49966. /**
  49967. * The color of a material in ambient lighting.
  49968. */
  49969. protected _ambientColor: Color3;
  49970. /**
  49971. * AKA Diffuse Color in other nomenclature.
  49972. */
  49973. protected _albedoColor: Color3;
  49974. /**
  49975. * AKA Specular Color in other nomenclature.
  49976. */
  49977. protected _reflectivityColor: Color3;
  49978. /**
  49979. * The color applied when light is reflected from a material.
  49980. */
  49981. protected _reflectionColor: Color3;
  49982. /**
  49983. * The color applied when light is emitted from a material.
  49984. */
  49985. protected _emissiveColor: Color3;
  49986. /**
  49987. * AKA Glossiness in other nomenclature.
  49988. */
  49989. protected _microSurface: number;
  49990. /**
  49991. * Specifies that the material will use the light map as a show map.
  49992. */
  49993. protected _useLightmapAsShadowmap: boolean;
  49994. /**
  49995. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49996. * makes the reflect vector face the model (under horizon).
  49997. */
  49998. protected _useHorizonOcclusion: boolean;
  49999. /**
  50000. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50001. * too much the area relying on ambient texture to define their ambient occlusion.
  50002. */
  50003. protected _useRadianceOcclusion: boolean;
  50004. /**
  50005. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50006. */
  50007. protected _useAlphaFromAlbedoTexture: boolean;
  50008. /**
  50009. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50010. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50011. */
  50012. protected _useSpecularOverAlpha: boolean;
  50013. /**
  50014. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50015. */
  50016. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50017. /**
  50018. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50019. */
  50020. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50021. /**
  50022. * Specifies if the metallic texture contains the roughness information in its green channel.
  50023. */
  50024. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50025. /**
  50026. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50027. */
  50028. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50029. /**
  50030. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50031. */
  50032. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50033. /**
  50034. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50035. */
  50036. protected _useAmbientInGrayScale: boolean;
  50037. /**
  50038. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50039. * The material will try to infer what glossiness each pixel should be.
  50040. */
  50041. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50042. /**
  50043. * Defines the falloff type used in this material.
  50044. * It by default is Physical.
  50045. */
  50046. protected _lightFalloff: number;
  50047. /**
  50048. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50049. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50050. */
  50051. protected _useRadianceOverAlpha: boolean;
  50052. /**
  50053. * Allows using an object space normal map (instead of tangent space).
  50054. */
  50055. protected _useObjectSpaceNormalMap: boolean;
  50056. /**
  50057. * Allows using the bump map in parallax mode.
  50058. */
  50059. protected _useParallax: boolean;
  50060. /**
  50061. * Allows using the bump map in parallax occlusion mode.
  50062. */
  50063. protected _useParallaxOcclusion: boolean;
  50064. /**
  50065. * Controls the scale bias of the parallax mode.
  50066. */
  50067. protected _parallaxScaleBias: number;
  50068. /**
  50069. * If sets to true, disables all the lights affecting the material.
  50070. */
  50071. protected _disableLighting: boolean;
  50072. /**
  50073. * Number of Simultaneous lights allowed on the material.
  50074. */
  50075. protected _maxSimultaneousLights: number;
  50076. /**
  50077. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50078. */
  50079. protected _invertNormalMapX: boolean;
  50080. /**
  50081. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50082. */
  50083. protected _invertNormalMapY: boolean;
  50084. /**
  50085. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50086. */
  50087. protected _twoSidedLighting: boolean;
  50088. /**
  50089. * Defines the alpha limits in alpha test mode.
  50090. */
  50091. protected _alphaCutOff: number;
  50092. /**
  50093. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50094. */
  50095. protected _forceAlphaTest: boolean;
  50096. /**
  50097. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50098. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50099. */
  50100. protected _useAlphaFresnel: boolean;
  50101. /**
  50102. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50103. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50104. */
  50105. protected _useLinearAlphaFresnel: boolean;
  50106. /**
  50107. * The transparency mode of the material.
  50108. */
  50109. protected _transparencyMode: Nullable<number>;
  50110. /**
  50111. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50112. * from cos thetav and roughness:
  50113. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50114. */
  50115. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50116. /**
  50117. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50118. */
  50119. protected _forceIrradianceInFragment: boolean;
  50120. /**
  50121. * Force normal to face away from face.
  50122. */
  50123. protected _forceNormalForward: boolean;
  50124. /**
  50125. * Enables specular anti aliasing in the PBR shader.
  50126. * It will both interacts on the Geometry for analytical and IBL lighting.
  50127. * It also prefilter the roughness map based on the bump values.
  50128. */
  50129. protected _enableSpecularAntiAliasing: boolean;
  50130. /**
  50131. * Default configuration related to image processing available in the PBR Material.
  50132. */
  50133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50134. /**
  50135. * Keep track of the image processing observer to allow dispose and replace.
  50136. */
  50137. private _imageProcessingObserver;
  50138. /**
  50139. * Attaches a new image processing configuration to the PBR Material.
  50140. * @param configuration
  50141. */
  50142. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50143. /**
  50144. * Stores the available render targets.
  50145. */
  50146. private _renderTargets;
  50147. /**
  50148. * Sets the global ambient color for the material used in lighting calculations.
  50149. */
  50150. private _globalAmbientColor;
  50151. /**
  50152. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50153. */
  50154. private _useLogarithmicDepth;
  50155. /**
  50156. * If set to true, no lighting calculations will be applied.
  50157. */
  50158. private _unlit;
  50159. private _debugMode;
  50160. /**
  50161. * @hidden
  50162. * This is reserved for the inspector.
  50163. * Defines the material debug mode.
  50164. * It helps seeing only some components of the material while troubleshooting.
  50165. */
  50166. debugMode: number;
  50167. /**
  50168. * @hidden
  50169. * This is reserved for the inspector.
  50170. * Specify from where on screen the debug mode should start.
  50171. * The value goes from -1 (full screen) to 1 (not visible)
  50172. * It helps with side by side comparison against the final render
  50173. * This defaults to -1
  50174. */
  50175. private debugLimit;
  50176. /**
  50177. * @hidden
  50178. * This is reserved for the inspector.
  50179. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50180. * You can use the factor to better multiply the final value.
  50181. */
  50182. private debugFactor;
  50183. /**
  50184. * Defines the clear coat layer parameters for the material.
  50185. */
  50186. readonly clearCoat: PBRClearCoatConfiguration;
  50187. /**
  50188. * Defines the anisotropic parameters for the material.
  50189. */
  50190. readonly anisotropy: PBRAnisotropicConfiguration;
  50191. /**
  50192. * Defines the BRDF parameters for the material.
  50193. */
  50194. readonly brdf: PBRBRDFConfiguration;
  50195. /**
  50196. * Defines the Sheen parameters for the material.
  50197. */
  50198. readonly sheen: PBRSheenConfiguration;
  50199. /**
  50200. * Defines the SubSurface parameters for the material.
  50201. */
  50202. readonly subSurface: PBRSubSurfaceConfiguration;
  50203. /**
  50204. * Custom callback helping to override the default shader used in the material.
  50205. */
  50206. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50207. protected _rebuildInParallel: boolean;
  50208. /**
  50209. * Instantiates a new PBRMaterial instance.
  50210. *
  50211. * @param name The material name
  50212. * @param scene The scene the material will be use in.
  50213. */
  50214. constructor(name: string, scene: Scene);
  50215. /**
  50216. * Gets a boolean indicating that current material needs to register RTT
  50217. */
  50218. readonly hasRenderTargetTextures: boolean;
  50219. /**
  50220. * Gets the name of the material class.
  50221. */
  50222. getClassName(): string;
  50223. /**
  50224. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50225. */
  50226. /**
  50227. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50228. */
  50229. useLogarithmicDepth: boolean;
  50230. /**
  50231. * Gets the current transparency mode.
  50232. */
  50233. /**
  50234. * Sets the transparency mode of the material.
  50235. *
  50236. * | Value | Type | Description |
  50237. * | ----- | ----------------------------------- | ----------- |
  50238. * | 0 | OPAQUE | |
  50239. * | 1 | ALPHATEST | |
  50240. * | 2 | ALPHABLEND | |
  50241. * | 3 | ALPHATESTANDBLEND | |
  50242. *
  50243. */
  50244. transparencyMode: Nullable<number>;
  50245. /**
  50246. * Returns true if alpha blending should be disabled.
  50247. */
  50248. private readonly _disableAlphaBlending;
  50249. /**
  50250. * Specifies whether or not this material should be rendered in alpha blend mode.
  50251. */
  50252. needAlphaBlending(): boolean;
  50253. /**
  50254. * Specifies if the mesh will require alpha blending.
  50255. * @param mesh - BJS mesh.
  50256. */
  50257. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50258. /**
  50259. * Specifies whether or not this material should be rendered in alpha test mode.
  50260. */
  50261. needAlphaTesting(): boolean;
  50262. /**
  50263. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50264. */
  50265. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50266. /**
  50267. * Gets the texture used for the alpha test.
  50268. */
  50269. getAlphaTestTexture(): Nullable<BaseTexture>;
  50270. /**
  50271. * Specifies that the submesh is ready to be used.
  50272. * @param mesh - BJS mesh.
  50273. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50274. * @param useInstances - Specifies that instances should be used.
  50275. * @returns - boolean indicating that the submesh is ready or not.
  50276. */
  50277. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50278. /**
  50279. * Specifies if the material uses metallic roughness workflow.
  50280. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50281. */
  50282. isMetallicWorkflow(): boolean;
  50283. private _prepareEffect;
  50284. private _prepareDefines;
  50285. /**
  50286. * Force shader compilation
  50287. */
  50288. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50289. /**
  50290. * Initializes the uniform buffer layout for the shader.
  50291. */
  50292. buildUniformLayout(): void;
  50293. /**
  50294. * Unbinds the material from the mesh
  50295. */
  50296. unbind(): void;
  50297. /**
  50298. * Binds the submesh data.
  50299. * @param world - The world matrix.
  50300. * @param mesh - The BJS mesh.
  50301. * @param subMesh - A submesh of the BJS mesh.
  50302. */
  50303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50304. /**
  50305. * Returns the animatable textures.
  50306. * @returns - Array of animatable textures.
  50307. */
  50308. getAnimatables(): IAnimatable[];
  50309. /**
  50310. * Returns the texture used for reflections.
  50311. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50312. */
  50313. private _getReflectionTexture;
  50314. /**
  50315. * Returns an array of the actively used textures.
  50316. * @returns - Array of BaseTextures
  50317. */
  50318. getActiveTextures(): BaseTexture[];
  50319. /**
  50320. * Checks to see if a texture is used in the material.
  50321. * @param texture - Base texture to use.
  50322. * @returns - Boolean specifying if a texture is used in the material.
  50323. */
  50324. hasTexture(texture: BaseTexture): boolean;
  50325. /**
  50326. * Disposes the resources of the material.
  50327. * @param forceDisposeEffect - Forces the disposal of effects.
  50328. * @param forceDisposeTextures - Forces the disposal of all textures.
  50329. */
  50330. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50331. }
  50332. }
  50333. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50334. import { Nullable } from "babylonjs/types";
  50335. import { Scene } from "babylonjs/scene";
  50336. import { Color3 } from "babylonjs/Maths/math.color";
  50337. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50338. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50340. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50341. /**
  50342. * The Physically based material of BJS.
  50343. *
  50344. * This offers the main features of a standard PBR material.
  50345. * For more information, please refer to the documentation :
  50346. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50347. */
  50348. export class PBRMaterial extends PBRBaseMaterial {
  50349. /**
  50350. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50351. */
  50352. static readonly PBRMATERIAL_OPAQUE: number;
  50353. /**
  50354. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50355. */
  50356. static readonly PBRMATERIAL_ALPHATEST: number;
  50357. /**
  50358. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50359. */
  50360. static readonly PBRMATERIAL_ALPHABLEND: number;
  50361. /**
  50362. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50363. * They are also discarded below the alpha cutoff threshold to improve performances.
  50364. */
  50365. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50366. /**
  50367. * Defines the default value of how much AO map is occluding the analytical lights
  50368. * (point spot...).
  50369. */
  50370. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50371. /**
  50372. * Intensity of the direct lights e.g. the four lights available in your scene.
  50373. * This impacts both the direct diffuse and specular highlights.
  50374. */
  50375. directIntensity: number;
  50376. /**
  50377. * Intensity of the emissive part of the material.
  50378. * This helps controlling the emissive effect without modifying the emissive color.
  50379. */
  50380. emissiveIntensity: number;
  50381. /**
  50382. * Intensity of the environment e.g. how much the environment will light the object
  50383. * either through harmonics for rough material or through the refelction for shiny ones.
  50384. */
  50385. environmentIntensity: number;
  50386. /**
  50387. * This is a special control allowing the reduction of the specular highlights coming from the
  50388. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50389. */
  50390. specularIntensity: number;
  50391. /**
  50392. * Debug Control allowing disabling the bump map on this material.
  50393. */
  50394. disableBumpMap: boolean;
  50395. /**
  50396. * AKA Diffuse Texture in standard nomenclature.
  50397. */
  50398. albedoTexture: BaseTexture;
  50399. /**
  50400. * AKA Occlusion Texture in other nomenclature.
  50401. */
  50402. ambientTexture: BaseTexture;
  50403. /**
  50404. * AKA Occlusion Texture Intensity in other nomenclature.
  50405. */
  50406. ambientTextureStrength: number;
  50407. /**
  50408. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50409. * 1 means it completely occludes it
  50410. * 0 mean it has no impact
  50411. */
  50412. ambientTextureImpactOnAnalyticalLights: number;
  50413. /**
  50414. * Stores the alpha values in a texture.
  50415. */
  50416. opacityTexture: BaseTexture;
  50417. /**
  50418. * Stores the reflection values in a texture.
  50419. */
  50420. reflectionTexture: Nullable<BaseTexture>;
  50421. /**
  50422. * Stores the emissive values in a texture.
  50423. */
  50424. emissiveTexture: BaseTexture;
  50425. /**
  50426. * AKA Specular texture in other nomenclature.
  50427. */
  50428. reflectivityTexture: BaseTexture;
  50429. /**
  50430. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50431. */
  50432. metallicTexture: BaseTexture;
  50433. /**
  50434. * Specifies the metallic scalar of the metallic/roughness workflow.
  50435. * Can also be used to scale the metalness values of the metallic texture.
  50436. */
  50437. metallic: Nullable<number>;
  50438. /**
  50439. * Specifies the roughness scalar of the metallic/roughness workflow.
  50440. * Can also be used to scale the roughness values of the metallic texture.
  50441. */
  50442. roughness: Nullable<number>;
  50443. /**
  50444. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50445. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50446. */
  50447. microSurfaceTexture: BaseTexture;
  50448. /**
  50449. * Stores surface normal data used to displace a mesh in a texture.
  50450. */
  50451. bumpTexture: BaseTexture;
  50452. /**
  50453. * Stores the pre-calculated light information of a mesh in a texture.
  50454. */
  50455. lightmapTexture: BaseTexture;
  50456. /**
  50457. * Stores the refracted light information in a texture.
  50458. */
  50459. refractionTexture: Nullable<BaseTexture>;
  50460. /**
  50461. * The color of a material in ambient lighting.
  50462. */
  50463. ambientColor: Color3;
  50464. /**
  50465. * AKA Diffuse Color in other nomenclature.
  50466. */
  50467. albedoColor: Color3;
  50468. /**
  50469. * AKA Specular Color in other nomenclature.
  50470. */
  50471. reflectivityColor: Color3;
  50472. /**
  50473. * The color reflected from the material.
  50474. */
  50475. reflectionColor: Color3;
  50476. /**
  50477. * The color emitted from the material.
  50478. */
  50479. emissiveColor: Color3;
  50480. /**
  50481. * AKA Glossiness in other nomenclature.
  50482. */
  50483. microSurface: number;
  50484. /**
  50485. * source material index of refraction (IOR)' / 'destination material IOR.
  50486. */
  50487. indexOfRefraction: number;
  50488. /**
  50489. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50490. */
  50491. invertRefractionY: boolean;
  50492. /**
  50493. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50494. * Materials half opaque for instance using refraction could benefit from this control.
  50495. */
  50496. linkRefractionWithTransparency: boolean;
  50497. /**
  50498. * If true, the light map contains occlusion information instead of lighting info.
  50499. */
  50500. useLightmapAsShadowmap: boolean;
  50501. /**
  50502. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50503. */
  50504. useAlphaFromAlbedoTexture: boolean;
  50505. /**
  50506. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50507. */
  50508. forceAlphaTest: boolean;
  50509. /**
  50510. * Defines the alpha limits in alpha test mode.
  50511. */
  50512. alphaCutOff: number;
  50513. /**
  50514. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50515. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50516. */
  50517. useSpecularOverAlpha: boolean;
  50518. /**
  50519. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50520. */
  50521. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50522. /**
  50523. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50524. */
  50525. useRoughnessFromMetallicTextureAlpha: boolean;
  50526. /**
  50527. * Specifies if the metallic texture contains the roughness information in its green channel.
  50528. */
  50529. useRoughnessFromMetallicTextureGreen: boolean;
  50530. /**
  50531. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50532. */
  50533. useMetallnessFromMetallicTextureBlue: boolean;
  50534. /**
  50535. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50536. */
  50537. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50538. /**
  50539. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50540. */
  50541. useAmbientInGrayScale: boolean;
  50542. /**
  50543. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50544. * The material will try to infer what glossiness each pixel should be.
  50545. */
  50546. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50547. /**
  50548. * BJS is using an harcoded light falloff based on a manually sets up range.
  50549. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50550. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50551. */
  50552. /**
  50553. * BJS is using an harcoded light falloff based on a manually sets up range.
  50554. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50555. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50556. */
  50557. usePhysicalLightFalloff: boolean;
  50558. /**
  50559. * In order to support the falloff compatibility with gltf, a special mode has been added
  50560. * to reproduce the gltf light falloff.
  50561. */
  50562. /**
  50563. * In order to support the falloff compatibility with gltf, a special mode has been added
  50564. * to reproduce the gltf light falloff.
  50565. */
  50566. useGLTFLightFalloff: boolean;
  50567. /**
  50568. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50569. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50570. */
  50571. useRadianceOverAlpha: boolean;
  50572. /**
  50573. * Allows using an object space normal map (instead of tangent space).
  50574. */
  50575. useObjectSpaceNormalMap: boolean;
  50576. /**
  50577. * Allows using the bump map in parallax mode.
  50578. */
  50579. useParallax: boolean;
  50580. /**
  50581. * Allows using the bump map in parallax occlusion mode.
  50582. */
  50583. useParallaxOcclusion: boolean;
  50584. /**
  50585. * Controls the scale bias of the parallax mode.
  50586. */
  50587. parallaxScaleBias: number;
  50588. /**
  50589. * If sets to true, disables all the lights affecting the material.
  50590. */
  50591. disableLighting: boolean;
  50592. /**
  50593. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50594. */
  50595. forceIrradianceInFragment: boolean;
  50596. /**
  50597. * Number of Simultaneous lights allowed on the material.
  50598. */
  50599. maxSimultaneousLights: number;
  50600. /**
  50601. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50602. */
  50603. invertNormalMapX: boolean;
  50604. /**
  50605. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50606. */
  50607. invertNormalMapY: boolean;
  50608. /**
  50609. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50610. */
  50611. twoSidedLighting: boolean;
  50612. /**
  50613. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50614. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50615. */
  50616. useAlphaFresnel: boolean;
  50617. /**
  50618. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50619. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50620. */
  50621. useLinearAlphaFresnel: boolean;
  50622. /**
  50623. * Let user defines the brdf lookup texture used for IBL.
  50624. * A default 8bit version is embedded but you could point at :
  50625. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50626. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50627. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50628. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50629. */
  50630. environmentBRDFTexture: Nullable<BaseTexture>;
  50631. /**
  50632. * Force normal to face away from face.
  50633. */
  50634. forceNormalForward: boolean;
  50635. /**
  50636. * Enables specular anti aliasing in the PBR shader.
  50637. * It will both interacts on the Geometry for analytical and IBL lighting.
  50638. * It also prefilter the roughness map based on the bump values.
  50639. */
  50640. enableSpecularAntiAliasing: boolean;
  50641. /**
  50642. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50643. * makes the reflect vector face the model (under horizon).
  50644. */
  50645. useHorizonOcclusion: boolean;
  50646. /**
  50647. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50648. * too much the area relying on ambient texture to define their ambient occlusion.
  50649. */
  50650. useRadianceOcclusion: boolean;
  50651. /**
  50652. * If set to true, no lighting calculations will be applied.
  50653. */
  50654. unlit: boolean;
  50655. /**
  50656. * Gets the image processing configuration used either in this material.
  50657. */
  50658. /**
  50659. * Sets the Default image processing configuration used either in the this material.
  50660. *
  50661. * If sets to null, the scene one is in use.
  50662. */
  50663. imageProcessingConfiguration: ImageProcessingConfiguration;
  50664. /**
  50665. * Gets wether the color curves effect is enabled.
  50666. */
  50667. /**
  50668. * Sets wether the color curves effect is enabled.
  50669. */
  50670. cameraColorCurvesEnabled: boolean;
  50671. /**
  50672. * Gets wether the color grading effect is enabled.
  50673. */
  50674. /**
  50675. * Gets wether the color grading effect is enabled.
  50676. */
  50677. cameraColorGradingEnabled: boolean;
  50678. /**
  50679. * Gets wether tonemapping is enabled or not.
  50680. */
  50681. /**
  50682. * Sets wether tonemapping is enabled or not
  50683. */
  50684. cameraToneMappingEnabled: boolean;
  50685. /**
  50686. * The camera exposure used on this material.
  50687. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50688. * This corresponds to a photographic exposure.
  50689. */
  50690. /**
  50691. * The camera exposure used on this material.
  50692. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50693. * This corresponds to a photographic exposure.
  50694. */
  50695. cameraExposure: number;
  50696. /**
  50697. * Gets The camera contrast used on this material.
  50698. */
  50699. /**
  50700. * Sets The camera contrast used on this material.
  50701. */
  50702. cameraContrast: number;
  50703. /**
  50704. * Gets the Color Grading 2D Lookup Texture.
  50705. */
  50706. /**
  50707. * Sets the Color Grading 2D Lookup Texture.
  50708. */
  50709. cameraColorGradingTexture: Nullable<BaseTexture>;
  50710. /**
  50711. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50712. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50713. * 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;
  50714. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50715. */
  50716. /**
  50717. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50718. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50719. * 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;
  50720. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50721. */
  50722. cameraColorCurves: Nullable<ColorCurves>;
  50723. /**
  50724. * Instantiates a new PBRMaterial instance.
  50725. *
  50726. * @param name The material name
  50727. * @param scene The scene the material will be use in.
  50728. */
  50729. constructor(name: string, scene: Scene);
  50730. /**
  50731. * Returns the name of this material class.
  50732. */
  50733. getClassName(): string;
  50734. /**
  50735. * Makes a duplicate of the current material.
  50736. * @param name - name to use for the new material.
  50737. */
  50738. clone(name: string): PBRMaterial;
  50739. /**
  50740. * Serializes this PBR Material.
  50741. * @returns - An object with the serialized material.
  50742. */
  50743. serialize(): any;
  50744. /**
  50745. * Parses a PBR Material from a serialized object.
  50746. * @param source - Serialized object.
  50747. * @param scene - BJS scene instance.
  50748. * @param rootUrl - url for the scene object
  50749. * @returns - PBRMaterial
  50750. */
  50751. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50752. }
  50753. }
  50754. declare module "babylonjs/Misc/dds" {
  50755. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50757. import { Nullable } from "babylonjs/types";
  50758. import { Scene } from "babylonjs/scene";
  50759. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50760. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50761. /**
  50762. * Direct draw surface info
  50763. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50764. */
  50765. export interface DDSInfo {
  50766. /**
  50767. * Width of the texture
  50768. */
  50769. width: number;
  50770. /**
  50771. * Width of the texture
  50772. */
  50773. height: number;
  50774. /**
  50775. * Number of Mipmaps for the texture
  50776. * @see https://en.wikipedia.org/wiki/Mipmap
  50777. */
  50778. mipmapCount: number;
  50779. /**
  50780. * If the textures format is a known fourCC format
  50781. * @see https://www.fourcc.org/
  50782. */
  50783. isFourCC: boolean;
  50784. /**
  50785. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50786. */
  50787. isRGB: boolean;
  50788. /**
  50789. * If the texture is a lumincance format
  50790. */
  50791. isLuminance: boolean;
  50792. /**
  50793. * If this is a cube texture
  50794. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50795. */
  50796. isCube: boolean;
  50797. /**
  50798. * If the texture is a compressed format eg. FOURCC_DXT1
  50799. */
  50800. isCompressed: boolean;
  50801. /**
  50802. * The dxgiFormat of the texture
  50803. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50804. */
  50805. dxgiFormat: number;
  50806. /**
  50807. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50808. */
  50809. textureType: number;
  50810. /**
  50811. * Sphericle polynomial created for the dds texture
  50812. */
  50813. sphericalPolynomial?: SphericalPolynomial;
  50814. }
  50815. /**
  50816. * Class used to provide DDS decompression tools
  50817. */
  50818. export class DDSTools {
  50819. /**
  50820. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50821. */
  50822. static StoreLODInAlphaChannel: boolean;
  50823. /**
  50824. * Gets DDS information from an array buffer
  50825. * @param arrayBuffer defines the array buffer to read data from
  50826. * @returns the DDS information
  50827. */
  50828. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50829. private static _FloatView;
  50830. private static _Int32View;
  50831. private static _ToHalfFloat;
  50832. private static _FromHalfFloat;
  50833. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50834. private static _GetHalfFloatRGBAArrayBuffer;
  50835. private static _GetFloatRGBAArrayBuffer;
  50836. private static _GetFloatAsUIntRGBAArrayBuffer;
  50837. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50838. private static _GetRGBAArrayBuffer;
  50839. private static _ExtractLongWordOrder;
  50840. private static _GetRGBArrayBuffer;
  50841. private static _GetLuminanceArrayBuffer;
  50842. /**
  50843. * Uploads DDS Levels to a Babylon Texture
  50844. * @hidden
  50845. */
  50846. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50847. }
  50848. module "babylonjs/Engines/thinEngine" {
  50849. interface ThinEngine {
  50850. /**
  50851. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50852. * @param rootUrl defines the url where the file to load is located
  50853. * @param scene defines the current scene
  50854. * @param lodScale defines scale to apply to the mip map selection
  50855. * @param lodOffset defines offset to apply to the mip map selection
  50856. * @param onLoad defines an optional callback raised when the texture is loaded
  50857. * @param onError defines an optional callback raised if there is an issue to load the texture
  50858. * @param format defines the format of the data
  50859. * @param forcedExtension defines the extension to use to pick the right loader
  50860. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50861. * @returns the cube texture as an InternalTexture
  50862. */
  50863. 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;
  50864. }
  50865. }
  50866. }
  50867. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50868. import { Nullable } from "babylonjs/types";
  50869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50870. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50871. /**
  50872. * Implementation of the DDS Texture Loader.
  50873. * @hidden
  50874. */
  50875. export class _DDSTextureLoader implements IInternalTextureLoader {
  50876. /**
  50877. * Defines wether the loader supports cascade loading the different faces.
  50878. */
  50879. readonly supportCascades: boolean;
  50880. /**
  50881. * This returns if the loader support the current file information.
  50882. * @param extension defines the file extension of the file being loaded
  50883. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50884. * @param fallback defines the fallback internal texture if any
  50885. * @param isBase64 defines whether the texture is encoded as a base64
  50886. * @param isBuffer defines whether the texture data are stored as a buffer
  50887. * @returns true if the loader can load the specified file
  50888. */
  50889. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50890. /**
  50891. * Transform the url before loading if required.
  50892. * @param rootUrl the url of the texture
  50893. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50894. * @returns the transformed texture
  50895. */
  50896. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50897. /**
  50898. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50899. * @param rootUrl the url of the texture
  50900. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50901. * @returns the fallback texture
  50902. */
  50903. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50904. /**
  50905. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50906. * @param data contains the texture data
  50907. * @param texture defines the BabylonJS internal texture
  50908. * @param createPolynomials will be true if polynomials have been requested
  50909. * @param onLoad defines the callback to trigger once the texture is ready
  50910. * @param onError defines the callback to trigger in case of error
  50911. */
  50912. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50913. /**
  50914. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50915. * @param data contains the texture data
  50916. * @param texture defines the BabylonJS internal texture
  50917. * @param callback defines the method to call once ready to upload
  50918. */
  50919. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50920. }
  50921. }
  50922. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50923. import { Nullable } from "babylonjs/types";
  50924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50925. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50926. /**
  50927. * Implementation of the ENV Texture Loader.
  50928. * @hidden
  50929. */
  50930. export class _ENVTextureLoader implements IInternalTextureLoader {
  50931. /**
  50932. * Defines wether the loader supports cascade loading the different faces.
  50933. */
  50934. readonly supportCascades: boolean;
  50935. /**
  50936. * This returns if the loader support the current file information.
  50937. * @param extension defines the file extension of the file being loaded
  50938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50939. * @param fallback defines the fallback internal texture if any
  50940. * @param isBase64 defines whether the texture is encoded as a base64
  50941. * @param isBuffer defines whether the texture data are stored as a buffer
  50942. * @returns true if the loader can load the specified file
  50943. */
  50944. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50945. /**
  50946. * Transform the url before loading if required.
  50947. * @param rootUrl the url of the texture
  50948. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50949. * @returns the transformed texture
  50950. */
  50951. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50952. /**
  50953. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50954. * @param rootUrl the url of the texture
  50955. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50956. * @returns the fallback texture
  50957. */
  50958. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50959. /**
  50960. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50961. * @param data contains the texture data
  50962. * @param texture defines the BabylonJS internal texture
  50963. * @param createPolynomials will be true if polynomials have been requested
  50964. * @param onLoad defines the callback to trigger once the texture is ready
  50965. * @param onError defines the callback to trigger in case of error
  50966. */
  50967. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50968. /**
  50969. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50970. * @param data contains the texture data
  50971. * @param texture defines the BabylonJS internal texture
  50972. * @param callback defines the method to call once ready to upload
  50973. */
  50974. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50975. }
  50976. }
  50977. declare module "babylonjs/Misc/khronosTextureContainer" {
  50978. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50979. /**
  50980. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50981. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50982. */
  50983. export class KhronosTextureContainer {
  50984. /** contents of the KTX container file */
  50985. arrayBuffer: any;
  50986. private static HEADER_LEN;
  50987. private static COMPRESSED_2D;
  50988. private static COMPRESSED_3D;
  50989. private static TEX_2D;
  50990. private static TEX_3D;
  50991. /**
  50992. * Gets the openGL type
  50993. */
  50994. glType: number;
  50995. /**
  50996. * Gets the openGL type size
  50997. */
  50998. glTypeSize: number;
  50999. /**
  51000. * Gets the openGL format
  51001. */
  51002. glFormat: number;
  51003. /**
  51004. * Gets the openGL internal format
  51005. */
  51006. glInternalFormat: number;
  51007. /**
  51008. * Gets the base internal format
  51009. */
  51010. glBaseInternalFormat: number;
  51011. /**
  51012. * Gets image width in pixel
  51013. */
  51014. pixelWidth: number;
  51015. /**
  51016. * Gets image height in pixel
  51017. */
  51018. pixelHeight: number;
  51019. /**
  51020. * Gets image depth in pixels
  51021. */
  51022. pixelDepth: number;
  51023. /**
  51024. * Gets the number of array elements
  51025. */
  51026. numberOfArrayElements: number;
  51027. /**
  51028. * Gets the number of faces
  51029. */
  51030. numberOfFaces: number;
  51031. /**
  51032. * Gets the number of mipmap levels
  51033. */
  51034. numberOfMipmapLevels: number;
  51035. /**
  51036. * Gets the bytes of key value data
  51037. */
  51038. bytesOfKeyValueData: number;
  51039. /**
  51040. * Gets the load type
  51041. */
  51042. loadType: number;
  51043. /**
  51044. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51045. */
  51046. isInvalid: boolean;
  51047. /**
  51048. * Creates a new KhronosTextureContainer
  51049. * @param arrayBuffer contents of the KTX container file
  51050. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51051. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51052. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51053. */
  51054. constructor(
  51055. /** contents of the KTX container file */
  51056. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51057. /**
  51058. * Uploads KTX content to a Babylon Texture.
  51059. * It is assumed that the texture has already been created & is currently bound
  51060. * @hidden
  51061. */
  51062. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51063. private _upload2DCompressedLevels;
  51064. }
  51065. }
  51066. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51067. import { Nullable } from "babylonjs/types";
  51068. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51069. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51070. /**
  51071. * Implementation of the KTX Texture Loader.
  51072. * @hidden
  51073. */
  51074. export class _KTXTextureLoader implements IInternalTextureLoader {
  51075. /**
  51076. * Defines wether the loader supports cascade loading the different faces.
  51077. */
  51078. readonly supportCascades: boolean;
  51079. /**
  51080. * This returns if the loader support the current file information.
  51081. * @param extension defines the file extension of the file being loaded
  51082. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51083. * @param fallback defines the fallback internal texture if any
  51084. * @param isBase64 defines whether the texture is encoded as a base64
  51085. * @param isBuffer defines whether the texture data are stored as a buffer
  51086. * @returns true if the loader can load the specified file
  51087. */
  51088. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51089. /**
  51090. * Transform the url before loading if required.
  51091. * @param rootUrl the url of the texture
  51092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51093. * @returns the transformed texture
  51094. */
  51095. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51096. /**
  51097. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51098. * @param rootUrl the url of the texture
  51099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51100. * @returns the fallback texture
  51101. */
  51102. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51103. /**
  51104. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51105. * @param data contains the texture data
  51106. * @param texture defines the BabylonJS internal texture
  51107. * @param createPolynomials will be true if polynomials have been requested
  51108. * @param onLoad defines the callback to trigger once the texture is ready
  51109. * @param onError defines the callback to trigger in case of error
  51110. */
  51111. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51112. /**
  51113. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51114. * @param data contains the texture data
  51115. * @param texture defines the BabylonJS internal texture
  51116. * @param callback defines the method to call once ready to upload
  51117. */
  51118. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51119. }
  51120. }
  51121. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51122. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51123. import { Scene } from "babylonjs/scene";
  51124. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51125. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51126. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51127. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51128. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  51129. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51131. /**
  51132. * Options for the default xr helper
  51133. */
  51134. export class WebXRDefaultExperienceOptions {
  51135. /**
  51136. * Floor meshes that should be used for teleporting
  51137. */
  51138. floorMeshes: Array<AbstractMesh>;
  51139. }
  51140. /**
  51141. * Default experience which provides a similar setup to the previous webVRExperience
  51142. */
  51143. export class WebXRDefaultExperience {
  51144. /**
  51145. * Base experience
  51146. */
  51147. baseExperience: WebXRExperienceHelper;
  51148. /**
  51149. * Input experience extension
  51150. */
  51151. input: WebXRInput;
  51152. /**
  51153. * Loads the controller models
  51154. */
  51155. controllerModelLoader: WebXRControllerModelLoader;
  51156. /**
  51157. * Enables laser pointer and selection
  51158. */
  51159. pointerSelection: WebXRControllerPointerSelection;
  51160. /**
  51161. * Enables teleportation
  51162. */
  51163. teleportation: WebXRControllerTeleportation;
  51164. /**
  51165. * Enables ui for enetering/exiting xr
  51166. */
  51167. enterExitUI: WebXREnterExitUI;
  51168. /**
  51169. * Default output canvas xr should render to
  51170. */
  51171. outputCanvas: WebXRManagedOutputCanvas;
  51172. /**
  51173. * Creates the default xr experience
  51174. * @param scene scene
  51175. * @param options options for basic configuration
  51176. * @returns resulting WebXRDefaultExperience
  51177. */
  51178. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51179. private constructor();
  51180. /**
  51181. * DIsposes of the experience helper
  51182. */
  51183. dispose(): void;
  51184. }
  51185. }
  51186. declare module "babylonjs/Helpers/sceneHelpers" {
  51187. import { Nullable } from "babylonjs/types";
  51188. import { Mesh } from "babylonjs/Meshes/mesh";
  51189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51190. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51191. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51192. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51193. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51194. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51195. import "babylonjs/Meshes/Builders/boxBuilder";
  51196. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51197. /** @hidden */
  51198. export var _forceSceneHelpersToBundle: boolean;
  51199. module "babylonjs/scene" {
  51200. interface Scene {
  51201. /**
  51202. * Creates a default light for the scene.
  51203. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51204. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51205. */
  51206. createDefaultLight(replace?: boolean): void;
  51207. /**
  51208. * Creates a default camera for the scene.
  51209. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51210. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51211. * @param replace has default false, when true replaces the active camera in the scene
  51212. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51213. */
  51214. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51215. /**
  51216. * Creates a default camera and a default light.
  51217. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51218. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51219. * @param replace has the default false, when true replaces the active camera/light in the scene
  51220. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51221. */
  51222. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51223. /**
  51224. * Creates a new sky box
  51225. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51226. * @param environmentTexture defines the texture to use as environment texture
  51227. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51228. * @param scale defines the overall scale of the skybox
  51229. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51230. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51231. * @returns a new mesh holding the sky box
  51232. */
  51233. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51234. /**
  51235. * Creates a new environment
  51236. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51237. * @param options defines the options you can use to configure the environment
  51238. * @returns the new EnvironmentHelper
  51239. */
  51240. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51241. /**
  51242. * Creates a new VREXperienceHelper
  51243. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51244. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51245. * @returns a new VREXperienceHelper
  51246. */
  51247. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51248. /**
  51249. * Creates a new WebXRDefaultExperience
  51250. * @see http://doc.babylonjs.com/how_to/webxr
  51251. * @param options experience options
  51252. * @returns a promise for a new WebXRDefaultExperience
  51253. */
  51254. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51255. }
  51256. }
  51257. }
  51258. declare module "babylonjs/Helpers/videoDome" {
  51259. import { Scene } from "babylonjs/scene";
  51260. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51261. import { Mesh } from "babylonjs/Meshes/mesh";
  51262. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51263. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51264. import "babylonjs/Meshes/Builders/sphereBuilder";
  51265. /**
  51266. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51267. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51268. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51269. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51270. */
  51271. export class VideoDome extends TransformNode {
  51272. /**
  51273. * Define the video source as a Monoscopic panoramic 360 video.
  51274. */
  51275. static readonly MODE_MONOSCOPIC: number;
  51276. /**
  51277. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51278. */
  51279. static readonly MODE_TOPBOTTOM: number;
  51280. /**
  51281. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51282. */
  51283. static readonly MODE_SIDEBYSIDE: number;
  51284. private _halfDome;
  51285. private _useDirectMapping;
  51286. /**
  51287. * The video texture being displayed on the sphere
  51288. */
  51289. protected _videoTexture: VideoTexture;
  51290. /**
  51291. * Gets the video texture being displayed on the sphere
  51292. */
  51293. readonly videoTexture: VideoTexture;
  51294. /**
  51295. * The skybox material
  51296. */
  51297. protected _material: BackgroundMaterial;
  51298. /**
  51299. * The surface used for the skybox
  51300. */
  51301. protected _mesh: Mesh;
  51302. /**
  51303. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51304. */
  51305. private _halfDomeMask;
  51306. /**
  51307. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51308. * Also see the options.resolution property.
  51309. */
  51310. fovMultiplier: number;
  51311. private _videoMode;
  51312. /**
  51313. * Gets or set the current video mode for the video. It can be:
  51314. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51315. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51316. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51317. */
  51318. videoMode: number;
  51319. /**
  51320. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51321. *
  51322. */
  51323. /**
  51324. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51325. */
  51326. halfDome: boolean;
  51327. /**
  51328. * Oberserver used in Stereoscopic VR Mode.
  51329. */
  51330. private _onBeforeCameraRenderObserver;
  51331. /**
  51332. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51333. * @param name Element's name, child elements will append suffixes for their own names.
  51334. * @param urlsOrVideo defines the url(s) or the video element to use
  51335. * @param options An object containing optional or exposed sub element properties
  51336. */
  51337. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51338. resolution?: number;
  51339. clickToPlay?: boolean;
  51340. autoPlay?: boolean;
  51341. loop?: boolean;
  51342. size?: number;
  51343. poster?: string;
  51344. faceForward?: boolean;
  51345. useDirectMapping?: boolean;
  51346. halfDomeMode?: boolean;
  51347. }, scene: Scene);
  51348. private _changeVideoMode;
  51349. /**
  51350. * Releases resources associated with this node.
  51351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51353. */
  51354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51355. }
  51356. }
  51357. declare module "babylonjs/Helpers/index" {
  51358. export * from "babylonjs/Helpers/environmentHelper";
  51359. export * from "babylonjs/Helpers/photoDome";
  51360. export * from "babylonjs/Helpers/sceneHelpers";
  51361. export * from "babylonjs/Helpers/videoDome";
  51362. }
  51363. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51364. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51365. import { IDisposable } from "babylonjs/scene";
  51366. import { Engine } from "babylonjs/Engines/engine";
  51367. /**
  51368. * This class can be used to get instrumentation data from a Babylon engine
  51369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51370. */
  51371. export class EngineInstrumentation implements IDisposable {
  51372. /**
  51373. * Define the instrumented engine.
  51374. */
  51375. engine: Engine;
  51376. private _captureGPUFrameTime;
  51377. private _gpuFrameTimeToken;
  51378. private _gpuFrameTime;
  51379. private _captureShaderCompilationTime;
  51380. private _shaderCompilationTime;
  51381. private _onBeginFrameObserver;
  51382. private _onEndFrameObserver;
  51383. private _onBeforeShaderCompilationObserver;
  51384. private _onAfterShaderCompilationObserver;
  51385. /**
  51386. * Gets the perf counter used for GPU frame time
  51387. */
  51388. readonly gpuFrameTimeCounter: PerfCounter;
  51389. /**
  51390. * Gets the GPU frame time capture status
  51391. */
  51392. /**
  51393. * Enable or disable the GPU frame time capture
  51394. */
  51395. captureGPUFrameTime: boolean;
  51396. /**
  51397. * Gets the perf counter used for shader compilation time
  51398. */
  51399. readonly shaderCompilationTimeCounter: PerfCounter;
  51400. /**
  51401. * Gets the shader compilation time capture status
  51402. */
  51403. /**
  51404. * Enable or disable the shader compilation time capture
  51405. */
  51406. captureShaderCompilationTime: boolean;
  51407. /**
  51408. * Instantiates a new engine instrumentation.
  51409. * This class can be used to get instrumentation data from a Babylon engine
  51410. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51411. * @param engine Defines the engine to instrument
  51412. */
  51413. constructor(
  51414. /**
  51415. * Define the instrumented engine.
  51416. */
  51417. engine: Engine);
  51418. /**
  51419. * Dispose and release associated resources.
  51420. */
  51421. dispose(): void;
  51422. }
  51423. }
  51424. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51425. import { Scene, IDisposable } from "babylonjs/scene";
  51426. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51427. /**
  51428. * This class can be used to get instrumentation data from a Babylon engine
  51429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51430. */
  51431. export class SceneInstrumentation implements IDisposable {
  51432. /**
  51433. * Defines the scene to instrument
  51434. */
  51435. scene: Scene;
  51436. private _captureActiveMeshesEvaluationTime;
  51437. private _activeMeshesEvaluationTime;
  51438. private _captureRenderTargetsRenderTime;
  51439. private _renderTargetsRenderTime;
  51440. private _captureFrameTime;
  51441. private _frameTime;
  51442. private _captureRenderTime;
  51443. private _renderTime;
  51444. private _captureInterFrameTime;
  51445. private _interFrameTime;
  51446. private _captureParticlesRenderTime;
  51447. private _particlesRenderTime;
  51448. private _captureSpritesRenderTime;
  51449. private _spritesRenderTime;
  51450. private _capturePhysicsTime;
  51451. private _physicsTime;
  51452. private _captureAnimationsTime;
  51453. private _animationsTime;
  51454. private _captureCameraRenderTime;
  51455. private _cameraRenderTime;
  51456. private _onBeforeActiveMeshesEvaluationObserver;
  51457. private _onAfterActiveMeshesEvaluationObserver;
  51458. private _onBeforeRenderTargetsRenderObserver;
  51459. private _onAfterRenderTargetsRenderObserver;
  51460. private _onAfterRenderObserver;
  51461. private _onBeforeDrawPhaseObserver;
  51462. private _onAfterDrawPhaseObserver;
  51463. private _onBeforeAnimationsObserver;
  51464. private _onBeforeParticlesRenderingObserver;
  51465. private _onAfterParticlesRenderingObserver;
  51466. private _onBeforeSpritesRenderingObserver;
  51467. private _onAfterSpritesRenderingObserver;
  51468. private _onBeforePhysicsObserver;
  51469. private _onAfterPhysicsObserver;
  51470. private _onAfterAnimationsObserver;
  51471. private _onBeforeCameraRenderObserver;
  51472. private _onAfterCameraRenderObserver;
  51473. /**
  51474. * Gets the perf counter used for active meshes evaluation time
  51475. */
  51476. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51477. /**
  51478. * Gets the active meshes evaluation time capture status
  51479. */
  51480. /**
  51481. * Enable or disable the active meshes evaluation time capture
  51482. */
  51483. captureActiveMeshesEvaluationTime: boolean;
  51484. /**
  51485. * Gets the perf counter used for render targets render time
  51486. */
  51487. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51488. /**
  51489. * Gets the render targets render time capture status
  51490. */
  51491. /**
  51492. * Enable or disable the render targets render time capture
  51493. */
  51494. captureRenderTargetsRenderTime: boolean;
  51495. /**
  51496. * Gets the perf counter used for particles render time
  51497. */
  51498. readonly particlesRenderTimeCounter: PerfCounter;
  51499. /**
  51500. * Gets the particles render time capture status
  51501. */
  51502. /**
  51503. * Enable or disable the particles render time capture
  51504. */
  51505. captureParticlesRenderTime: boolean;
  51506. /**
  51507. * Gets the perf counter used for sprites render time
  51508. */
  51509. readonly spritesRenderTimeCounter: PerfCounter;
  51510. /**
  51511. * Gets the sprites render time capture status
  51512. */
  51513. /**
  51514. * Enable or disable the sprites render time capture
  51515. */
  51516. captureSpritesRenderTime: boolean;
  51517. /**
  51518. * Gets the perf counter used for physics time
  51519. */
  51520. readonly physicsTimeCounter: PerfCounter;
  51521. /**
  51522. * Gets the physics time capture status
  51523. */
  51524. /**
  51525. * Enable or disable the physics time capture
  51526. */
  51527. capturePhysicsTime: boolean;
  51528. /**
  51529. * Gets the perf counter used for animations time
  51530. */
  51531. readonly animationsTimeCounter: PerfCounter;
  51532. /**
  51533. * Gets the animations time capture status
  51534. */
  51535. /**
  51536. * Enable or disable the animations time capture
  51537. */
  51538. captureAnimationsTime: boolean;
  51539. /**
  51540. * Gets the perf counter used for frame time capture
  51541. */
  51542. readonly frameTimeCounter: PerfCounter;
  51543. /**
  51544. * Gets the frame time capture status
  51545. */
  51546. /**
  51547. * Enable or disable the frame time capture
  51548. */
  51549. captureFrameTime: boolean;
  51550. /**
  51551. * Gets the perf counter used for inter-frames time capture
  51552. */
  51553. readonly interFrameTimeCounter: PerfCounter;
  51554. /**
  51555. * Gets the inter-frames time capture status
  51556. */
  51557. /**
  51558. * Enable or disable the inter-frames time capture
  51559. */
  51560. captureInterFrameTime: boolean;
  51561. /**
  51562. * Gets the perf counter used for render time capture
  51563. */
  51564. readonly renderTimeCounter: PerfCounter;
  51565. /**
  51566. * Gets the render time capture status
  51567. */
  51568. /**
  51569. * Enable or disable the render time capture
  51570. */
  51571. captureRenderTime: boolean;
  51572. /**
  51573. * Gets the perf counter used for camera render time capture
  51574. */
  51575. readonly cameraRenderTimeCounter: PerfCounter;
  51576. /**
  51577. * Gets the camera render time capture status
  51578. */
  51579. /**
  51580. * Enable or disable the camera render time capture
  51581. */
  51582. captureCameraRenderTime: boolean;
  51583. /**
  51584. * Gets the perf counter used for draw calls
  51585. */
  51586. readonly drawCallsCounter: PerfCounter;
  51587. /**
  51588. * Instantiates a new scene instrumentation.
  51589. * This class can be used to get instrumentation data from a Babylon engine
  51590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51591. * @param scene Defines the scene to instrument
  51592. */
  51593. constructor(
  51594. /**
  51595. * Defines the scene to instrument
  51596. */
  51597. scene: Scene);
  51598. /**
  51599. * Dispose and release associated resources.
  51600. */
  51601. dispose(): void;
  51602. }
  51603. }
  51604. declare module "babylonjs/Instrumentation/index" {
  51605. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51606. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51607. export * from "babylonjs/Instrumentation/timeToken";
  51608. }
  51609. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51610. /** @hidden */
  51611. export var glowMapGenerationPixelShader: {
  51612. name: string;
  51613. shader: string;
  51614. };
  51615. }
  51616. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51617. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51618. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51619. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51620. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51621. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51622. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51623. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51624. /** @hidden */
  51625. export var glowMapGenerationVertexShader: {
  51626. name: string;
  51627. shader: string;
  51628. };
  51629. }
  51630. declare module "babylonjs/Layers/effectLayer" {
  51631. import { Observable } from "babylonjs/Misc/observable";
  51632. import { Nullable } from "babylonjs/types";
  51633. import { Camera } from "babylonjs/Cameras/camera";
  51634. import { Scene } from "babylonjs/scene";
  51635. import { ISize } from "babylonjs/Maths/math.size";
  51636. import { Color4 } from "babylonjs/Maths/math.color";
  51637. import { Engine } from "babylonjs/Engines/engine";
  51638. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51640. import { Mesh } from "babylonjs/Meshes/mesh";
  51641. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51642. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51643. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51644. import { Effect } from "babylonjs/Materials/effect";
  51645. import { Material } from "babylonjs/Materials/material";
  51646. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51647. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51648. /**
  51649. * Effect layer options. This helps customizing the behaviour
  51650. * of the effect layer.
  51651. */
  51652. export interface IEffectLayerOptions {
  51653. /**
  51654. * Multiplication factor apply to the canvas size to compute the render target size
  51655. * used to generated the objects (the smaller the faster).
  51656. */
  51657. mainTextureRatio: number;
  51658. /**
  51659. * Enforces a fixed size texture to ensure effect stability across devices.
  51660. */
  51661. mainTextureFixedSize?: number;
  51662. /**
  51663. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51664. */
  51665. alphaBlendingMode: number;
  51666. /**
  51667. * The camera attached to the layer.
  51668. */
  51669. camera: Nullable<Camera>;
  51670. /**
  51671. * The rendering group to draw the layer in.
  51672. */
  51673. renderingGroupId: number;
  51674. }
  51675. /**
  51676. * The effect layer Helps adding post process effect blended with the main pass.
  51677. *
  51678. * This can be for instance use to generate glow or higlight effects on the scene.
  51679. *
  51680. * The effect layer class can not be used directly and is intented to inherited from to be
  51681. * customized per effects.
  51682. */
  51683. export abstract class EffectLayer {
  51684. private _vertexBuffers;
  51685. private _indexBuffer;
  51686. private _cachedDefines;
  51687. private _effectLayerMapGenerationEffect;
  51688. private _effectLayerOptions;
  51689. private _mergeEffect;
  51690. protected _scene: Scene;
  51691. protected _engine: Engine;
  51692. protected _maxSize: number;
  51693. protected _mainTextureDesiredSize: ISize;
  51694. protected _mainTexture: RenderTargetTexture;
  51695. protected _shouldRender: boolean;
  51696. protected _postProcesses: PostProcess[];
  51697. protected _textures: BaseTexture[];
  51698. protected _emissiveTextureAndColor: {
  51699. texture: Nullable<BaseTexture>;
  51700. color: Color4;
  51701. };
  51702. /**
  51703. * The name of the layer
  51704. */
  51705. name: string;
  51706. /**
  51707. * The clear color of the texture used to generate the glow map.
  51708. */
  51709. neutralColor: Color4;
  51710. /**
  51711. * Specifies wether the highlight layer is enabled or not.
  51712. */
  51713. isEnabled: boolean;
  51714. /**
  51715. * Gets the camera attached to the layer.
  51716. */
  51717. readonly camera: Nullable<Camera>;
  51718. /**
  51719. * Gets the rendering group id the layer should render in.
  51720. */
  51721. renderingGroupId: number;
  51722. /**
  51723. * An event triggered when the effect layer has been disposed.
  51724. */
  51725. onDisposeObservable: Observable<EffectLayer>;
  51726. /**
  51727. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51728. */
  51729. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51730. /**
  51731. * An event triggered when the generated texture is being merged in the scene.
  51732. */
  51733. onBeforeComposeObservable: Observable<EffectLayer>;
  51734. /**
  51735. * An event triggered when the generated texture has been merged in the scene.
  51736. */
  51737. onAfterComposeObservable: Observable<EffectLayer>;
  51738. /**
  51739. * An event triggered when the efffect layer changes its size.
  51740. */
  51741. onSizeChangedObservable: Observable<EffectLayer>;
  51742. /** @hidden */
  51743. static _SceneComponentInitialization: (scene: Scene) => void;
  51744. /**
  51745. * Instantiates a new effect Layer and references it in the scene.
  51746. * @param name The name of the layer
  51747. * @param scene The scene to use the layer in
  51748. */
  51749. constructor(
  51750. /** The Friendly of the effect in the scene */
  51751. name: string, scene: Scene);
  51752. /**
  51753. * Get the effect name of the layer.
  51754. * @return The effect name
  51755. */
  51756. abstract getEffectName(): string;
  51757. /**
  51758. * Checks for the readiness of the element composing the layer.
  51759. * @param subMesh the mesh to check for
  51760. * @param useInstances specify wether or not to use instances to render the mesh
  51761. * @return true if ready otherwise, false
  51762. */
  51763. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51764. /**
  51765. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51766. * @returns true if the effect requires stencil during the main canvas render pass.
  51767. */
  51768. abstract needStencil(): boolean;
  51769. /**
  51770. * Create the merge effect. This is the shader use to blit the information back
  51771. * to the main canvas at the end of the scene rendering.
  51772. * @returns The effect containing the shader used to merge the effect on the main canvas
  51773. */
  51774. protected abstract _createMergeEffect(): Effect;
  51775. /**
  51776. * Creates the render target textures and post processes used in the effect layer.
  51777. */
  51778. protected abstract _createTextureAndPostProcesses(): void;
  51779. /**
  51780. * Implementation specific of rendering the generating effect on the main canvas.
  51781. * @param effect The effect used to render through
  51782. */
  51783. protected abstract _internalRender(effect: Effect): void;
  51784. /**
  51785. * Sets the required values for both the emissive texture and and the main color.
  51786. */
  51787. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51788. /**
  51789. * Free any resources and references associated to a mesh.
  51790. * Internal use
  51791. * @param mesh The mesh to free.
  51792. */
  51793. abstract _disposeMesh(mesh: Mesh): void;
  51794. /**
  51795. * Serializes this layer (Glow or Highlight for example)
  51796. * @returns a serialized layer object
  51797. */
  51798. abstract serialize?(): any;
  51799. /**
  51800. * Initializes the effect layer with the required options.
  51801. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51802. */
  51803. protected _init(options: Partial<IEffectLayerOptions>): void;
  51804. /**
  51805. * Generates the index buffer of the full screen quad blending to the main canvas.
  51806. */
  51807. private _generateIndexBuffer;
  51808. /**
  51809. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51810. */
  51811. private _generateVertexBuffer;
  51812. /**
  51813. * Sets the main texture desired size which is the closest power of two
  51814. * of the engine canvas size.
  51815. */
  51816. private _setMainTextureSize;
  51817. /**
  51818. * Creates the main texture for the effect layer.
  51819. */
  51820. protected _createMainTexture(): void;
  51821. /**
  51822. * Adds specific effects defines.
  51823. * @param defines The defines to add specifics to.
  51824. */
  51825. protected _addCustomEffectDefines(defines: string[]): void;
  51826. /**
  51827. * Checks for the readiness of the element composing the layer.
  51828. * @param subMesh the mesh to check for
  51829. * @param useInstances specify wether or not to use instances to render the mesh
  51830. * @param emissiveTexture the associated emissive texture used to generate the glow
  51831. * @return true if ready otherwise, false
  51832. */
  51833. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51834. /**
  51835. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51836. */
  51837. render(): void;
  51838. /**
  51839. * Determine if a given mesh will be used in the current effect.
  51840. * @param mesh mesh to test
  51841. * @returns true if the mesh will be used
  51842. */
  51843. hasMesh(mesh: AbstractMesh): boolean;
  51844. /**
  51845. * Returns true if the layer contains information to display, otherwise false.
  51846. * @returns true if the glow layer should be rendered
  51847. */
  51848. shouldRender(): boolean;
  51849. /**
  51850. * Returns true if the mesh should render, otherwise false.
  51851. * @param mesh The mesh to render
  51852. * @returns true if it should render otherwise false
  51853. */
  51854. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51855. /**
  51856. * Returns true if the mesh can be rendered, otherwise false.
  51857. * @param mesh The mesh to render
  51858. * @param material The material used on the mesh
  51859. * @returns true if it can be rendered otherwise false
  51860. */
  51861. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51862. /**
  51863. * Returns true if the mesh should render, otherwise false.
  51864. * @param mesh The mesh to render
  51865. * @returns true if it should render otherwise false
  51866. */
  51867. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51868. /**
  51869. * Renders the submesh passed in parameter to the generation map.
  51870. */
  51871. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51872. /**
  51873. * Rebuild the required buffers.
  51874. * @hidden Internal use only.
  51875. */
  51876. _rebuild(): void;
  51877. /**
  51878. * Dispose only the render target textures and post process.
  51879. */
  51880. private _disposeTextureAndPostProcesses;
  51881. /**
  51882. * Dispose the highlight layer and free resources.
  51883. */
  51884. dispose(): void;
  51885. /**
  51886. * Gets the class name of the effect layer
  51887. * @returns the string with the class name of the effect layer
  51888. */
  51889. getClassName(): string;
  51890. /**
  51891. * Creates an effect layer from parsed effect layer data
  51892. * @param parsedEffectLayer defines effect layer data
  51893. * @param scene defines the current scene
  51894. * @param rootUrl defines the root URL containing the effect layer information
  51895. * @returns a parsed effect Layer
  51896. */
  51897. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51898. }
  51899. }
  51900. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51901. import { Scene } from "babylonjs/scene";
  51902. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51903. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51904. import { AbstractScene } from "babylonjs/abstractScene";
  51905. module "babylonjs/abstractScene" {
  51906. interface AbstractScene {
  51907. /**
  51908. * The list of effect layers (highlights/glow) added to the scene
  51909. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51910. * @see http://doc.babylonjs.com/how_to/glow_layer
  51911. */
  51912. effectLayers: Array<EffectLayer>;
  51913. /**
  51914. * Removes the given effect layer from this scene.
  51915. * @param toRemove defines the effect layer to remove
  51916. * @returns the index of the removed effect layer
  51917. */
  51918. removeEffectLayer(toRemove: EffectLayer): number;
  51919. /**
  51920. * Adds the given effect layer to this scene
  51921. * @param newEffectLayer defines the effect layer to add
  51922. */
  51923. addEffectLayer(newEffectLayer: EffectLayer): void;
  51924. }
  51925. }
  51926. /**
  51927. * Defines the layer scene component responsible to manage any effect layers
  51928. * in a given scene.
  51929. */
  51930. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51931. /**
  51932. * The component name helpfull to identify the component in the list of scene components.
  51933. */
  51934. readonly name: string;
  51935. /**
  51936. * The scene the component belongs to.
  51937. */
  51938. scene: Scene;
  51939. private _engine;
  51940. private _renderEffects;
  51941. private _needStencil;
  51942. private _previousStencilState;
  51943. /**
  51944. * Creates a new instance of the component for the given scene
  51945. * @param scene Defines the scene to register the component in
  51946. */
  51947. constructor(scene: Scene);
  51948. /**
  51949. * Registers the component in a given scene
  51950. */
  51951. register(): void;
  51952. /**
  51953. * Rebuilds the elements related to this component in case of
  51954. * context lost for instance.
  51955. */
  51956. rebuild(): void;
  51957. /**
  51958. * Serializes the component data to the specified json object
  51959. * @param serializationObject The object to serialize to
  51960. */
  51961. serialize(serializationObject: any): void;
  51962. /**
  51963. * Adds all the elements from the container to the scene
  51964. * @param container the container holding the elements
  51965. */
  51966. addFromContainer(container: AbstractScene): void;
  51967. /**
  51968. * Removes all the elements in the container from the scene
  51969. * @param container contains the elements to remove
  51970. * @param dispose if the removed element should be disposed (default: false)
  51971. */
  51972. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51973. /**
  51974. * Disposes the component and the associated ressources.
  51975. */
  51976. dispose(): void;
  51977. private _isReadyForMesh;
  51978. private _renderMainTexture;
  51979. private _setStencil;
  51980. private _setStencilBack;
  51981. private _draw;
  51982. private _drawCamera;
  51983. private _drawRenderingGroup;
  51984. }
  51985. }
  51986. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51987. /** @hidden */
  51988. export var glowMapMergePixelShader: {
  51989. name: string;
  51990. shader: string;
  51991. };
  51992. }
  51993. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51994. /** @hidden */
  51995. export var glowMapMergeVertexShader: {
  51996. name: string;
  51997. shader: string;
  51998. };
  51999. }
  52000. declare module "babylonjs/Layers/glowLayer" {
  52001. import { Nullable } from "babylonjs/types";
  52002. import { Camera } from "babylonjs/Cameras/camera";
  52003. import { Scene } from "babylonjs/scene";
  52004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52006. import { Mesh } from "babylonjs/Meshes/mesh";
  52007. import { Texture } from "babylonjs/Materials/Textures/texture";
  52008. import { Effect } from "babylonjs/Materials/effect";
  52009. import { Material } from "babylonjs/Materials/material";
  52010. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52011. import { Color4 } from "babylonjs/Maths/math.color";
  52012. import "babylonjs/Shaders/glowMapMerge.fragment";
  52013. import "babylonjs/Shaders/glowMapMerge.vertex";
  52014. import "babylonjs/Layers/effectLayerSceneComponent";
  52015. module "babylonjs/abstractScene" {
  52016. interface AbstractScene {
  52017. /**
  52018. * Return a the first highlight layer of the scene with a given name.
  52019. * @param name The name of the highlight layer to look for.
  52020. * @return The highlight layer if found otherwise null.
  52021. */
  52022. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52023. }
  52024. }
  52025. /**
  52026. * Glow layer options. This helps customizing the behaviour
  52027. * of the glow layer.
  52028. */
  52029. export interface IGlowLayerOptions {
  52030. /**
  52031. * Multiplication factor apply to the canvas size to compute the render target size
  52032. * used to generated the glowing objects (the smaller the faster).
  52033. */
  52034. mainTextureRatio: number;
  52035. /**
  52036. * Enforces a fixed size texture to ensure resize independant blur.
  52037. */
  52038. mainTextureFixedSize?: number;
  52039. /**
  52040. * How big is the kernel of the blur texture.
  52041. */
  52042. blurKernelSize: number;
  52043. /**
  52044. * The camera attached to the layer.
  52045. */
  52046. camera: Nullable<Camera>;
  52047. /**
  52048. * Enable MSAA by chosing the number of samples.
  52049. */
  52050. mainTextureSamples?: number;
  52051. /**
  52052. * The rendering group to draw the layer in.
  52053. */
  52054. renderingGroupId: number;
  52055. }
  52056. /**
  52057. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52058. *
  52059. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52060. * glowy meshes to your scene.
  52061. *
  52062. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52063. */
  52064. export class GlowLayer extends EffectLayer {
  52065. /**
  52066. * Effect Name of the layer.
  52067. */
  52068. static readonly EffectName: string;
  52069. /**
  52070. * The default blur kernel size used for the glow.
  52071. */
  52072. static DefaultBlurKernelSize: number;
  52073. /**
  52074. * The default texture size ratio used for the glow.
  52075. */
  52076. static DefaultTextureRatio: number;
  52077. /**
  52078. * Sets the kernel size of the blur.
  52079. */
  52080. /**
  52081. * Gets the kernel size of the blur.
  52082. */
  52083. blurKernelSize: number;
  52084. /**
  52085. * Sets the glow intensity.
  52086. */
  52087. /**
  52088. * Gets the glow intensity.
  52089. */
  52090. intensity: number;
  52091. private _options;
  52092. private _intensity;
  52093. private _horizontalBlurPostprocess1;
  52094. private _verticalBlurPostprocess1;
  52095. private _horizontalBlurPostprocess2;
  52096. private _verticalBlurPostprocess2;
  52097. private _blurTexture1;
  52098. private _blurTexture2;
  52099. private _postProcesses1;
  52100. private _postProcesses2;
  52101. private _includedOnlyMeshes;
  52102. private _excludedMeshes;
  52103. /**
  52104. * Callback used to let the user override the color selection on a per mesh basis
  52105. */
  52106. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52107. /**
  52108. * Callback used to let the user override the texture selection on a per mesh basis
  52109. */
  52110. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52111. /**
  52112. * Instantiates a new glow Layer and references it to the scene.
  52113. * @param name The name of the layer
  52114. * @param scene The scene to use the layer in
  52115. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52116. */
  52117. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52118. /**
  52119. * Get the effect name of the layer.
  52120. * @return The effect name
  52121. */
  52122. getEffectName(): string;
  52123. /**
  52124. * Create the merge effect. This is the shader use to blit the information back
  52125. * to the main canvas at the end of the scene rendering.
  52126. */
  52127. protected _createMergeEffect(): Effect;
  52128. /**
  52129. * Creates the render target textures and post processes used in the glow layer.
  52130. */
  52131. protected _createTextureAndPostProcesses(): void;
  52132. /**
  52133. * Checks for the readiness of the element composing the layer.
  52134. * @param subMesh the mesh to check for
  52135. * @param useInstances specify wether or not to use instances to render the mesh
  52136. * @param emissiveTexture the associated emissive texture used to generate the glow
  52137. * @return true if ready otherwise, false
  52138. */
  52139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52140. /**
  52141. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52142. */
  52143. needStencil(): boolean;
  52144. /**
  52145. * Returns true if the mesh can be rendered, otherwise false.
  52146. * @param mesh The mesh to render
  52147. * @param material The material used on the mesh
  52148. * @returns true if it can be rendered otherwise false
  52149. */
  52150. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52151. /**
  52152. * Implementation specific of rendering the generating effect on the main canvas.
  52153. * @param effect The effect used to render through
  52154. */
  52155. protected _internalRender(effect: Effect): void;
  52156. /**
  52157. * Sets the required values for both the emissive texture and and the main color.
  52158. */
  52159. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52160. /**
  52161. * Returns true if the mesh should render, otherwise false.
  52162. * @param mesh The mesh to render
  52163. * @returns true if it should render otherwise false
  52164. */
  52165. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52166. /**
  52167. * Adds specific effects defines.
  52168. * @param defines The defines to add specifics to.
  52169. */
  52170. protected _addCustomEffectDefines(defines: string[]): void;
  52171. /**
  52172. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52173. * @param mesh The mesh to exclude from the glow layer
  52174. */
  52175. addExcludedMesh(mesh: Mesh): void;
  52176. /**
  52177. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52178. * @param mesh The mesh to remove
  52179. */
  52180. removeExcludedMesh(mesh: Mesh): void;
  52181. /**
  52182. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52183. * @param mesh The mesh to include in the glow layer
  52184. */
  52185. addIncludedOnlyMesh(mesh: Mesh): void;
  52186. /**
  52187. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52188. * @param mesh The mesh to remove
  52189. */
  52190. removeIncludedOnlyMesh(mesh: Mesh): void;
  52191. /**
  52192. * Determine if a given mesh will be used in the glow layer
  52193. * @param mesh The mesh to test
  52194. * @returns true if the mesh will be highlighted by the current glow layer
  52195. */
  52196. hasMesh(mesh: AbstractMesh): boolean;
  52197. /**
  52198. * Free any resources and references associated to a mesh.
  52199. * Internal use
  52200. * @param mesh The mesh to free.
  52201. * @hidden
  52202. */
  52203. _disposeMesh(mesh: Mesh): void;
  52204. /**
  52205. * Gets the class name of the effect layer
  52206. * @returns the string with the class name of the effect layer
  52207. */
  52208. getClassName(): string;
  52209. /**
  52210. * Serializes this glow layer
  52211. * @returns a serialized glow layer object
  52212. */
  52213. serialize(): any;
  52214. /**
  52215. * Creates a Glow Layer from parsed glow layer data
  52216. * @param parsedGlowLayer defines glow layer data
  52217. * @param scene defines the current scene
  52218. * @param rootUrl defines the root URL containing the glow layer information
  52219. * @returns a parsed Glow Layer
  52220. */
  52221. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52222. }
  52223. }
  52224. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52225. /** @hidden */
  52226. export var glowBlurPostProcessPixelShader: {
  52227. name: string;
  52228. shader: string;
  52229. };
  52230. }
  52231. declare module "babylonjs/Layers/highlightLayer" {
  52232. import { Observable } from "babylonjs/Misc/observable";
  52233. import { Nullable } from "babylonjs/types";
  52234. import { Camera } from "babylonjs/Cameras/camera";
  52235. import { Scene } from "babylonjs/scene";
  52236. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52238. import { Mesh } from "babylonjs/Meshes/mesh";
  52239. import { Effect } from "babylonjs/Materials/effect";
  52240. import { Material } from "babylonjs/Materials/material";
  52241. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52242. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52243. import "babylonjs/Shaders/glowMapMerge.fragment";
  52244. import "babylonjs/Shaders/glowMapMerge.vertex";
  52245. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52246. module "babylonjs/abstractScene" {
  52247. interface AbstractScene {
  52248. /**
  52249. * Return a the first highlight layer of the scene with a given name.
  52250. * @param name The name of the highlight layer to look for.
  52251. * @return The highlight layer if found otherwise null.
  52252. */
  52253. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52254. }
  52255. }
  52256. /**
  52257. * Highlight layer options. This helps customizing the behaviour
  52258. * of the highlight layer.
  52259. */
  52260. export interface IHighlightLayerOptions {
  52261. /**
  52262. * Multiplication factor apply to the canvas size to compute the render target size
  52263. * used to generated the glowing objects (the smaller the faster).
  52264. */
  52265. mainTextureRatio: number;
  52266. /**
  52267. * Enforces a fixed size texture to ensure resize independant blur.
  52268. */
  52269. mainTextureFixedSize?: number;
  52270. /**
  52271. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52272. * of the picture to blur (the smaller the faster).
  52273. */
  52274. blurTextureSizeRatio: number;
  52275. /**
  52276. * How big in texel of the blur texture is the vertical blur.
  52277. */
  52278. blurVerticalSize: number;
  52279. /**
  52280. * How big in texel of the blur texture is the horizontal blur.
  52281. */
  52282. blurHorizontalSize: number;
  52283. /**
  52284. * Alpha blending mode used to apply the blur. Default is combine.
  52285. */
  52286. alphaBlendingMode: number;
  52287. /**
  52288. * The camera attached to the layer.
  52289. */
  52290. camera: Nullable<Camera>;
  52291. /**
  52292. * Should we display highlight as a solid stroke?
  52293. */
  52294. isStroke?: boolean;
  52295. /**
  52296. * The rendering group to draw the layer in.
  52297. */
  52298. renderingGroupId: number;
  52299. }
  52300. /**
  52301. * The highlight layer Helps adding a glow effect around a mesh.
  52302. *
  52303. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52304. * glowy meshes to your scene.
  52305. *
  52306. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52307. */
  52308. export class HighlightLayer extends EffectLayer {
  52309. name: string;
  52310. /**
  52311. * Effect Name of the highlight layer.
  52312. */
  52313. static readonly EffectName: string;
  52314. /**
  52315. * The neutral color used during the preparation of the glow effect.
  52316. * This is black by default as the blend operation is a blend operation.
  52317. */
  52318. static NeutralColor: Color4;
  52319. /**
  52320. * Stencil value used for glowing meshes.
  52321. */
  52322. static GlowingMeshStencilReference: number;
  52323. /**
  52324. * Stencil value used for the other meshes in the scene.
  52325. */
  52326. static NormalMeshStencilReference: number;
  52327. /**
  52328. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52329. */
  52330. innerGlow: boolean;
  52331. /**
  52332. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52333. */
  52334. outerGlow: boolean;
  52335. /**
  52336. * Specifies the horizontal size of the blur.
  52337. */
  52338. /**
  52339. * Gets the horizontal size of the blur.
  52340. */
  52341. blurHorizontalSize: number;
  52342. /**
  52343. * Specifies the vertical size of the blur.
  52344. */
  52345. /**
  52346. * Gets the vertical size of the blur.
  52347. */
  52348. blurVerticalSize: number;
  52349. /**
  52350. * An event triggered when the highlight layer is being blurred.
  52351. */
  52352. onBeforeBlurObservable: Observable<HighlightLayer>;
  52353. /**
  52354. * An event triggered when the highlight layer has been blurred.
  52355. */
  52356. onAfterBlurObservable: Observable<HighlightLayer>;
  52357. private _instanceGlowingMeshStencilReference;
  52358. private _options;
  52359. private _downSamplePostprocess;
  52360. private _horizontalBlurPostprocess;
  52361. private _verticalBlurPostprocess;
  52362. private _blurTexture;
  52363. private _meshes;
  52364. private _excludedMeshes;
  52365. /**
  52366. * Instantiates a new highlight Layer and references it to the scene..
  52367. * @param name The name of the layer
  52368. * @param scene The scene to use the layer in
  52369. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52370. */
  52371. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52372. /**
  52373. * Get the effect name of the layer.
  52374. * @return The effect name
  52375. */
  52376. getEffectName(): string;
  52377. /**
  52378. * Create the merge effect. This is the shader use to blit the information back
  52379. * to the main canvas at the end of the scene rendering.
  52380. */
  52381. protected _createMergeEffect(): Effect;
  52382. /**
  52383. * Creates the render target textures and post processes used in the highlight layer.
  52384. */
  52385. protected _createTextureAndPostProcesses(): void;
  52386. /**
  52387. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52388. */
  52389. needStencil(): boolean;
  52390. /**
  52391. * Checks for the readiness of the element composing the layer.
  52392. * @param subMesh the mesh to check for
  52393. * @param useInstances specify wether or not to use instances to render the mesh
  52394. * @param emissiveTexture the associated emissive texture used to generate the glow
  52395. * @return true if ready otherwise, false
  52396. */
  52397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52398. /**
  52399. * Implementation specific of rendering the generating effect on the main canvas.
  52400. * @param effect The effect used to render through
  52401. */
  52402. protected _internalRender(effect: Effect): void;
  52403. /**
  52404. * Returns true if the layer contains information to display, otherwise false.
  52405. */
  52406. shouldRender(): boolean;
  52407. /**
  52408. * Returns true if the mesh should render, otherwise false.
  52409. * @param mesh The mesh to render
  52410. * @returns true if it should render otherwise false
  52411. */
  52412. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52413. /**
  52414. * Sets the required values for both the emissive texture and and the main color.
  52415. */
  52416. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52417. /**
  52418. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52419. * @param mesh The mesh to exclude from the highlight layer
  52420. */
  52421. addExcludedMesh(mesh: Mesh): void;
  52422. /**
  52423. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52424. * @param mesh The mesh to highlight
  52425. */
  52426. removeExcludedMesh(mesh: Mesh): void;
  52427. /**
  52428. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52429. * @param mesh mesh to test
  52430. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52431. */
  52432. hasMesh(mesh: AbstractMesh): boolean;
  52433. /**
  52434. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52435. * @param mesh The mesh to highlight
  52436. * @param color The color of the highlight
  52437. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52438. */
  52439. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52440. /**
  52441. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52442. * @param mesh The mesh to highlight
  52443. */
  52444. removeMesh(mesh: Mesh): void;
  52445. /**
  52446. * Force the stencil to the normal expected value for none glowing parts
  52447. */
  52448. private _defaultStencilReference;
  52449. /**
  52450. * Free any resources and references associated to a mesh.
  52451. * Internal use
  52452. * @param mesh The mesh to free.
  52453. * @hidden
  52454. */
  52455. _disposeMesh(mesh: Mesh): void;
  52456. /**
  52457. * Dispose the highlight layer and free resources.
  52458. */
  52459. dispose(): void;
  52460. /**
  52461. * Gets the class name of the effect layer
  52462. * @returns the string with the class name of the effect layer
  52463. */
  52464. getClassName(): string;
  52465. /**
  52466. * Serializes this Highlight layer
  52467. * @returns a serialized Highlight layer object
  52468. */
  52469. serialize(): any;
  52470. /**
  52471. * Creates a Highlight layer from parsed Highlight layer data
  52472. * @param parsedHightlightLayer defines the Highlight layer data
  52473. * @param scene defines the current scene
  52474. * @param rootUrl defines the root URL containing the Highlight layer information
  52475. * @returns a parsed Highlight layer
  52476. */
  52477. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52478. }
  52479. }
  52480. declare module "babylonjs/Layers/layerSceneComponent" {
  52481. import { Scene } from "babylonjs/scene";
  52482. import { ISceneComponent } from "babylonjs/sceneComponent";
  52483. import { Layer } from "babylonjs/Layers/layer";
  52484. import { AbstractScene } from "babylonjs/abstractScene";
  52485. module "babylonjs/abstractScene" {
  52486. interface AbstractScene {
  52487. /**
  52488. * The list of layers (background and foreground) of the scene
  52489. */
  52490. layers: Array<Layer>;
  52491. }
  52492. }
  52493. /**
  52494. * Defines the layer scene component responsible to manage any layers
  52495. * in a given scene.
  52496. */
  52497. export class LayerSceneComponent implements ISceneComponent {
  52498. /**
  52499. * The component name helpfull to identify the component in the list of scene components.
  52500. */
  52501. readonly name: string;
  52502. /**
  52503. * The scene the component belongs to.
  52504. */
  52505. scene: Scene;
  52506. private _engine;
  52507. /**
  52508. * Creates a new instance of the component for the given scene
  52509. * @param scene Defines the scene to register the component in
  52510. */
  52511. constructor(scene: Scene);
  52512. /**
  52513. * Registers the component in a given scene
  52514. */
  52515. register(): void;
  52516. /**
  52517. * Rebuilds the elements related to this component in case of
  52518. * context lost for instance.
  52519. */
  52520. rebuild(): void;
  52521. /**
  52522. * Disposes the component and the associated ressources.
  52523. */
  52524. dispose(): void;
  52525. private _draw;
  52526. private _drawCameraPredicate;
  52527. private _drawCameraBackground;
  52528. private _drawCameraForeground;
  52529. private _drawRenderTargetPredicate;
  52530. private _drawRenderTargetBackground;
  52531. private _drawRenderTargetForeground;
  52532. /**
  52533. * Adds all the elements from the container to the scene
  52534. * @param container the container holding the elements
  52535. */
  52536. addFromContainer(container: AbstractScene): void;
  52537. /**
  52538. * Removes all the elements in the container from the scene
  52539. * @param container contains the elements to remove
  52540. * @param dispose if the removed element should be disposed (default: false)
  52541. */
  52542. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52543. }
  52544. }
  52545. declare module "babylonjs/Shaders/layer.fragment" {
  52546. /** @hidden */
  52547. export var layerPixelShader: {
  52548. name: string;
  52549. shader: string;
  52550. };
  52551. }
  52552. declare module "babylonjs/Shaders/layer.vertex" {
  52553. /** @hidden */
  52554. export var layerVertexShader: {
  52555. name: string;
  52556. shader: string;
  52557. };
  52558. }
  52559. declare module "babylonjs/Layers/layer" {
  52560. import { Observable } from "babylonjs/Misc/observable";
  52561. import { Nullable } from "babylonjs/types";
  52562. import { Scene } from "babylonjs/scene";
  52563. import { Vector2 } from "babylonjs/Maths/math.vector";
  52564. import { Color4 } from "babylonjs/Maths/math.color";
  52565. import { Texture } from "babylonjs/Materials/Textures/texture";
  52566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52567. import "babylonjs/Shaders/layer.fragment";
  52568. import "babylonjs/Shaders/layer.vertex";
  52569. /**
  52570. * This represents a full screen 2d layer.
  52571. * This can be useful to display a picture in the background of your scene for instance.
  52572. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52573. */
  52574. export class Layer {
  52575. /**
  52576. * Define the name of the layer.
  52577. */
  52578. name: string;
  52579. /**
  52580. * Define the texture the layer should display.
  52581. */
  52582. texture: Nullable<Texture>;
  52583. /**
  52584. * Is the layer in background or foreground.
  52585. */
  52586. isBackground: boolean;
  52587. /**
  52588. * Define the color of the layer (instead of texture).
  52589. */
  52590. color: Color4;
  52591. /**
  52592. * Define the scale of the layer in order to zoom in out of the texture.
  52593. */
  52594. scale: Vector2;
  52595. /**
  52596. * Define an offset for the layer in order to shift the texture.
  52597. */
  52598. offset: Vector2;
  52599. /**
  52600. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52601. */
  52602. alphaBlendingMode: number;
  52603. /**
  52604. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52605. * Alpha test will not mix with the background color in case of transparency.
  52606. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52607. */
  52608. alphaTest: boolean;
  52609. /**
  52610. * Define a mask to restrict the layer to only some of the scene cameras.
  52611. */
  52612. layerMask: number;
  52613. /**
  52614. * Define the list of render target the layer is visible into.
  52615. */
  52616. renderTargetTextures: RenderTargetTexture[];
  52617. /**
  52618. * Define if the layer is only used in renderTarget or if it also
  52619. * renders in the main frame buffer of the canvas.
  52620. */
  52621. renderOnlyInRenderTargetTextures: boolean;
  52622. private _scene;
  52623. private _vertexBuffers;
  52624. private _indexBuffer;
  52625. private _effect;
  52626. private _alphaTestEffect;
  52627. /**
  52628. * An event triggered when the layer is disposed.
  52629. */
  52630. onDisposeObservable: Observable<Layer>;
  52631. private _onDisposeObserver;
  52632. /**
  52633. * Back compatibility with callback before the onDisposeObservable existed.
  52634. * The set callback will be triggered when the layer has been disposed.
  52635. */
  52636. onDispose: () => void;
  52637. /**
  52638. * An event triggered before rendering the scene
  52639. */
  52640. onBeforeRenderObservable: Observable<Layer>;
  52641. private _onBeforeRenderObserver;
  52642. /**
  52643. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52644. * The set callback will be triggered just before rendering the layer.
  52645. */
  52646. onBeforeRender: () => void;
  52647. /**
  52648. * An event triggered after rendering the scene
  52649. */
  52650. onAfterRenderObservable: Observable<Layer>;
  52651. private _onAfterRenderObserver;
  52652. /**
  52653. * Back compatibility with callback before the onAfterRenderObservable existed.
  52654. * The set callback will be triggered just after rendering the layer.
  52655. */
  52656. onAfterRender: () => void;
  52657. /**
  52658. * Instantiates a new layer.
  52659. * This represents a full screen 2d layer.
  52660. * This can be useful to display a picture in the background of your scene for instance.
  52661. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52662. * @param name Define the name of the layer in the scene
  52663. * @param imgUrl Define the url of the texture to display in the layer
  52664. * @param scene Define the scene the layer belongs to
  52665. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52666. * @param color Defines a color for the layer
  52667. */
  52668. constructor(
  52669. /**
  52670. * Define the name of the layer.
  52671. */
  52672. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52673. private _createIndexBuffer;
  52674. /** @hidden */
  52675. _rebuild(): void;
  52676. /**
  52677. * Renders the layer in the scene.
  52678. */
  52679. render(): void;
  52680. /**
  52681. * Disposes and releases the associated ressources.
  52682. */
  52683. dispose(): void;
  52684. }
  52685. }
  52686. declare module "babylonjs/Layers/index" {
  52687. export * from "babylonjs/Layers/effectLayer";
  52688. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52689. export * from "babylonjs/Layers/glowLayer";
  52690. export * from "babylonjs/Layers/highlightLayer";
  52691. export * from "babylonjs/Layers/layer";
  52692. export * from "babylonjs/Layers/layerSceneComponent";
  52693. }
  52694. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52695. /** @hidden */
  52696. export var lensFlarePixelShader: {
  52697. name: string;
  52698. shader: string;
  52699. };
  52700. }
  52701. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52702. /** @hidden */
  52703. export var lensFlareVertexShader: {
  52704. name: string;
  52705. shader: string;
  52706. };
  52707. }
  52708. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52709. import { Scene } from "babylonjs/scene";
  52710. import { Vector3 } from "babylonjs/Maths/math.vector";
  52711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52712. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52713. import "babylonjs/Shaders/lensFlare.fragment";
  52714. import "babylonjs/Shaders/lensFlare.vertex";
  52715. import { Viewport } from "babylonjs/Maths/math.viewport";
  52716. /**
  52717. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52718. * It is usually composed of several `lensFlare`.
  52719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52720. */
  52721. export class LensFlareSystem {
  52722. /**
  52723. * Define the name of the lens flare system
  52724. */
  52725. name: string;
  52726. /**
  52727. * List of lens flares used in this system.
  52728. */
  52729. lensFlares: LensFlare[];
  52730. /**
  52731. * Define a limit from the border the lens flare can be visible.
  52732. */
  52733. borderLimit: number;
  52734. /**
  52735. * Define a viewport border we do not want to see the lens flare in.
  52736. */
  52737. viewportBorder: number;
  52738. /**
  52739. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52740. */
  52741. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52742. /**
  52743. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52744. */
  52745. layerMask: number;
  52746. /**
  52747. * Define the id of the lens flare system in the scene.
  52748. * (equal to name by default)
  52749. */
  52750. id: string;
  52751. private _scene;
  52752. private _emitter;
  52753. private _vertexBuffers;
  52754. private _indexBuffer;
  52755. private _effect;
  52756. private _positionX;
  52757. private _positionY;
  52758. private _isEnabled;
  52759. /** @hidden */
  52760. static _SceneComponentInitialization: (scene: Scene) => void;
  52761. /**
  52762. * Instantiates a lens flare system.
  52763. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52764. * It is usually composed of several `lensFlare`.
  52765. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52766. * @param name Define the name of the lens flare system in the scene
  52767. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52768. * @param scene Define the scene the lens flare system belongs to
  52769. */
  52770. constructor(
  52771. /**
  52772. * Define the name of the lens flare system
  52773. */
  52774. name: string, emitter: any, scene: Scene);
  52775. /**
  52776. * Define if the lens flare system is enabled.
  52777. */
  52778. isEnabled: boolean;
  52779. /**
  52780. * Get the scene the effects belongs to.
  52781. * @returns the scene holding the lens flare system
  52782. */
  52783. getScene(): Scene;
  52784. /**
  52785. * Get the emitter of the lens flare system.
  52786. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52787. * @returns the emitter of the lens flare system
  52788. */
  52789. getEmitter(): any;
  52790. /**
  52791. * Set the emitter of the lens flare system.
  52792. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52793. * @param newEmitter Define the new emitter of the system
  52794. */
  52795. setEmitter(newEmitter: any): void;
  52796. /**
  52797. * Get the lens flare system emitter position.
  52798. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52799. * @returns the position
  52800. */
  52801. getEmitterPosition(): Vector3;
  52802. /**
  52803. * @hidden
  52804. */
  52805. computeEffectivePosition(globalViewport: Viewport): boolean;
  52806. /** @hidden */
  52807. _isVisible(): boolean;
  52808. /**
  52809. * @hidden
  52810. */
  52811. render(): boolean;
  52812. /**
  52813. * Dispose and release the lens flare with its associated resources.
  52814. */
  52815. dispose(): void;
  52816. /**
  52817. * Parse a lens flare system from a JSON repressentation
  52818. * @param parsedLensFlareSystem Define the JSON to parse
  52819. * @param scene Define the scene the parsed system should be instantiated in
  52820. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52821. * @returns the parsed system
  52822. */
  52823. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52824. /**
  52825. * Serialize the current Lens Flare System into a JSON representation.
  52826. * @returns the serialized JSON
  52827. */
  52828. serialize(): any;
  52829. }
  52830. }
  52831. declare module "babylonjs/LensFlares/lensFlare" {
  52832. import { Nullable } from "babylonjs/types";
  52833. import { Color3 } from "babylonjs/Maths/math.color";
  52834. import { Texture } from "babylonjs/Materials/Textures/texture";
  52835. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52836. /**
  52837. * This represents one of the lens effect in a `lensFlareSystem`.
  52838. * It controls one of the indiviual texture used in the effect.
  52839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52840. */
  52841. export class LensFlare {
  52842. /**
  52843. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52844. */
  52845. size: number;
  52846. /**
  52847. * 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.
  52848. */
  52849. position: number;
  52850. /**
  52851. * Define the lens color.
  52852. */
  52853. color: Color3;
  52854. /**
  52855. * Define the lens texture.
  52856. */
  52857. texture: Nullable<Texture>;
  52858. /**
  52859. * Define the alpha mode to render this particular lens.
  52860. */
  52861. alphaMode: number;
  52862. private _system;
  52863. /**
  52864. * Creates a new Lens Flare.
  52865. * This represents one of the lens effect in a `lensFlareSystem`.
  52866. * It controls one of the indiviual texture used in the effect.
  52867. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52868. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52869. * @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.
  52870. * @param color Define the lens color
  52871. * @param imgUrl Define the lens texture url
  52872. * @param system Define the `lensFlareSystem` this flare is part of
  52873. * @returns The newly created Lens Flare
  52874. */
  52875. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52876. /**
  52877. * Instantiates a new Lens Flare.
  52878. * This represents one of the lens effect in a `lensFlareSystem`.
  52879. * It controls one of the indiviual texture used in the effect.
  52880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52881. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52882. * @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.
  52883. * @param color Define the lens color
  52884. * @param imgUrl Define the lens texture url
  52885. * @param system Define the `lensFlareSystem` this flare is part of
  52886. */
  52887. constructor(
  52888. /**
  52889. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52890. */
  52891. size: number,
  52892. /**
  52893. * 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.
  52894. */
  52895. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52896. /**
  52897. * Dispose and release the lens flare with its associated resources.
  52898. */
  52899. dispose(): void;
  52900. }
  52901. }
  52902. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52903. import { Nullable } from "babylonjs/types";
  52904. import { Scene } from "babylonjs/scene";
  52905. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52906. import { AbstractScene } from "babylonjs/abstractScene";
  52907. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52908. module "babylonjs/abstractScene" {
  52909. interface AbstractScene {
  52910. /**
  52911. * The list of lens flare system added to the scene
  52912. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52913. */
  52914. lensFlareSystems: Array<LensFlareSystem>;
  52915. /**
  52916. * Removes the given lens flare system from this scene.
  52917. * @param toRemove The lens flare system to remove
  52918. * @returns The index of the removed lens flare system
  52919. */
  52920. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52921. /**
  52922. * Adds the given lens flare system to this scene
  52923. * @param newLensFlareSystem The lens flare system to add
  52924. */
  52925. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52926. /**
  52927. * Gets a lens flare system using its name
  52928. * @param name defines the name to look for
  52929. * @returns the lens flare system or null if not found
  52930. */
  52931. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52932. /**
  52933. * Gets a lens flare system using its id
  52934. * @param id defines the id to look for
  52935. * @returns the lens flare system or null if not found
  52936. */
  52937. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52938. }
  52939. }
  52940. /**
  52941. * Defines the lens flare scene component responsible to manage any lens flares
  52942. * in a given scene.
  52943. */
  52944. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52945. /**
  52946. * The component name helpfull to identify the component in the list of scene components.
  52947. */
  52948. readonly name: string;
  52949. /**
  52950. * The scene the component belongs to.
  52951. */
  52952. scene: Scene;
  52953. /**
  52954. * Creates a new instance of the component for the given scene
  52955. * @param scene Defines the scene to register the component in
  52956. */
  52957. constructor(scene: Scene);
  52958. /**
  52959. * Registers the component in a given scene
  52960. */
  52961. register(): void;
  52962. /**
  52963. * Rebuilds the elements related to this component in case of
  52964. * context lost for instance.
  52965. */
  52966. rebuild(): void;
  52967. /**
  52968. * Adds all the elements from the container to the scene
  52969. * @param container the container holding the elements
  52970. */
  52971. addFromContainer(container: AbstractScene): void;
  52972. /**
  52973. * Removes all the elements in the container from the scene
  52974. * @param container contains the elements to remove
  52975. * @param dispose if the removed element should be disposed (default: false)
  52976. */
  52977. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52978. /**
  52979. * Serializes the component data to the specified json object
  52980. * @param serializationObject The object to serialize to
  52981. */
  52982. serialize(serializationObject: any): void;
  52983. /**
  52984. * Disposes the component and the associated ressources.
  52985. */
  52986. dispose(): void;
  52987. private _draw;
  52988. }
  52989. }
  52990. declare module "babylonjs/LensFlares/index" {
  52991. export * from "babylonjs/LensFlares/lensFlare";
  52992. export * from "babylonjs/LensFlares/lensFlareSystem";
  52993. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52994. }
  52995. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52996. import { Scene } from "babylonjs/scene";
  52997. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52998. import { AbstractScene } from "babylonjs/abstractScene";
  52999. /**
  53000. * Defines the shadow generator component responsible to manage any shadow generators
  53001. * in a given scene.
  53002. */
  53003. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53004. /**
  53005. * The component name helpfull to identify the component in the list of scene components.
  53006. */
  53007. readonly name: string;
  53008. /**
  53009. * The scene the component belongs to.
  53010. */
  53011. scene: Scene;
  53012. /**
  53013. * Creates a new instance of the component for the given scene
  53014. * @param scene Defines the scene to register the component in
  53015. */
  53016. constructor(scene: Scene);
  53017. /**
  53018. * Registers the component in a given scene
  53019. */
  53020. register(): void;
  53021. /**
  53022. * Rebuilds the elements related to this component in case of
  53023. * context lost for instance.
  53024. */
  53025. rebuild(): void;
  53026. /**
  53027. * Serializes the component data to the specified json object
  53028. * @param serializationObject The object to serialize to
  53029. */
  53030. serialize(serializationObject: any): void;
  53031. /**
  53032. * Adds all the elements from the container to the scene
  53033. * @param container the container holding the elements
  53034. */
  53035. addFromContainer(container: AbstractScene): void;
  53036. /**
  53037. * Removes all the elements in the container from the scene
  53038. * @param container contains the elements to remove
  53039. * @param dispose if the removed element should be disposed (default: false)
  53040. */
  53041. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53042. /**
  53043. * Rebuilds the elements related to this component in case of
  53044. * context lost for instance.
  53045. */
  53046. dispose(): void;
  53047. private _gatherRenderTargets;
  53048. }
  53049. }
  53050. declare module "babylonjs/Lights/Shadows/index" {
  53051. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53052. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53053. }
  53054. declare module "babylonjs/Lights/pointLight" {
  53055. import { Scene } from "babylonjs/scene";
  53056. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53058. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53059. import { Effect } from "babylonjs/Materials/effect";
  53060. /**
  53061. * A point light is a light defined by an unique point in world space.
  53062. * The light is emitted in every direction from this point.
  53063. * A good example of a point light is a standard light bulb.
  53064. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53065. */
  53066. export class PointLight extends ShadowLight {
  53067. private _shadowAngle;
  53068. /**
  53069. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53070. * This specifies what angle the shadow will use to be created.
  53071. *
  53072. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53073. */
  53074. /**
  53075. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53076. * This specifies what angle the shadow will use to be created.
  53077. *
  53078. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53079. */
  53080. shadowAngle: number;
  53081. /**
  53082. * Gets the direction if it has been set.
  53083. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53084. */
  53085. /**
  53086. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53087. */
  53088. direction: Vector3;
  53089. /**
  53090. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53091. * A PointLight emits the light in every direction.
  53092. * It can cast shadows.
  53093. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53094. * ```javascript
  53095. * var pointLight = new PointLight("pl", camera.position, scene);
  53096. * ```
  53097. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53098. * @param name The light friendly name
  53099. * @param position The position of the point light in the scene
  53100. * @param scene The scene the lights belongs to
  53101. */
  53102. constructor(name: string, position: Vector3, scene: Scene);
  53103. /**
  53104. * Returns the string "PointLight"
  53105. * @returns the class name
  53106. */
  53107. getClassName(): string;
  53108. /**
  53109. * Returns the integer 0.
  53110. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53111. */
  53112. getTypeID(): number;
  53113. /**
  53114. * Specifies wether or not the shadowmap should be a cube texture.
  53115. * @returns true if the shadowmap needs to be a cube texture.
  53116. */
  53117. needCube(): boolean;
  53118. /**
  53119. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53120. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53121. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53122. */
  53123. getShadowDirection(faceIndex?: number): Vector3;
  53124. /**
  53125. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53126. * - fov = PI / 2
  53127. * - aspect ratio : 1.0
  53128. * - z-near and far equal to the active camera minZ and maxZ.
  53129. * Returns the PointLight.
  53130. */
  53131. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53132. protected _buildUniformLayout(): void;
  53133. /**
  53134. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53135. * @param effect The effect to update
  53136. * @param lightIndex The index of the light in the effect to update
  53137. * @returns The point light
  53138. */
  53139. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53140. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53141. /**
  53142. * Prepares the list of defines specific to the light type.
  53143. * @param defines the list of defines
  53144. * @param lightIndex defines the index of the light for the effect
  53145. */
  53146. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53147. }
  53148. }
  53149. declare module "babylonjs/Lights/index" {
  53150. export * from "babylonjs/Lights/light";
  53151. export * from "babylonjs/Lights/shadowLight";
  53152. export * from "babylonjs/Lights/Shadows/index";
  53153. export * from "babylonjs/Lights/directionalLight";
  53154. export * from "babylonjs/Lights/hemisphericLight";
  53155. export * from "babylonjs/Lights/pointLight";
  53156. export * from "babylonjs/Lights/spotLight";
  53157. }
  53158. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53159. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53160. /**
  53161. * Header information of HDR texture files.
  53162. */
  53163. export interface HDRInfo {
  53164. /**
  53165. * The height of the texture in pixels.
  53166. */
  53167. height: number;
  53168. /**
  53169. * The width of the texture in pixels.
  53170. */
  53171. width: number;
  53172. /**
  53173. * The index of the beginning of the data in the binary file.
  53174. */
  53175. dataPosition: number;
  53176. }
  53177. /**
  53178. * This groups tools to convert HDR texture to native colors array.
  53179. */
  53180. export class HDRTools {
  53181. private static Ldexp;
  53182. private static Rgbe2float;
  53183. private static readStringLine;
  53184. /**
  53185. * Reads header information from an RGBE texture stored in a native array.
  53186. * More information on this format are available here:
  53187. * https://en.wikipedia.org/wiki/RGBE_image_format
  53188. *
  53189. * @param uint8array The binary file stored in native array.
  53190. * @return The header information.
  53191. */
  53192. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53193. /**
  53194. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53195. * This RGBE texture needs to store the information as a panorama.
  53196. *
  53197. * More information on this format are available here:
  53198. * https://en.wikipedia.org/wiki/RGBE_image_format
  53199. *
  53200. * @param buffer The binary file stored in an array buffer.
  53201. * @param size The expected size of the extracted cubemap.
  53202. * @return The Cube Map information.
  53203. */
  53204. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53205. /**
  53206. * Returns the pixels data extracted from an RGBE texture.
  53207. * This pixels will be stored left to right up to down in the R G B order in one array.
  53208. *
  53209. * More information on this format are available here:
  53210. * https://en.wikipedia.org/wiki/RGBE_image_format
  53211. *
  53212. * @param uint8array The binary file stored in an array buffer.
  53213. * @param hdrInfo The header information of the file.
  53214. * @return The pixels data in RGB right to left up to down order.
  53215. */
  53216. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53217. private static RGBE_ReadPixels_RLE;
  53218. }
  53219. }
  53220. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53221. import { Nullable } from "babylonjs/types";
  53222. import { Scene } from "babylonjs/scene";
  53223. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53225. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53226. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53227. /**
  53228. * This represents a texture coming from an HDR input.
  53229. *
  53230. * The only supported format is currently panorama picture stored in RGBE format.
  53231. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53232. */
  53233. export class HDRCubeTexture extends BaseTexture {
  53234. private static _facesMapping;
  53235. private _generateHarmonics;
  53236. private _noMipmap;
  53237. private _textureMatrix;
  53238. private _size;
  53239. private _onLoad;
  53240. private _onError;
  53241. /**
  53242. * The texture URL.
  53243. */
  53244. url: string;
  53245. /**
  53246. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53247. */
  53248. coordinatesMode: number;
  53249. protected _isBlocking: boolean;
  53250. /**
  53251. * Sets wether or not the texture is blocking during loading.
  53252. */
  53253. /**
  53254. * Gets wether or not the texture is blocking during loading.
  53255. */
  53256. isBlocking: boolean;
  53257. protected _rotationY: number;
  53258. /**
  53259. * Sets texture matrix rotation angle around Y axis in radians.
  53260. */
  53261. /**
  53262. * Gets texture matrix rotation angle around Y axis radians.
  53263. */
  53264. rotationY: number;
  53265. /**
  53266. * Gets or sets the center of the bounding box associated with the cube texture
  53267. * It must define where the camera used to render the texture was set
  53268. */
  53269. boundingBoxPosition: Vector3;
  53270. private _boundingBoxSize;
  53271. /**
  53272. * Gets or sets the size of the bounding box associated with the cube texture
  53273. * When defined, the cubemap will switch to local mode
  53274. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53275. * @example https://www.babylonjs-playground.com/#RNASML
  53276. */
  53277. boundingBoxSize: Vector3;
  53278. /**
  53279. * Instantiates an HDRTexture from the following parameters.
  53280. *
  53281. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53282. * @param scene The scene the texture will be used in
  53283. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53284. * @param noMipmap Forces to not generate the mipmap if true
  53285. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53286. * @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)
  53287. * @param reserved Reserved flag for internal use.
  53288. */
  53289. 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>);
  53290. /**
  53291. * Get the current class name of the texture useful for serialization or dynamic coding.
  53292. * @returns "HDRCubeTexture"
  53293. */
  53294. getClassName(): string;
  53295. /**
  53296. * Occurs when the file is raw .hdr file.
  53297. */
  53298. private loadTexture;
  53299. clone(): HDRCubeTexture;
  53300. delayLoad(): void;
  53301. /**
  53302. * Get the texture reflection matrix used to rotate/transform the reflection.
  53303. * @returns the reflection matrix
  53304. */
  53305. getReflectionTextureMatrix(): Matrix;
  53306. /**
  53307. * Set the texture reflection matrix used to rotate/transform the reflection.
  53308. * @param value Define the reflection matrix to set
  53309. */
  53310. setReflectionTextureMatrix(value: Matrix): void;
  53311. /**
  53312. * Parses a JSON representation of an HDR Texture in order to create the texture
  53313. * @param parsedTexture Define the JSON representation
  53314. * @param scene Define the scene the texture should be created in
  53315. * @param rootUrl Define the root url in case we need to load relative dependencies
  53316. * @returns the newly created texture after parsing
  53317. */
  53318. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53319. serialize(): any;
  53320. }
  53321. }
  53322. declare module "babylonjs/Physics/physicsEngine" {
  53323. import { Nullable } from "babylonjs/types";
  53324. import { Vector3 } from "babylonjs/Maths/math.vector";
  53325. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53326. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53327. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53328. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53329. /**
  53330. * Class used to control physics engine
  53331. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53332. */
  53333. export class PhysicsEngine implements IPhysicsEngine {
  53334. private _physicsPlugin;
  53335. /**
  53336. * Global value used to control the smallest number supported by the simulation
  53337. */
  53338. static Epsilon: number;
  53339. private _impostors;
  53340. private _joints;
  53341. /**
  53342. * Gets the gravity vector used by the simulation
  53343. */
  53344. gravity: Vector3;
  53345. /**
  53346. * Factory used to create the default physics plugin.
  53347. * @returns The default physics plugin
  53348. */
  53349. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53350. /**
  53351. * Creates a new Physics Engine
  53352. * @param gravity defines the gravity vector used by the simulation
  53353. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53354. */
  53355. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53356. /**
  53357. * Sets the gravity vector used by the simulation
  53358. * @param gravity defines the gravity vector to use
  53359. */
  53360. setGravity(gravity: Vector3): void;
  53361. /**
  53362. * Set the time step of the physics engine.
  53363. * Default is 1/60.
  53364. * To slow it down, enter 1/600 for example.
  53365. * To speed it up, 1/30
  53366. * @param newTimeStep defines the new timestep to apply to this world.
  53367. */
  53368. setTimeStep(newTimeStep?: number): void;
  53369. /**
  53370. * Get the time step of the physics engine.
  53371. * @returns the current time step
  53372. */
  53373. getTimeStep(): number;
  53374. /**
  53375. * Release all resources
  53376. */
  53377. dispose(): void;
  53378. /**
  53379. * Gets the name of the current physics plugin
  53380. * @returns the name of the plugin
  53381. */
  53382. getPhysicsPluginName(): string;
  53383. /**
  53384. * Adding a new impostor for the impostor tracking.
  53385. * This will be done by the impostor itself.
  53386. * @param impostor the impostor to add
  53387. */
  53388. addImpostor(impostor: PhysicsImpostor): void;
  53389. /**
  53390. * Remove an impostor from the engine.
  53391. * This impostor and its mesh will not longer be updated by the physics engine.
  53392. * @param impostor the impostor to remove
  53393. */
  53394. removeImpostor(impostor: PhysicsImpostor): void;
  53395. /**
  53396. * Add a joint to the physics engine
  53397. * @param mainImpostor defines the main impostor to which the joint is added.
  53398. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53399. * @param joint defines the joint that will connect both impostors.
  53400. */
  53401. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53402. /**
  53403. * Removes a joint from the simulation
  53404. * @param mainImpostor defines the impostor used with the joint
  53405. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53406. * @param joint defines the joint to remove
  53407. */
  53408. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53409. /**
  53410. * Called by the scene. No need to call it.
  53411. * @param delta defines the timespam between frames
  53412. */
  53413. _step(delta: number): void;
  53414. /**
  53415. * Gets the current plugin used to run the simulation
  53416. * @returns current plugin
  53417. */
  53418. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53419. /**
  53420. * Gets the list of physic impostors
  53421. * @returns an array of PhysicsImpostor
  53422. */
  53423. getImpostors(): Array<PhysicsImpostor>;
  53424. /**
  53425. * Gets the impostor for a physics enabled object
  53426. * @param object defines the object impersonated by the impostor
  53427. * @returns the PhysicsImpostor or null if not found
  53428. */
  53429. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53430. /**
  53431. * Gets the impostor for a physics body object
  53432. * @param body defines physics body used by the impostor
  53433. * @returns the PhysicsImpostor or null if not found
  53434. */
  53435. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53436. /**
  53437. * Does a raycast in the physics world
  53438. * @param from when should the ray start?
  53439. * @param to when should the ray end?
  53440. * @returns PhysicsRaycastResult
  53441. */
  53442. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53443. }
  53444. }
  53445. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53446. import { Nullable } from "babylonjs/types";
  53447. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53449. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53450. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53451. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53452. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53453. /** @hidden */
  53454. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53455. private _useDeltaForWorldStep;
  53456. world: any;
  53457. name: string;
  53458. private _physicsMaterials;
  53459. private _fixedTimeStep;
  53460. private _cannonRaycastResult;
  53461. private _raycastResult;
  53462. private _physicsBodysToRemoveAfterStep;
  53463. BJSCANNON: any;
  53464. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53465. setGravity(gravity: Vector3): void;
  53466. setTimeStep(timeStep: number): void;
  53467. getTimeStep(): number;
  53468. executeStep(delta: number): void;
  53469. private _removeMarkedPhysicsBodiesFromWorld;
  53470. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53471. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53472. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53473. private _processChildMeshes;
  53474. removePhysicsBody(impostor: PhysicsImpostor): void;
  53475. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53476. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53477. private _addMaterial;
  53478. private _checkWithEpsilon;
  53479. private _createShape;
  53480. private _createHeightmap;
  53481. private _minus90X;
  53482. private _plus90X;
  53483. private _tmpPosition;
  53484. private _tmpDeltaPosition;
  53485. private _tmpUnityRotation;
  53486. private _updatePhysicsBodyTransformation;
  53487. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53488. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53489. isSupported(): boolean;
  53490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53491. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53492. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53493. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53494. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53495. getBodyMass(impostor: PhysicsImpostor): number;
  53496. getBodyFriction(impostor: PhysicsImpostor): number;
  53497. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53498. getBodyRestitution(impostor: PhysicsImpostor): number;
  53499. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53500. sleepBody(impostor: PhysicsImpostor): void;
  53501. wakeUpBody(impostor: PhysicsImpostor): void;
  53502. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53503. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53504. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53505. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53506. getRadius(impostor: PhysicsImpostor): number;
  53507. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53508. dispose(): void;
  53509. private _extendNamespace;
  53510. /**
  53511. * Does a raycast in the physics world
  53512. * @param from when should the ray start?
  53513. * @param to when should the ray end?
  53514. * @returns PhysicsRaycastResult
  53515. */
  53516. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53517. }
  53518. }
  53519. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53520. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53521. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53522. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53524. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53525. import { Nullable } from "babylonjs/types";
  53526. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53527. /** @hidden */
  53528. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53529. world: any;
  53530. name: string;
  53531. BJSOIMO: any;
  53532. private _raycastResult;
  53533. constructor(iterations?: number, oimoInjection?: any);
  53534. setGravity(gravity: Vector3): void;
  53535. setTimeStep(timeStep: number): void;
  53536. getTimeStep(): number;
  53537. private _tmpImpostorsArray;
  53538. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53539. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53540. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53541. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53542. private _tmpPositionVector;
  53543. removePhysicsBody(impostor: PhysicsImpostor): void;
  53544. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53545. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53546. isSupported(): boolean;
  53547. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53548. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53549. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53550. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53551. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53552. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53553. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53554. getBodyMass(impostor: PhysicsImpostor): number;
  53555. getBodyFriction(impostor: PhysicsImpostor): number;
  53556. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53557. getBodyRestitution(impostor: PhysicsImpostor): number;
  53558. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53559. sleepBody(impostor: PhysicsImpostor): void;
  53560. wakeUpBody(impostor: PhysicsImpostor): void;
  53561. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53562. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53563. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53564. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53565. getRadius(impostor: PhysicsImpostor): number;
  53566. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53567. dispose(): void;
  53568. /**
  53569. * Does a raycast in the physics world
  53570. * @param from when should the ray start?
  53571. * @param to when should the ray end?
  53572. * @returns PhysicsRaycastResult
  53573. */
  53574. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53575. }
  53576. }
  53577. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53578. import { Nullable } from "babylonjs/types";
  53579. import { Scene } from "babylonjs/scene";
  53580. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53581. import { Color4 } from "babylonjs/Maths/math.color";
  53582. import { Mesh } from "babylonjs/Meshes/mesh";
  53583. /**
  53584. * Class containing static functions to help procedurally build meshes
  53585. */
  53586. export class RibbonBuilder {
  53587. /**
  53588. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53589. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53590. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53591. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53592. * * 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
  53593. * * 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
  53594. * * 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
  53595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53598. * * 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
  53599. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53600. * * 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
  53601. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53603. * @param name defines the name of the mesh
  53604. * @param options defines the options used to create the mesh
  53605. * @param scene defines the hosting scene
  53606. * @returns the ribbon mesh
  53607. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53609. */
  53610. static CreateRibbon(name: string, options: {
  53611. pathArray: Vector3[][];
  53612. closeArray?: boolean;
  53613. closePath?: boolean;
  53614. offset?: number;
  53615. updatable?: boolean;
  53616. sideOrientation?: number;
  53617. frontUVs?: Vector4;
  53618. backUVs?: Vector4;
  53619. instance?: Mesh;
  53620. invertUV?: boolean;
  53621. uvs?: Vector2[];
  53622. colors?: Color4[];
  53623. }, scene?: Nullable<Scene>): Mesh;
  53624. }
  53625. }
  53626. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53627. import { Nullable } from "babylonjs/types";
  53628. import { Scene } from "babylonjs/scene";
  53629. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53630. import { Mesh } from "babylonjs/Meshes/mesh";
  53631. /**
  53632. * Class containing static functions to help procedurally build meshes
  53633. */
  53634. export class ShapeBuilder {
  53635. /**
  53636. * 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.
  53637. * * 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.
  53638. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53639. * * 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.
  53640. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53641. * * 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
  53642. * * 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
  53643. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53648. * @param name defines the name of the mesh
  53649. * @param options defines the options used to create the mesh
  53650. * @param scene defines the hosting scene
  53651. * @returns the extruded shape mesh
  53652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53654. */
  53655. static ExtrudeShape(name: string, options: {
  53656. shape: Vector3[];
  53657. path: Vector3[];
  53658. scale?: number;
  53659. rotation?: number;
  53660. cap?: number;
  53661. updatable?: boolean;
  53662. sideOrientation?: number;
  53663. frontUVs?: Vector4;
  53664. backUVs?: Vector4;
  53665. instance?: Mesh;
  53666. invertUV?: boolean;
  53667. }, scene?: Nullable<Scene>): Mesh;
  53668. /**
  53669. * Creates an custom extruded shape mesh.
  53670. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53671. * * 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.
  53672. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53673. * * 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
  53674. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53675. * * 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
  53676. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53677. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53678. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53679. * * 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
  53680. * * 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
  53681. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53684. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53686. * @param name defines the name of the mesh
  53687. * @param options defines the options used to create the mesh
  53688. * @param scene defines the hosting scene
  53689. * @returns the custom extruded shape mesh
  53690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53693. */
  53694. static ExtrudeShapeCustom(name: string, options: {
  53695. shape: Vector3[];
  53696. path: Vector3[];
  53697. scaleFunction?: any;
  53698. rotationFunction?: any;
  53699. ribbonCloseArray?: boolean;
  53700. ribbonClosePath?: boolean;
  53701. cap?: number;
  53702. updatable?: boolean;
  53703. sideOrientation?: number;
  53704. frontUVs?: Vector4;
  53705. backUVs?: Vector4;
  53706. instance?: Mesh;
  53707. invertUV?: boolean;
  53708. }, scene?: Nullable<Scene>): Mesh;
  53709. private static _ExtrudeShapeGeneric;
  53710. }
  53711. }
  53712. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53713. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53714. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53715. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53716. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53717. import { Nullable } from "babylonjs/types";
  53718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53719. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53720. /**
  53721. * AmmoJS Physics plugin
  53722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53723. * @see https://github.com/kripken/ammo.js/
  53724. */
  53725. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53726. private _useDeltaForWorldStep;
  53727. /**
  53728. * Reference to the Ammo library
  53729. */
  53730. bjsAMMO: any;
  53731. /**
  53732. * Created ammoJS world which physics bodies are added to
  53733. */
  53734. world: any;
  53735. /**
  53736. * Name of the plugin
  53737. */
  53738. name: string;
  53739. private _timeStep;
  53740. private _fixedTimeStep;
  53741. private _maxSteps;
  53742. private _tmpQuaternion;
  53743. private _tmpAmmoTransform;
  53744. private _tmpAmmoQuaternion;
  53745. private _tmpAmmoConcreteContactResultCallback;
  53746. private _collisionConfiguration;
  53747. private _dispatcher;
  53748. private _overlappingPairCache;
  53749. private _solver;
  53750. private _softBodySolver;
  53751. private _tmpAmmoVectorA;
  53752. private _tmpAmmoVectorB;
  53753. private _tmpAmmoVectorC;
  53754. private _tmpAmmoVectorD;
  53755. private _tmpContactCallbackResult;
  53756. private _tmpAmmoVectorRCA;
  53757. private _tmpAmmoVectorRCB;
  53758. private _raycastResult;
  53759. private static readonly DISABLE_COLLISION_FLAG;
  53760. private static readonly KINEMATIC_FLAG;
  53761. private static readonly DISABLE_DEACTIVATION_FLAG;
  53762. /**
  53763. * Initializes the ammoJS plugin
  53764. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53765. * @param ammoInjection can be used to inject your own ammo reference
  53766. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53767. */
  53768. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53769. /**
  53770. * Sets the gravity of the physics world (m/(s^2))
  53771. * @param gravity Gravity to set
  53772. */
  53773. setGravity(gravity: Vector3): void;
  53774. /**
  53775. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53776. * @param timeStep timestep to use in seconds
  53777. */
  53778. setTimeStep(timeStep: number): void;
  53779. /**
  53780. * 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)
  53781. * @param fixedTimeStep fixedTimeStep to use in seconds
  53782. */
  53783. setFixedTimeStep(fixedTimeStep: number): void;
  53784. /**
  53785. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53786. * @param maxSteps the maximum number of steps by the physics engine per frame
  53787. */
  53788. setMaxSteps(maxSteps: number): void;
  53789. /**
  53790. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53791. * @returns the current timestep in seconds
  53792. */
  53793. getTimeStep(): number;
  53794. private _isImpostorInContact;
  53795. private _isImpostorPairInContact;
  53796. private _stepSimulation;
  53797. /**
  53798. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53799. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53800. * After the step the babylon meshes are set to the position of the physics imposters
  53801. * @param delta amount of time to step forward
  53802. * @param impostors array of imposters to update before/after the step
  53803. */
  53804. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53805. /**
  53806. * Update babylon mesh to match physics world object
  53807. * @param impostor imposter to match
  53808. */
  53809. private _afterSoftStep;
  53810. /**
  53811. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53812. * @param impostor imposter to match
  53813. */
  53814. private _ropeStep;
  53815. /**
  53816. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53817. * @param impostor imposter to match
  53818. */
  53819. private _softbodyOrClothStep;
  53820. private _tmpVector;
  53821. private _tmpMatrix;
  53822. /**
  53823. * Applies an impulse on the imposter
  53824. * @param impostor imposter to apply impulse to
  53825. * @param force amount of force to be applied to the imposter
  53826. * @param contactPoint the location to apply the impulse on the imposter
  53827. */
  53828. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53829. /**
  53830. * Applies a force on the imposter
  53831. * @param impostor imposter to apply force
  53832. * @param force amount of force to be applied to the imposter
  53833. * @param contactPoint the location to apply the force on the imposter
  53834. */
  53835. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53836. /**
  53837. * Creates a physics body using the plugin
  53838. * @param impostor the imposter to create the physics body on
  53839. */
  53840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53841. /**
  53842. * Removes the physics body from the imposter and disposes of the body's memory
  53843. * @param impostor imposter to remove the physics body from
  53844. */
  53845. removePhysicsBody(impostor: PhysicsImpostor): void;
  53846. /**
  53847. * Generates a joint
  53848. * @param impostorJoint the imposter joint to create the joint with
  53849. */
  53850. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53851. /**
  53852. * Removes a joint
  53853. * @param impostorJoint the imposter joint to remove the joint from
  53854. */
  53855. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53856. private _addMeshVerts;
  53857. /**
  53858. * Initialise the soft body vertices to match its object's (mesh) vertices
  53859. * Softbody vertices (nodes) are in world space and to match this
  53860. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53861. * @param impostor to create the softbody for
  53862. */
  53863. private _softVertexData;
  53864. /**
  53865. * Create an impostor's soft body
  53866. * @param impostor to create the softbody for
  53867. */
  53868. private _createSoftbody;
  53869. /**
  53870. * Create cloth for an impostor
  53871. * @param impostor to create the softbody for
  53872. */
  53873. private _createCloth;
  53874. /**
  53875. * Create rope for an impostor
  53876. * @param impostor to create the softbody for
  53877. */
  53878. private _createRope;
  53879. private _addHullVerts;
  53880. private _createShape;
  53881. /**
  53882. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53883. * @param impostor imposter containing the physics body and babylon object
  53884. */
  53885. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53886. /**
  53887. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53888. * @param impostor imposter containing the physics body and babylon object
  53889. * @param newPosition new position
  53890. * @param newRotation new rotation
  53891. */
  53892. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53893. /**
  53894. * If this plugin is supported
  53895. * @returns true if its supported
  53896. */
  53897. isSupported(): boolean;
  53898. /**
  53899. * Sets the linear velocity of the physics body
  53900. * @param impostor imposter to set the velocity on
  53901. * @param velocity velocity to set
  53902. */
  53903. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53904. /**
  53905. * Sets the angular velocity of the physics body
  53906. * @param impostor imposter to set the velocity on
  53907. * @param velocity velocity to set
  53908. */
  53909. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53910. /**
  53911. * gets the linear velocity
  53912. * @param impostor imposter to get linear velocity from
  53913. * @returns linear velocity
  53914. */
  53915. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53916. /**
  53917. * gets the angular velocity
  53918. * @param impostor imposter to get angular velocity from
  53919. * @returns angular velocity
  53920. */
  53921. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53922. /**
  53923. * Sets the mass of physics body
  53924. * @param impostor imposter to set the mass on
  53925. * @param mass mass to set
  53926. */
  53927. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53928. /**
  53929. * Gets the mass of the physics body
  53930. * @param impostor imposter to get the mass from
  53931. * @returns mass
  53932. */
  53933. getBodyMass(impostor: PhysicsImpostor): number;
  53934. /**
  53935. * Gets friction of the impostor
  53936. * @param impostor impostor to get friction from
  53937. * @returns friction value
  53938. */
  53939. getBodyFriction(impostor: PhysicsImpostor): number;
  53940. /**
  53941. * Sets friction of the impostor
  53942. * @param impostor impostor to set friction on
  53943. * @param friction friction value
  53944. */
  53945. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53946. /**
  53947. * Gets restitution of the impostor
  53948. * @param impostor impostor to get restitution from
  53949. * @returns restitution value
  53950. */
  53951. getBodyRestitution(impostor: PhysicsImpostor): number;
  53952. /**
  53953. * Sets resitution of the impostor
  53954. * @param impostor impostor to set resitution on
  53955. * @param restitution resitution value
  53956. */
  53957. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53958. /**
  53959. * Gets pressure inside the impostor
  53960. * @param impostor impostor to get pressure from
  53961. * @returns pressure value
  53962. */
  53963. getBodyPressure(impostor: PhysicsImpostor): number;
  53964. /**
  53965. * Sets pressure inside a soft body impostor
  53966. * Cloth and rope must remain 0 pressure
  53967. * @param impostor impostor to set pressure on
  53968. * @param pressure pressure value
  53969. */
  53970. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53971. /**
  53972. * Gets stiffness of the impostor
  53973. * @param impostor impostor to get stiffness from
  53974. * @returns pressure value
  53975. */
  53976. getBodyStiffness(impostor: PhysicsImpostor): number;
  53977. /**
  53978. * Sets stiffness of the impostor
  53979. * @param impostor impostor to set stiffness on
  53980. * @param stiffness stiffness value from 0 to 1
  53981. */
  53982. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53983. /**
  53984. * Gets velocityIterations of the impostor
  53985. * @param impostor impostor to get velocity iterations from
  53986. * @returns velocityIterations value
  53987. */
  53988. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53989. /**
  53990. * Sets velocityIterations of the impostor
  53991. * @param impostor impostor to set velocity iterations on
  53992. * @param velocityIterations velocityIterations value
  53993. */
  53994. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53995. /**
  53996. * Gets positionIterations of the impostor
  53997. * @param impostor impostor to get position iterations from
  53998. * @returns positionIterations value
  53999. */
  54000. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54001. /**
  54002. * Sets positionIterations of the impostor
  54003. * @param impostor impostor to set position on
  54004. * @param positionIterations positionIterations value
  54005. */
  54006. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54007. /**
  54008. * Append an anchor to a cloth object
  54009. * @param impostor is the cloth impostor to add anchor to
  54010. * @param otherImpostor is the rigid impostor to anchor to
  54011. * @param width ratio across width from 0 to 1
  54012. * @param height ratio up height from 0 to 1
  54013. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54014. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54015. */
  54016. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54017. /**
  54018. * Append an hook to a rope object
  54019. * @param impostor is the rope impostor to add hook to
  54020. * @param otherImpostor is the rigid impostor to hook to
  54021. * @param length ratio along the rope from 0 to 1
  54022. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54023. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54024. */
  54025. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54026. /**
  54027. * Sleeps the physics body and stops it from being active
  54028. * @param impostor impostor to sleep
  54029. */
  54030. sleepBody(impostor: PhysicsImpostor): void;
  54031. /**
  54032. * Activates the physics body
  54033. * @param impostor impostor to activate
  54034. */
  54035. wakeUpBody(impostor: PhysicsImpostor): void;
  54036. /**
  54037. * Updates the distance parameters of the joint
  54038. * @param joint joint to update
  54039. * @param maxDistance maximum distance of the joint
  54040. * @param minDistance minimum distance of the joint
  54041. */
  54042. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54043. /**
  54044. * Sets a motor on the joint
  54045. * @param joint joint to set motor on
  54046. * @param speed speed of the motor
  54047. * @param maxForce maximum force of the motor
  54048. * @param motorIndex index of the motor
  54049. */
  54050. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54051. /**
  54052. * Sets the motors limit
  54053. * @param joint joint to set limit on
  54054. * @param upperLimit upper limit
  54055. * @param lowerLimit lower limit
  54056. */
  54057. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54058. /**
  54059. * Syncs the position and rotation of a mesh with the impostor
  54060. * @param mesh mesh to sync
  54061. * @param impostor impostor to update the mesh with
  54062. */
  54063. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54064. /**
  54065. * Gets the radius of the impostor
  54066. * @param impostor impostor to get radius from
  54067. * @returns the radius
  54068. */
  54069. getRadius(impostor: PhysicsImpostor): number;
  54070. /**
  54071. * Gets the box size of the impostor
  54072. * @param impostor impostor to get box size from
  54073. * @param result the resulting box size
  54074. */
  54075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54076. /**
  54077. * Disposes of the impostor
  54078. */
  54079. dispose(): void;
  54080. /**
  54081. * Does a raycast in the physics world
  54082. * @param from when should the ray start?
  54083. * @param to when should the ray end?
  54084. * @returns PhysicsRaycastResult
  54085. */
  54086. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54087. }
  54088. }
  54089. declare module "babylonjs/Probes/reflectionProbe" {
  54090. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54091. import { Vector3 } from "babylonjs/Maths/math.vector";
  54092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54093. import { Nullable } from "babylonjs/types";
  54094. import { Scene } from "babylonjs/scene";
  54095. module "babylonjs/abstractScene" {
  54096. interface AbstractScene {
  54097. /**
  54098. * The list of reflection probes added to the scene
  54099. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54100. */
  54101. reflectionProbes: Array<ReflectionProbe>;
  54102. /**
  54103. * Removes the given reflection probe from this scene.
  54104. * @param toRemove The reflection probe to remove
  54105. * @returns The index of the removed reflection probe
  54106. */
  54107. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54108. /**
  54109. * Adds the given reflection probe to this scene.
  54110. * @param newReflectionProbe The reflection probe to add
  54111. */
  54112. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54113. }
  54114. }
  54115. /**
  54116. * Class used to generate realtime reflection / refraction cube textures
  54117. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54118. */
  54119. export class ReflectionProbe {
  54120. /** defines the name of the probe */
  54121. name: string;
  54122. private _scene;
  54123. private _renderTargetTexture;
  54124. private _projectionMatrix;
  54125. private _viewMatrix;
  54126. private _target;
  54127. private _add;
  54128. private _attachedMesh;
  54129. private _invertYAxis;
  54130. /** Gets or sets probe position (center of the cube map) */
  54131. position: Vector3;
  54132. /**
  54133. * Creates a new reflection probe
  54134. * @param name defines the name of the probe
  54135. * @param size defines the texture resolution (for each face)
  54136. * @param scene defines the hosting scene
  54137. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54138. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54139. */
  54140. constructor(
  54141. /** defines the name of the probe */
  54142. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54143. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54144. samples: number;
  54145. /** Gets or sets the refresh rate to use (on every frame by default) */
  54146. refreshRate: number;
  54147. /**
  54148. * Gets the hosting scene
  54149. * @returns a Scene
  54150. */
  54151. getScene(): Scene;
  54152. /** Gets the internal CubeTexture used to render to */
  54153. readonly cubeTexture: RenderTargetTexture;
  54154. /** Gets the list of meshes to render */
  54155. readonly renderList: Nullable<AbstractMesh[]>;
  54156. /**
  54157. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54158. * @param mesh defines the mesh to attach to
  54159. */
  54160. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54161. /**
  54162. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54163. * @param renderingGroupId The rendering group id corresponding to its index
  54164. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54165. */
  54166. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54167. /**
  54168. * Clean all associated resources
  54169. */
  54170. dispose(): void;
  54171. /**
  54172. * Converts the reflection probe information to a readable string for debug purpose.
  54173. * @param fullDetails Supports for multiple levels of logging within scene loading
  54174. * @returns the human readable reflection probe info
  54175. */
  54176. toString(fullDetails?: boolean): string;
  54177. /**
  54178. * Get the class name of the relfection probe.
  54179. * @returns "ReflectionProbe"
  54180. */
  54181. getClassName(): string;
  54182. /**
  54183. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54184. * @returns The JSON representation of the texture
  54185. */
  54186. serialize(): any;
  54187. /**
  54188. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54189. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54190. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54191. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54192. * @returns The parsed reflection probe if successful
  54193. */
  54194. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54195. }
  54196. }
  54197. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54198. /** @hidden */
  54199. export var _BabylonLoaderRegistered: boolean;
  54200. }
  54201. declare module "babylonjs/Loading/Plugins/index" {
  54202. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54203. }
  54204. declare module "babylonjs/Loading/index" {
  54205. export * from "babylonjs/Loading/loadingScreen";
  54206. export * from "babylonjs/Loading/Plugins/index";
  54207. export * from "babylonjs/Loading/sceneLoader";
  54208. export * from "babylonjs/Loading/sceneLoaderFlags";
  54209. }
  54210. declare module "babylonjs/Materials/Background/index" {
  54211. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54212. }
  54213. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54214. import { Scene } from "babylonjs/scene";
  54215. import { Color3 } from "babylonjs/Maths/math.color";
  54216. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54218. /**
  54219. * The Physically based simple base material of BJS.
  54220. *
  54221. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54222. * It is used as the base class for both the specGloss and metalRough conventions.
  54223. */
  54224. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54225. /**
  54226. * Number of Simultaneous lights allowed on the material.
  54227. */
  54228. maxSimultaneousLights: number;
  54229. /**
  54230. * If sets to true, disables all the lights affecting the material.
  54231. */
  54232. disableLighting: boolean;
  54233. /**
  54234. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54235. */
  54236. environmentTexture: BaseTexture;
  54237. /**
  54238. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54239. */
  54240. invertNormalMapX: boolean;
  54241. /**
  54242. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54243. */
  54244. invertNormalMapY: boolean;
  54245. /**
  54246. * Normal map used in the model.
  54247. */
  54248. normalTexture: BaseTexture;
  54249. /**
  54250. * Emissivie color used to self-illuminate the model.
  54251. */
  54252. emissiveColor: Color3;
  54253. /**
  54254. * Emissivie texture used to self-illuminate the model.
  54255. */
  54256. emissiveTexture: BaseTexture;
  54257. /**
  54258. * Occlusion Channel Strenght.
  54259. */
  54260. occlusionStrength: number;
  54261. /**
  54262. * Occlusion Texture of the material (adding extra occlusion effects).
  54263. */
  54264. occlusionTexture: BaseTexture;
  54265. /**
  54266. * Defines the alpha limits in alpha test mode.
  54267. */
  54268. alphaCutOff: number;
  54269. /**
  54270. * Gets the current double sided mode.
  54271. */
  54272. /**
  54273. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54274. */
  54275. doubleSided: boolean;
  54276. /**
  54277. * Stores the pre-calculated light information of a mesh in a texture.
  54278. */
  54279. lightmapTexture: BaseTexture;
  54280. /**
  54281. * If true, the light map contains occlusion information instead of lighting info.
  54282. */
  54283. useLightmapAsShadowmap: boolean;
  54284. /**
  54285. * Instantiates a new PBRMaterial instance.
  54286. *
  54287. * @param name The material name
  54288. * @param scene The scene the material will be use in.
  54289. */
  54290. constructor(name: string, scene: Scene);
  54291. getClassName(): string;
  54292. }
  54293. }
  54294. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54295. import { Scene } from "babylonjs/scene";
  54296. import { Color3 } from "babylonjs/Maths/math.color";
  54297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54298. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54299. /**
  54300. * The PBR material of BJS following the metal roughness convention.
  54301. *
  54302. * This fits to the PBR convention in the GLTF definition:
  54303. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54304. */
  54305. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54306. /**
  54307. * The base color has two different interpretations depending on the value of metalness.
  54308. * When the material is a metal, the base color is the specific measured reflectance value
  54309. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54310. * of the material.
  54311. */
  54312. baseColor: Color3;
  54313. /**
  54314. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54315. * well as opacity information in the alpha channel.
  54316. */
  54317. baseTexture: BaseTexture;
  54318. /**
  54319. * Specifies the metallic scalar value of the material.
  54320. * Can also be used to scale the metalness values of the metallic texture.
  54321. */
  54322. metallic: number;
  54323. /**
  54324. * Specifies the roughness scalar value of the material.
  54325. * Can also be used to scale the roughness values of the metallic texture.
  54326. */
  54327. roughness: number;
  54328. /**
  54329. * Texture containing both the metallic value in the B channel and the
  54330. * roughness value in the G channel to keep better precision.
  54331. */
  54332. metallicRoughnessTexture: BaseTexture;
  54333. /**
  54334. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54335. *
  54336. * @param name The material name
  54337. * @param scene The scene the material will be use in.
  54338. */
  54339. constructor(name: string, scene: Scene);
  54340. /**
  54341. * Return the currrent class name of the material.
  54342. */
  54343. getClassName(): string;
  54344. /**
  54345. * Makes a duplicate of the current material.
  54346. * @param name - name to use for the new material.
  54347. */
  54348. clone(name: string): PBRMetallicRoughnessMaterial;
  54349. /**
  54350. * Serialize the material to a parsable JSON object.
  54351. */
  54352. serialize(): any;
  54353. /**
  54354. * Parses a JSON object correponding to the serialize function.
  54355. */
  54356. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54357. }
  54358. }
  54359. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54360. import { Scene } from "babylonjs/scene";
  54361. import { Color3 } from "babylonjs/Maths/math.color";
  54362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54363. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54364. /**
  54365. * The PBR material of BJS following the specular glossiness convention.
  54366. *
  54367. * This fits to the PBR convention in the GLTF definition:
  54368. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54369. */
  54370. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54371. /**
  54372. * Specifies the diffuse color of the material.
  54373. */
  54374. diffuseColor: Color3;
  54375. /**
  54376. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54377. * channel.
  54378. */
  54379. diffuseTexture: BaseTexture;
  54380. /**
  54381. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54382. */
  54383. specularColor: Color3;
  54384. /**
  54385. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54386. */
  54387. glossiness: number;
  54388. /**
  54389. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54390. */
  54391. specularGlossinessTexture: BaseTexture;
  54392. /**
  54393. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54394. *
  54395. * @param name The material name
  54396. * @param scene The scene the material will be use in.
  54397. */
  54398. constructor(name: string, scene: Scene);
  54399. /**
  54400. * Return the currrent class name of the material.
  54401. */
  54402. getClassName(): string;
  54403. /**
  54404. * Makes a duplicate of the current material.
  54405. * @param name - name to use for the new material.
  54406. */
  54407. clone(name: string): PBRSpecularGlossinessMaterial;
  54408. /**
  54409. * Serialize the material to a parsable JSON object.
  54410. */
  54411. serialize(): any;
  54412. /**
  54413. * Parses a JSON object correponding to the serialize function.
  54414. */
  54415. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54416. }
  54417. }
  54418. declare module "babylonjs/Materials/PBR/index" {
  54419. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54420. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54421. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54422. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54423. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54424. }
  54425. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54426. import { Nullable } from "babylonjs/types";
  54427. import { Scene } from "babylonjs/scene";
  54428. import { Matrix } from "babylonjs/Maths/math.vector";
  54429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54430. /**
  54431. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54432. * It can help converting any input color in a desired output one. This can then be used to create effects
  54433. * from sepia, black and white to sixties or futuristic rendering...
  54434. *
  54435. * The only supported format is currently 3dl.
  54436. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54437. */
  54438. export class ColorGradingTexture extends BaseTexture {
  54439. /**
  54440. * The current texture matrix. (will always be identity in color grading texture)
  54441. */
  54442. private _textureMatrix;
  54443. /**
  54444. * The texture URL.
  54445. */
  54446. url: string;
  54447. /**
  54448. * Empty line regex stored for GC.
  54449. */
  54450. private static _noneEmptyLineRegex;
  54451. private _engine;
  54452. /**
  54453. * Instantiates a ColorGradingTexture from the following parameters.
  54454. *
  54455. * @param url The location of the color gradind data (currently only supporting 3dl)
  54456. * @param scene The scene the texture will be used in
  54457. */
  54458. constructor(url: string, scene: Scene);
  54459. /**
  54460. * Returns the texture matrix used in most of the material.
  54461. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54462. */
  54463. getTextureMatrix(): Matrix;
  54464. /**
  54465. * Occurs when the file being loaded is a .3dl LUT file.
  54466. */
  54467. private load3dlTexture;
  54468. /**
  54469. * Starts the loading process of the texture.
  54470. */
  54471. private loadTexture;
  54472. /**
  54473. * Clones the color gradind texture.
  54474. */
  54475. clone(): ColorGradingTexture;
  54476. /**
  54477. * Called during delayed load for textures.
  54478. */
  54479. delayLoad(): void;
  54480. /**
  54481. * Parses a color grading texture serialized by Babylon.
  54482. * @param parsedTexture The texture information being parsedTexture
  54483. * @param scene The scene to load the texture in
  54484. * @param rootUrl The root url of the data assets to load
  54485. * @return A color gradind texture
  54486. */
  54487. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54488. /**
  54489. * Serializes the LUT texture to json format.
  54490. */
  54491. serialize(): any;
  54492. }
  54493. }
  54494. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54496. import { Scene } from "babylonjs/scene";
  54497. import { Nullable } from "babylonjs/types";
  54498. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54499. /**
  54500. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54501. */
  54502. export class EquiRectangularCubeTexture extends BaseTexture {
  54503. /** The six faces of the cube. */
  54504. private static _FacesMapping;
  54505. private _noMipmap;
  54506. private _onLoad;
  54507. private _onError;
  54508. /** The size of the cubemap. */
  54509. private _size;
  54510. /** The buffer of the image. */
  54511. private _buffer;
  54512. /** The width of the input image. */
  54513. private _width;
  54514. /** The height of the input image. */
  54515. private _height;
  54516. /** The URL to the image. */
  54517. url: string;
  54518. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54519. coordinatesMode: number;
  54520. /**
  54521. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54522. * @param url The location of the image
  54523. * @param scene The scene the texture will be used in
  54524. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54525. * @param noMipmap Forces to not generate the mipmap if true
  54526. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54527. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54528. * @param onLoad — defines a callback called when texture is loaded
  54529. * @param onError — defines a callback called if there is an error
  54530. */
  54531. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54532. /**
  54533. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54534. */
  54535. private loadImage;
  54536. /**
  54537. * Convert the image buffer into a cubemap and create a CubeTexture.
  54538. */
  54539. private loadTexture;
  54540. /**
  54541. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54542. * @param buffer The ArrayBuffer that should be converted.
  54543. * @returns The buffer as Float32Array.
  54544. */
  54545. private getFloat32ArrayFromArrayBuffer;
  54546. /**
  54547. * Get the current class name of the texture useful for serialization or dynamic coding.
  54548. * @returns "EquiRectangularCubeTexture"
  54549. */
  54550. getClassName(): string;
  54551. /**
  54552. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54553. * @returns A clone of the current EquiRectangularCubeTexture.
  54554. */
  54555. clone(): EquiRectangularCubeTexture;
  54556. }
  54557. }
  54558. declare module "babylonjs/Misc/tga" {
  54559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54560. /**
  54561. * Based on jsTGALoader - Javascript loader for TGA file
  54562. * By Vincent Thibault
  54563. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54564. */
  54565. export class TGATools {
  54566. private static _TYPE_INDEXED;
  54567. private static _TYPE_RGB;
  54568. private static _TYPE_GREY;
  54569. private static _TYPE_RLE_INDEXED;
  54570. private static _TYPE_RLE_RGB;
  54571. private static _TYPE_RLE_GREY;
  54572. private static _ORIGIN_MASK;
  54573. private static _ORIGIN_SHIFT;
  54574. private static _ORIGIN_BL;
  54575. private static _ORIGIN_BR;
  54576. private static _ORIGIN_UL;
  54577. private static _ORIGIN_UR;
  54578. /**
  54579. * Gets the header of a TGA file
  54580. * @param data defines the TGA data
  54581. * @returns the header
  54582. */
  54583. static GetTGAHeader(data: Uint8Array): any;
  54584. /**
  54585. * Uploads TGA content to a Babylon Texture
  54586. * @hidden
  54587. */
  54588. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54589. /** @hidden */
  54590. 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;
  54591. /** @hidden */
  54592. 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;
  54593. /** @hidden */
  54594. 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;
  54595. /** @hidden */
  54596. 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;
  54597. /** @hidden */
  54598. 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;
  54599. /** @hidden */
  54600. 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;
  54601. }
  54602. }
  54603. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54604. import { Nullable } from "babylonjs/types";
  54605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54606. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54607. /**
  54608. * Implementation of the TGA Texture Loader.
  54609. * @hidden
  54610. */
  54611. export class _TGATextureLoader implements IInternalTextureLoader {
  54612. /**
  54613. * Defines wether the loader supports cascade loading the different faces.
  54614. */
  54615. readonly supportCascades: boolean;
  54616. /**
  54617. * This returns if the loader support the current file information.
  54618. * @param extension defines the file extension of the file being loaded
  54619. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54620. * @param fallback defines the fallback internal texture if any
  54621. * @param isBase64 defines whether the texture is encoded as a base64
  54622. * @param isBuffer defines whether the texture data are stored as a buffer
  54623. * @returns true if the loader can load the specified file
  54624. */
  54625. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54626. /**
  54627. * Transform the url before loading if required.
  54628. * @param rootUrl the url of the texture
  54629. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54630. * @returns the transformed texture
  54631. */
  54632. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54633. /**
  54634. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54635. * @param rootUrl the url of the texture
  54636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54637. * @returns the fallback texture
  54638. */
  54639. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54640. /**
  54641. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54642. * @param data contains the texture data
  54643. * @param texture defines the BabylonJS internal texture
  54644. * @param createPolynomials will be true if polynomials have been requested
  54645. * @param onLoad defines the callback to trigger once the texture is ready
  54646. * @param onError defines the callback to trigger in case of error
  54647. */
  54648. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54649. /**
  54650. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54651. * @param data contains the texture data
  54652. * @param texture defines the BabylonJS internal texture
  54653. * @param callback defines the method to call once ready to upload
  54654. */
  54655. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54656. }
  54657. }
  54658. declare module "babylonjs/Misc/basis" {
  54659. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54660. /**
  54661. * Info about the .basis files
  54662. */
  54663. class BasisFileInfo {
  54664. /**
  54665. * If the file has alpha
  54666. */
  54667. hasAlpha: boolean;
  54668. /**
  54669. * Info about each image of the basis file
  54670. */
  54671. images: Array<{
  54672. levels: Array<{
  54673. width: number;
  54674. height: number;
  54675. transcodedPixels: ArrayBufferView;
  54676. }>;
  54677. }>;
  54678. }
  54679. /**
  54680. * Result of transcoding a basis file
  54681. */
  54682. class TranscodeResult {
  54683. /**
  54684. * Info about the .basis file
  54685. */
  54686. fileInfo: BasisFileInfo;
  54687. /**
  54688. * Format to use when loading the file
  54689. */
  54690. format: number;
  54691. }
  54692. /**
  54693. * Configuration options for the Basis transcoder
  54694. */
  54695. export class BasisTranscodeConfiguration {
  54696. /**
  54697. * Supported compression formats used to determine the supported output format of the transcoder
  54698. */
  54699. supportedCompressionFormats?: {
  54700. /**
  54701. * etc1 compression format
  54702. */
  54703. etc1?: boolean;
  54704. /**
  54705. * s3tc compression format
  54706. */
  54707. s3tc?: boolean;
  54708. /**
  54709. * pvrtc compression format
  54710. */
  54711. pvrtc?: boolean;
  54712. /**
  54713. * etc2 compression format
  54714. */
  54715. etc2?: boolean;
  54716. };
  54717. /**
  54718. * If mipmap levels should be loaded for transcoded images (Default: true)
  54719. */
  54720. loadMipmapLevels?: boolean;
  54721. /**
  54722. * Index of a single image to load (Default: all images)
  54723. */
  54724. loadSingleImage?: number;
  54725. }
  54726. /**
  54727. * Used to load .Basis files
  54728. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54729. */
  54730. export class BasisTools {
  54731. private static _IgnoreSupportedFormats;
  54732. /**
  54733. * URL to use when loading the basis transcoder
  54734. */
  54735. static JSModuleURL: string;
  54736. /**
  54737. * URL to use when loading the wasm module for the transcoder
  54738. */
  54739. static WasmModuleURL: string;
  54740. /**
  54741. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54742. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54743. * @returns internal format corresponding to the Basis format
  54744. */
  54745. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54746. private static _WorkerPromise;
  54747. private static _Worker;
  54748. private static _actionId;
  54749. private static _CreateWorkerAsync;
  54750. /**
  54751. * Transcodes a loaded image file to compressed pixel data
  54752. * @param imageData image data to transcode
  54753. * @param config configuration options for the transcoding
  54754. * @returns a promise resulting in the transcoded image
  54755. */
  54756. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54757. /**
  54758. * Loads a texture from the transcode result
  54759. * @param texture texture load to
  54760. * @param transcodeResult the result of transcoding the basis file to load from
  54761. */
  54762. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54763. }
  54764. }
  54765. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54766. import { Nullable } from "babylonjs/types";
  54767. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54768. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54769. /**
  54770. * Loader for .basis file format
  54771. */
  54772. export class _BasisTextureLoader implements IInternalTextureLoader {
  54773. /**
  54774. * Defines whether the loader supports cascade loading the different faces.
  54775. */
  54776. readonly supportCascades: boolean;
  54777. /**
  54778. * This returns if the loader support the current file information.
  54779. * @param extension defines the file extension of the file being loaded
  54780. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54781. * @param fallback defines the fallback internal texture if any
  54782. * @param isBase64 defines whether the texture is encoded as a base64
  54783. * @param isBuffer defines whether the texture data are stored as a buffer
  54784. * @returns true if the loader can load the specified file
  54785. */
  54786. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54787. /**
  54788. * Transform the url before loading if required.
  54789. * @param rootUrl the url of the texture
  54790. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54791. * @returns the transformed texture
  54792. */
  54793. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54794. /**
  54795. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54796. * @param rootUrl the url of the texture
  54797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54798. * @returns the fallback texture
  54799. */
  54800. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54801. /**
  54802. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54803. * @param data contains the texture data
  54804. * @param texture defines the BabylonJS internal texture
  54805. * @param createPolynomials will be true if polynomials have been requested
  54806. * @param onLoad defines the callback to trigger once the texture is ready
  54807. * @param onError defines the callback to trigger in case of error
  54808. */
  54809. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54810. /**
  54811. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54812. * @param data contains the texture data
  54813. * @param texture defines the BabylonJS internal texture
  54814. * @param callback defines the method to call once ready to upload
  54815. */
  54816. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54817. }
  54818. }
  54819. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54820. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54821. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54822. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54823. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54824. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54825. }
  54826. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54827. import { Scene } from "babylonjs/scene";
  54828. import { Texture } from "babylonjs/Materials/Textures/texture";
  54829. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54830. /**
  54831. * 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.
  54832. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54833. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54834. */
  54835. export class CustomProceduralTexture extends ProceduralTexture {
  54836. private _animate;
  54837. private _time;
  54838. private _config;
  54839. private _texturePath;
  54840. /**
  54841. * Instantiates a new Custom Procedural Texture.
  54842. * 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.
  54843. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54844. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54845. * @param name Define the name of the texture
  54846. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54847. * @param size Define the size of the texture to create
  54848. * @param scene Define the scene the texture belongs to
  54849. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54850. * @param generateMipMaps Define if the texture should creates mip maps or not
  54851. */
  54852. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54853. private _loadJson;
  54854. /**
  54855. * Is the texture ready to be used ? (rendered at least once)
  54856. * @returns true if ready, otherwise, false.
  54857. */
  54858. isReady(): boolean;
  54859. /**
  54860. * Render the texture to its associated render target.
  54861. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54862. */
  54863. render(useCameraPostProcess?: boolean): void;
  54864. /**
  54865. * Update the list of dependant textures samplers in the shader.
  54866. */
  54867. updateTextures(): void;
  54868. /**
  54869. * Update the uniform values of the procedural texture in the shader.
  54870. */
  54871. updateShaderUniforms(): void;
  54872. /**
  54873. * Define if the texture animates or not.
  54874. */
  54875. animate: boolean;
  54876. }
  54877. }
  54878. declare module "babylonjs/Shaders/noise.fragment" {
  54879. /** @hidden */
  54880. export var noisePixelShader: {
  54881. name: string;
  54882. shader: string;
  54883. };
  54884. }
  54885. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54886. import { Nullable } from "babylonjs/types";
  54887. import { Scene } from "babylonjs/scene";
  54888. import { Texture } from "babylonjs/Materials/Textures/texture";
  54889. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54890. import "babylonjs/Shaders/noise.fragment";
  54891. /**
  54892. * Class used to generate noise procedural textures
  54893. */
  54894. export class NoiseProceduralTexture extends ProceduralTexture {
  54895. private _time;
  54896. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54897. brightness: number;
  54898. /** Defines the number of octaves to process */
  54899. octaves: number;
  54900. /** Defines the level of persistence (0.8 by default) */
  54901. persistence: number;
  54902. /** Gets or sets animation speed factor (default is 1) */
  54903. animationSpeedFactor: number;
  54904. /**
  54905. * Creates a new NoiseProceduralTexture
  54906. * @param name defines the name fo the texture
  54907. * @param size defines the size of the texture (default is 256)
  54908. * @param scene defines the hosting scene
  54909. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54910. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54911. */
  54912. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54913. private _updateShaderUniforms;
  54914. protected _getDefines(): string;
  54915. /** Generate the current state of the procedural texture */
  54916. render(useCameraPostProcess?: boolean): void;
  54917. /**
  54918. * Serializes this noise procedural texture
  54919. * @returns a serialized noise procedural texture object
  54920. */
  54921. serialize(): any;
  54922. /**
  54923. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54924. * @param parsedTexture defines parsed texture data
  54925. * @param scene defines the current scene
  54926. * @param rootUrl defines the root URL containing noise procedural texture information
  54927. * @returns a parsed NoiseProceduralTexture
  54928. */
  54929. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54930. }
  54931. }
  54932. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54933. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54934. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54935. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54936. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54937. }
  54938. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54939. import { Nullable } from "babylonjs/types";
  54940. import { Scene } from "babylonjs/scene";
  54941. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54942. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54943. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54944. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54945. /**
  54946. * Raw cube texture where the raw buffers are passed in
  54947. */
  54948. export class RawCubeTexture extends CubeTexture {
  54949. /**
  54950. * Creates a cube texture where the raw buffers are passed in.
  54951. * @param scene defines the scene the texture is attached to
  54952. * @param data defines the array of data to use to create each face
  54953. * @param size defines the size of the textures
  54954. * @param format defines the format of the data
  54955. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54956. * @param generateMipMaps defines if the engine should generate the mip levels
  54957. * @param invertY defines if data must be stored with Y axis inverted
  54958. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54959. * @param compression defines the compression used (null by default)
  54960. */
  54961. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54962. /**
  54963. * Updates the raw cube texture.
  54964. * @param data defines the data to store
  54965. * @param format defines the data format
  54966. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54967. * @param invertY defines if data must be stored with Y axis inverted
  54968. * @param compression defines the compression used (null by default)
  54969. * @param level defines which level of the texture to update
  54970. */
  54971. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54972. /**
  54973. * Updates a raw cube texture with RGBD encoded data.
  54974. * @param data defines the array of data [mipmap][face] to use to create each face
  54975. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54976. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54977. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54978. * @returns a promsie that resolves when the operation is complete
  54979. */
  54980. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54981. /**
  54982. * Clones the raw cube texture.
  54983. * @return a new cube texture
  54984. */
  54985. clone(): CubeTexture;
  54986. /** @hidden */
  54987. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54988. }
  54989. }
  54990. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54991. import { Scene } from "babylonjs/scene";
  54992. import { Texture } from "babylonjs/Materials/Textures/texture";
  54993. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54994. /**
  54995. * Class used to store 3D textures containing user data
  54996. */
  54997. export class RawTexture3D extends Texture {
  54998. /** Gets or sets the texture format to use */
  54999. format: number;
  55000. private _engine;
  55001. /**
  55002. * Create a new RawTexture3D
  55003. * @param data defines the data of the texture
  55004. * @param width defines the width of the texture
  55005. * @param height defines the height of the texture
  55006. * @param depth defines the depth of the texture
  55007. * @param format defines the texture format to use
  55008. * @param scene defines the hosting scene
  55009. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55010. * @param invertY defines if texture must be stored with Y axis inverted
  55011. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55012. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55013. */
  55014. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55015. /** Gets or sets the texture format to use */
  55016. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55017. /**
  55018. * Update the texture with new data
  55019. * @param data defines the data to store in the texture
  55020. */
  55021. update(data: ArrayBufferView): void;
  55022. }
  55023. }
  55024. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55025. import { Scene } from "babylonjs/scene";
  55026. import { Plane } from "babylonjs/Maths/math.plane";
  55027. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55028. /**
  55029. * Creates a refraction texture used by refraction channel of the standard material.
  55030. * It is like a mirror but to see through a material.
  55031. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55032. */
  55033. export class RefractionTexture extends RenderTargetTexture {
  55034. /**
  55035. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55036. * 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.
  55037. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55038. */
  55039. refractionPlane: Plane;
  55040. /**
  55041. * Define how deep under the surface we should see.
  55042. */
  55043. depth: number;
  55044. /**
  55045. * Creates a refraction texture used by refraction channel of the standard material.
  55046. * It is like a mirror but to see through a material.
  55047. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55048. * @param name Define the texture name
  55049. * @param size Define the size of the underlying texture
  55050. * @param scene Define the scene the refraction belongs to
  55051. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55052. */
  55053. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55054. /**
  55055. * Clone the refraction texture.
  55056. * @returns the cloned texture
  55057. */
  55058. clone(): RefractionTexture;
  55059. /**
  55060. * Serialize the texture to a JSON representation you could use in Parse later on
  55061. * @returns the serialized JSON representation
  55062. */
  55063. serialize(): any;
  55064. }
  55065. }
  55066. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55067. import { Nullable } from "babylonjs/types";
  55068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55069. import { Matrix } from "babylonjs/Maths/math.vector";
  55070. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55071. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55072. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55073. import { Scene } from "babylonjs/scene";
  55074. /**
  55075. * Defines the options related to the creation of an HtmlElementTexture
  55076. */
  55077. export interface IHtmlElementTextureOptions {
  55078. /**
  55079. * Defines wether mip maps should be created or not.
  55080. */
  55081. generateMipMaps?: boolean;
  55082. /**
  55083. * Defines the sampling mode of the texture.
  55084. */
  55085. samplingMode?: number;
  55086. /**
  55087. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55088. */
  55089. engine: Nullable<ThinEngine>;
  55090. /**
  55091. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55092. */
  55093. scene: Nullable<Scene>;
  55094. }
  55095. /**
  55096. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55097. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55098. * is automatically managed.
  55099. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55100. * in your application.
  55101. *
  55102. * As the update is not automatic, you need to call them manually.
  55103. */
  55104. export class HtmlElementTexture extends BaseTexture {
  55105. /**
  55106. * The texture URL.
  55107. */
  55108. element: HTMLVideoElement | HTMLCanvasElement;
  55109. private static readonly DefaultOptions;
  55110. private _textureMatrix;
  55111. private _engine;
  55112. private _isVideo;
  55113. private _generateMipMaps;
  55114. private _samplingMode;
  55115. /**
  55116. * Instantiates a HtmlElementTexture from the following parameters.
  55117. *
  55118. * @param name Defines the name of the texture
  55119. * @param element Defines the video or canvas the texture is filled with
  55120. * @param options Defines the other none mandatory texture creation options
  55121. */
  55122. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55123. private _createInternalTexture;
  55124. /**
  55125. * Returns the texture matrix used in most of the material.
  55126. */
  55127. getTextureMatrix(): Matrix;
  55128. /**
  55129. * Updates the content of the texture.
  55130. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55131. */
  55132. update(invertY?: Nullable<boolean>): void;
  55133. }
  55134. }
  55135. declare module "babylonjs/Materials/Textures/index" {
  55136. export * from "babylonjs/Materials/Textures/baseTexture";
  55137. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55138. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55139. export * from "babylonjs/Materials/Textures/cubeTexture";
  55140. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55141. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55142. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55143. export * from "babylonjs/Materials/Textures/internalTexture";
  55144. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55145. export * from "babylonjs/Materials/Textures/Loaders/index";
  55146. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55147. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55148. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55149. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55150. export * from "babylonjs/Materials/Textures/rawTexture";
  55151. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55152. export * from "babylonjs/Materials/Textures/refractionTexture";
  55153. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55154. export * from "babylonjs/Materials/Textures/texture";
  55155. export * from "babylonjs/Materials/Textures/videoTexture";
  55156. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55157. }
  55158. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55159. /**
  55160. * Enum used to define the target of a block
  55161. */
  55162. export enum NodeMaterialBlockTargets {
  55163. /** Vertex shader */
  55164. Vertex = 1,
  55165. /** Fragment shader */
  55166. Fragment = 2,
  55167. /** Neutral */
  55168. Neutral = 4,
  55169. /** Vertex and Fragment */
  55170. VertexAndFragment = 3
  55171. }
  55172. }
  55173. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55174. /**
  55175. * Defines the kind of connection point for node based material
  55176. */
  55177. export enum NodeMaterialBlockConnectionPointTypes {
  55178. /** Float */
  55179. Float = 1,
  55180. /** Int */
  55181. Int = 2,
  55182. /** Vector2 */
  55183. Vector2 = 4,
  55184. /** Vector3 */
  55185. Vector3 = 8,
  55186. /** Vector4 */
  55187. Vector4 = 16,
  55188. /** Color3 */
  55189. Color3 = 32,
  55190. /** Color4 */
  55191. Color4 = 64,
  55192. /** Matrix */
  55193. Matrix = 128,
  55194. /** Detect type based on connection */
  55195. AutoDetect = 1024,
  55196. /** Output type that will be defined by input type */
  55197. BasedOnInput = 2048
  55198. }
  55199. }
  55200. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55201. /**
  55202. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55203. */
  55204. export enum NodeMaterialBlockConnectionPointMode {
  55205. /** Value is an uniform */
  55206. Uniform = 0,
  55207. /** Value is a mesh attribute */
  55208. Attribute = 1,
  55209. /** Value is a varying between vertex and fragment shaders */
  55210. Varying = 2,
  55211. /** Mode is undefined */
  55212. Undefined = 3
  55213. }
  55214. }
  55215. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55216. /**
  55217. * Enum used to define system values e.g. values automatically provided by the system
  55218. */
  55219. export enum NodeMaterialSystemValues {
  55220. /** World */
  55221. World = 1,
  55222. /** View */
  55223. View = 2,
  55224. /** Projection */
  55225. Projection = 3,
  55226. /** ViewProjection */
  55227. ViewProjection = 4,
  55228. /** WorldView */
  55229. WorldView = 5,
  55230. /** WorldViewProjection */
  55231. WorldViewProjection = 6,
  55232. /** CameraPosition */
  55233. CameraPosition = 7,
  55234. /** Fog Color */
  55235. FogColor = 8,
  55236. /** Delta time */
  55237. DeltaTime = 9
  55238. }
  55239. }
  55240. declare module "babylonjs/Materials/Node/Enums/index" {
  55241. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55242. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55243. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55244. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55245. }
  55246. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55248. /**
  55249. * Root class for all node material optimizers
  55250. */
  55251. export class NodeMaterialOptimizer {
  55252. /**
  55253. * Function used to optimize a NodeMaterial graph
  55254. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55255. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55256. */
  55257. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55258. }
  55259. }
  55260. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55264. import { Scene } from "babylonjs/scene";
  55265. /**
  55266. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55267. */
  55268. export class TransformBlock extends NodeMaterialBlock {
  55269. /**
  55270. * Defines the value to use to complement W value to transform it to a Vector4
  55271. */
  55272. complementW: number;
  55273. /**
  55274. * Defines the value to use to complement z value to transform it to a Vector4
  55275. */
  55276. complementZ: number;
  55277. /**
  55278. * Creates a new TransformBlock
  55279. * @param name defines the block name
  55280. */
  55281. constructor(name: string);
  55282. /**
  55283. * Gets the current class name
  55284. * @returns the class name
  55285. */
  55286. getClassName(): string;
  55287. /**
  55288. * Gets the vector input
  55289. */
  55290. readonly vector: NodeMaterialConnectionPoint;
  55291. /**
  55292. * Gets the output component
  55293. */
  55294. readonly output: NodeMaterialConnectionPoint;
  55295. /**
  55296. * Gets the matrix transform input
  55297. */
  55298. readonly transform: NodeMaterialConnectionPoint;
  55299. protected _buildBlock(state: NodeMaterialBuildState): this;
  55300. serialize(): any;
  55301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55302. protected _dumpPropertiesCode(): string;
  55303. }
  55304. }
  55305. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55309. /**
  55310. * Block used to output the vertex position
  55311. */
  55312. export class VertexOutputBlock extends NodeMaterialBlock {
  55313. /**
  55314. * Creates a new VertexOutputBlock
  55315. * @param name defines the block name
  55316. */
  55317. constructor(name: string);
  55318. /**
  55319. * Gets the current class name
  55320. * @returns the class name
  55321. */
  55322. getClassName(): string;
  55323. /**
  55324. * Gets the vector input component
  55325. */
  55326. readonly vector: NodeMaterialConnectionPoint;
  55327. protected _buildBlock(state: NodeMaterialBuildState): this;
  55328. }
  55329. }
  55330. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55334. /**
  55335. * Block used to output the final color
  55336. */
  55337. export class FragmentOutputBlock extends NodeMaterialBlock {
  55338. /**
  55339. * Create a new FragmentOutputBlock
  55340. * @param name defines the block name
  55341. */
  55342. constructor(name: string);
  55343. /**
  55344. * Gets the current class name
  55345. * @returns the class name
  55346. */
  55347. getClassName(): string;
  55348. /**
  55349. * Gets the rgba input component
  55350. */
  55351. readonly rgba: NodeMaterialConnectionPoint;
  55352. /**
  55353. * Gets the rgb input component
  55354. */
  55355. readonly rgb: NodeMaterialConnectionPoint;
  55356. /**
  55357. * Gets the a input component
  55358. */
  55359. readonly a: NodeMaterialConnectionPoint;
  55360. protected _buildBlock(state: NodeMaterialBuildState): this;
  55361. }
  55362. }
  55363. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55369. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55370. import { Effect } from "babylonjs/Materials/effect";
  55371. import { Mesh } from "babylonjs/Meshes/mesh";
  55372. import { Nullable } from "babylonjs/types";
  55373. import { Scene } from "babylonjs/scene";
  55374. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55375. /**
  55376. * Block used to read a reflection texture from a sampler
  55377. */
  55378. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55379. private _define3DName;
  55380. private _defineCubicName;
  55381. private _defineExplicitName;
  55382. private _defineProjectionName;
  55383. private _defineLocalCubicName;
  55384. private _defineSphericalName;
  55385. private _definePlanarName;
  55386. private _defineEquirectangularName;
  55387. private _defineMirroredEquirectangularFixedName;
  55388. private _defineEquirectangularFixedName;
  55389. private _defineSkyboxName;
  55390. private _cubeSamplerName;
  55391. private _2DSamplerName;
  55392. private _positionUVWName;
  55393. private _directionWName;
  55394. private _reflectionCoordsName;
  55395. private _reflection2DCoordsName;
  55396. private _reflectionColorName;
  55397. private _reflectionMatrixName;
  55398. /**
  55399. * Gets or sets the texture associated with the node
  55400. */
  55401. texture: Nullable<BaseTexture>;
  55402. /**
  55403. * Create a new TextureBlock
  55404. * @param name defines the block name
  55405. */
  55406. constructor(name: string);
  55407. /**
  55408. * Gets the current class name
  55409. * @returns the class name
  55410. */
  55411. getClassName(): string;
  55412. /**
  55413. * Gets the world position input component
  55414. */
  55415. readonly position: NodeMaterialConnectionPoint;
  55416. /**
  55417. * Gets the world position input component
  55418. */
  55419. readonly worldPosition: NodeMaterialConnectionPoint;
  55420. /**
  55421. * Gets the world normal input component
  55422. */
  55423. readonly worldNormal: NodeMaterialConnectionPoint;
  55424. /**
  55425. * Gets the world input component
  55426. */
  55427. readonly world: NodeMaterialConnectionPoint;
  55428. /**
  55429. * Gets the camera (or eye) position component
  55430. */
  55431. readonly cameraPosition: NodeMaterialConnectionPoint;
  55432. /**
  55433. * Gets the view input component
  55434. */
  55435. readonly view: NodeMaterialConnectionPoint;
  55436. /**
  55437. * Gets the rgb output component
  55438. */
  55439. readonly rgb: NodeMaterialConnectionPoint;
  55440. /**
  55441. * Gets the r output component
  55442. */
  55443. readonly r: NodeMaterialConnectionPoint;
  55444. /**
  55445. * Gets the g output component
  55446. */
  55447. readonly g: NodeMaterialConnectionPoint;
  55448. /**
  55449. * Gets the b output component
  55450. */
  55451. readonly b: NodeMaterialConnectionPoint;
  55452. autoConfigure(material: NodeMaterial): void;
  55453. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55454. isReady(): boolean;
  55455. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55456. private _injectVertexCode;
  55457. private _writeOutput;
  55458. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55459. serialize(): any;
  55460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55461. }
  55462. }
  55463. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55465. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55466. import { Scene } from "babylonjs/scene";
  55467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55468. import { Matrix } from "babylonjs/Maths/math.vector";
  55469. import { Mesh } from "babylonjs/Meshes/mesh";
  55470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55471. import { Observable } from "babylonjs/Misc/observable";
  55472. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55473. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55474. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55475. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55476. import { Nullable } from "babylonjs/types";
  55477. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55478. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55479. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55480. /**
  55481. * Interface used to configure the node material editor
  55482. */
  55483. export interface INodeMaterialEditorOptions {
  55484. /** Define the URl to load node editor script */
  55485. editorURL?: string;
  55486. }
  55487. /** @hidden */
  55488. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55489. /** BONES */
  55490. NUM_BONE_INFLUENCERS: number;
  55491. BonesPerMesh: number;
  55492. BONETEXTURE: boolean;
  55493. /** MORPH TARGETS */
  55494. MORPHTARGETS: boolean;
  55495. MORPHTARGETS_NORMAL: boolean;
  55496. MORPHTARGETS_TANGENT: boolean;
  55497. MORPHTARGETS_UV: boolean;
  55498. NUM_MORPH_INFLUENCERS: number;
  55499. /** IMAGE PROCESSING */
  55500. IMAGEPROCESSING: boolean;
  55501. VIGNETTE: boolean;
  55502. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55503. VIGNETTEBLENDMODEOPAQUE: boolean;
  55504. TONEMAPPING: boolean;
  55505. TONEMAPPING_ACES: boolean;
  55506. CONTRAST: boolean;
  55507. EXPOSURE: boolean;
  55508. COLORCURVES: boolean;
  55509. COLORGRADING: boolean;
  55510. COLORGRADING3D: boolean;
  55511. SAMPLER3DGREENDEPTH: boolean;
  55512. SAMPLER3DBGRMAP: boolean;
  55513. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55514. /** MISC. */
  55515. BUMPDIRECTUV: number;
  55516. constructor();
  55517. setValue(name: string, value: boolean): void;
  55518. }
  55519. /**
  55520. * Class used to configure NodeMaterial
  55521. */
  55522. export interface INodeMaterialOptions {
  55523. /**
  55524. * Defines if blocks should emit comments
  55525. */
  55526. emitComments: boolean;
  55527. }
  55528. /**
  55529. * Class used to create a node based material built by assembling shader blocks
  55530. */
  55531. export class NodeMaterial extends PushMaterial {
  55532. private static _BuildIdGenerator;
  55533. private _options;
  55534. private _vertexCompilationState;
  55535. private _fragmentCompilationState;
  55536. private _sharedData;
  55537. private _buildId;
  55538. private _buildWasSuccessful;
  55539. private _cachedWorldViewMatrix;
  55540. private _cachedWorldViewProjectionMatrix;
  55541. private _optimizers;
  55542. private _animationFrame;
  55543. /** Define the URl to load node editor script */
  55544. static EditorURL: string;
  55545. private BJSNODEMATERIALEDITOR;
  55546. /** Get the inspector from bundle or global */
  55547. private _getGlobalNodeMaterialEditor;
  55548. /**
  55549. * 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)
  55550. */
  55551. ignoreAlpha: boolean;
  55552. /**
  55553. * Defines the maximum number of lights that can be used in the material
  55554. */
  55555. maxSimultaneousLights: number;
  55556. /**
  55557. * Observable raised when the material is built
  55558. */
  55559. onBuildObservable: Observable<NodeMaterial>;
  55560. /**
  55561. * Gets or sets the root nodes of the material vertex shader
  55562. */
  55563. _vertexOutputNodes: NodeMaterialBlock[];
  55564. /**
  55565. * Gets or sets the root nodes of the material fragment (pixel) shader
  55566. */
  55567. _fragmentOutputNodes: NodeMaterialBlock[];
  55568. /** Gets or sets options to control the node material overall behavior */
  55569. options: INodeMaterialOptions;
  55570. /**
  55571. * Default configuration related to image processing available in the standard Material.
  55572. */
  55573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55574. /**
  55575. * Gets the image processing configuration used either in this material.
  55576. */
  55577. /**
  55578. * Sets the Default image processing configuration used either in the this material.
  55579. *
  55580. * If sets to null, the scene one is in use.
  55581. */
  55582. imageProcessingConfiguration: ImageProcessingConfiguration;
  55583. /**
  55584. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55585. */
  55586. attachedBlocks: NodeMaterialBlock[];
  55587. /**
  55588. * Create a new node based material
  55589. * @param name defines the material name
  55590. * @param scene defines the hosting scene
  55591. * @param options defines creation option
  55592. */
  55593. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55594. /**
  55595. * Gets the current class name of the material e.g. "NodeMaterial"
  55596. * @returns the class name
  55597. */
  55598. getClassName(): string;
  55599. /**
  55600. * Keep track of the image processing observer to allow dispose and replace.
  55601. */
  55602. private _imageProcessingObserver;
  55603. /**
  55604. * Attaches a new image processing configuration to the Standard Material.
  55605. * @param configuration
  55606. */
  55607. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55608. /**
  55609. * Get a block by its name
  55610. * @param name defines the name of the block to retrieve
  55611. * @returns the required block or null if not found
  55612. */
  55613. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55614. /**
  55615. * Get a block by its name
  55616. * @param predicate defines the predicate used to find the good candidate
  55617. * @returns the required block or null if not found
  55618. */
  55619. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55620. /**
  55621. * Get an input block by its name
  55622. * @param predicate defines the predicate used to find the good candidate
  55623. * @returns the required input block or null if not found
  55624. */
  55625. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55626. /**
  55627. * Gets the list of input blocks attached to this material
  55628. * @returns an array of InputBlocks
  55629. */
  55630. getInputBlocks(): InputBlock[];
  55631. /**
  55632. * Adds a new optimizer to the list of optimizers
  55633. * @param optimizer defines the optimizers to add
  55634. * @returns the current material
  55635. */
  55636. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55637. /**
  55638. * Remove an optimizer from the list of optimizers
  55639. * @param optimizer defines the optimizers to remove
  55640. * @returns the current material
  55641. */
  55642. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55643. /**
  55644. * Add a new block to the list of output nodes
  55645. * @param node defines the node to add
  55646. * @returns the current material
  55647. */
  55648. addOutputNode(node: NodeMaterialBlock): this;
  55649. /**
  55650. * Remove a block from the list of root nodes
  55651. * @param node defines the node to remove
  55652. * @returns the current material
  55653. */
  55654. removeOutputNode(node: NodeMaterialBlock): this;
  55655. private _addVertexOutputNode;
  55656. private _removeVertexOutputNode;
  55657. private _addFragmentOutputNode;
  55658. private _removeFragmentOutputNode;
  55659. /**
  55660. * Specifies if the material will require alpha blending
  55661. * @returns a boolean specifying if alpha blending is needed
  55662. */
  55663. needAlphaBlending(): boolean;
  55664. /**
  55665. * Specifies if this material should be rendered in alpha test mode
  55666. * @returns a boolean specifying if an alpha test is needed.
  55667. */
  55668. needAlphaTesting(): boolean;
  55669. private _initializeBlock;
  55670. private _resetDualBlocks;
  55671. /**
  55672. * Build the material and generates the inner effect
  55673. * @param verbose defines if the build should log activity
  55674. */
  55675. build(verbose?: boolean): void;
  55676. /**
  55677. * Runs an otpimization phase to try to improve the shader code
  55678. */
  55679. optimize(): void;
  55680. private _prepareDefinesForAttributes;
  55681. /**
  55682. * Get if the submesh is ready to be used and all its information available.
  55683. * Child classes can use it to update shaders
  55684. * @param mesh defines the mesh to check
  55685. * @param subMesh defines which submesh to check
  55686. * @param useInstances specifies that instances should be used
  55687. * @returns a boolean indicating that the submesh is ready or not
  55688. */
  55689. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55690. /**
  55691. * Get a string representing the shaders built by the current node graph
  55692. */
  55693. readonly compiledShaders: string;
  55694. /**
  55695. * Binds the world matrix to the material
  55696. * @param world defines the world transformation matrix
  55697. */
  55698. bindOnlyWorldMatrix(world: Matrix): void;
  55699. /**
  55700. * Binds the submesh to this material by preparing the effect and shader to draw
  55701. * @param world defines the world transformation matrix
  55702. * @param mesh defines the mesh containing the submesh
  55703. * @param subMesh defines the submesh to bind the material to
  55704. */
  55705. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55706. /**
  55707. * Gets the active textures from the material
  55708. * @returns an array of textures
  55709. */
  55710. getActiveTextures(): BaseTexture[];
  55711. /**
  55712. * Gets the list of texture blocks
  55713. * @returns an array of texture blocks
  55714. */
  55715. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55716. /**
  55717. * Specifies if the material uses a texture
  55718. * @param texture defines the texture to check against the material
  55719. * @returns a boolean specifying if the material uses the texture
  55720. */
  55721. hasTexture(texture: BaseTexture): boolean;
  55722. /**
  55723. * Disposes the material
  55724. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55725. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55726. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55727. */
  55728. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55729. /** Creates the node editor window. */
  55730. private _createNodeEditor;
  55731. /**
  55732. * Launch the node material editor
  55733. * @param config Define the configuration of the editor
  55734. * @return a promise fulfilled when the node editor is visible
  55735. */
  55736. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55737. /**
  55738. * Clear the current material
  55739. */
  55740. clear(): void;
  55741. /**
  55742. * Clear the current material and set it to a default state
  55743. */
  55744. setToDefault(): void;
  55745. /**
  55746. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55747. * @param url defines the url to load from
  55748. * @returns a promise that will fullfil when the material is fully loaded
  55749. */
  55750. loadAsync(url: string): Promise<void>;
  55751. private _gatherBlocks;
  55752. /**
  55753. * Generate a string containing the code declaration required to create an equivalent of this material
  55754. * @returns a string
  55755. */
  55756. generateCode(): string;
  55757. /**
  55758. * Serializes this material in a JSON representation
  55759. * @returns the serialized material object
  55760. */
  55761. serialize(): any;
  55762. private _restoreConnections;
  55763. /**
  55764. * Clear the current graph and load a new one from a serialization object
  55765. * @param source defines the JSON representation of the material
  55766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55767. */
  55768. loadFromSerialization(source: any, rootUrl?: string): void;
  55769. /**
  55770. * Creates a node material from parsed material data
  55771. * @param source defines the JSON representation of the material
  55772. * @param scene defines the hosting scene
  55773. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55774. * @returns a new node material
  55775. */
  55776. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55777. /**
  55778. * Creates a new node material set to default basic configuration
  55779. * @param name defines the name of the material
  55780. * @param scene defines the hosting scene
  55781. * @returns a new NodeMaterial
  55782. */
  55783. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55784. }
  55785. }
  55786. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55789. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55792. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55793. import { Effect } from "babylonjs/Materials/effect";
  55794. import { Mesh } from "babylonjs/Meshes/mesh";
  55795. import { Nullable } from "babylonjs/types";
  55796. import { Texture } from "babylonjs/Materials/Textures/texture";
  55797. import { Scene } from "babylonjs/scene";
  55798. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55799. /**
  55800. * Block used to read a texture from a sampler
  55801. */
  55802. export class TextureBlock extends NodeMaterialBlock {
  55803. private _defineName;
  55804. private _linearDefineName;
  55805. private _samplerName;
  55806. private _transformedUVName;
  55807. private _textureTransformName;
  55808. private _textureInfoName;
  55809. private _mainUVName;
  55810. private _mainUVDefineName;
  55811. /**
  55812. * Gets or sets the texture associated with the node
  55813. */
  55814. texture: Nullable<Texture>;
  55815. /**
  55816. * Create a new TextureBlock
  55817. * @param name defines the block name
  55818. */
  55819. constructor(name: string);
  55820. /**
  55821. * Gets the current class name
  55822. * @returns the class name
  55823. */
  55824. getClassName(): string;
  55825. /**
  55826. * Gets the uv input component
  55827. */
  55828. readonly uv: NodeMaterialConnectionPoint;
  55829. /**
  55830. * Gets the rgba output component
  55831. */
  55832. readonly rgba: NodeMaterialConnectionPoint;
  55833. /**
  55834. * Gets the rgb output component
  55835. */
  55836. readonly rgb: NodeMaterialConnectionPoint;
  55837. /**
  55838. * Gets the r output component
  55839. */
  55840. readonly r: NodeMaterialConnectionPoint;
  55841. /**
  55842. * Gets the g output component
  55843. */
  55844. readonly g: NodeMaterialConnectionPoint;
  55845. /**
  55846. * Gets the b output component
  55847. */
  55848. readonly b: NodeMaterialConnectionPoint;
  55849. /**
  55850. * Gets the a output component
  55851. */
  55852. readonly a: NodeMaterialConnectionPoint;
  55853. readonly target: NodeMaterialBlockTargets;
  55854. autoConfigure(material: NodeMaterial): void;
  55855. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55857. isReady(): boolean;
  55858. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55859. private readonly _isMixed;
  55860. private _injectVertexCode;
  55861. private _writeOutput;
  55862. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55863. protected _dumpPropertiesCode(): string;
  55864. serialize(): any;
  55865. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55866. }
  55867. }
  55868. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55871. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55872. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55873. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55874. import { Scene } from "babylonjs/scene";
  55875. /**
  55876. * Class used to store shared data between 2 NodeMaterialBuildState
  55877. */
  55878. export class NodeMaterialBuildStateSharedData {
  55879. /**
  55880. * Gets the list of emitted varyings
  55881. */
  55882. temps: string[];
  55883. /**
  55884. * Gets the list of emitted varyings
  55885. */
  55886. varyings: string[];
  55887. /**
  55888. * Gets the varying declaration string
  55889. */
  55890. varyingDeclaration: string;
  55891. /**
  55892. * Input blocks
  55893. */
  55894. inputBlocks: InputBlock[];
  55895. /**
  55896. * Input blocks
  55897. */
  55898. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55899. /**
  55900. * Bindable blocks (Blocks that need to set data to the effect)
  55901. */
  55902. bindableBlocks: NodeMaterialBlock[];
  55903. /**
  55904. * List of blocks that can provide a compilation fallback
  55905. */
  55906. blocksWithFallbacks: NodeMaterialBlock[];
  55907. /**
  55908. * List of blocks that can provide a define update
  55909. */
  55910. blocksWithDefines: NodeMaterialBlock[];
  55911. /**
  55912. * List of blocks that can provide a repeatable content
  55913. */
  55914. repeatableContentBlocks: NodeMaterialBlock[];
  55915. /**
  55916. * List of blocks that can provide a dynamic list of uniforms
  55917. */
  55918. dynamicUniformBlocks: NodeMaterialBlock[];
  55919. /**
  55920. * List of blocks that can block the isReady function for the material
  55921. */
  55922. blockingBlocks: NodeMaterialBlock[];
  55923. /**
  55924. * Gets the list of animated inputs
  55925. */
  55926. animatedInputs: InputBlock[];
  55927. /**
  55928. * Build Id used to avoid multiple recompilations
  55929. */
  55930. buildId: number;
  55931. /** List of emitted variables */
  55932. variableNames: {
  55933. [key: string]: number;
  55934. };
  55935. /** List of emitted defines */
  55936. defineNames: {
  55937. [key: string]: number;
  55938. };
  55939. /** Should emit comments? */
  55940. emitComments: boolean;
  55941. /** Emit build activity */
  55942. verbose: boolean;
  55943. /** Gets or sets the hosting scene */
  55944. scene: Scene;
  55945. /**
  55946. * Gets the compilation hints emitted at compilation time
  55947. */
  55948. hints: {
  55949. needWorldViewMatrix: boolean;
  55950. needWorldViewProjectionMatrix: boolean;
  55951. needAlphaBlending: boolean;
  55952. needAlphaTesting: boolean;
  55953. };
  55954. /**
  55955. * List of compilation checks
  55956. */
  55957. checks: {
  55958. emitVertex: boolean;
  55959. emitFragment: boolean;
  55960. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55961. };
  55962. /** Creates a new shared data */
  55963. constructor();
  55964. /**
  55965. * Emits console errors and exceptions if there is a failing check
  55966. */
  55967. emitErrors(): void;
  55968. }
  55969. }
  55970. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55971. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55972. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55973. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55974. /**
  55975. * Class used to store node based material build state
  55976. */
  55977. export class NodeMaterialBuildState {
  55978. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55979. supportUniformBuffers: boolean;
  55980. /**
  55981. * Gets the list of emitted attributes
  55982. */
  55983. attributes: string[];
  55984. /**
  55985. * Gets the list of emitted uniforms
  55986. */
  55987. uniforms: string[];
  55988. /**
  55989. * Gets the list of emitted constants
  55990. */
  55991. constants: string[];
  55992. /**
  55993. * Gets the list of emitted samplers
  55994. */
  55995. samplers: string[];
  55996. /**
  55997. * Gets the list of emitted functions
  55998. */
  55999. functions: {
  56000. [key: string]: string;
  56001. };
  56002. /**
  56003. * Gets the list of emitted extensions
  56004. */
  56005. extensions: {
  56006. [key: string]: string;
  56007. };
  56008. /**
  56009. * Gets the target of the compilation state
  56010. */
  56011. target: NodeMaterialBlockTargets;
  56012. /**
  56013. * Gets the list of emitted counters
  56014. */
  56015. counters: {
  56016. [key: string]: number;
  56017. };
  56018. /**
  56019. * Shared data between multiple NodeMaterialBuildState instances
  56020. */
  56021. sharedData: NodeMaterialBuildStateSharedData;
  56022. /** @hidden */
  56023. _vertexState: NodeMaterialBuildState;
  56024. /** @hidden */
  56025. _attributeDeclaration: string;
  56026. /** @hidden */
  56027. _uniformDeclaration: string;
  56028. /** @hidden */
  56029. _constantDeclaration: string;
  56030. /** @hidden */
  56031. _samplerDeclaration: string;
  56032. /** @hidden */
  56033. _varyingTransfer: string;
  56034. private _repeatableContentAnchorIndex;
  56035. /** @hidden */
  56036. _builtCompilationString: string;
  56037. /**
  56038. * Gets the emitted compilation strings
  56039. */
  56040. compilationString: string;
  56041. /**
  56042. * Finalize the compilation strings
  56043. * @param state defines the current compilation state
  56044. */
  56045. finalize(state: NodeMaterialBuildState): void;
  56046. /** @hidden */
  56047. readonly _repeatableContentAnchor: string;
  56048. /** @hidden */
  56049. _getFreeVariableName(prefix: string): string;
  56050. /** @hidden */
  56051. _getFreeDefineName(prefix: string): string;
  56052. /** @hidden */
  56053. _excludeVariableName(name: string): void;
  56054. /** @hidden */
  56055. _emit2DSampler(name: string): void;
  56056. /** @hidden */
  56057. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56058. /** @hidden */
  56059. _emitExtension(name: string, extension: string): void;
  56060. /** @hidden */
  56061. _emitFunction(name: string, code: string, comments: string): void;
  56062. /** @hidden */
  56063. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56064. replaceStrings?: {
  56065. search: RegExp;
  56066. replace: string;
  56067. }[];
  56068. repeatKey?: string;
  56069. }): string;
  56070. /** @hidden */
  56071. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56072. repeatKey?: string;
  56073. removeAttributes?: boolean;
  56074. removeUniforms?: boolean;
  56075. removeVaryings?: boolean;
  56076. removeIfDef?: boolean;
  56077. replaceStrings?: {
  56078. search: RegExp;
  56079. replace: string;
  56080. }[];
  56081. }, storeKey?: string): void;
  56082. /** @hidden */
  56083. _registerTempVariable(name: string): boolean;
  56084. /** @hidden */
  56085. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56086. /** @hidden */
  56087. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56088. /** @hidden */
  56089. _emitFloat(value: number): string;
  56090. }
  56091. }
  56092. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56093. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56095. import { Nullable } from "babylonjs/types";
  56096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56097. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56098. import { Effect } from "babylonjs/Materials/effect";
  56099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56100. import { Mesh } from "babylonjs/Meshes/mesh";
  56101. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56102. import { Scene } from "babylonjs/scene";
  56103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56104. /**
  56105. * Defines a block that can be used inside a node based material
  56106. */
  56107. export class NodeMaterialBlock {
  56108. private _buildId;
  56109. private _buildTarget;
  56110. private _target;
  56111. private _isFinalMerger;
  56112. private _isInput;
  56113. /** @hidden */
  56114. _codeVariableName: string;
  56115. /** @hidden */
  56116. _inputs: NodeMaterialConnectionPoint[];
  56117. /** @hidden */
  56118. _outputs: NodeMaterialConnectionPoint[];
  56119. /** @hidden */
  56120. _preparationId: number;
  56121. /**
  56122. * Gets or sets the name of the block
  56123. */
  56124. name: string;
  56125. /**
  56126. * Gets or sets the unique id of the node
  56127. */
  56128. uniqueId: number;
  56129. /**
  56130. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56131. */
  56132. readonly isFinalMerger: boolean;
  56133. /**
  56134. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56135. */
  56136. readonly isInput: boolean;
  56137. /**
  56138. * Gets or sets the build Id
  56139. */
  56140. buildId: number;
  56141. /**
  56142. * Gets or sets the target of the block
  56143. */
  56144. target: NodeMaterialBlockTargets;
  56145. /**
  56146. * Gets the list of input points
  56147. */
  56148. readonly inputs: NodeMaterialConnectionPoint[];
  56149. /** Gets the list of output points */
  56150. readonly outputs: NodeMaterialConnectionPoint[];
  56151. /**
  56152. * Find an input by its name
  56153. * @param name defines the name of the input to look for
  56154. * @returns the input or null if not found
  56155. */
  56156. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56157. /**
  56158. * Find an output by its name
  56159. * @param name defines the name of the outputto look for
  56160. * @returns the output or null if not found
  56161. */
  56162. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56163. /**
  56164. * Creates a new NodeMaterialBlock
  56165. * @param name defines the block name
  56166. * @param target defines the target of that block (Vertex by default)
  56167. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56168. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56169. */
  56170. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56171. /**
  56172. * Initialize the block and prepare the context for build
  56173. * @param state defines the state that will be used for the build
  56174. */
  56175. initialize(state: NodeMaterialBuildState): void;
  56176. /**
  56177. * Bind data to effect. Will only be called for blocks with isBindable === true
  56178. * @param effect defines the effect to bind data to
  56179. * @param nodeMaterial defines the hosting NodeMaterial
  56180. * @param mesh defines the mesh that will be rendered
  56181. */
  56182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56183. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56184. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56185. protected _writeFloat(value: number): string;
  56186. /**
  56187. * Gets the current class name e.g. "NodeMaterialBlock"
  56188. * @returns the class name
  56189. */
  56190. getClassName(): string;
  56191. /**
  56192. * Register a new input. Must be called inside a block constructor
  56193. * @param name defines the connection point name
  56194. * @param type defines the connection point type
  56195. * @param isOptional defines a boolean indicating that this input can be omitted
  56196. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56197. * @returns the current block
  56198. */
  56199. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56200. /**
  56201. * Register a new output. Must be called inside a block constructor
  56202. * @param name defines the connection point name
  56203. * @param type defines the connection point type
  56204. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56205. * @returns the current block
  56206. */
  56207. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56208. /**
  56209. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56210. * @param forOutput defines an optional connection point to check compatibility with
  56211. * @returns the first available input or null
  56212. */
  56213. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56214. /**
  56215. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56216. * @param forBlock defines an optional block to check compatibility with
  56217. * @returns the first available input or null
  56218. */
  56219. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56220. /**
  56221. * Gets the sibling of the given output
  56222. * @param current defines the current output
  56223. * @returns the next output in the list or null
  56224. */
  56225. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56226. /**
  56227. * Connect current block with another block
  56228. * @param other defines the block to connect with
  56229. * @param options define the various options to help pick the right connections
  56230. * @returns the current block
  56231. */
  56232. connectTo(other: NodeMaterialBlock, options?: {
  56233. input?: string;
  56234. output?: string;
  56235. outputSwizzle?: string;
  56236. }): this | undefined;
  56237. protected _buildBlock(state: NodeMaterialBuildState): void;
  56238. /**
  56239. * Add uniforms, samplers and uniform buffers at compilation time
  56240. * @param state defines the state to update
  56241. * @param nodeMaterial defines the node material requesting the update
  56242. * @param defines defines the material defines to update
  56243. * @param uniformBuffers defines the list of uniform buffer names
  56244. */
  56245. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56246. /**
  56247. * Add potential fallbacks if shader compilation fails
  56248. * @param mesh defines the mesh to be rendered
  56249. * @param fallbacks defines the current prioritized list of fallbacks
  56250. */
  56251. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56252. /**
  56253. * Initialize defines for shader compilation
  56254. * @param mesh defines the mesh to be rendered
  56255. * @param nodeMaterial defines the node material requesting the update
  56256. * @param defines defines the material defines to update
  56257. * @param useInstances specifies that instances should be used
  56258. */
  56259. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56260. /**
  56261. * Update defines for shader compilation
  56262. * @param mesh defines the mesh to be rendered
  56263. * @param nodeMaterial defines the node material requesting the update
  56264. * @param defines defines the material defines to update
  56265. * @param useInstances specifies that instances should be used
  56266. */
  56267. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56268. /**
  56269. * Lets the block try to connect some inputs automatically
  56270. * @param material defines the hosting NodeMaterial
  56271. */
  56272. autoConfigure(material: NodeMaterial): void;
  56273. /**
  56274. * Function called when a block is declared as repeatable content generator
  56275. * @param vertexShaderState defines the current compilation state for the vertex shader
  56276. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56277. * @param mesh defines the mesh to be rendered
  56278. * @param defines defines the material defines to update
  56279. */
  56280. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56281. /**
  56282. * Checks if the block is ready
  56283. * @param mesh defines the mesh to be rendered
  56284. * @param nodeMaterial defines the node material requesting the update
  56285. * @param defines defines the material defines to update
  56286. * @param useInstances specifies that instances should be used
  56287. * @returns true if the block is ready
  56288. */
  56289. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56290. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56291. private _processBuild;
  56292. /**
  56293. * Compile the current node and generate the shader code
  56294. * @param state defines the current compilation state (uniforms, samplers, current string)
  56295. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56296. * @returns true if already built
  56297. */
  56298. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56299. protected _inputRename(name: string): string;
  56300. protected _outputRename(name: string): string;
  56301. protected _dumpPropertiesCode(): string;
  56302. /** @hidden */
  56303. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56304. /**
  56305. * Clone the current block to a new identical block
  56306. * @param scene defines the hosting scene
  56307. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56308. * @returns a copy of the current block
  56309. */
  56310. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56311. /**
  56312. * Serializes this block in a JSON representation
  56313. * @returns the serialized block object
  56314. */
  56315. serialize(): any;
  56316. /** @hidden */
  56317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56318. /**
  56319. * Release resources
  56320. */
  56321. dispose(): void;
  56322. }
  56323. }
  56324. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56325. /**
  56326. * Enum defining the type of animations supported by InputBlock
  56327. */
  56328. export enum AnimatedInputBlockTypes {
  56329. /** No animation */
  56330. None = 0,
  56331. /** Time based animation. Will only work for floats */
  56332. Time = 1
  56333. }
  56334. }
  56335. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56336. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56337. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56338. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56339. import { Nullable } from "babylonjs/types";
  56340. import { Effect } from "babylonjs/Materials/effect";
  56341. import { Matrix } from "babylonjs/Maths/math.vector";
  56342. import { Scene } from "babylonjs/scene";
  56343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56345. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56346. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56347. /**
  56348. * Block used to expose an input value
  56349. */
  56350. export class InputBlock extends NodeMaterialBlock {
  56351. private _mode;
  56352. private _associatedVariableName;
  56353. private _storedValue;
  56354. private _valueCallback;
  56355. private _type;
  56356. private _animationType;
  56357. /** Gets or set a value used to limit the range of float values */
  56358. min: number;
  56359. /** Gets or set a value used to limit the range of float values */
  56360. max: number;
  56361. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56362. matrixMode: number;
  56363. /** @hidden */
  56364. _systemValue: Nullable<NodeMaterialSystemValues>;
  56365. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56366. visibleInInspector: boolean;
  56367. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56368. isConstant: boolean;
  56369. /**
  56370. * Gets or sets the connection point type (default is float)
  56371. */
  56372. readonly type: NodeMaterialBlockConnectionPointTypes;
  56373. /**
  56374. * Creates a new InputBlock
  56375. * @param name defines the block name
  56376. * @param target defines the target of that block (Vertex by default)
  56377. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56378. */
  56379. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56380. /**
  56381. * Gets the output component
  56382. */
  56383. readonly output: NodeMaterialConnectionPoint;
  56384. /**
  56385. * Set the source of this connection point to a vertex attribute
  56386. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56387. * @returns the current connection point
  56388. */
  56389. setAsAttribute(attributeName?: string): InputBlock;
  56390. /**
  56391. * Set the source of this connection point to a system value
  56392. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56393. * @returns the current connection point
  56394. */
  56395. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56396. /**
  56397. * Gets or sets the value of that point.
  56398. * Please note that this value will be ignored if valueCallback is defined
  56399. */
  56400. value: any;
  56401. /**
  56402. * Gets or sets a callback used to get the value of that point.
  56403. * Please note that setting this value will force the connection point to ignore the value property
  56404. */
  56405. valueCallback: () => any;
  56406. /**
  56407. * Gets or sets the associated variable name in the shader
  56408. */
  56409. associatedVariableName: string;
  56410. /** Gets or sets the type of animation applied to the input */
  56411. animationType: AnimatedInputBlockTypes;
  56412. /**
  56413. * Gets a boolean indicating that this connection point not defined yet
  56414. */
  56415. readonly isUndefined: boolean;
  56416. /**
  56417. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56418. * In this case the connection point name must be the name of the uniform to use.
  56419. * Can only be set on inputs
  56420. */
  56421. isUniform: boolean;
  56422. /**
  56423. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56424. * In this case the connection point name must be the name of the attribute to use
  56425. * Can only be set on inputs
  56426. */
  56427. isAttribute: boolean;
  56428. /**
  56429. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56430. * Can only be set on exit points
  56431. */
  56432. isVarying: boolean;
  56433. /**
  56434. * Gets a boolean indicating that the current connection point is a system value
  56435. */
  56436. readonly isSystemValue: boolean;
  56437. /**
  56438. * Gets or sets the current well known value or null if not defined as a system value
  56439. */
  56440. systemValue: Nullable<NodeMaterialSystemValues>;
  56441. /**
  56442. * Gets the current class name
  56443. * @returns the class name
  56444. */
  56445. getClassName(): string;
  56446. /**
  56447. * Animate the input if animationType !== None
  56448. * @param scene defines the rendering scene
  56449. */
  56450. animate(scene: Scene): void;
  56451. private _emitDefine;
  56452. initialize(state: NodeMaterialBuildState): void;
  56453. /**
  56454. * Set the input block to its default value (based on its type)
  56455. */
  56456. setDefaultValue(): void;
  56457. private _emitConstant;
  56458. private _emit;
  56459. /** @hidden */
  56460. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56461. /** @hidden */
  56462. _transmit(effect: Effect, scene: Scene): void;
  56463. protected _buildBlock(state: NodeMaterialBuildState): void;
  56464. protected _dumpPropertiesCode(): string;
  56465. serialize(): any;
  56466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56467. }
  56468. }
  56469. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56470. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56471. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56472. import { Nullable } from "babylonjs/types";
  56473. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56474. import { Observable } from "babylonjs/Misc/observable";
  56475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56476. /**
  56477. * Defines a connection point for a block
  56478. */
  56479. export class NodeMaterialConnectionPoint {
  56480. /** @hidden */
  56481. _ownerBlock: NodeMaterialBlock;
  56482. /** @hidden */
  56483. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56484. private _endpoints;
  56485. private _associatedVariableName;
  56486. /** @hidden */
  56487. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56488. /** @hidden */
  56489. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56490. private _type;
  56491. /** @hidden */
  56492. _enforceAssociatedVariableName: boolean;
  56493. /**
  56494. * Gets or sets the additional types supported by this connection point
  56495. */
  56496. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56497. /**
  56498. * Gets or sets the additional types excluded by this connection point
  56499. */
  56500. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56501. /**
  56502. * Observable triggered when this point is connected
  56503. */
  56504. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56505. /**
  56506. * Gets or sets the associated variable name in the shader
  56507. */
  56508. associatedVariableName: string;
  56509. /**
  56510. * Gets or sets the connection point type (default is float)
  56511. */
  56512. type: NodeMaterialBlockConnectionPointTypes;
  56513. /**
  56514. * Gets or sets the connection point name
  56515. */
  56516. name: string;
  56517. /**
  56518. * Gets or sets a boolean indicating that this connection point can be omitted
  56519. */
  56520. isOptional: boolean;
  56521. /**
  56522. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56523. */
  56524. define: string;
  56525. /** @hidden */
  56526. _prioritizeVertex: boolean;
  56527. private _target;
  56528. /** Gets or sets the target of that connection point */
  56529. target: NodeMaterialBlockTargets;
  56530. /**
  56531. * Gets a boolean indicating that the current point is connected
  56532. */
  56533. readonly isConnected: boolean;
  56534. /**
  56535. * Gets a boolean indicating that the current point is connected to an input block
  56536. */
  56537. readonly isConnectedToInputBlock: boolean;
  56538. /**
  56539. * Gets a the connected input block (if any)
  56540. */
  56541. readonly connectInputBlock: Nullable<InputBlock>;
  56542. /** Get the other side of the connection (if any) */
  56543. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56544. /** Get the block that owns this connection point */
  56545. readonly ownerBlock: NodeMaterialBlock;
  56546. /** Get the block connected on the other side of this connection (if any) */
  56547. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56548. /** Get the block connected on the endpoints of this connection (if any) */
  56549. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56550. /** Gets the list of connected endpoints */
  56551. readonly endpoints: NodeMaterialConnectionPoint[];
  56552. /** Gets a boolean indicating if that output point is connected to at least one input */
  56553. readonly hasEndpoints: boolean;
  56554. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56555. readonly isConnectedInVertexShader: boolean;
  56556. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56557. readonly isConnectedInFragmentShader: boolean;
  56558. /**
  56559. * Creates a new connection point
  56560. * @param name defines the connection point name
  56561. * @param ownerBlock defines the block hosting this connection point
  56562. */
  56563. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56564. /**
  56565. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56566. * @returns the class name
  56567. */
  56568. getClassName(): string;
  56569. /**
  56570. * Gets an boolean indicating if the current point can be connected to another point
  56571. * @param connectionPoint defines the other connection point
  56572. * @returns true if the connection is possible
  56573. */
  56574. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56575. /**
  56576. * Connect this point to another connection point
  56577. * @param connectionPoint defines the other connection point
  56578. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56579. * @returns the current connection point
  56580. */
  56581. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56582. /**
  56583. * Disconnect this point from one of his endpoint
  56584. * @param endpoint defines the other connection point
  56585. * @returns the current connection point
  56586. */
  56587. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56588. /**
  56589. * Serializes this point in a JSON representation
  56590. * @returns the serialized point object
  56591. */
  56592. serialize(): any;
  56593. /**
  56594. * Release resources
  56595. */
  56596. dispose(): void;
  56597. }
  56598. }
  56599. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56603. import { Mesh } from "babylonjs/Meshes/mesh";
  56604. import { Effect } from "babylonjs/Materials/effect";
  56605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56606. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56607. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56608. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56609. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56610. /**
  56611. * Block used to add support for vertex skinning (bones)
  56612. */
  56613. export class BonesBlock extends NodeMaterialBlock {
  56614. /**
  56615. * Creates a new BonesBlock
  56616. * @param name defines the block name
  56617. */
  56618. constructor(name: string);
  56619. /**
  56620. * Initialize the block and prepare the context for build
  56621. * @param state defines the state that will be used for the build
  56622. */
  56623. initialize(state: NodeMaterialBuildState): void;
  56624. /**
  56625. * Gets the current class name
  56626. * @returns the class name
  56627. */
  56628. getClassName(): string;
  56629. /**
  56630. * Gets the matrix indices input component
  56631. */
  56632. readonly matricesIndices: NodeMaterialConnectionPoint;
  56633. /**
  56634. * Gets the matrix weights input component
  56635. */
  56636. readonly matricesWeights: NodeMaterialConnectionPoint;
  56637. /**
  56638. * Gets the extra matrix indices input component
  56639. */
  56640. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56641. /**
  56642. * Gets the extra matrix weights input component
  56643. */
  56644. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56645. /**
  56646. * Gets the world input component
  56647. */
  56648. readonly world: NodeMaterialConnectionPoint;
  56649. /**
  56650. * Gets the output component
  56651. */
  56652. readonly output: NodeMaterialConnectionPoint;
  56653. autoConfigure(material: NodeMaterial): void;
  56654. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56657. protected _buildBlock(state: NodeMaterialBuildState): this;
  56658. }
  56659. }
  56660. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56665. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56666. /**
  56667. * Block used to add support for instances
  56668. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56669. */
  56670. export class InstancesBlock extends NodeMaterialBlock {
  56671. /**
  56672. * Creates a new InstancesBlock
  56673. * @param name defines the block name
  56674. */
  56675. constructor(name: string);
  56676. /**
  56677. * Gets the current class name
  56678. * @returns the class name
  56679. */
  56680. getClassName(): string;
  56681. /**
  56682. * Gets the first world row input component
  56683. */
  56684. readonly world0: NodeMaterialConnectionPoint;
  56685. /**
  56686. * Gets the second world row input component
  56687. */
  56688. readonly world1: NodeMaterialConnectionPoint;
  56689. /**
  56690. * Gets the third world row input component
  56691. */
  56692. readonly world2: NodeMaterialConnectionPoint;
  56693. /**
  56694. * Gets the forth world row input component
  56695. */
  56696. readonly world3: NodeMaterialConnectionPoint;
  56697. /**
  56698. * Gets the world input component
  56699. */
  56700. readonly world: NodeMaterialConnectionPoint;
  56701. /**
  56702. * Gets the output component
  56703. */
  56704. readonly output: NodeMaterialConnectionPoint;
  56705. autoConfigure(material: NodeMaterial): void;
  56706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56707. protected _buildBlock(state: NodeMaterialBuildState): this;
  56708. }
  56709. }
  56710. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56715. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56716. import { Effect } from "babylonjs/Materials/effect";
  56717. import { Mesh } from "babylonjs/Meshes/mesh";
  56718. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56719. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56720. /**
  56721. * Block used to add morph targets support to vertex shader
  56722. */
  56723. export class MorphTargetsBlock extends NodeMaterialBlock {
  56724. private _repeatableContentAnchor;
  56725. private _repeatebleContentGenerated;
  56726. /**
  56727. * Create a new MorphTargetsBlock
  56728. * @param name defines the block name
  56729. */
  56730. constructor(name: string);
  56731. /**
  56732. * Gets the current class name
  56733. * @returns the class name
  56734. */
  56735. getClassName(): string;
  56736. /**
  56737. * Gets the position input component
  56738. */
  56739. readonly position: NodeMaterialConnectionPoint;
  56740. /**
  56741. * Gets the normal input component
  56742. */
  56743. readonly normal: NodeMaterialConnectionPoint;
  56744. /**
  56745. * Gets the tangent input component
  56746. */
  56747. readonly tangent: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the tangent input component
  56750. */
  56751. readonly uv: NodeMaterialConnectionPoint;
  56752. /**
  56753. * Gets the position output component
  56754. */
  56755. readonly positionOutput: NodeMaterialConnectionPoint;
  56756. /**
  56757. * Gets the normal output component
  56758. */
  56759. readonly normalOutput: NodeMaterialConnectionPoint;
  56760. /**
  56761. * Gets the tangent output component
  56762. */
  56763. readonly tangentOutput: NodeMaterialConnectionPoint;
  56764. /**
  56765. * Gets the tangent output component
  56766. */
  56767. readonly uvOutput: NodeMaterialConnectionPoint;
  56768. initialize(state: NodeMaterialBuildState): void;
  56769. autoConfigure(material: NodeMaterial): void;
  56770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56771. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56772. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56773. protected _buildBlock(state: NodeMaterialBuildState): this;
  56774. }
  56775. }
  56776. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56777. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56778. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56780. import { Nullable } from "babylonjs/types";
  56781. import { Scene } from "babylonjs/scene";
  56782. import { Effect } from "babylonjs/Materials/effect";
  56783. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56784. import { Mesh } from "babylonjs/Meshes/mesh";
  56785. import { Light } from "babylonjs/Lights/light";
  56786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56787. /**
  56788. * Block used to get data information from a light
  56789. */
  56790. export class LightInformationBlock extends NodeMaterialBlock {
  56791. private _lightDataUniformName;
  56792. private _lightColorUniformName;
  56793. private _lightTypeDefineName;
  56794. /**
  56795. * Gets or sets the light associated with this block
  56796. */
  56797. light: Nullable<Light>;
  56798. /**
  56799. * Creates a new LightInformationBlock
  56800. * @param name defines the block name
  56801. */
  56802. constructor(name: string);
  56803. /**
  56804. * Gets the current class name
  56805. * @returns the class name
  56806. */
  56807. getClassName(): string;
  56808. /**
  56809. * Gets the world position input component
  56810. */
  56811. readonly worldPosition: NodeMaterialConnectionPoint;
  56812. /**
  56813. * Gets the direction output component
  56814. */
  56815. readonly direction: NodeMaterialConnectionPoint;
  56816. /**
  56817. * Gets the direction output component
  56818. */
  56819. readonly color: NodeMaterialConnectionPoint;
  56820. /**
  56821. * Gets the direction output component
  56822. */
  56823. readonly intensity: NodeMaterialConnectionPoint;
  56824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56826. protected _buildBlock(state: NodeMaterialBuildState): this;
  56827. serialize(): any;
  56828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56829. }
  56830. }
  56831. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56832. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56833. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56834. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56835. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56836. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56837. }
  56838. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56843. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56844. import { Effect } from "babylonjs/Materials/effect";
  56845. import { Mesh } from "babylonjs/Meshes/mesh";
  56846. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56847. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56848. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56849. /**
  56850. * Block used to add image processing support to fragment shader
  56851. */
  56852. export class ImageProcessingBlock extends NodeMaterialBlock {
  56853. /**
  56854. * Create a new ImageProcessingBlock
  56855. * @param name defines the block name
  56856. */
  56857. constructor(name: string);
  56858. /**
  56859. * Gets the current class name
  56860. * @returns the class name
  56861. */
  56862. getClassName(): string;
  56863. /**
  56864. * Gets the color input component
  56865. */
  56866. readonly color: NodeMaterialConnectionPoint;
  56867. /**
  56868. * Gets the output component
  56869. */
  56870. readonly output: NodeMaterialConnectionPoint;
  56871. /**
  56872. * Initialize the block and prepare the context for build
  56873. * @param state defines the state that will be used for the build
  56874. */
  56875. initialize(state: NodeMaterialBuildState): void;
  56876. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56879. protected _buildBlock(state: NodeMaterialBuildState): this;
  56880. }
  56881. }
  56882. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56886. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56888. import { Effect } from "babylonjs/Materials/effect";
  56889. import { Mesh } from "babylonjs/Meshes/mesh";
  56890. import { Scene } from "babylonjs/scene";
  56891. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56892. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56893. /**
  56894. * Block used to pertub normals based on a normal map
  56895. */
  56896. export class PerturbNormalBlock extends NodeMaterialBlock {
  56897. private _tangentSpaceParameterName;
  56898. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56899. invertX: boolean;
  56900. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56901. invertY: boolean;
  56902. /**
  56903. * Create a new PerturbNormalBlock
  56904. * @param name defines the block name
  56905. */
  56906. constructor(name: string);
  56907. /**
  56908. * Gets the current class name
  56909. * @returns the class name
  56910. */
  56911. getClassName(): string;
  56912. /**
  56913. * Gets the world position input component
  56914. */
  56915. readonly worldPosition: NodeMaterialConnectionPoint;
  56916. /**
  56917. * Gets the world normal input component
  56918. */
  56919. readonly worldNormal: NodeMaterialConnectionPoint;
  56920. /**
  56921. * Gets the uv input component
  56922. */
  56923. readonly uv: NodeMaterialConnectionPoint;
  56924. /**
  56925. * Gets the normal map color input component
  56926. */
  56927. readonly normalMapColor: NodeMaterialConnectionPoint;
  56928. /**
  56929. * Gets the strength input component
  56930. */
  56931. readonly strength: NodeMaterialConnectionPoint;
  56932. /**
  56933. * Gets the output component
  56934. */
  56935. readonly output: NodeMaterialConnectionPoint;
  56936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56937. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56938. autoConfigure(material: NodeMaterial): void;
  56939. protected _buildBlock(state: NodeMaterialBuildState): this;
  56940. protected _dumpPropertiesCode(): string;
  56941. serialize(): any;
  56942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56943. }
  56944. }
  56945. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56949. /**
  56950. * Block used to discard a pixel if a value is smaller than a cutoff
  56951. */
  56952. export class DiscardBlock extends NodeMaterialBlock {
  56953. /**
  56954. * Create a new DiscardBlock
  56955. * @param name defines the block name
  56956. */
  56957. constructor(name: string);
  56958. /**
  56959. * Gets the current class name
  56960. * @returns the class name
  56961. */
  56962. getClassName(): string;
  56963. /**
  56964. * Gets the color input component
  56965. */
  56966. readonly value: NodeMaterialConnectionPoint;
  56967. /**
  56968. * Gets the cutoff input component
  56969. */
  56970. readonly cutoff: NodeMaterialConnectionPoint;
  56971. protected _buildBlock(state: NodeMaterialBuildState): this;
  56972. }
  56973. }
  56974. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56975. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56976. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56977. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56978. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56979. }
  56980. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56983. import { Mesh } from "babylonjs/Meshes/mesh";
  56984. import { Effect } from "babylonjs/Materials/effect";
  56985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56987. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56988. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56989. /**
  56990. * Block used to add support for scene fog
  56991. */
  56992. export class FogBlock extends NodeMaterialBlock {
  56993. private _fogDistanceName;
  56994. private _fogParameters;
  56995. /**
  56996. * Create a new FogBlock
  56997. * @param name defines the block name
  56998. */
  56999. constructor(name: string);
  57000. /**
  57001. * Gets the current class name
  57002. * @returns the class name
  57003. */
  57004. getClassName(): string;
  57005. /**
  57006. * Gets the world position input component
  57007. */
  57008. readonly worldPosition: NodeMaterialConnectionPoint;
  57009. /**
  57010. * Gets the view input component
  57011. */
  57012. readonly view: NodeMaterialConnectionPoint;
  57013. /**
  57014. * Gets the color input component
  57015. */
  57016. readonly input: NodeMaterialConnectionPoint;
  57017. /**
  57018. * Gets the fog color input component
  57019. */
  57020. readonly fogColor: NodeMaterialConnectionPoint;
  57021. /**
  57022. * Gets the output component
  57023. */
  57024. readonly output: NodeMaterialConnectionPoint;
  57025. autoConfigure(material: NodeMaterial): void;
  57026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57027. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57028. protected _buildBlock(state: NodeMaterialBuildState): this;
  57029. }
  57030. }
  57031. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57036. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57037. import { Effect } from "babylonjs/Materials/effect";
  57038. import { Mesh } from "babylonjs/Meshes/mesh";
  57039. import { Light } from "babylonjs/Lights/light";
  57040. import { Nullable } from "babylonjs/types";
  57041. import { Scene } from "babylonjs/scene";
  57042. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57043. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57044. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57045. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57046. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57047. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57048. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57049. /**
  57050. * Block used to add light in the fragment shader
  57051. */
  57052. export class LightBlock extends NodeMaterialBlock {
  57053. private _lightId;
  57054. /**
  57055. * Gets or sets the light associated with this block
  57056. */
  57057. light: Nullable<Light>;
  57058. /**
  57059. * Create a new LightBlock
  57060. * @param name defines the block name
  57061. */
  57062. constructor(name: string);
  57063. /**
  57064. * Gets the current class name
  57065. * @returns the class name
  57066. */
  57067. getClassName(): string;
  57068. /**
  57069. * Gets the world position input component
  57070. */
  57071. readonly worldPosition: NodeMaterialConnectionPoint;
  57072. /**
  57073. * Gets the world normal input component
  57074. */
  57075. readonly worldNormal: NodeMaterialConnectionPoint;
  57076. /**
  57077. * Gets the camera (or eye) position component
  57078. */
  57079. readonly cameraPosition: NodeMaterialConnectionPoint;
  57080. /**
  57081. * Gets the glossiness component
  57082. */
  57083. readonly glossiness: NodeMaterialConnectionPoint;
  57084. /**
  57085. * Gets the glossinness power component
  57086. */
  57087. readonly glossPower: NodeMaterialConnectionPoint;
  57088. /**
  57089. * Gets the diffuse color component
  57090. */
  57091. readonly diffuseColor: NodeMaterialConnectionPoint;
  57092. /**
  57093. * Gets the specular color component
  57094. */
  57095. readonly specularColor: NodeMaterialConnectionPoint;
  57096. /**
  57097. * Gets the diffuse output component
  57098. */
  57099. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57100. /**
  57101. * Gets the specular output component
  57102. */
  57103. readonly specularOutput: NodeMaterialConnectionPoint;
  57104. autoConfigure(material: NodeMaterial): void;
  57105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57106. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57108. private _injectVertexCode;
  57109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57110. serialize(): any;
  57111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57112. }
  57113. }
  57114. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57115. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57116. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57117. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57118. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57119. }
  57120. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57121. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57122. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57123. }
  57124. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57128. /**
  57129. * Block used to multiply 2 values
  57130. */
  57131. export class MultiplyBlock extends NodeMaterialBlock {
  57132. /**
  57133. * Creates a new MultiplyBlock
  57134. * @param name defines the block name
  57135. */
  57136. constructor(name: string);
  57137. /**
  57138. * Gets the current class name
  57139. * @returns the class name
  57140. */
  57141. getClassName(): string;
  57142. /**
  57143. * Gets the left operand input component
  57144. */
  57145. readonly left: NodeMaterialConnectionPoint;
  57146. /**
  57147. * Gets the right operand input component
  57148. */
  57149. readonly right: NodeMaterialConnectionPoint;
  57150. /**
  57151. * Gets the output component
  57152. */
  57153. readonly output: NodeMaterialConnectionPoint;
  57154. protected _buildBlock(state: NodeMaterialBuildState): this;
  57155. }
  57156. }
  57157. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57161. /**
  57162. * Block used to add 2 vectors
  57163. */
  57164. export class AddBlock extends NodeMaterialBlock {
  57165. /**
  57166. * Creates a new AddBlock
  57167. * @param name defines the block name
  57168. */
  57169. constructor(name: string);
  57170. /**
  57171. * Gets the current class name
  57172. * @returns the class name
  57173. */
  57174. getClassName(): string;
  57175. /**
  57176. * Gets the left operand input component
  57177. */
  57178. readonly left: NodeMaterialConnectionPoint;
  57179. /**
  57180. * Gets the right operand input component
  57181. */
  57182. readonly right: NodeMaterialConnectionPoint;
  57183. /**
  57184. * Gets the output component
  57185. */
  57186. readonly output: NodeMaterialConnectionPoint;
  57187. protected _buildBlock(state: NodeMaterialBuildState): this;
  57188. }
  57189. }
  57190. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57194. /**
  57195. * Block used to scale a vector by a float
  57196. */
  57197. export class ScaleBlock extends NodeMaterialBlock {
  57198. /**
  57199. * Creates a new ScaleBlock
  57200. * @param name defines the block name
  57201. */
  57202. constructor(name: string);
  57203. /**
  57204. * Gets the current class name
  57205. * @returns the class name
  57206. */
  57207. getClassName(): string;
  57208. /**
  57209. * Gets the input component
  57210. */
  57211. readonly input: NodeMaterialConnectionPoint;
  57212. /**
  57213. * Gets the factor input component
  57214. */
  57215. readonly factor: NodeMaterialConnectionPoint;
  57216. /**
  57217. * Gets the output component
  57218. */
  57219. readonly output: NodeMaterialConnectionPoint;
  57220. protected _buildBlock(state: NodeMaterialBuildState): this;
  57221. }
  57222. }
  57223. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57227. import { Scene } from "babylonjs/scene";
  57228. /**
  57229. * Block used to clamp a float
  57230. */
  57231. export class ClampBlock extends NodeMaterialBlock {
  57232. /** Gets or sets the minimum range */
  57233. minimum: number;
  57234. /** Gets or sets the maximum range */
  57235. maximum: number;
  57236. /**
  57237. * Creates a new ClampBlock
  57238. * @param name defines the block name
  57239. */
  57240. constructor(name: string);
  57241. /**
  57242. * Gets the current class name
  57243. * @returns the class name
  57244. */
  57245. getClassName(): string;
  57246. /**
  57247. * Gets the value input component
  57248. */
  57249. readonly value: NodeMaterialConnectionPoint;
  57250. /**
  57251. * Gets the output component
  57252. */
  57253. readonly output: NodeMaterialConnectionPoint;
  57254. protected _buildBlock(state: NodeMaterialBuildState): this;
  57255. protected _dumpPropertiesCode(): string;
  57256. serialize(): any;
  57257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57258. }
  57259. }
  57260. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57264. /**
  57265. * Block used to apply a cross product between 2 vectors
  57266. */
  57267. export class CrossBlock extends NodeMaterialBlock {
  57268. /**
  57269. * Creates a new CrossBlock
  57270. * @param name defines the block name
  57271. */
  57272. constructor(name: string);
  57273. /**
  57274. * Gets the current class name
  57275. * @returns the class name
  57276. */
  57277. getClassName(): string;
  57278. /**
  57279. * Gets the left operand input component
  57280. */
  57281. readonly left: NodeMaterialConnectionPoint;
  57282. /**
  57283. * Gets the right operand input component
  57284. */
  57285. readonly right: NodeMaterialConnectionPoint;
  57286. /**
  57287. * Gets the output component
  57288. */
  57289. readonly output: NodeMaterialConnectionPoint;
  57290. protected _buildBlock(state: NodeMaterialBuildState): this;
  57291. }
  57292. }
  57293. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57296. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57297. /**
  57298. * Block used to apply a dot product between 2 vectors
  57299. */
  57300. export class DotBlock extends NodeMaterialBlock {
  57301. /**
  57302. * Creates a new DotBlock
  57303. * @param name defines the block name
  57304. */
  57305. constructor(name: string);
  57306. /**
  57307. * Gets the current class name
  57308. * @returns the class name
  57309. */
  57310. getClassName(): string;
  57311. /**
  57312. * Gets the left operand input component
  57313. */
  57314. readonly left: NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the right operand input component
  57317. */
  57318. readonly right: NodeMaterialConnectionPoint;
  57319. /**
  57320. * Gets the output component
  57321. */
  57322. readonly output: NodeMaterialConnectionPoint;
  57323. protected _buildBlock(state: NodeMaterialBuildState): this;
  57324. }
  57325. }
  57326. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57330. import { Vector2 } from "babylonjs/Maths/math.vector";
  57331. import { Scene } from "babylonjs/scene";
  57332. /**
  57333. * Block used to remap a float from a range to a new one
  57334. */
  57335. export class RemapBlock extends NodeMaterialBlock {
  57336. /**
  57337. * Gets or sets the source range
  57338. */
  57339. sourceRange: Vector2;
  57340. /**
  57341. * Gets or sets the target range
  57342. */
  57343. targetRange: Vector2;
  57344. /**
  57345. * Creates a new RemapBlock
  57346. * @param name defines the block name
  57347. */
  57348. constructor(name: string);
  57349. /**
  57350. * Gets the current class name
  57351. * @returns the class name
  57352. */
  57353. getClassName(): string;
  57354. /**
  57355. * Gets the input component
  57356. */
  57357. readonly input: NodeMaterialConnectionPoint;
  57358. /**
  57359. * Gets the source min input component
  57360. */
  57361. readonly sourceMin: NodeMaterialConnectionPoint;
  57362. /**
  57363. * Gets the source max input component
  57364. */
  57365. readonly sourceMax: NodeMaterialConnectionPoint;
  57366. /**
  57367. * Gets the target min input component
  57368. */
  57369. readonly targetMin: NodeMaterialConnectionPoint;
  57370. /**
  57371. * Gets the target max input component
  57372. */
  57373. readonly targetMax: NodeMaterialConnectionPoint;
  57374. /**
  57375. * Gets the output component
  57376. */
  57377. readonly output: NodeMaterialConnectionPoint;
  57378. protected _buildBlock(state: NodeMaterialBuildState): this;
  57379. protected _dumpPropertiesCode(): string;
  57380. serialize(): any;
  57381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57382. }
  57383. }
  57384. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57388. /**
  57389. * Block used to normalize a vector
  57390. */
  57391. export class NormalizeBlock extends NodeMaterialBlock {
  57392. /**
  57393. * Creates a new NormalizeBlock
  57394. * @param name defines the block name
  57395. */
  57396. constructor(name: string);
  57397. /**
  57398. * Gets the current class name
  57399. * @returns the class name
  57400. */
  57401. getClassName(): string;
  57402. /**
  57403. * Gets the input component
  57404. */
  57405. readonly input: NodeMaterialConnectionPoint;
  57406. /**
  57407. * Gets the output component
  57408. */
  57409. readonly output: NodeMaterialConnectionPoint;
  57410. protected _buildBlock(state: NodeMaterialBuildState): this;
  57411. }
  57412. }
  57413. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57417. import { Scene } from "babylonjs/scene";
  57418. /**
  57419. * Operations supported by the Trigonometry block
  57420. */
  57421. export enum TrigonometryBlockOperations {
  57422. /** Cos */
  57423. Cos = 0,
  57424. /** Sin */
  57425. Sin = 1,
  57426. /** Abs */
  57427. Abs = 2,
  57428. /** Exp */
  57429. Exp = 3,
  57430. /** Exp2 */
  57431. Exp2 = 4,
  57432. /** Round */
  57433. Round = 5,
  57434. /** Floor */
  57435. Floor = 6,
  57436. /** Ceiling */
  57437. Ceiling = 7,
  57438. /** Square root */
  57439. Sqrt = 8,
  57440. /** Log */
  57441. Log = 9,
  57442. /** Tangent */
  57443. Tan = 10,
  57444. /** Arc tangent */
  57445. ArcTan = 11,
  57446. /** Arc cosinus */
  57447. ArcCos = 12,
  57448. /** Arc sinus */
  57449. ArcSin = 13,
  57450. /** Fraction */
  57451. Fract = 14,
  57452. /** Sign */
  57453. Sign = 15,
  57454. /** To radians (from degrees) */
  57455. Radians = 16,
  57456. /** To degrees (from radians) */
  57457. Degrees = 17
  57458. }
  57459. /**
  57460. * Block used to apply trigonometry operation to floats
  57461. */
  57462. export class TrigonometryBlock extends NodeMaterialBlock {
  57463. /**
  57464. * Gets or sets the operation applied by the block
  57465. */
  57466. operation: TrigonometryBlockOperations;
  57467. /**
  57468. * Creates a new TrigonometryBlock
  57469. * @param name defines the block name
  57470. */
  57471. constructor(name: string);
  57472. /**
  57473. * Gets the current class name
  57474. * @returns the class name
  57475. */
  57476. getClassName(): string;
  57477. /**
  57478. * Gets the input component
  57479. */
  57480. readonly input: NodeMaterialConnectionPoint;
  57481. /**
  57482. * Gets the output component
  57483. */
  57484. readonly output: NodeMaterialConnectionPoint;
  57485. protected _buildBlock(state: NodeMaterialBuildState): this;
  57486. serialize(): any;
  57487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57488. }
  57489. }
  57490. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57494. /**
  57495. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57496. */
  57497. export class ColorMergerBlock extends NodeMaterialBlock {
  57498. /**
  57499. * Create a new ColorMergerBlock
  57500. * @param name defines the block name
  57501. */
  57502. constructor(name: string);
  57503. /**
  57504. * Gets the current class name
  57505. * @returns the class name
  57506. */
  57507. getClassName(): string;
  57508. /**
  57509. * Gets the r component (input)
  57510. */
  57511. readonly r: NodeMaterialConnectionPoint;
  57512. /**
  57513. * Gets the g component (input)
  57514. */
  57515. readonly g: NodeMaterialConnectionPoint;
  57516. /**
  57517. * Gets the b component (input)
  57518. */
  57519. readonly b: NodeMaterialConnectionPoint;
  57520. /**
  57521. * Gets the a component (input)
  57522. */
  57523. readonly a: NodeMaterialConnectionPoint;
  57524. /**
  57525. * Gets the rgba component (output)
  57526. */
  57527. readonly rgba: NodeMaterialConnectionPoint;
  57528. /**
  57529. * Gets the rgb component (output)
  57530. */
  57531. readonly rgb: NodeMaterialConnectionPoint;
  57532. protected _buildBlock(state: NodeMaterialBuildState): this;
  57533. }
  57534. }
  57535. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57539. /**
  57540. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57541. */
  57542. export class VectorMergerBlock extends NodeMaterialBlock {
  57543. /**
  57544. * Create a new VectorMergerBlock
  57545. * @param name defines the block name
  57546. */
  57547. constructor(name: string);
  57548. /**
  57549. * Gets the current class name
  57550. * @returns the class name
  57551. */
  57552. getClassName(): string;
  57553. /**
  57554. * Gets the x component (input)
  57555. */
  57556. readonly x: NodeMaterialConnectionPoint;
  57557. /**
  57558. * Gets the y component (input)
  57559. */
  57560. readonly y: NodeMaterialConnectionPoint;
  57561. /**
  57562. * Gets the z component (input)
  57563. */
  57564. readonly z: NodeMaterialConnectionPoint;
  57565. /**
  57566. * Gets the w component (input)
  57567. */
  57568. readonly w: NodeMaterialConnectionPoint;
  57569. /**
  57570. * Gets the xyzw component (output)
  57571. */
  57572. readonly xyzw: NodeMaterialConnectionPoint;
  57573. /**
  57574. * Gets the xyz component (output)
  57575. */
  57576. readonly xyz: NodeMaterialConnectionPoint;
  57577. /**
  57578. * Gets the xy component (output)
  57579. */
  57580. readonly xy: NodeMaterialConnectionPoint;
  57581. protected _buildBlock(state: NodeMaterialBuildState): this;
  57582. }
  57583. }
  57584. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57586. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57587. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57588. /**
  57589. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57590. */
  57591. export class ColorSplitterBlock extends NodeMaterialBlock {
  57592. /**
  57593. * Create a new ColorSplitterBlock
  57594. * @param name defines the block name
  57595. */
  57596. constructor(name: string);
  57597. /**
  57598. * Gets the current class name
  57599. * @returns the class name
  57600. */
  57601. getClassName(): string;
  57602. /**
  57603. * Gets the rgba component (input)
  57604. */
  57605. readonly rgba: NodeMaterialConnectionPoint;
  57606. /**
  57607. * Gets the rgb component (input)
  57608. */
  57609. readonly rgbIn: NodeMaterialConnectionPoint;
  57610. /**
  57611. * Gets the rgb component (output)
  57612. */
  57613. readonly rgbOut: NodeMaterialConnectionPoint;
  57614. /**
  57615. * Gets the r component (output)
  57616. */
  57617. readonly r: NodeMaterialConnectionPoint;
  57618. /**
  57619. * Gets the g component (output)
  57620. */
  57621. readonly g: NodeMaterialConnectionPoint;
  57622. /**
  57623. * Gets the b component (output)
  57624. */
  57625. readonly b: NodeMaterialConnectionPoint;
  57626. /**
  57627. * Gets the a component (output)
  57628. */
  57629. readonly a: NodeMaterialConnectionPoint;
  57630. protected _inputRename(name: string): string;
  57631. protected _outputRename(name: string): string;
  57632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57633. }
  57634. }
  57635. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  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. /**
  57640. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57641. */
  57642. export class VectorSplitterBlock extends NodeMaterialBlock {
  57643. /**
  57644. * Create a new VectorSplitterBlock
  57645. * @param name defines the block name
  57646. */
  57647. constructor(name: string);
  57648. /**
  57649. * Gets the current class name
  57650. * @returns the class name
  57651. */
  57652. getClassName(): string;
  57653. /**
  57654. * Gets the xyzw component (input)
  57655. */
  57656. readonly xyzw: NodeMaterialConnectionPoint;
  57657. /**
  57658. * Gets the xyz component (input)
  57659. */
  57660. readonly xyzIn: NodeMaterialConnectionPoint;
  57661. /**
  57662. * Gets the xy component (input)
  57663. */
  57664. readonly xyIn: NodeMaterialConnectionPoint;
  57665. /**
  57666. * Gets the xyz component (output)
  57667. */
  57668. readonly xyzOut: NodeMaterialConnectionPoint;
  57669. /**
  57670. * Gets the xy component (output)
  57671. */
  57672. readonly xyOut: NodeMaterialConnectionPoint;
  57673. /**
  57674. * Gets the x component (output)
  57675. */
  57676. readonly x: NodeMaterialConnectionPoint;
  57677. /**
  57678. * Gets the y component (output)
  57679. */
  57680. readonly y: NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the z component (output)
  57683. */
  57684. readonly z: NodeMaterialConnectionPoint;
  57685. /**
  57686. * Gets the w component (output)
  57687. */
  57688. readonly w: NodeMaterialConnectionPoint;
  57689. protected _inputRename(name: string): string;
  57690. protected _outputRename(name: string): string;
  57691. protected _buildBlock(state: NodeMaterialBuildState): this;
  57692. }
  57693. }
  57694. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57698. /**
  57699. * Block used to lerp between 2 values
  57700. */
  57701. export class LerpBlock extends NodeMaterialBlock {
  57702. /**
  57703. * Creates a new LerpBlock
  57704. * @param name defines the block name
  57705. */
  57706. constructor(name: string);
  57707. /**
  57708. * Gets the current class name
  57709. * @returns the class name
  57710. */
  57711. getClassName(): string;
  57712. /**
  57713. * Gets the left operand input component
  57714. */
  57715. readonly left: NodeMaterialConnectionPoint;
  57716. /**
  57717. * Gets the right operand input component
  57718. */
  57719. readonly right: NodeMaterialConnectionPoint;
  57720. /**
  57721. * Gets the gradient operand input component
  57722. */
  57723. readonly gradient: NodeMaterialConnectionPoint;
  57724. /**
  57725. * Gets the output component
  57726. */
  57727. readonly output: NodeMaterialConnectionPoint;
  57728. protected _buildBlock(state: NodeMaterialBuildState): this;
  57729. }
  57730. }
  57731. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57735. /**
  57736. * Block used to divide 2 vectors
  57737. */
  57738. export class DivideBlock extends NodeMaterialBlock {
  57739. /**
  57740. * Creates a new DivideBlock
  57741. * @param name defines the block name
  57742. */
  57743. constructor(name: string);
  57744. /**
  57745. * Gets the current class name
  57746. * @returns the class name
  57747. */
  57748. getClassName(): string;
  57749. /**
  57750. * Gets the left operand input component
  57751. */
  57752. readonly left: NodeMaterialConnectionPoint;
  57753. /**
  57754. * Gets the right operand input component
  57755. */
  57756. readonly right: NodeMaterialConnectionPoint;
  57757. /**
  57758. * Gets the output component
  57759. */
  57760. readonly output: NodeMaterialConnectionPoint;
  57761. protected _buildBlock(state: NodeMaterialBuildState): this;
  57762. }
  57763. }
  57764. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57768. /**
  57769. * Block used to subtract 2 vectors
  57770. */
  57771. export class SubtractBlock extends NodeMaterialBlock {
  57772. /**
  57773. * Creates a new SubtractBlock
  57774. * @param name defines the block name
  57775. */
  57776. constructor(name: string);
  57777. /**
  57778. * Gets the current class name
  57779. * @returns the class name
  57780. */
  57781. getClassName(): string;
  57782. /**
  57783. * Gets the left operand input component
  57784. */
  57785. readonly left: NodeMaterialConnectionPoint;
  57786. /**
  57787. * Gets the right operand input component
  57788. */
  57789. readonly right: NodeMaterialConnectionPoint;
  57790. /**
  57791. * Gets the output component
  57792. */
  57793. readonly output: NodeMaterialConnectionPoint;
  57794. protected _buildBlock(state: NodeMaterialBuildState): this;
  57795. }
  57796. }
  57797. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57801. /**
  57802. * Block used to step a value
  57803. */
  57804. export class StepBlock extends NodeMaterialBlock {
  57805. /**
  57806. * Creates a new StepBlock
  57807. * @param name defines the block name
  57808. */
  57809. constructor(name: string);
  57810. /**
  57811. * Gets the current class name
  57812. * @returns the class name
  57813. */
  57814. getClassName(): string;
  57815. /**
  57816. * Gets the value operand input component
  57817. */
  57818. readonly value: NodeMaterialConnectionPoint;
  57819. /**
  57820. * Gets the edge operand input component
  57821. */
  57822. readonly edge: NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the output component
  57825. */
  57826. readonly output: NodeMaterialConnectionPoint;
  57827. protected _buildBlock(state: NodeMaterialBuildState): this;
  57828. }
  57829. }
  57830. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57834. /**
  57835. * Block used to get the opposite (1 - x) of a value
  57836. */
  57837. export class OneMinusBlock extends NodeMaterialBlock {
  57838. /**
  57839. * Creates a new OneMinusBlock
  57840. * @param name defines the block name
  57841. */
  57842. constructor(name: string);
  57843. /**
  57844. * Gets the current class name
  57845. * @returns the class name
  57846. */
  57847. getClassName(): string;
  57848. /**
  57849. * Gets the input component
  57850. */
  57851. readonly input: NodeMaterialConnectionPoint;
  57852. /**
  57853. * Gets the output component
  57854. */
  57855. readonly output: NodeMaterialConnectionPoint;
  57856. protected _buildBlock(state: NodeMaterialBuildState): this;
  57857. }
  57858. }
  57859. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57863. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57864. /**
  57865. * Block used to get the view direction
  57866. */
  57867. export class ViewDirectionBlock extends NodeMaterialBlock {
  57868. /**
  57869. * Creates a new ViewDirectionBlock
  57870. * @param name defines the block name
  57871. */
  57872. constructor(name: string);
  57873. /**
  57874. * Gets the current class name
  57875. * @returns the class name
  57876. */
  57877. getClassName(): string;
  57878. /**
  57879. * Gets the world position component
  57880. */
  57881. readonly worldPosition: NodeMaterialConnectionPoint;
  57882. /**
  57883. * Gets the camera position component
  57884. */
  57885. readonly cameraPosition: NodeMaterialConnectionPoint;
  57886. /**
  57887. * Gets the output component
  57888. */
  57889. readonly output: NodeMaterialConnectionPoint;
  57890. autoConfigure(material: NodeMaterial): void;
  57891. protected _buildBlock(state: NodeMaterialBuildState): this;
  57892. }
  57893. }
  57894. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57895. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57896. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57897. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57898. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57899. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57900. /**
  57901. * Block used to compute fresnel value
  57902. */
  57903. export class FresnelBlock extends NodeMaterialBlock {
  57904. /**
  57905. * Create a new FresnelBlock
  57906. * @param name defines the block name
  57907. */
  57908. constructor(name: string);
  57909. /**
  57910. * Gets the current class name
  57911. * @returns the class name
  57912. */
  57913. getClassName(): string;
  57914. /**
  57915. * Gets the world normal input component
  57916. */
  57917. readonly worldNormal: NodeMaterialConnectionPoint;
  57918. /**
  57919. * Gets the view direction input component
  57920. */
  57921. readonly viewDirection: NodeMaterialConnectionPoint;
  57922. /**
  57923. * Gets the bias input component
  57924. */
  57925. readonly bias: NodeMaterialConnectionPoint;
  57926. /**
  57927. * Gets the camera (or eye) position component
  57928. */
  57929. readonly power: NodeMaterialConnectionPoint;
  57930. /**
  57931. * Gets the fresnel output component
  57932. */
  57933. readonly fresnel: NodeMaterialConnectionPoint;
  57934. autoConfigure(material: NodeMaterial): void;
  57935. protected _buildBlock(state: NodeMaterialBuildState): this;
  57936. }
  57937. }
  57938. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57942. /**
  57943. * Block used to get the max of 2 values
  57944. */
  57945. export class MaxBlock extends NodeMaterialBlock {
  57946. /**
  57947. * Creates a new MaxBlock
  57948. * @param name defines the block name
  57949. */
  57950. constructor(name: string);
  57951. /**
  57952. * Gets the current class name
  57953. * @returns the class name
  57954. */
  57955. getClassName(): string;
  57956. /**
  57957. * Gets the left operand input component
  57958. */
  57959. readonly left: NodeMaterialConnectionPoint;
  57960. /**
  57961. * Gets the right operand input component
  57962. */
  57963. readonly right: NodeMaterialConnectionPoint;
  57964. /**
  57965. * Gets the output component
  57966. */
  57967. readonly output: NodeMaterialConnectionPoint;
  57968. protected _buildBlock(state: NodeMaterialBuildState): this;
  57969. }
  57970. }
  57971. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57975. /**
  57976. * Block used to get the min of 2 values
  57977. */
  57978. export class MinBlock extends NodeMaterialBlock {
  57979. /**
  57980. * Creates a new MinBlock
  57981. * @param name defines the block name
  57982. */
  57983. constructor(name: string);
  57984. /**
  57985. * Gets the current class name
  57986. * @returns the class name
  57987. */
  57988. getClassName(): string;
  57989. /**
  57990. * Gets the left operand input component
  57991. */
  57992. readonly left: NodeMaterialConnectionPoint;
  57993. /**
  57994. * Gets the right operand input component
  57995. */
  57996. readonly right: NodeMaterialConnectionPoint;
  57997. /**
  57998. * Gets the output component
  57999. */
  58000. readonly output: NodeMaterialConnectionPoint;
  58001. protected _buildBlock(state: NodeMaterialBuildState): this;
  58002. }
  58003. }
  58004. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58008. /**
  58009. * Block used to get the distance between 2 values
  58010. */
  58011. export class DistanceBlock extends NodeMaterialBlock {
  58012. /**
  58013. * Creates a new DistanceBlock
  58014. * @param name defines the block name
  58015. */
  58016. constructor(name: string);
  58017. /**
  58018. * Gets the current class name
  58019. * @returns the class name
  58020. */
  58021. getClassName(): string;
  58022. /**
  58023. * Gets the left operand input component
  58024. */
  58025. readonly left: NodeMaterialConnectionPoint;
  58026. /**
  58027. * Gets the right operand input component
  58028. */
  58029. readonly right: NodeMaterialConnectionPoint;
  58030. /**
  58031. * Gets the output component
  58032. */
  58033. readonly output: NodeMaterialConnectionPoint;
  58034. protected _buildBlock(state: NodeMaterialBuildState): this;
  58035. }
  58036. }
  58037. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58041. /**
  58042. * Block used to get the length of a vector
  58043. */
  58044. export class LengthBlock extends NodeMaterialBlock {
  58045. /**
  58046. * Creates a new LengthBlock
  58047. * @param name defines the block name
  58048. */
  58049. constructor(name: string);
  58050. /**
  58051. * Gets the current class name
  58052. * @returns the class name
  58053. */
  58054. getClassName(): string;
  58055. /**
  58056. * Gets the value input component
  58057. */
  58058. readonly value: NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the output component
  58061. */
  58062. readonly output: NodeMaterialConnectionPoint;
  58063. protected _buildBlock(state: NodeMaterialBuildState): this;
  58064. }
  58065. }
  58066. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58070. /**
  58071. * Block used to get negative version of a value (i.e. x * -1)
  58072. */
  58073. export class NegateBlock extends NodeMaterialBlock {
  58074. /**
  58075. * Creates a new NegateBlock
  58076. * @param name defines the block name
  58077. */
  58078. constructor(name: string);
  58079. /**
  58080. * Gets the current class name
  58081. * @returns the class name
  58082. */
  58083. getClassName(): string;
  58084. /**
  58085. * Gets the value input component
  58086. */
  58087. readonly value: NodeMaterialConnectionPoint;
  58088. /**
  58089. * Gets the output component
  58090. */
  58091. readonly output: NodeMaterialConnectionPoint;
  58092. protected _buildBlock(state: NodeMaterialBuildState): this;
  58093. }
  58094. }
  58095. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58099. /**
  58100. * Block used to get the value of the first parameter raised to the power of the second
  58101. */
  58102. export class PowBlock extends NodeMaterialBlock {
  58103. /**
  58104. * Creates a new PowBlock
  58105. * @param name defines the block name
  58106. */
  58107. constructor(name: string);
  58108. /**
  58109. * Gets the current class name
  58110. * @returns the class name
  58111. */
  58112. getClassName(): string;
  58113. /**
  58114. * Gets the value operand input component
  58115. */
  58116. readonly value: NodeMaterialConnectionPoint;
  58117. /**
  58118. * Gets the power operand input component
  58119. */
  58120. readonly power: NodeMaterialConnectionPoint;
  58121. /**
  58122. * Gets the output component
  58123. */
  58124. readonly output: NodeMaterialConnectionPoint;
  58125. protected _buildBlock(state: NodeMaterialBuildState): this;
  58126. }
  58127. }
  58128. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58132. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58133. /**
  58134. * Block used to get a random number
  58135. */
  58136. export class RandomNumberBlock extends NodeMaterialBlock {
  58137. /**
  58138. * Creates a new RandomNumberBlock
  58139. * @param name defines the block name
  58140. */
  58141. constructor(name: string);
  58142. /**
  58143. * Gets the current class name
  58144. * @returns the class name
  58145. */
  58146. getClassName(): string;
  58147. /**
  58148. * Gets the seed input component
  58149. */
  58150. readonly seed: NodeMaterialConnectionPoint;
  58151. /**
  58152. * Gets the output component
  58153. */
  58154. readonly output: NodeMaterialConnectionPoint;
  58155. protected _buildBlock(state: NodeMaterialBuildState): this;
  58156. }
  58157. }
  58158. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58159. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58160. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58161. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58162. /**
  58163. * Block used to compute arc tangent of 2 values
  58164. */
  58165. export class ArcTan2Block extends NodeMaterialBlock {
  58166. /**
  58167. * Creates a new ArcTan2Block
  58168. * @param name defines the block name
  58169. */
  58170. constructor(name: string);
  58171. /**
  58172. * Gets the current class name
  58173. * @returns the class name
  58174. */
  58175. getClassName(): string;
  58176. /**
  58177. * Gets the x operand input component
  58178. */
  58179. readonly x: NodeMaterialConnectionPoint;
  58180. /**
  58181. * Gets the y operand input component
  58182. */
  58183. readonly y: NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the output component
  58186. */
  58187. readonly output: NodeMaterialConnectionPoint;
  58188. protected _buildBlock(state: NodeMaterialBuildState): this;
  58189. }
  58190. }
  58191. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58192. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58193. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58194. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58195. /**
  58196. * Block used to smooth step a value
  58197. */
  58198. export class SmoothStepBlock extends NodeMaterialBlock {
  58199. /**
  58200. * Creates a new SmoothStepBlock
  58201. * @param name defines the block name
  58202. */
  58203. constructor(name: string);
  58204. /**
  58205. * Gets the current class name
  58206. * @returns the class name
  58207. */
  58208. getClassName(): string;
  58209. /**
  58210. * Gets the value operand input component
  58211. */
  58212. readonly value: NodeMaterialConnectionPoint;
  58213. /**
  58214. * Gets the first edge operand input component
  58215. */
  58216. readonly edge0: NodeMaterialConnectionPoint;
  58217. /**
  58218. * Gets the second edge operand input component
  58219. */
  58220. readonly edge1: NodeMaterialConnectionPoint;
  58221. /**
  58222. * Gets the output component
  58223. */
  58224. readonly output: NodeMaterialConnectionPoint;
  58225. protected _buildBlock(state: NodeMaterialBuildState): this;
  58226. }
  58227. }
  58228. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58232. /**
  58233. * Block used to get the reciprocal (1 / x) of a value
  58234. */
  58235. export class ReciprocalBlock extends NodeMaterialBlock {
  58236. /**
  58237. * Creates a new ReciprocalBlock
  58238. * @param name defines the block name
  58239. */
  58240. constructor(name: string);
  58241. /**
  58242. * Gets the current class name
  58243. * @returns the class name
  58244. */
  58245. getClassName(): string;
  58246. /**
  58247. * Gets the input component
  58248. */
  58249. readonly input: NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the output component
  58252. */
  58253. readonly output: NodeMaterialConnectionPoint;
  58254. protected _buildBlock(state: NodeMaterialBuildState): this;
  58255. }
  58256. }
  58257. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58261. /**
  58262. * Block used to replace a color by another one
  58263. */
  58264. export class ReplaceColorBlock extends NodeMaterialBlock {
  58265. /**
  58266. * Creates a new ReplaceColorBlock
  58267. * @param name defines the block name
  58268. */
  58269. constructor(name: string);
  58270. /**
  58271. * Gets the current class name
  58272. * @returns the class name
  58273. */
  58274. getClassName(): string;
  58275. /**
  58276. * Gets the value input component
  58277. */
  58278. readonly value: NodeMaterialConnectionPoint;
  58279. /**
  58280. * Gets the reference input component
  58281. */
  58282. readonly reference: NodeMaterialConnectionPoint;
  58283. /**
  58284. * Gets the distance input component
  58285. */
  58286. readonly distance: NodeMaterialConnectionPoint;
  58287. /**
  58288. * Gets the replacement input component
  58289. */
  58290. readonly replacement: NodeMaterialConnectionPoint;
  58291. /**
  58292. * Gets the output component
  58293. */
  58294. readonly output: NodeMaterialConnectionPoint;
  58295. protected _buildBlock(state: NodeMaterialBuildState): this;
  58296. }
  58297. }
  58298. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58300. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58301. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58302. /**
  58303. * Block used to posterize a value
  58304. * @see https://en.wikipedia.org/wiki/Posterization
  58305. */
  58306. export class PosterizeBlock extends NodeMaterialBlock {
  58307. /**
  58308. * Creates a new PosterizeBlock
  58309. * @param name defines the block name
  58310. */
  58311. constructor(name: string);
  58312. /**
  58313. * Gets the current class name
  58314. * @returns the class name
  58315. */
  58316. getClassName(): string;
  58317. /**
  58318. * Gets the value input component
  58319. */
  58320. readonly value: NodeMaterialConnectionPoint;
  58321. /**
  58322. * Gets the steps input component
  58323. */
  58324. readonly steps: NodeMaterialConnectionPoint;
  58325. /**
  58326. * Gets the output component
  58327. */
  58328. readonly output: NodeMaterialConnectionPoint;
  58329. protected _buildBlock(state: NodeMaterialBuildState): this;
  58330. }
  58331. }
  58332. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58336. import { Scene } from "babylonjs/scene";
  58337. /**
  58338. * Operations supported by the Wave block
  58339. */
  58340. export enum WaveBlockKind {
  58341. /** SawTooth */
  58342. SawTooth = 0,
  58343. /** Square */
  58344. Square = 1,
  58345. /** Triangle */
  58346. Triangle = 2
  58347. }
  58348. /**
  58349. * Block used to apply wave operation to floats
  58350. */
  58351. export class WaveBlock extends NodeMaterialBlock {
  58352. /**
  58353. * Gets or sets the kibnd of wave to be applied by the block
  58354. */
  58355. kind: WaveBlockKind;
  58356. /**
  58357. * Creates a new WaveBlock
  58358. * @param name defines the block name
  58359. */
  58360. constructor(name: string);
  58361. /**
  58362. * Gets the current class name
  58363. * @returns the class name
  58364. */
  58365. getClassName(): string;
  58366. /**
  58367. * Gets the input component
  58368. */
  58369. readonly input: NodeMaterialConnectionPoint;
  58370. /**
  58371. * Gets the output component
  58372. */
  58373. readonly output: NodeMaterialConnectionPoint;
  58374. protected _buildBlock(state: NodeMaterialBuildState): this;
  58375. serialize(): any;
  58376. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58377. }
  58378. }
  58379. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58383. import { Color3 } from "babylonjs/Maths/math.color";
  58384. import { Scene } from "babylonjs/scene";
  58385. /**
  58386. * Class used to store a color step for the GradientBlock
  58387. */
  58388. export class GradientBlockColorStep {
  58389. /**
  58390. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58391. */
  58392. step: number;
  58393. /**
  58394. * Gets or sets the color associated with this step
  58395. */
  58396. color: Color3;
  58397. /**
  58398. * Creates a new GradientBlockColorStep
  58399. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58400. * @param color defines the color associated with this step
  58401. */
  58402. constructor(
  58403. /**
  58404. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58405. */
  58406. step: number,
  58407. /**
  58408. * Gets or sets the color associated with this step
  58409. */
  58410. color: Color3);
  58411. }
  58412. /**
  58413. * Block used to return a color from a gradient based on an input value between 0 and 1
  58414. */
  58415. export class GradientBlock extends NodeMaterialBlock {
  58416. /**
  58417. * Gets or sets the list of color steps
  58418. */
  58419. colorSteps: GradientBlockColorStep[];
  58420. /**
  58421. * Creates a new GradientBlock
  58422. * @param name defines the block name
  58423. */
  58424. constructor(name: string);
  58425. /**
  58426. * Gets the current class name
  58427. * @returns the class name
  58428. */
  58429. getClassName(): string;
  58430. /**
  58431. * Gets the gradient input component
  58432. */
  58433. readonly gradient: NodeMaterialConnectionPoint;
  58434. /**
  58435. * Gets the output component
  58436. */
  58437. readonly output: NodeMaterialConnectionPoint;
  58438. private _writeColorConstant;
  58439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58440. serialize(): any;
  58441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58442. protected _dumpPropertiesCode(): string;
  58443. }
  58444. }
  58445. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58449. /**
  58450. * Block used to normalize lerp between 2 values
  58451. */
  58452. export class NLerpBlock extends NodeMaterialBlock {
  58453. /**
  58454. * Creates a new NLerpBlock
  58455. * @param name defines the block name
  58456. */
  58457. constructor(name: string);
  58458. /**
  58459. * Gets the current class name
  58460. * @returns the class name
  58461. */
  58462. getClassName(): string;
  58463. /**
  58464. * Gets the left operand input component
  58465. */
  58466. readonly left: NodeMaterialConnectionPoint;
  58467. /**
  58468. * Gets the right operand input component
  58469. */
  58470. readonly right: NodeMaterialConnectionPoint;
  58471. /**
  58472. * Gets the gradient operand input component
  58473. */
  58474. readonly gradient: NodeMaterialConnectionPoint;
  58475. /**
  58476. * Gets the output component
  58477. */
  58478. readonly output: NodeMaterialConnectionPoint;
  58479. protected _buildBlock(state: NodeMaterialBuildState): this;
  58480. }
  58481. }
  58482. declare module "babylonjs/Materials/Node/Blocks/frontFacingBlock" {
  58483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58486. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58487. /**
  58488. * Block used to test if the fragment shader is front facing
  58489. */
  58490. export class FrontFacingBlock extends NodeMaterialBlock {
  58491. /**
  58492. * Creates a new FrontFacingBlock
  58493. * @param name defines the block name
  58494. */
  58495. constructor(name: string);
  58496. /**
  58497. * Gets the current class name
  58498. * @returns the class name
  58499. */
  58500. getClassName(): string;
  58501. /**
  58502. * Gets the world normal component
  58503. */
  58504. readonly worldNormal: NodeMaterialConnectionPoint;
  58505. /**
  58506. * Gets the view direction input component
  58507. */
  58508. readonly viewDirection: NodeMaterialConnectionPoint;
  58509. /**
  58510. * Gets the output component
  58511. */
  58512. readonly output: NodeMaterialConnectionPoint;
  58513. autoConfigure(material: NodeMaterial): void;
  58514. protected _buildBlock(state: NodeMaterialBuildState): this;
  58515. }
  58516. }
  58517. declare module "babylonjs/Materials/Node/Blocks/index" {
  58518. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58519. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58520. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58521. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58522. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58523. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58524. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58525. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58526. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58527. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58528. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58529. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58530. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58531. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58532. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58533. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58534. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58535. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58536. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58537. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58538. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58539. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58540. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58541. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58542. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58543. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58544. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58545. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58546. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58547. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58548. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58549. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58550. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58551. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58552. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58553. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58554. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58555. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58556. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58557. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58558. export * from "babylonjs/Materials/Node/Blocks/frontFacingBlock";
  58559. }
  58560. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58561. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58562. }
  58563. declare module "babylonjs/Materials/Node/index" {
  58564. export * from "babylonjs/Materials/Node/Enums/index";
  58565. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58566. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58567. export * from "babylonjs/Materials/Node/nodeMaterial";
  58568. export * from "babylonjs/Materials/Node/Blocks/index";
  58569. export * from "babylonjs/Materials/Node/Optimizers/index";
  58570. }
  58571. declare module "babylonjs/Materials/effectRenderer" {
  58572. import { Nullable } from "babylonjs/types";
  58573. import { Texture } from "babylonjs/Materials/Textures/texture";
  58574. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58575. import { Viewport } from "babylonjs/Maths/math.viewport";
  58576. import { Observable } from "babylonjs/Misc/observable";
  58577. import { Effect } from "babylonjs/Materials/effect";
  58578. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58579. import "babylonjs/Shaders/postprocess.vertex";
  58580. /**
  58581. * Effect Render Options
  58582. */
  58583. export interface IEffectRendererOptions {
  58584. /**
  58585. * Defines the vertices positions.
  58586. */
  58587. positions?: number[];
  58588. /**
  58589. * Defines the indices.
  58590. */
  58591. indices?: number[];
  58592. }
  58593. /**
  58594. * Helper class to render one or more effects
  58595. */
  58596. export class EffectRenderer {
  58597. private engine;
  58598. private static _DefaultOptions;
  58599. private _vertexBuffers;
  58600. private _indexBuffer;
  58601. private _ringBufferIndex;
  58602. private _ringScreenBuffer;
  58603. private _fullscreenViewport;
  58604. private _getNextFrameBuffer;
  58605. /**
  58606. * Creates an effect renderer
  58607. * @param engine the engine to use for rendering
  58608. * @param options defines the options of the effect renderer
  58609. */
  58610. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58611. /**
  58612. * Sets the current viewport in normalized coordinates 0-1
  58613. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58614. */
  58615. setViewport(viewport?: Viewport): void;
  58616. /**
  58617. * Binds the embedded attributes buffer to the effect.
  58618. * @param effect Defines the effect to bind the attributes for
  58619. */
  58620. bindBuffers(effect: Effect): void;
  58621. /**
  58622. * Sets the current effect wrapper to use during draw.
  58623. * The effect needs to be ready before calling this api.
  58624. * This also sets the default full screen position attribute.
  58625. * @param effectWrapper Defines the effect to draw with
  58626. */
  58627. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58628. /**
  58629. * Draws a full screen quad.
  58630. */
  58631. draw(): void;
  58632. /**
  58633. * renders one or more effects to a specified texture
  58634. * @param effectWrappers list of effects to renderer
  58635. * @param outputTexture texture to draw to, if null it will render to the screen
  58636. */
  58637. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58638. /**
  58639. * Disposes of the effect renderer
  58640. */
  58641. dispose(): void;
  58642. }
  58643. /**
  58644. * Options to create an EffectWrapper
  58645. */
  58646. interface EffectWrapperCreationOptions {
  58647. /**
  58648. * Engine to use to create the effect
  58649. */
  58650. engine: ThinEngine;
  58651. /**
  58652. * Fragment shader for the effect
  58653. */
  58654. fragmentShader: string;
  58655. /**
  58656. * Vertex shader for the effect
  58657. */
  58658. vertexShader?: string;
  58659. /**
  58660. * Attributes to use in the shader
  58661. */
  58662. attributeNames?: Array<string>;
  58663. /**
  58664. * Uniforms to use in the shader
  58665. */
  58666. uniformNames?: Array<string>;
  58667. /**
  58668. * Texture sampler names to use in the shader
  58669. */
  58670. samplerNames?: Array<string>;
  58671. /**
  58672. * The friendly name of the effect displayed in Spector.
  58673. */
  58674. name?: string;
  58675. }
  58676. /**
  58677. * Wraps an effect to be used for rendering
  58678. */
  58679. export class EffectWrapper {
  58680. /**
  58681. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58682. */
  58683. onApplyObservable: Observable<{}>;
  58684. /**
  58685. * The underlying effect
  58686. */
  58687. effect: Effect;
  58688. /**
  58689. * Creates an effect to be renderer
  58690. * @param creationOptions options to create the effect
  58691. */
  58692. constructor(creationOptions: EffectWrapperCreationOptions);
  58693. /**
  58694. * Disposes of the effect wrapper
  58695. */
  58696. dispose(): void;
  58697. }
  58698. }
  58699. declare module "babylonjs/Materials/index" {
  58700. export * from "babylonjs/Materials/Background/index";
  58701. export * from "babylonjs/Materials/colorCurves";
  58702. export * from "babylonjs/Materials/iEffectFallbacks";
  58703. export * from "babylonjs/Materials/effectFallbacks";
  58704. export * from "babylonjs/Materials/effect";
  58705. export * from "babylonjs/Materials/fresnelParameters";
  58706. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58707. export * from "babylonjs/Materials/material";
  58708. export * from "babylonjs/Materials/materialDefines";
  58709. export * from "babylonjs/Materials/materialHelper";
  58710. export * from "babylonjs/Materials/multiMaterial";
  58711. export * from "babylonjs/Materials/PBR/index";
  58712. export * from "babylonjs/Materials/pushMaterial";
  58713. export * from "babylonjs/Materials/shaderMaterial";
  58714. export * from "babylonjs/Materials/standardMaterial";
  58715. export * from "babylonjs/Materials/Textures/index";
  58716. export * from "babylonjs/Materials/uniformBuffer";
  58717. export * from "babylonjs/Materials/materialFlags";
  58718. export * from "babylonjs/Materials/Node/index";
  58719. export * from "babylonjs/Materials/effectRenderer";
  58720. }
  58721. declare module "babylonjs/Maths/index" {
  58722. export * from "babylonjs/Maths/math.scalar";
  58723. export * from "babylonjs/Maths/math";
  58724. export * from "babylonjs/Maths/sphericalPolynomial";
  58725. }
  58726. declare module "babylonjs/Misc/workerPool" {
  58727. import { IDisposable } from "babylonjs/scene";
  58728. /**
  58729. * Helper class to push actions to a pool of workers.
  58730. */
  58731. export class WorkerPool implements IDisposable {
  58732. private _workerInfos;
  58733. private _pendingActions;
  58734. /**
  58735. * Constructor
  58736. * @param workers Array of workers to use for actions
  58737. */
  58738. constructor(workers: Array<Worker>);
  58739. /**
  58740. * Terminates all workers and clears any pending actions.
  58741. */
  58742. dispose(): void;
  58743. /**
  58744. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58745. * pended until a worker has completed its action.
  58746. * @param action The action to perform. Call onComplete when the action is complete.
  58747. */
  58748. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58749. private _execute;
  58750. }
  58751. }
  58752. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58753. import { IDisposable } from "babylonjs/scene";
  58754. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58755. /**
  58756. * Configuration for Draco compression
  58757. */
  58758. export interface IDracoCompressionConfiguration {
  58759. /**
  58760. * Configuration for the decoder.
  58761. */
  58762. decoder: {
  58763. /**
  58764. * The url to the WebAssembly module.
  58765. */
  58766. wasmUrl?: string;
  58767. /**
  58768. * The url to the WebAssembly binary.
  58769. */
  58770. wasmBinaryUrl?: string;
  58771. /**
  58772. * The url to the fallback JavaScript module.
  58773. */
  58774. fallbackUrl?: string;
  58775. };
  58776. }
  58777. /**
  58778. * Draco compression (https://google.github.io/draco/)
  58779. *
  58780. * This class wraps the Draco module.
  58781. *
  58782. * **Encoder**
  58783. *
  58784. * The encoder is not currently implemented.
  58785. *
  58786. * **Decoder**
  58787. *
  58788. * 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.
  58789. *
  58790. * To update the configuration, use the following code:
  58791. * ```javascript
  58792. * DracoCompression.Configuration = {
  58793. * decoder: {
  58794. * wasmUrl: "<url to the WebAssembly library>",
  58795. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58796. * fallbackUrl: "<url to the fallback JavaScript library>",
  58797. * }
  58798. * };
  58799. * ```
  58800. *
  58801. * 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.
  58802. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58803. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58804. *
  58805. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58806. * ```javascript
  58807. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58808. * ```
  58809. *
  58810. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58811. */
  58812. export class DracoCompression implements IDisposable {
  58813. private _workerPoolPromise?;
  58814. private _decoderModulePromise?;
  58815. /**
  58816. * The configuration. Defaults to the following urls:
  58817. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58818. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58819. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58820. */
  58821. static Configuration: IDracoCompressionConfiguration;
  58822. /**
  58823. * Returns true if the decoder configuration is available.
  58824. */
  58825. static readonly DecoderAvailable: boolean;
  58826. /**
  58827. * Default number of workers to create when creating the draco compression object.
  58828. */
  58829. static DefaultNumWorkers: number;
  58830. private static GetDefaultNumWorkers;
  58831. private static _Default;
  58832. /**
  58833. * Default instance for the draco compression object.
  58834. */
  58835. static readonly Default: DracoCompression;
  58836. /**
  58837. * Constructor
  58838. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58839. */
  58840. constructor(numWorkers?: number);
  58841. /**
  58842. * Stop all async operations and release resources.
  58843. */
  58844. dispose(): void;
  58845. /**
  58846. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58847. * @returns a promise that resolves when ready
  58848. */
  58849. whenReadyAsync(): Promise<void>;
  58850. /**
  58851. * Decode Draco compressed mesh data to vertex data.
  58852. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58853. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58854. * @returns A promise that resolves with the decoded vertex data
  58855. */
  58856. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58857. [kind: string]: number;
  58858. }): Promise<VertexData>;
  58859. }
  58860. }
  58861. declare module "babylonjs/Meshes/Compression/index" {
  58862. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58863. }
  58864. declare module "babylonjs/Meshes/csg" {
  58865. import { Nullable } from "babylonjs/types";
  58866. import { Scene } from "babylonjs/scene";
  58867. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58868. import { Mesh } from "babylonjs/Meshes/mesh";
  58869. import { Material } from "babylonjs/Materials/material";
  58870. /**
  58871. * Class for building Constructive Solid Geometry
  58872. */
  58873. export class CSG {
  58874. private polygons;
  58875. /**
  58876. * The world matrix
  58877. */
  58878. matrix: Matrix;
  58879. /**
  58880. * Stores the position
  58881. */
  58882. position: Vector3;
  58883. /**
  58884. * Stores the rotation
  58885. */
  58886. rotation: Vector3;
  58887. /**
  58888. * Stores the rotation quaternion
  58889. */
  58890. rotationQuaternion: Nullable<Quaternion>;
  58891. /**
  58892. * Stores the scaling vector
  58893. */
  58894. scaling: Vector3;
  58895. /**
  58896. * Convert the Mesh to CSG
  58897. * @param mesh The Mesh to convert to CSG
  58898. * @returns A new CSG from the Mesh
  58899. */
  58900. static FromMesh(mesh: Mesh): CSG;
  58901. /**
  58902. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58903. * @param polygons Polygons used to construct a CSG solid
  58904. */
  58905. private static FromPolygons;
  58906. /**
  58907. * Clones, or makes a deep copy, of the CSG
  58908. * @returns A new CSG
  58909. */
  58910. clone(): CSG;
  58911. /**
  58912. * Unions this CSG with another CSG
  58913. * @param csg The CSG to union against this CSG
  58914. * @returns The unioned CSG
  58915. */
  58916. union(csg: CSG): CSG;
  58917. /**
  58918. * Unions this CSG with another CSG in place
  58919. * @param csg The CSG to union against this CSG
  58920. */
  58921. unionInPlace(csg: CSG): void;
  58922. /**
  58923. * Subtracts this CSG with another CSG
  58924. * @param csg The CSG to subtract against this CSG
  58925. * @returns A new CSG
  58926. */
  58927. subtract(csg: CSG): CSG;
  58928. /**
  58929. * Subtracts this CSG with another CSG in place
  58930. * @param csg The CSG to subtact against this CSG
  58931. */
  58932. subtractInPlace(csg: CSG): void;
  58933. /**
  58934. * Intersect this CSG with another CSG
  58935. * @param csg The CSG to intersect against this CSG
  58936. * @returns A new CSG
  58937. */
  58938. intersect(csg: CSG): CSG;
  58939. /**
  58940. * Intersects this CSG with another CSG in place
  58941. * @param csg The CSG to intersect against this CSG
  58942. */
  58943. intersectInPlace(csg: CSG): void;
  58944. /**
  58945. * Return a new CSG solid with solid and empty space switched. This solid is
  58946. * not modified.
  58947. * @returns A new CSG solid with solid and empty space switched
  58948. */
  58949. inverse(): CSG;
  58950. /**
  58951. * Inverses the CSG in place
  58952. */
  58953. inverseInPlace(): void;
  58954. /**
  58955. * This is used to keep meshes transformations so they can be restored
  58956. * when we build back a Babylon Mesh
  58957. * NB : All CSG operations are performed in world coordinates
  58958. * @param csg The CSG to copy the transform attributes from
  58959. * @returns This CSG
  58960. */
  58961. copyTransformAttributes(csg: CSG): CSG;
  58962. /**
  58963. * Build Raw mesh from CSG
  58964. * Coordinates here are in world space
  58965. * @param name The name of the mesh geometry
  58966. * @param scene The Scene
  58967. * @param keepSubMeshes Specifies if the submeshes should be kept
  58968. * @returns A new Mesh
  58969. */
  58970. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58971. /**
  58972. * Build Mesh from CSG taking material and transforms into account
  58973. * @param name The name of the Mesh
  58974. * @param material The material of the Mesh
  58975. * @param scene The Scene
  58976. * @param keepSubMeshes Specifies if submeshes should be kept
  58977. * @returns The new Mesh
  58978. */
  58979. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58980. }
  58981. }
  58982. declare module "babylonjs/Meshes/trailMesh" {
  58983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58984. import { Mesh } from "babylonjs/Meshes/mesh";
  58985. import { Scene } from "babylonjs/scene";
  58986. /**
  58987. * Class used to create a trail following a mesh
  58988. */
  58989. export class TrailMesh extends Mesh {
  58990. private _generator;
  58991. private _autoStart;
  58992. private _running;
  58993. private _diameter;
  58994. private _length;
  58995. private _sectionPolygonPointsCount;
  58996. private _sectionVectors;
  58997. private _sectionNormalVectors;
  58998. private _beforeRenderObserver;
  58999. /**
  59000. * @constructor
  59001. * @param name The value used by scene.getMeshByName() to do a lookup.
  59002. * @param generator The mesh to generate a trail.
  59003. * @param scene The scene to add this mesh to.
  59004. * @param diameter Diameter of trailing mesh. Default is 1.
  59005. * @param length Length of trailing mesh. Default is 60.
  59006. * @param autoStart Automatically start trailing mesh. Default true.
  59007. */
  59008. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59009. /**
  59010. * "TrailMesh"
  59011. * @returns "TrailMesh"
  59012. */
  59013. getClassName(): string;
  59014. private _createMesh;
  59015. /**
  59016. * Start trailing mesh.
  59017. */
  59018. start(): void;
  59019. /**
  59020. * Stop trailing mesh.
  59021. */
  59022. stop(): void;
  59023. /**
  59024. * Update trailing mesh geometry.
  59025. */
  59026. update(): void;
  59027. /**
  59028. * Returns a new TrailMesh object.
  59029. * @param name is a string, the name given to the new mesh
  59030. * @param newGenerator use new generator object for cloned trail mesh
  59031. * @returns a new mesh
  59032. */
  59033. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59034. /**
  59035. * Serializes this trail mesh
  59036. * @param serializationObject object to write serialization to
  59037. */
  59038. serialize(serializationObject: any): void;
  59039. /**
  59040. * Parses a serialized trail mesh
  59041. * @param parsedMesh the serialized mesh
  59042. * @param scene the scene to create the trail mesh in
  59043. * @returns the created trail mesh
  59044. */
  59045. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59046. }
  59047. }
  59048. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59049. import { Nullable } from "babylonjs/types";
  59050. import { Scene } from "babylonjs/scene";
  59051. import { Vector4 } from "babylonjs/Maths/math.vector";
  59052. import { Color4 } from "babylonjs/Maths/math.color";
  59053. import { Mesh } from "babylonjs/Meshes/mesh";
  59054. /**
  59055. * Class containing static functions to help procedurally build meshes
  59056. */
  59057. export class TiledBoxBuilder {
  59058. /**
  59059. * Creates a box mesh
  59060. * 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)
  59061. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59065. * @param name defines the name of the mesh
  59066. * @param options defines the options used to create the mesh
  59067. * @param scene defines the hosting scene
  59068. * @returns the box mesh
  59069. */
  59070. static CreateTiledBox(name: string, options: {
  59071. pattern?: number;
  59072. width?: number;
  59073. height?: number;
  59074. depth?: number;
  59075. tileSize?: number;
  59076. tileWidth?: number;
  59077. tileHeight?: number;
  59078. alignHorizontal?: number;
  59079. alignVertical?: number;
  59080. faceUV?: Vector4[];
  59081. faceColors?: Color4[];
  59082. sideOrientation?: number;
  59083. updatable?: boolean;
  59084. }, scene?: Nullable<Scene>): Mesh;
  59085. }
  59086. }
  59087. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59088. import { Vector4 } from "babylonjs/Maths/math.vector";
  59089. import { Mesh } from "babylonjs/Meshes/mesh";
  59090. /**
  59091. * Class containing static functions to help procedurally build meshes
  59092. */
  59093. export class TorusKnotBuilder {
  59094. /**
  59095. * Creates a torus knot mesh
  59096. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59097. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59098. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59099. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59103. * @param name defines the name of the mesh
  59104. * @param options defines the options used to create the mesh
  59105. * @param scene defines the hosting scene
  59106. * @returns the torus knot mesh
  59107. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59108. */
  59109. static CreateTorusKnot(name: string, options: {
  59110. radius?: number;
  59111. tube?: number;
  59112. radialSegments?: number;
  59113. tubularSegments?: number;
  59114. p?: number;
  59115. q?: number;
  59116. updatable?: boolean;
  59117. sideOrientation?: number;
  59118. frontUVs?: Vector4;
  59119. backUVs?: Vector4;
  59120. }, scene: any): Mesh;
  59121. }
  59122. }
  59123. declare module "babylonjs/Meshes/polygonMesh" {
  59124. import { Scene } from "babylonjs/scene";
  59125. import { Vector2 } from "babylonjs/Maths/math.vector";
  59126. import { Mesh } from "babylonjs/Meshes/mesh";
  59127. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59128. import { Path2 } from "babylonjs/Maths/math.path";
  59129. /**
  59130. * Polygon
  59131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59132. */
  59133. export class Polygon {
  59134. /**
  59135. * Creates a rectangle
  59136. * @param xmin bottom X coord
  59137. * @param ymin bottom Y coord
  59138. * @param xmax top X coord
  59139. * @param ymax top Y coord
  59140. * @returns points that make the resulting rectation
  59141. */
  59142. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59143. /**
  59144. * Creates a circle
  59145. * @param radius radius of circle
  59146. * @param cx scale in x
  59147. * @param cy scale in y
  59148. * @param numberOfSides number of sides that make up the circle
  59149. * @returns points that make the resulting circle
  59150. */
  59151. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59152. /**
  59153. * Creates a polygon from input string
  59154. * @param input Input polygon data
  59155. * @returns the parsed points
  59156. */
  59157. static Parse(input: string): Vector2[];
  59158. /**
  59159. * Starts building a polygon from x and y coordinates
  59160. * @param x x coordinate
  59161. * @param y y coordinate
  59162. * @returns the started path2
  59163. */
  59164. static StartingAt(x: number, y: number): Path2;
  59165. }
  59166. /**
  59167. * Builds a polygon
  59168. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59169. */
  59170. export class PolygonMeshBuilder {
  59171. private _points;
  59172. private _outlinepoints;
  59173. private _holes;
  59174. private _name;
  59175. private _scene;
  59176. private _epoints;
  59177. private _eholes;
  59178. private _addToepoint;
  59179. /**
  59180. * Babylon reference to the earcut plugin.
  59181. */
  59182. bjsEarcut: any;
  59183. /**
  59184. * Creates a PolygonMeshBuilder
  59185. * @param name name of the builder
  59186. * @param contours Path of the polygon
  59187. * @param scene scene to add to when creating the mesh
  59188. * @param earcutInjection can be used to inject your own earcut reference
  59189. */
  59190. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59191. /**
  59192. * Adds a whole within the polygon
  59193. * @param hole Array of points defining the hole
  59194. * @returns this
  59195. */
  59196. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59197. /**
  59198. * Creates the polygon
  59199. * @param updatable If the mesh should be updatable
  59200. * @param depth The depth of the mesh created
  59201. * @returns the created mesh
  59202. */
  59203. build(updatable?: boolean, depth?: number): Mesh;
  59204. /**
  59205. * Creates the polygon
  59206. * @param depth The depth of the mesh created
  59207. * @returns the created VertexData
  59208. */
  59209. buildVertexData(depth?: number): VertexData;
  59210. /**
  59211. * Adds a side to the polygon
  59212. * @param positions points that make the polygon
  59213. * @param normals normals of the polygon
  59214. * @param uvs uvs of the polygon
  59215. * @param indices indices of the polygon
  59216. * @param bounds bounds of the polygon
  59217. * @param points points of the polygon
  59218. * @param depth depth of the polygon
  59219. * @param flip flip of the polygon
  59220. */
  59221. private addSide;
  59222. }
  59223. }
  59224. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59225. import { Scene } from "babylonjs/scene";
  59226. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59227. import { Color4 } from "babylonjs/Maths/math.color";
  59228. import { Mesh } from "babylonjs/Meshes/mesh";
  59229. import { Nullable } from "babylonjs/types";
  59230. /**
  59231. * Class containing static functions to help procedurally build meshes
  59232. */
  59233. export class PolygonBuilder {
  59234. /**
  59235. * Creates a polygon mesh
  59236. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59237. * * 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
  59238. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59241. * * Remember you can only change the shape positions, not their number when updating a polygon
  59242. * @param name defines the name of the mesh
  59243. * @param options defines the options used to create the mesh
  59244. * @param scene defines the hosting scene
  59245. * @param earcutInjection can be used to inject your own earcut reference
  59246. * @returns the polygon mesh
  59247. */
  59248. static CreatePolygon(name: string, options: {
  59249. shape: Vector3[];
  59250. holes?: Vector3[][];
  59251. depth?: number;
  59252. faceUV?: Vector4[];
  59253. faceColors?: Color4[];
  59254. updatable?: boolean;
  59255. sideOrientation?: number;
  59256. frontUVs?: Vector4;
  59257. backUVs?: Vector4;
  59258. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59259. /**
  59260. * Creates an extruded polygon mesh, with depth in the Y direction.
  59261. * * 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)
  59262. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59263. * @param name defines the name of the mesh
  59264. * @param options defines the options used to create the mesh
  59265. * @param scene defines the hosting scene
  59266. * @param earcutInjection can be used to inject your own earcut reference
  59267. * @returns the polygon mesh
  59268. */
  59269. static ExtrudePolygon(name: string, options: {
  59270. shape: Vector3[];
  59271. holes?: Vector3[][];
  59272. depth?: number;
  59273. faceUV?: Vector4[];
  59274. faceColors?: Color4[];
  59275. updatable?: boolean;
  59276. sideOrientation?: number;
  59277. frontUVs?: Vector4;
  59278. backUVs?: Vector4;
  59279. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59280. }
  59281. }
  59282. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59283. import { Scene } from "babylonjs/scene";
  59284. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59285. import { Mesh } from "babylonjs/Meshes/mesh";
  59286. import { Nullable } from "babylonjs/types";
  59287. /**
  59288. * Class containing static functions to help procedurally build meshes
  59289. */
  59290. export class LatheBuilder {
  59291. /**
  59292. * Creates lathe mesh.
  59293. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59294. * * 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
  59295. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59296. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59297. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59298. * * 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
  59299. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59300. * * 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
  59301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59303. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59305. * @param name defines the name of the mesh
  59306. * @param options defines the options used to create the mesh
  59307. * @param scene defines the hosting scene
  59308. * @returns the lathe mesh
  59309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59310. */
  59311. static CreateLathe(name: string, options: {
  59312. shape: Vector3[];
  59313. radius?: number;
  59314. tessellation?: number;
  59315. clip?: number;
  59316. arc?: number;
  59317. closed?: boolean;
  59318. updatable?: boolean;
  59319. sideOrientation?: number;
  59320. frontUVs?: Vector4;
  59321. backUVs?: Vector4;
  59322. cap?: number;
  59323. invertUV?: boolean;
  59324. }, scene?: Nullable<Scene>): Mesh;
  59325. }
  59326. }
  59327. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59328. import { Nullable } from "babylonjs/types";
  59329. import { Scene } from "babylonjs/scene";
  59330. import { Vector4 } from "babylonjs/Maths/math.vector";
  59331. import { Mesh } from "babylonjs/Meshes/mesh";
  59332. /**
  59333. * Class containing static functions to help procedurally build meshes
  59334. */
  59335. export class TiledPlaneBuilder {
  59336. /**
  59337. * Creates a tiled plane mesh
  59338. * * The parameter `pattern` will, depending on value, do nothing or
  59339. * * * flip (reflect about central vertical) alternate tiles across and up
  59340. * * * flip every tile on alternate rows
  59341. * * * rotate (180 degs) alternate tiles across and up
  59342. * * * rotate every tile on alternate rows
  59343. * * * flip and rotate alternate tiles across and up
  59344. * * * flip and rotate every tile on alternate rows
  59345. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59346. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59349. * * 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)
  59350. * * 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)
  59351. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59352. * @param name defines the name of the mesh
  59353. * @param options defines the options used to create the mesh
  59354. * @param scene defines the hosting scene
  59355. * @returns the box mesh
  59356. */
  59357. static CreateTiledPlane(name: string, options: {
  59358. pattern?: number;
  59359. tileSize?: number;
  59360. tileWidth?: number;
  59361. tileHeight?: number;
  59362. size?: number;
  59363. width?: number;
  59364. height?: number;
  59365. alignHorizontal?: number;
  59366. alignVertical?: number;
  59367. sideOrientation?: number;
  59368. frontUVs?: Vector4;
  59369. backUVs?: Vector4;
  59370. updatable?: boolean;
  59371. }, scene?: Nullable<Scene>): Mesh;
  59372. }
  59373. }
  59374. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59375. import { Nullable } from "babylonjs/types";
  59376. import { Scene } from "babylonjs/scene";
  59377. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59378. import { Mesh } from "babylonjs/Meshes/mesh";
  59379. /**
  59380. * Class containing static functions to help procedurally build meshes
  59381. */
  59382. export class TubeBuilder {
  59383. /**
  59384. * Creates a tube mesh.
  59385. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59386. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59387. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59388. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59389. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59390. * * 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)
  59391. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59392. * * 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
  59393. * * 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
  59394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59398. * @param name defines the name of the mesh
  59399. * @param options defines the options used to create the mesh
  59400. * @param scene defines the hosting scene
  59401. * @returns the tube mesh
  59402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59403. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59404. */
  59405. static CreateTube(name: string, options: {
  59406. path: Vector3[];
  59407. radius?: number;
  59408. tessellation?: number;
  59409. radiusFunction?: {
  59410. (i: number, distance: number): number;
  59411. };
  59412. cap?: number;
  59413. arc?: number;
  59414. updatable?: boolean;
  59415. sideOrientation?: number;
  59416. frontUVs?: Vector4;
  59417. backUVs?: Vector4;
  59418. instance?: Mesh;
  59419. invertUV?: boolean;
  59420. }, scene?: Nullable<Scene>): Mesh;
  59421. }
  59422. }
  59423. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59424. import { Scene } from "babylonjs/scene";
  59425. import { Vector4 } from "babylonjs/Maths/math.vector";
  59426. import { Mesh } from "babylonjs/Meshes/mesh";
  59427. import { Nullable } from "babylonjs/types";
  59428. /**
  59429. * Class containing static functions to help procedurally build meshes
  59430. */
  59431. export class IcoSphereBuilder {
  59432. /**
  59433. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59434. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59435. * * 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`)
  59436. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59437. * * 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
  59438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59441. * @param name defines the name of the mesh
  59442. * @param options defines the options used to create the mesh
  59443. * @param scene defines the hosting scene
  59444. * @returns the icosahedron mesh
  59445. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59446. */
  59447. static CreateIcoSphere(name: string, options: {
  59448. radius?: number;
  59449. radiusX?: number;
  59450. radiusY?: number;
  59451. radiusZ?: number;
  59452. flat?: boolean;
  59453. subdivisions?: number;
  59454. sideOrientation?: number;
  59455. frontUVs?: Vector4;
  59456. backUVs?: Vector4;
  59457. updatable?: boolean;
  59458. }, scene?: Nullable<Scene>): Mesh;
  59459. }
  59460. }
  59461. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59462. import { Vector3 } from "babylonjs/Maths/math.vector";
  59463. import { Mesh } from "babylonjs/Meshes/mesh";
  59464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59465. /**
  59466. * Class containing static functions to help procedurally build meshes
  59467. */
  59468. export class DecalBuilder {
  59469. /**
  59470. * Creates a decal mesh.
  59471. * 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
  59472. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59473. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59474. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59475. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59476. * @param name defines the name of the mesh
  59477. * @param sourceMesh defines the mesh where the decal must be applied
  59478. * @param options defines the options used to create the mesh
  59479. * @param scene defines the hosting scene
  59480. * @returns the decal mesh
  59481. * @see https://doc.babylonjs.com/how_to/decals
  59482. */
  59483. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59484. position?: Vector3;
  59485. normal?: Vector3;
  59486. size?: Vector3;
  59487. angle?: number;
  59488. }): Mesh;
  59489. }
  59490. }
  59491. declare module "babylonjs/Meshes/meshBuilder" {
  59492. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59493. import { Nullable } from "babylonjs/types";
  59494. import { Scene } from "babylonjs/scene";
  59495. import { Mesh } from "babylonjs/Meshes/mesh";
  59496. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59497. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59499. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59500. import { Plane } from "babylonjs/Maths/math.plane";
  59501. /**
  59502. * Class containing static functions to help procedurally build meshes
  59503. */
  59504. export class MeshBuilder {
  59505. /**
  59506. * Creates a box mesh
  59507. * * The parameter `size` sets the size (float) of each box side (default 1)
  59508. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59509. * * 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)
  59510. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59514. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59515. * @param name defines the name of the mesh
  59516. * @param options defines the options used to create the mesh
  59517. * @param scene defines the hosting scene
  59518. * @returns the box mesh
  59519. */
  59520. static CreateBox(name: string, options: {
  59521. size?: number;
  59522. width?: number;
  59523. height?: number;
  59524. depth?: number;
  59525. faceUV?: Vector4[];
  59526. faceColors?: Color4[];
  59527. sideOrientation?: number;
  59528. frontUVs?: Vector4;
  59529. backUVs?: Vector4;
  59530. updatable?: boolean;
  59531. }, scene?: Nullable<Scene>): Mesh;
  59532. /**
  59533. * Creates a tiled box mesh
  59534. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59536. * @param name defines the name of the mesh
  59537. * @param options defines the options used to create the mesh
  59538. * @param scene defines the hosting scene
  59539. * @returns the tiled box mesh
  59540. */
  59541. static CreateTiledBox(name: string, options: {
  59542. pattern?: number;
  59543. size?: number;
  59544. width?: number;
  59545. height?: number;
  59546. depth: number;
  59547. tileSize?: number;
  59548. tileWidth?: number;
  59549. tileHeight?: number;
  59550. faceUV?: Vector4[];
  59551. faceColors?: Color4[];
  59552. alignHorizontal?: number;
  59553. alignVertical?: number;
  59554. sideOrientation?: number;
  59555. updatable?: boolean;
  59556. }, scene?: Nullable<Scene>): Mesh;
  59557. /**
  59558. * Creates a sphere mesh
  59559. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59560. * * 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`)
  59561. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59562. * * 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
  59563. * * 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)
  59564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59567. * @param name defines the name of the mesh
  59568. * @param options defines the options used to create the mesh
  59569. * @param scene defines the hosting scene
  59570. * @returns the sphere mesh
  59571. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59572. */
  59573. static CreateSphere(name: string, options: {
  59574. segments?: number;
  59575. diameter?: number;
  59576. diameterX?: number;
  59577. diameterY?: number;
  59578. diameterZ?: number;
  59579. arc?: number;
  59580. slice?: number;
  59581. sideOrientation?: number;
  59582. frontUVs?: Vector4;
  59583. backUVs?: Vector4;
  59584. updatable?: boolean;
  59585. }, scene?: Nullable<Scene>): Mesh;
  59586. /**
  59587. * Creates a plane polygonal mesh. By default, this is a disc
  59588. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59589. * * 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
  59590. * * 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
  59591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59594. * @param name defines the name of the mesh
  59595. * @param options defines the options used to create the mesh
  59596. * @param scene defines the hosting scene
  59597. * @returns the plane polygonal mesh
  59598. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59599. */
  59600. static CreateDisc(name: string, options: {
  59601. radius?: number;
  59602. tessellation?: number;
  59603. arc?: number;
  59604. updatable?: boolean;
  59605. sideOrientation?: number;
  59606. frontUVs?: Vector4;
  59607. backUVs?: Vector4;
  59608. }, scene?: Nullable<Scene>): Mesh;
  59609. /**
  59610. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59611. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59612. * * 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`)
  59613. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59614. * * 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
  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 icosahedron mesh
  59622. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59623. */
  59624. static CreateIcoSphere(name: string, options: {
  59625. radius?: number;
  59626. radiusX?: number;
  59627. radiusY?: number;
  59628. radiusZ?: number;
  59629. flat?: boolean;
  59630. subdivisions?: number;
  59631. sideOrientation?: number;
  59632. frontUVs?: Vector4;
  59633. backUVs?: Vector4;
  59634. updatable?: boolean;
  59635. }, scene?: Nullable<Scene>): Mesh;
  59636. /**
  59637. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59638. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59639. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59640. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59641. * * 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
  59642. * * 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
  59643. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59647. * * 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
  59648. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59649. * * 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
  59650. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59652. * @param name defines the name of the mesh
  59653. * @param options defines the options used to create the mesh
  59654. * @param scene defines the hosting scene
  59655. * @returns the ribbon mesh
  59656. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59657. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59658. */
  59659. static CreateRibbon(name: string, options: {
  59660. pathArray: Vector3[][];
  59661. closeArray?: boolean;
  59662. closePath?: boolean;
  59663. offset?: number;
  59664. updatable?: boolean;
  59665. sideOrientation?: number;
  59666. frontUVs?: Vector4;
  59667. backUVs?: Vector4;
  59668. instance?: Mesh;
  59669. invertUV?: boolean;
  59670. uvs?: Vector2[];
  59671. colors?: Color4[];
  59672. }, scene?: Nullable<Scene>): Mesh;
  59673. /**
  59674. * Creates a cylinder or a cone mesh
  59675. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59676. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59677. * * 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.
  59678. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59679. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59680. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59681. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59682. * * 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).
  59683. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59684. * * 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).
  59685. * * 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
  59686. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59687. * * 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
  59688. * * 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.
  59689. * * If `enclose` is false, a ring surface is one element.
  59690. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59691. * * 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
  59692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59695. * @param name defines the name of the mesh
  59696. * @param options defines the options used to create the mesh
  59697. * @param scene defines the hosting scene
  59698. * @returns the cylinder mesh
  59699. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59700. */
  59701. static CreateCylinder(name: string, options: {
  59702. height?: number;
  59703. diameterTop?: number;
  59704. diameterBottom?: number;
  59705. diameter?: number;
  59706. tessellation?: number;
  59707. subdivisions?: number;
  59708. arc?: number;
  59709. faceColors?: Color4[];
  59710. faceUV?: Vector4[];
  59711. updatable?: boolean;
  59712. hasRings?: boolean;
  59713. enclose?: boolean;
  59714. cap?: number;
  59715. sideOrientation?: number;
  59716. frontUVs?: Vector4;
  59717. backUVs?: Vector4;
  59718. }, scene?: Nullable<Scene>): Mesh;
  59719. /**
  59720. * Creates a torus mesh
  59721. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59722. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59723. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59727. * @param name defines the name of the mesh
  59728. * @param options defines the options used to create the mesh
  59729. * @param scene defines the hosting scene
  59730. * @returns the torus mesh
  59731. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59732. */
  59733. static CreateTorus(name: string, options: {
  59734. diameter?: number;
  59735. thickness?: number;
  59736. tessellation?: number;
  59737. updatable?: boolean;
  59738. sideOrientation?: number;
  59739. frontUVs?: Vector4;
  59740. backUVs?: Vector4;
  59741. }, scene?: Nullable<Scene>): Mesh;
  59742. /**
  59743. * Creates a torus knot mesh
  59744. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59745. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59746. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59747. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59751. * @param name defines the name of the mesh
  59752. * @param options defines the options used to create the mesh
  59753. * @param scene defines the hosting scene
  59754. * @returns the torus knot mesh
  59755. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59756. */
  59757. static CreateTorusKnot(name: string, options: {
  59758. radius?: number;
  59759. tube?: number;
  59760. radialSegments?: number;
  59761. tubularSegments?: number;
  59762. p?: number;
  59763. q?: number;
  59764. updatable?: boolean;
  59765. sideOrientation?: number;
  59766. frontUVs?: Vector4;
  59767. backUVs?: Vector4;
  59768. }, scene?: Nullable<Scene>): Mesh;
  59769. /**
  59770. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59771. * * 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
  59772. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59773. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59774. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59775. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59776. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59777. * * 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
  59778. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59781. * @param name defines the name of the new line system
  59782. * @param options defines the options used to create the line system
  59783. * @param scene defines the hosting scene
  59784. * @returns a new line system mesh
  59785. */
  59786. static CreateLineSystem(name: string, options: {
  59787. lines: Vector3[][];
  59788. updatable?: boolean;
  59789. instance?: Nullable<LinesMesh>;
  59790. colors?: Nullable<Color4[][]>;
  59791. useVertexAlpha?: boolean;
  59792. }, scene: Nullable<Scene>): LinesMesh;
  59793. /**
  59794. * Creates a line mesh
  59795. * 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
  59796. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59797. * * The parameter `points` is an array successive Vector3
  59798. * * 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
  59799. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59800. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59801. * * When updating an instance, remember that only point positions can change, not the number of points
  59802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59803. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59804. * @param name defines the name of the new line system
  59805. * @param options defines the options used to create the line system
  59806. * @param scene defines the hosting scene
  59807. * @returns a new line mesh
  59808. */
  59809. static CreateLines(name: string, options: {
  59810. points: Vector3[];
  59811. updatable?: boolean;
  59812. instance?: Nullable<LinesMesh>;
  59813. colors?: Color4[];
  59814. useVertexAlpha?: boolean;
  59815. }, scene?: Nullable<Scene>): LinesMesh;
  59816. /**
  59817. * Creates a dashed line mesh
  59818. * * 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
  59819. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59820. * * The parameter `points` is an array successive Vector3
  59821. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59822. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59823. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59824. * * 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
  59825. * * When updating an instance, remember that only point positions can change, not the number of points
  59826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59827. * @param name defines the name of the mesh
  59828. * @param options defines the options used to create the mesh
  59829. * @param scene defines the hosting scene
  59830. * @returns the dashed line mesh
  59831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59832. */
  59833. static CreateDashedLines(name: string, options: {
  59834. points: Vector3[];
  59835. dashSize?: number;
  59836. gapSize?: number;
  59837. dashNb?: number;
  59838. updatable?: boolean;
  59839. instance?: LinesMesh;
  59840. }, scene?: Nullable<Scene>): LinesMesh;
  59841. /**
  59842. * 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.
  59843. * * 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.
  59844. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59845. * * 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.
  59846. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59847. * * 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
  59848. * * 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
  59849. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59854. * @param name defines the name of the mesh
  59855. * @param options defines the options used to create the mesh
  59856. * @param scene defines the hosting scene
  59857. * @returns the extruded shape mesh
  59858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59860. */
  59861. static ExtrudeShape(name: string, options: {
  59862. shape: Vector3[];
  59863. path: Vector3[];
  59864. scale?: number;
  59865. rotation?: number;
  59866. cap?: number;
  59867. updatable?: boolean;
  59868. sideOrientation?: number;
  59869. frontUVs?: Vector4;
  59870. backUVs?: Vector4;
  59871. instance?: Mesh;
  59872. invertUV?: boolean;
  59873. }, scene?: Nullable<Scene>): Mesh;
  59874. /**
  59875. * Creates an custom extruded shape mesh.
  59876. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59877. * * 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.
  59878. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59879. * * 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
  59880. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59881. * * 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
  59882. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59883. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59884. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59885. * * 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
  59886. * * 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
  59887. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59892. * @param name defines the name of the mesh
  59893. * @param options defines the options used to create the mesh
  59894. * @param scene defines the hosting scene
  59895. * @returns the custom extruded shape mesh
  59896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59897. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59899. */
  59900. static ExtrudeShapeCustom(name: string, options: {
  59901. shape: Vector3[];
  59902. path: Vector3[];
  59903. scaleFunction?: any;
  59904. rotationFunction?: any;
  59905. ribbonCloseArray?: boolean;
  59906. ribbonClosePath?: boolean;
  59907. cap?: number;
  59908. updatable?: boolean;
  59909. sideOrientation?: number;
  59910. frontUVs?: Vector4;
  59911. backUVs?: Vector4;
  59912. instance?: Mesh;
  59913. invertUV?: boolean;
  59914. }, scene?: Nullable<Scene>): Mesh;
  59915. /**
  59916. * Creates lathe mesh.
  59917. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59918. * * 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
  59919. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59920. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59921. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59922. * * 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
  59923. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59924. * * 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
  59925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59927. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59929. * @param name defines the name of the mesh
  59930. * @param options defines the options used to create the mesh
  59931. * @param scene defines the hosting scene
  59932. * @returns the lathe mesh
  59933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59934. */
  59935. static CreateLathe(name: string, options: {
  59936. shape: Vector3[];
  59937. radius?: number;
  59938. tessellation?: number;
  59939. clip?: number;
  59940. arc?: number;
  59941. closed?: boolean;
  59942. updatable?: boolean;
  59943. sideOrientation?: number;
  59944. frontUVs?: Vector4;
  59945. backUVs?: Vector4;
  59946. cap?: number;
  59947. invertUV?: boolean;
  59948. }, scene?: Nullable<Scene>): Mesh;
  59949. /**
  59950. * Creates a tiled plane mesh
  59951. * * You can set a limited pattern arrangement with the tiles
  59952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59955. * @param name defines the name of the mesh
  59956. * @param options defines the options used to create the mesh
  59957. * @param scene defines the hosting scene
  59958. * @returns the plane mesh
  59959. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59960. */
  59961. static CreateTiledPlane(name: string, options: {
  59962. pattern?: number;
  59963. tileSize?: number;
  59964. tileWidth?: number;
  59965. tileHeight?: number;
  59966. size?: number;
  59967. width?: number;
  59968. height?: number;
  59969. alignHorizontal?: number;
  59970. alignVertical?: number;
  59971. sideOrientation?: number;
  59972. frontUVs?: Vector4;
  59973. backUVs?: Vector4;
  59974. updatable?: boolean;
  59975. }, scene?: Nullable<Scene>): Mesh;
  59976. /**
  59977. * Creates a plane mesh
  59978. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59979. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59980. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59984. * @param name defines the name of the mesh
  59985. * @param options defines the options used to create the mesh
  59986. * @param scene defines the hosting scene
  59987. * @returns the plane mesh
  59988. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59989. */
  59990. static CreatePlane(name: string, options: {
  59991. size?: number;
  59992. width?: number;
  59993. height?: number;
  59994. sideOrientation?: number;
  59995. frontUVs?: Vector4;
  59996. backUVs?: Vector4;
  59997. updatable?: boolean;
  59998. sourcePlane?: Plane;
  59999. }, scene?: Nullable<Scene>): Mesh;
  60000. /**
  60001. * Creates a ground mesh
  60002. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60003. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60005. * @param name defines the name of the mesh
  60006. * @param options defines the options used to create the mesh
  60007. * @param scene defines the hosting scene
  60008. * @returns the ground mesh
  60009. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60010. */
  60011. static CreateGround(name: string, options: {
  60012. width?: number;
  60013. height?: number;
  60014. subdivisions?: number;
  60015. subdivisionsX?: number;
  60016. subdivisionsY?: number;
  60017. updatable?: boolean;
  60018. }, scene?: Nullable<Scene>): Mesh;
  60019. /**
  60020. * Creates a tiled ground mesh
  60021. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60022. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60023. * * 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
  60024. * * 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
  60025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60026. * @param name defines the name of the mesh
  60027. * @param options defines the options used to create the mesh
  60028. * @param scene defines the hosting scene
  60029. * @returns the tiled ground mesh
  60030. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60031. */
  60032. static CreateTiledGround(name: string, options: {
  60033. xmin: number;
  60034. zmin: number;
  60035. xmax: number;
  60036. zmax: number;
  60037. subdivisions?: {
  60038. w: number;
  60039. h: number;
  60040. };
  60041. precision?: {
  60042. w: number;
  60043. h: number;
  60044. };
  60045. updatable?: boolean;
  60046. }, scene?: Nullable<Scene>): Mesh;
  60047. /**
  60048. * Creates a ground mesh from a height map
  60049. * * The parameter `url` sets the URL of the height map image resource.
  60050. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60051. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60052. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60053. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60054. * * 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.
  60055. * * 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).
  60056. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60058. * @param name defines the name of the mesh
  60059. * @param url defines the url to the height map
  60060. * @param options defines the options used to create the mesh
  60061. * @param scene defines the hosting scene
  60062. * @returns the ground mesh
  60063. * @see https://doc.babylonjs.com/babylon101/height_map
  60064. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60065. */
  60066. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60067. width?: number;
  60068. height?: number;
  60069. subdivisions?: number;
  60070. minHeight?: number;
  60071. maxHeight?: number;
  60072. colorFilter?: Color3;
  60073. alphaFilter?: number;
  60074. updatable?: boolean;
  60075. onReady?: (mesh: GroundMesh) => void;
  60076. }, scene?: Nullable<Scene>): GroundMesh;
  60077. /**
  60078. * Creates a polygon mesh
  60079. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60080. * * 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
  60081. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60084. * * Remember you can only change the shape positions, not their number when updating a polygon
  60085. * @param name defines the name of the mesh
  60086. * @param options defines the options used to create the mesh
  60087. * @param scene defines the hosting scene
  60088. * @param earcutInjection can be used to inject your own earcut reference
  60089. * @returns the polygon mesh
  60090. */
  60091. static CreatePolygon(name: string, options: {
  60092. shape: Vector3[];
  60093. holes?: Vector3[][];
  60094. depth?: number;
  60095. faceUV?: Vector4[];
  60096. faceColors?: Color4[];
  60097. updatable?: boolean;
  60098. sideOrientation?: number;
  60099. frontUVs?: Vector4;
  60100. backUVs?: Vector4;
  60101. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60102. /**
  60103. * Creates an extruded polygon mesh, with depth in the Y direction.
  60104. * * 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)
  60105. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60106. * @param name defines the name of the mesh
  60107. * @param options defines the options used to create the mesh
  60108. * @param scene defines the hosting scene
  60109. * @param earcutInjection can be used to inject your own earcut reference
  60110. * @returns the polygon mesh
  60111. */
  60112. static ExtrudePolygon(name: string, options: {
  60113. shape: Vector3[];
  60114. holes?: Vector3[][];
  60115. depth?: number;
  60116. faceUV?: Vector4[];
  60117. faceColors?: Color4[];
  60118. updatable?: boolean;
  60119. sideOrientation?: number;
  60120. frontUVs?: Vector4;
  60121. backUVs?: Vector4;
  60122. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60123. /**
  60124. * Creates a tube mesh.
  60125. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60126. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60127. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60128. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60129. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60130. * * 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)
  60131. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60132. * * 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
  60133. * * 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
  60134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60138. * @param name defines the name of the mesh
  60139. * @param options defines the options used to create the mesh
  60140. * @param scene defines the hosting scene
  60141. * @returns the tube mesh
  60142. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60143. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60144. */
  60145. static CreateTube(name: string, options: {
  60146. path: Vector3[];
  60147. radius?: number;
  60148. tessellation?: number;
  60149. radiusFunction?: {
  60150. (i: number, distance: number): number;
  60151. };
  60152. cap?: number;
  60153. arc?: number;
  60154. updatable?: boolean;
  60155. sideOrientation?: number;
  60156. frontUVs?: Vector4;
  60157. backUVs?: Vector4;
  60158. instance?: Mesh;
  60159. invertUV?: boolean;
  60160. }, scene?: Nullable<Scene>): Mesh;
  60161. /**
  60162. * Creates a polyhedron mesh
  60163. * * 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
  60164. * * The parameter `size` (positive float, default 1) sets the polygon size
  60165. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60166. * * 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`
  60167. * * 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
  60168. * * 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)`)
  60169. * * 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
  60170. * * 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
  60171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60174. * @param name defines the name of the mesh
  60175. * @param options defines the options used to create the mesh
  60176. * @param scene defines the hosting scene
  60177. * @returns the polyhedron mesh
  60178. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60179. */
  60180. static CreatePolyhedron(name: string, options: {
  60181. type?: number;
  60182. size?: number;
  60183. sizeX?: number;
  60184. sizeY?: number;
  60185. sizeZ?: number;
  60186. custom?: any;
  60187. faceUV?: Vector4[];
  60188. faceColors?: Color4[];
  60189. flat?: boolean;
  60190. updatable?: boolean;
  60191. sideOrientation?: number;
  60192. frontUVs?: Vector4;
  60193. backUVs?: Vector4;
  60194. }, scene?: Nullable<Scene>): Mesh;
  60195. /**
  60196. * Creates a decal mesh.
  60197. * 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
  60198. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60199. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60200. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60201. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60202. * @param name defines the name of the mesh
  60203. * @param sourceMesh defines the mesh where the decal must be applied
  60204. * @param options defines the options used to create the mesh
  60205. * @param scene defines the hosting scene
  60206. * @returns the decal mesh
  60207. * @see https://doc.babylonjs.com/how_to/decals
  60208. */
  60209. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60210. position?: Vector3;
  60211. normal?: Vector3;
  60212. size?: Vector3;
  60213. angle?: number;
  60214. }): Mesh;
  60215. }
  60216. }
  60217. declare module "babylonjs/Meshes/meshSimplification" {
  60218. import { Mesh } from "babylonjs/Meshes/mesh";
  60219. /**
  60220. * A simplifier interface for future simplification implementations
  60221. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60222. */
  60223. export interface ISimplifier {
  60224. /**
  60225. * Simplification of a given mesh according to the given settings.
  60226. * Since this requires computation, it is assumed that the function runs async.
  60227. * @param settings The settings of the simplification, including quality and distance
  60228. * @param successCallback A callback that will be called after the mesh was simplified.
  60229. * @param errorCallback in case of an error, this callback will be called. optional.
  60230. */
  60231. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60232. }
  60233. /**
  60234. * Expected simplification settings.
  60235. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60236. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60237. */
  60238. export interface ISimplificationSettings {
  60239. /**
  60240. * Gets or sets the expected quality
  60241. */
  60242. quality: number;
  60243. /**
  60244. * Gets or sets the distance when this optimized version should be used
  60245. */
  60246. distance: number;
  60247. /**
  60248. * Gets an already optimized mesh
  60249. */
  60250. optimizeMesh?: boolean;
  60251. }
  60252. /**
  60253. * Class used to specify simplification options
  60254. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60255. */
  60256. export class SimplificationSettings implements ISimplificationSettings {
  60257. /** expected quality */
  60258. quality: number;
  60259. /** distance when this optimized version should be used */
  60260. distance: number;
  60261. /** already optimized mesh */
  60262. optimizeMesh?: boolean | undefined;
  60263. /**
  60264. * Creates a SimplificationSettings
  60265. * @param quality expected quality
  60266. * @param distance distance when this optimized version should be used
  60267. * @param optimizeMesh already optimized mesh
  60268. */
  60269. constructor(
  60270. /** expected quality */
  60271. quality: number,
  60272. /** distance when this optimized version should be used */
  60273. distance: number,
  60274. /** already optimized mesh */
  60275. optimizeMesh?: boolean | undefined);
  60276. }
  60277. /**
  60278. * Interface used to define a simplification task
  60279. */
  60280. export interface ISimplificationTask {
  60281. /**
  60282. * Array of settings
  60283. */
  60284. settings: Array<ISimplificationSettings>;
  60285. /**
  60286. * Simplification type
  60287. */
  60288. simplificationType: SimplificationType;
  60289. /**
  60290. * Mesh to simplify
  60291. */
  60292. mesh: Mesh;
  60293. /**
  60294. * Callback called on success
  60295. */
  60296. successCallback?: () => void;
  60297. /**
  60298. * Defines if parallel processing can be used
  60299. */
  60300. parallelProcessing: boolean;
  60301. }
  60302. /**
  60303. * Queue used to order the simplification tasks
  60304. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60305. */
  60306. export class SimplificationQueue {
  60307. private _simplificationArray;
  60308. /**
  60309. * Gets a boolean indicating that the process is still running
  60310. */
  60311. running: boolean;
  60312. /**
  60313. * Creates a new queue
  60314. */
  60315. constructor();
  60316. /**
  60317. * Adds a new simplification task
  60318. * @param task defines a task to add
  60319. */
  60320. addTask(task: ISimplificationTask): void;
  60321. /**
  60322. * Execute next task
  60323. */
  60324. executeNext(): void;
  60325. /**
  60326. * Execute a simplification task
  60327. * @param task defines the task to run
  60328. */
  60329. runSimplification(task: ISimplificationTask): void;
  60330. private getSimplifier;
  60331. }
  60332. /**
  60333. * The implemented types of simplification
  60334. * At the moment only Quadratic Error Decimation is implemented
  60335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60336. */
  60337. export enum SimplificationType {
  60338. /** Quadratic error decimation */
  60339. QUADRATIC = 0
  60340. }
  60341. }
  60342. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60343. import { Scene } from "babylonjs/scene";
  60344. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60345. import { ISceneComponent } from "babylonjs/sceneComponent";
  60346. module "babylonjs/scene" {
  60347. interface Scene {
  60348. /** @hidden (Backing field) */
  60349. _simplificationQueue: SimplificationQueue;
  60350. /**
  60351. * Gets or sets the simplification queue attached to the scene
  60352. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60353. */
  60354. simplificationQueue: SimplificationQueue;
  60355. }
  60356. }
  60357. module "babylonjs/Meshes/mesh" {
  60358. interface Mesh {
  60359. /**
  60360. * Simplify the mesh according to the given array of settings.
  60361. * Function will return immediately and will simplify async
  60362. * @param settings a collection of simplification settings
  60363. * @param parallelProcessing should all levels calculate parallel or one after the other
  60364. * @param simplificationType the type of simplification to run
  60365. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60366. * @returns the current mesh
  60367. */
  60368. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60369. }
  60370. }
  60371. /**
  60372. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60373. * created in a scene
  60374. */
  60375. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60376. /**
  60377. * The component name helpfull to identify the component in the list of scene components.
  60378. */
  60379. readonly name: string;
  60380. /**
  60381. * The scene the component belongs to.
  60382. */
  60383. scene: Scene;
  60384. /**
  60385. * Creates a new instance of the component for the given scene
  60386. * @param scene Defines the scene to register the component in
  60387. */
  60388. constructor(scene: Scene);
  60389. /**
  60390. * Registers the component in a given scene
  60391. */
  60392. register(): void;
  60393. /**
  60394. * Rebuilds the elements related to this component in case of
  60395. * context lost for instance.
  60396. */
  60397. rebuild(): void;
  60398. /**
  60399. * Disposes the component and the associated ressources
  60400. */
  60401. dispose(): void;
  60402. private _beforeCameraUpdate;
  60403. }
  60404. }
  60405. declare module "babylonjs/Meshes/Builders/index" {
  60406. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60407. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60408. export * from "babylonjs/Meshes/Builders/discBuilder";
  60409. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60410. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60411. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60412. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60413. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60414. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60415. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60416. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60417. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60418. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60419. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60420. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60421. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60422. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60423. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60424. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60425. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60426. }
  60427. declare module "babylonjs/Meshes/index" {
  60428. export * from "babylonjs/Meshes/abstractMesh";
  60429. export * from "babylonjs/Meshes/buffer";
  60430. export * from "babylonjs/Meshes/Compression/index";
  60431. export * from "babylonjs/Meshes/csg";
  60432. export * from "babylonjs/Meshes/geometry";
  60433. export * from "babylonjs/Meshes/groundMesh";
  60434. export * from "babylonjs/Meshes/trailMesh";
  60435. export * from "babylonjs/Meshes/instancedMesh";
  60436. export * from "babylonjs/Meshes/linesMesh";
  60437. export * from "babylonjs/Meshes/mesh";
  60438. export * from "babylonjs/Meshes/mesh.vertexData";
  60439. export * from "babylonjs/Meshes/meshBuilder";
  60440. export * from "babylonjs/Meshes/meshSimplification";
  60441. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60442. export * from "babylonjs/Meshes/polygonMesh";
  60443. export * from "babylonjs/Meshes/subMesh";
  60444. export * from "babylonjs/Meshes/meshLODLevel";
  60445. export * from "babylonjs/Meshes/transformNode";
  60446. export * from "babylonjs/Meshes/Builders/index";
  60447. export * from "babylonjs/Meshes/dataBuffer";
  60448. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60449. }
  60450. declare module "babylonjs/Morph/index" {
  60451. export * from "babylonjs/Morph/morphTarget";
  60452. export * from "babylonjs/Morph/morphTargetManager";
  60453. }
  60454. declare module "babylonjs/Navigation/INavigationEngine" {
  60455. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60456. import { Vector3 } from "babylonjs/Maths/math";
  60457. import { Mesh } from "babylonjs/Meshes/mesh";
  60458. import { Scene } from "babylonjs/scene";
  60459. /**
  60460. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60461. */
  60462. export interface INavigationEnginePlugin {
  60463. /**
  60464. * plugin name
  60465. */
  60466. name: string;
  60467. /**
  60468. * Creates a navigation mesh
  60469. * @param meshes array of all the geometry used to compute the navigatio mesh
  60470. * @param parameters bunch of parameters used to filter geometry
  60471. */
  60472. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60473. /**
  60474. * Create a navigation mesh debug mesh
  60475. * @param scene is where the mesh will be added
  60476. * @returns debug display mesh
  60477. */
  60478. createDebugNavMesh(scene: Scene): Mesh;
  60479. /**
  60480. * Get a navigation mesh constrained position, closest to the parameter position
  60481. * @param position world position
  60482. * @returns the closest point to position constrained by the navigation mesh
  60483. */
  60484. getClosestPoint(position: Vector3): Vector3;
  60485. /**
  60486. * Get a navigation mesh constrained position, within a particular radius
  60487. * @param position world position
  60488. * @param maxRadius the maximum distance to the constrained world position
  60489. * @returns the closest point to position constrained by the navigation mesh
  60490. */
  60491. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60492. /**
  60493. * Compute the final position from a segment made of destination-position
  60494. * @param position world position
  60495. * @param destination world position
  60496. * @returns the resulting point along the navmesh
  60497. */
  60498. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60499. /**
  60500. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60501. * @param start world position
  60502. * @param end world position
  60503. * @returns array containing world position composing the path
  60504. */
  60505. computePath(start: Vector3, end: Vector3): Vector3[];
  60506. /**
  60507. * If this plugin is supported
  60508. * @returns true if plugin is supported
  60509. */
  60510. isSupported(): boolean;
  60511. /**
  60512. * Create a new Crowd so you can add agents
  60513. * @param maxAgents the maximum agent count in the crowd
  60514. * @param maxAgentRadius the maximum radius an agent can have
  60515. * @param scene to attach the crowd to
  60516. * @returns the crowd you can add agents to
  60517. */
  60518. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60519. /**
  60520. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60521. * The queries will try to find a solution within those bounds
  60522. * default is (1,1,1)
  60523. * @param extent x,y,z value that define the extent around the queries point of reference
  60524. */
  60525. setDefaultQueryExtent(extent: Vector3): void;
  60526. /**
  60527. * Get the Bounding box extent specified by setDefaultQueryExtent
  60528. * @returns the box extent values
  60529. */
  60530. getDefaultQueryExtent(): Vector3;
  60531. /**
  60532. * Release all resources
  60533. */
  60534. dispose(): void;
  60535. }
  60536. /**
  60537. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60538. */
  60539. export interface ICrowd {
  60540. /**
  60541. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60542. * You can attach anything to that node. The node position is updated in the scene update tick.
  60543. * @param pos world position that will be constrained by the navigation mesh
  60544. * @param parameters agent parameters
  60545. * @param transform hooked to the agent that will be update by the scene
  60546. * @returns agent index
  60547. */
  60548. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60549. /**
  60550. * Returns the agent position in world space
  60551. * @param index agent index returned by addAgent
  60552. * @returns world space position
  60553. */
  60554. getAgentPosition(index: number): Vector3;
  60555. /**
  60556. * Gets the agent velocity in world space
  60557. * @param index agent index returned by addAgent
  60558. * @returns world space velocity
  60559. */
  60560. getAgentVelocity(index: number): Vector3;
  60561. /**
  60562. * remove a particular agent previously created
  60563. * @param index agent index returned by addAgent
  60564. */
  60565. removeAgent(index: number): void;
  60566. /**
  60567. * get the list of all agents attached to this crowd
  60568. * @returns list of agent indices
  60569. */
  60570. getAgents(): number[];
  60571. /**
  60572. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60573. * @param deltaTime in seconds
  60574. */
  60575. update(deltaTime: number): void;
  60576. /**
  60577. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60578. * @param index agent index returned by addAgent
  60579. * @param destination targeted world position
  60580. */
  60581. agentGoto(index: number, destination: Vector3): void;
  60582. /**
  60583. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60584. * The queries will try to find a solution within those bounds
  60585. * default is (1,1,1)
  60586. * @param extent x,y,z value that define the extent around the queries point of reference
  60587. */
  60588. setDefaultQueryExtent(extent: Vector3): void;
  60589. /**
  60590. * Get the Bounding box extent specified by setDefaultQueryExtent
  60591. * @returns the box extent values
  60592. */
  60593. getDefaultQueryExtent(): Vector3;
  60594. /**
  60595. * Release all resources
  60596. */
  60597. dispose(): void;
  60598. }
  60599. /**
  60600. * Configures an agent
  60601. */
  60602. export interface IAgentParameters {
  60603. /**
  60604. * Agent radius. [Limit: >= 0]
  60605. */
  60606. radius: number;
  60607. /**
  60608. * Agent height. [Limit: > 0]
  60609. */
  60610. height: number;
  60611. /**
  60612. * Maximum allowed acceleration. [Limit: >= 0]
  60613. */
  60614. maxAcceleration: number;
  60615. /**
  60616. * Maximum allowed speed. [Limit: >= 0]
  60617. */
  60618. maxSpeed: number;
  60619. /**
  60620. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60621. */
  60622. collisionQueryRange: number;
  60623. /**
  60624. * The path visibility optimization range. [Limit: > 0]
  60625. */
  60626. pathOptimizationRange: number;
  60627. /**
  60628. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60629. */
  60630. separationWeight: number;
  60631. }
  60632. /**
  60633. * Configures the navigation mesh creation
  60634. */
  60635. export interface INavMeshParameters {
  60636. /**
  60637. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60638. */
  60639. cs: number;
  60640. /**
  60641. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60642. */
  60643. ch: number;
  60644. /**
  60645. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60646. */
  60647. walkableSlopeAngle: number;
  60648. /**
  60649. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60650. * be considered walkable. [Limit: >= 3] [Units: vx]
  60651. */
  60652. walkableHeight: number;
  60653. /**
  60654. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60655. */
  60656. walkableClimb: number;
  60657. /**
  60658. * The distance to erode/shrink the walkable area of the heightfield away from
  60659. * obstructions. [Limit: >=0] [Units: vx]
  60660. */
  60661. walkableRadius: number;
  60662. /**
  60663. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60664. */
  60665. maxEdgeLen: number;
  60666. /**
  60667. * The maximum distance a simplfied contour's border edges should deviate
  60668. * the original raw contour. [Limit: >=0] [Units: vx]
  60669. */
  60670. maxSimplificationError: number;
  60671. /**
  60672. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60673. */
  60674. minRegionArea: number;
  60675. /**
  60676. * Any regions with a span count smaller than this value will, if possible,
  60677. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60678. */
  60679. mergeRegionArea: number;
  60680. /**
  60681. * The maximum number of vertices allowed for polygons generated during the
  60682. * contour to polygon conversion process. [Limit: >= 3]
  60683. */
  60684. maxVertsPerPoly: number;
  60685. /**
  60686. * Sets the sampling distance to use when generating the detail mesh.
  60687. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60688. */
  60689. detailSampleDist: number;
  60690. /**
  60691. * The maximum distance the detail mesh surface should deviate from heightfield
  60692. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60693. */
  60694. detailSampleMaxError: number;
  60695. }
  60696. }
  60697. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60698. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60699. import { Mesh } from "babylonjs/Meshes/mesh";
  60700. import { Scene } from "babylonjs/scene";
  60701. import { Vector3 } from "babylonjs/Maths/math";
  60702. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60703. /**
  60704. * RecastJS navigation plugin
  60705. */
  60706. export class RecastJSPlugin implements INavigationEnginePlugin {
  60707. /**
  60708. * Reference to the Recast library
  60709. */
  60710. bjsRECAST: any;
  60711. /**
  60712. * plugin name
  60713. */
  60714. name: string;
  60715. /**
  60716. * the first navmesh created. We might extend this to support multiple navmeshes
  60717. */
  60718. navMesh: any;
  60719. /**
  60720. * Initializes the recastJS plugin
  60721. * @param recastInjection can be used to inject your own recast reference
  60722. */
  60723. constructor(recastInjection?: any);
  60724. /**
  60725. * Creates a navigation mesh
  60726. * @param meshes array of all the geometry used to compute the navigatio mesh
  60727. * @param parameters bunch of parameters used to filter geometry
  60728. */
  60729. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60730. /**
  60731. * Create a navigation mesh debug mesh
  60732. * @param scene is where the mesh will be added
  60733. * @returns debug display mesh
  60734. */
  60735. createDebugNavMesh(scene: Scene): Mesh;
  60736. /**
  60737. * Get a navigation mesh constrained position, closest to the parameter position
  60738. * @param position world position
  60739. * @returns the closest point to position constrained by the navigation mesh
  60740. */
  60741. getClosestPoint(position: Vector3): Vector3;
  60742. /**
  60743. * Get a navigation mesh constrained position, within a particular radius
  60744. * @param position world position
  60745. * @param maxRadius the maximum distance to the constrained world position
  60746. * @returns the closest point to position constrained by the navigation mesh
  60747. */
  60748. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60749. /**
  60750. * Compute the final position from a segment made of destination-position
  60751. * @param position world position
  60752. * @param destination world position
  60753. * @returns the resulting point along the navmesh
  60754. */
  60755. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60756. /**
  60757. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60758. * @param start world position
  60759. * @param end world position
  60760. * @returns array containing world position composing the path
  60761. */
  60762. computePath(start: Vector3, end: Vector3): Vector3[];
  60763. /**
  60764. * Create a new Crowd so you can add agents
  60765. * @param maxAgents the maximum agent count in the crowd
  60766. * @param maxAgentRadius the maximum radius an agent can have
  60767. * @param scene to attach the crowd to
  60768. * @returns the crowd you can add agents to
  60769. */
  60770. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60771. /**
  60772. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60773. * The queries will try to find a solution within those bounds
  60774. * default is (1,1,1)
  60775. * @param extent x,y,z value that define the extent around the queries point of reference
  60776. */
  60777. setDefaultQueryExtent(extent: Vector3): void;
  60778. /**
  60779. * Get the Bounding box extent specified by setDefaultQueryExtent
  60780. * @returns the box extent values
  60781. */
  60782. getDefaultQueryExtent(): Vector3;
  60783. /**
  60784. * Disposes
  60785. */
  60786. dispose(): void;
  60787. /**
  60788. * If this plugin is supported
  60789. * @returns true if plugin is supported
  60790. */
  60791. isSupported(): boolean;
  60792. }
  60793. /**
  60794. * Recast detour crowd implementation
  60795. */
  60796. export class RecastJSCrowd implements ICrowd {
  60797. /**
  60798. * Recast/detour plugin
  60799. */
  60800. bjsRECASTPlugin: RecastJSPlugin;
  60801. /**
  60802. * Link to the detour crowd
  60803. */
  60804. recastCrowd: any;
  60805. /**
  60806. * One transform per agent
  60807. */
  60808. transforms: TransformNode[];
  60809. /**
  60810. * All agents created
  60811. */
  60812. agents: number[];
  60813. /**
  60814. * Link to the scene is kept to unregister the crowd from the scene
  60815. */
  60816. private _scene;
  60817. /**
  60818. * Observer for crowd updates
  60819. */
  60820. private _onBeforeAnimationsObserver;
  60821. /**
  60822. * Constructor
  60823. * @param plugin recastJS plugin
  60824. * @param maxAgents the maximum agent count in the crowd
  60825. * @param maxAgentRadius the maximum radius an agent can have
  60826. * @param scene to attach the crowd to
  60827. * @returns the crowd you can add agents to
  60828. */
  60829. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60830. /**
  60831. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60832. * You can attach anything to that node. The node position is updated in the scene update tick.
  60833. * @param pos world position that will be constrained by the navigation mesh
  60834. * @param parameters agent parameters
  60835. * @param transform hooked to the agent that will be update by the scene
  60836. * @returns agent index
  60837. */
  60838. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60839. /**
  60840. * Returns the agent position in world space
  60841. * @param index agent index returned by addAgent
  60842. * @returns world space position
  60843. */
  60844. getAgentPosition(index: number): Vector3;
  60845. /**
  60846. * Returns the agent velocity in world space
  60847. * @param index agent index returned by addAgent
  60848. * @returns world space velocity
  60849. */
  60850. getAgentVelocity(index: number): Vector3;
  60851. /**
  60852. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60853. * @param index agent index returned by addAgent
  60854. * @param destination targeted world position
  60855. */
  60856. agentGoto(index: number, destination: Vector3): void;
  60857. /**
  60858. * remove a particular agent previously created
  60859. * @param index agent index returned by addAgent
  60860. */
  60861. removeAgent(index: number): void;
  60862. /**
  60863. * get the list of all agents attached to this crowd
  60864. * @returns list of agent indices
  60865. */
  60866. getAgents(): number[];
  60867. /**
  60868. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60869. * @param deltaTime in seconds
  60870. */
  60871. update(deltaTime: number): void;
  60872. /**
  60873. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60874. * The queries will try to find a solution within those bounds
  60875. * default is (1,1,1)
  60876. * @param extent x,y,z value that define the extent around the queries point of reference
  60877. */
  60878. setDefaultQueryExtent(extent: Vector3): void;
  60879. /**
  60880. * Get the Bounding box extent specified by setDefaultQueryExtent
  60881. * @returns the box extent values
  60882. */
  60883. getDefaultQueryExtent(): Vector3;
  60884. /**
  60885. * Release all resources
  60886. */
  60887. dispose(): void;
  60888. }
  60889. }
  60890. declare module "babylonjs/Navigation/Plugins/index" {
  60891. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60892. }
  60893. declare module "babylonjs/Navigation/index" {
  60894. export * from "babylonjs/Navigation/INavigationEngine";
  60895. export * from "babylonjs/Navigation/Plugins/index";
  60896. }
  60897. declare module "babylonjs/Offline/database" {
  60898. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60899. /**
  60900. * Class used to enable access to IndexedDB
  60901. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60902. */
  60903. export class Database implements IOfflineProvider {
  60904. private _callbackManifestChecked;
  60905. private _currentSceneUrl;
  60906. private _db;
  60907. private _enableSceneOffline;
  60908. private _enableTexturesOffline;
  60909. private _manifestVersionFound;
  60910. private _mustUpdateRessources;
  60911. private _hasReachedQuota;
  60912. private _isSupported;
  60913. private _idbFactory;
  60914. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60915. private static IsUASupportingBlobStorage;
  60916. /**
  60917. * Gets a boolean indicating if Database storate is enabled (off by default)
  60918. */
  60919. static IDBStorageEnabled: boolean;
  60920. /**
  60921. * Gets a boolean indicating if scene must be saved in the database
  60922. */
  60923. readonly enableSceneOffline: boolean;
  60924. /**
  60925. * Gets a boolean indicating if textures must be saved in the database
  60926. */
  60927. readonly enableTexturesOffline: boolean;
  60928. /**
  60929. * Creates a new Database
  60930. * @param urlToScene defines the url to load the scene
  60931. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60932. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60933. */
  60934. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60935. private static _ParseURL;
  60936. private static _ReturnFullUrlLocation;
  60937. private _checkManifestFile;
  60938. /**
  60939. * Open the database and make it available
  60940. * @param successCallback defines the callback to call on success
  60941. * @param errorCallback defines the callback to call on error
  60942. */
  60943. open(successCallback: () => void, errorCallback: () => void): void;
  60944. /**
  60945. * Loads an image from the database
  60946. * @param url defines the url to load from
  60947. * @param image defines the target DOM image
  60948. */
  60949. loadImage(url: string, image: HTMLImageElement): void;
  60950. private _loadImageFromDBAsync;
  60951. private _saveImageIntoDBAsync;
  60952. private _checkVersionFromDB;
  60953. private _loadVersionFromDBAsync;
  60954. private _saveVersionIntoDBAsync;
  60955. /**
  60956. * Loads a file from database
  60957. * @param url defines the URL to load from
  60958. * @param sceneLoaded defines a callback to call on success
  60959. * @param progressCallBack defines a callback to call when progress changed
  60960. * @param errorCallback defines a callback to call on error
  60961. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60962. */
  60963. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60964. private _loadFileAsync;
  60965. private _saveFileAsync;
  60966. /**
  60967. * Validates if xhr data is correct
  60968. * @param xhr defines the request to validate
  60969. * @param dataType defines the expected data type
  60970. * @returns true if data is correct
  60971. */
  60972. private static _ValidateXHRData;
  60973. }
  60974. }
  60975. declare module "babylonjs/Offline/index" {
  60976. export * from "babylonjs/Offline/database";
  60977. export * from "babylonjs/Offline/IOfflineProvider";
  60978. }
  60979. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60980. /** @hidden */
  60981. export var gpuUpdateParticlesPixelShader: {
  60982. name: string;
  60983. shader: string;
  60984. };
  60985. }
  60986. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60987. /** @hidden */
  60988. export var gpuUpdateParticlesVertexShader: {
  60989. name: string;
  60990. shader: string;
  60991. };
  60992. }
  60993. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60994. /** @hidden */
  60995. export var clipPlaneFragmentDeclaration2: {
  60996. name: string;
  60997. shader: string;
  60998. };
  60999. }
  61000. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61001. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61002. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61003. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61004. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61005. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61006. /** @hidden */
  61007. export var gpuRenderParticlesPixelShader: {
  61008. name: string;
  61009. shader: string;
  61010. };
  61011. }
  61012. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61013. /** @hidden */
  61014. export var clipPlaneVertexDeclaration2: {
  61015. name: string;
  61016. shader: string;
  61017. };
  61018. }
  61019. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61020. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61021. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61022. /** @hidden */
  61023. export var gpuRenderParticlesVertexShader: {
  61024. name: string;
  61025. shader: string;
  61026. };
  61027. }
  61028. declare module "babylonjs/Particles/gpuParticleSystem" {
  61029. import { Nullable } from "babylonjs/types";
  61030. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61031. import { Observable } from "babylonjs/Misc/observable";
  61032. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61033. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61034. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61035. import { Scene, IDisposable } from "babylonjs/scene";
  61036. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61037. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61038. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61039. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61040. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61041. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61042. /**
  61043. * This represents a GPU particle system in Babylon
  61044. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61045. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61046. */
  61047. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61048. /**
  61049. * The layer mask we are rendering the particles through.
  61050. */
  61051. layerMask: number;
  61052. private _capacity;
  61053. private _activeCount;
  61054. private _currentActiveCount;
  61055. private _accumulatedCount;
  61056. private _renderEffect;
  61057. private _updateEffect;
  61058. private _buffer0;
  61059. private _buffer1;
  61060. private _spriteBuffer;
  61061. private _updateVAO;
  61062. private _renderVAO;
  61063. private _targetIndex;
  61064. private _sourceBuffer;
  61065. private _targetBuffer;
  61066. private _engine;
  61067. private _currentRenderId;
  61068. private _started;
  61069. private _stopped;
  61070. private _timeDelta;
  61071. private _randomTexture;
  61072. private _randomTexture2;
  61073. private _attributesStrideSize;
  61074. private _updateEffectOptions;
  61075. private _randomTextureSize;
  61076. private _actualFrame;
  61077. private readonly _rawTextureWidth;
  61078. /**
  61079. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61080. */
  61081. static readonly IsSupported: boolean;
  61082. /**
  61083. * An event triggered when the system is disposed.
  61084. */
  61085. onDisposeObservable: Observable<GPUParticleSystem>;
  61086. /**
  61087. * Gets the maximum number of particles active at the same time.
  61088. * @returns The max number of active particles.
  61089. */
  61090. getCapacity(): number;
  61091. /**
  61092. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61093. * to override the particles.
  61094. */
  61095. forceDepthWrite: boolean;
  61096. /**
  61097. * Gets or set the number of active particles
  61098. */
  61099. activeParticleCount: number;
  61100. private _preWarmDone;
  61101. /**
  61102. * Is this system ready to be used/rendered
  61103. * @return true if the system is ready
  61104. */
  61105. isReady(): boolean;
  61106. /**
  61107. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61108. * @returns True if it has been started, otherwise false.
  61109. */
  61110. isStarted(): boolean;
  61111. /**
  61112. * Starts the particle system and begins to emit
  61113. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61114. */
  61115. start(delay?: number): void;
  61116. /**
  61117. * Stops the particle system.
  61118. */
  61119. stop(): void;
  61120. /**
  61121. * Remove all active particles
  61122. */
  61123. reset(): void;
  61124. /**
  61125. * Returns the string "GPUParticleSystem"
  61126. * @returns a string containing the class name
  61127. */
  61128. getClassName(): string;
  61129. private _colorGradientsTexture;
  61130. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61131. /**
  61132. * Adds a new color gradient
  61133. * @param gradient defines the gradient to use (between 0 and 1)
  61134. * @param color1 defines the color to affect to the specified gradient
  61135. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61136. * @returns the current particle system
  61137. */
  61138. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61139. /**
  61140. * Remove a specific color gradient
  61141. * @param gradient defines the gradient to remove
  61142. * @returns the current particle system
  61143. */
  61144. removeColorGradient(gradient: number): GPUParticleSystem;
  61145. private _angularSpeedGradientsTexture;
  61146. private _sizeGradientsTexture;
  61147. private _velocityGradientsTexture;
  61148. private _limitVelocityGradientsTexture;
  61149. private _dragGradientsTexture;
  61150. private _addFactorGradient;
  61151. /**
  61152. * Adds a new size gradient
  61153. * @param gradient defines the gradient to use (between 0 and 1)
  61154. * @param factor defines the size factor to affect to the specified gradient
  61155. * @returns the current particle system
  61156. */
  61157. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61158. /**
  61159. * Remove a specific size gradient
  61160. * @param gradient defines the gradient to remove
  61161. * @returns the current particle system
  61162. */
  61163. removeSizeGradient(gradient: number): GPUParticleSystem;
  61164. /**
  61165. * Adds a new angular speed gradient
  61166. * @param gradient defines the gradient to use (between 0 and 1)
  61167. * @param factor defines the angular speed to affect to the specified gradient
  61168. * @returns the current particle system
  61169. */
  61170. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61171. /**
  61172. * Remove a specific angular speed gradient
  61173. * @param gradient defines the gradient to remove
  61174. * @returns the current particle system
  61175. */
  61176. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61177. /**
  61178. * Adds a new velocity gradient
  61179. * @param gradient defines the gradient to use (between 0 and 1)
  61180. * @param factor defines the velocity to affect to the specified gradient
  61181. * @returns the current particle system
  61182. */
  61183. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61184. /**
  61185. * Remove a specific velocity gradient
  61186. * @param gradient defines the gradient to remove
  61187. * @returns the current particle system
  61188. */
  61189. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61190. /**
  61191. * Adds a new limit velocity gradient
  61192. * @param gradient defines the gradient to use (between 0 and 1)
  61193. * @param factor defines the limit velocity value to affect to the specified gradient
  61194. * @returns the current particle system
  61195. */
  61196. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61197. /**
  61198. * Remove a specific limit velocity gradient
  61199. * @param gradient defines the gradient to remove
  61200. * @returns the current particle system
  61201. */
  61202. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61203. /**
  61204. * Adds a new drag gradient
  61205. * @param gradient defines the gradient to use (between 0 and 1)
  61206. * @param factor defines the drag value to affect to the specified gradient
  61207. * @returns the current particle system
  61208. */
  61209. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61210. /**
  61211. * Remove a specific drag gradient
  61212. * @param gradient defines the gradient to remove
  61213. * @returns the current particle system
  61214. */
  61215. removeDragGradient(gradient: number): GPUParticleSystem;
  61216. /**
  61217. * Not supported by GPUParticleSystem
  61218. * @param gradient defines the gradient to use (between 0 and 1)
  61219. * @param factor defines the emit rate value to affect to the specified gradient
  61220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61221. * @returns the current particle system
  61222. */
  61223. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61224. /**
  61225. * Not supported by GPUParticleSystem
  61226. * @param gradient defines the gradient to remove
  61227. * @returns the current particle system
  61228. */
  61229. removeEmitRateGradient(gradient: number): IParticleSystem;
  61230. /**
  61231. * Not supported by GPUParticleSystem
  61232. * @param gradient defines the gradient to use (between 0 and 1)
  61233. * @param factor defines the start size value to affect to the specified gradient
  61234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61235. * @returns the current particle system
  61236. */
  61237. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61238. /**
  61239. * Not supported by GPUParticleSystem
  61240. * @param gradient defines the gradient to remove
  61241. * @returns the current particle system
  61242. */
  61243. removeStartSizeGradient(gradient: number): IParticleSystem;
  61244. /**
  61245. * Not supported by GPUParticleSystem
  61246. * @param gradient defines the gradient to use (between 0 and 1)
  61247. * @param min defines the color remap minimal range
  61248. * @param max defines the color remap maximal range
  61249. * @returns the current particle system
  61250. */
  61251. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61252. /**
  61253. * Not supported by GPUParticleSystem
  61254. * @param gradient defines the gradient to remove
  61255. * @returns the current particle system
  61256. */
  61257. removeColorRemapGradient(): IParticleSystem;
  61258. /**
  61259. * Not supported by GPUParticleSystem
  61260. * @param gradient defines the gradient to use (between 0 and 1)
  61261. * @param min defines the alpha remap minimal range
  61262. * @param max defines the alpha remap maximal range
  61263. * @returns the current particle system
  61264. */
  61265. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61266. /**
  61267. * Not supported by GPUParticleSystem
  61268. * @param gradient defines the gradient to remove
  61269. * @returns the current particle system
  61270. */
  61271. removeAlphaRemapGradient(): IParticleSystem;
  61272. /**
  61273. * Not supported by GPUParticleSystem
  61274. * @param gradient defines the gradient to use (between 0 and 1)
  61275. * @param color defines the color to affect to the specified gradient
  61276. * @returns the current particle system
  61277. */
  61278. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61279. /**
  61280. * Not supported by GPUParticleSystem
  61281. * @param gradient defines the gradient to remove
  61282. * @returns the current particle system
  61283. */
  61284. removeRampGradient(): IParticleSystem;
  61285. /**
  61286. * Not supported by GPUParticleSystem
  61287. * @returns the list of ramp gradients
  61288. */
  61289. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61290. /**
  61291. * Not supported by GPUParticleSystem
  61292. * Gets or sets a boolean indicating that ramp gradients must be used
  61293. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61294. */
  61295. useRampGradients: boolean;
  61296. /**
  61297. * Not supported by GPUParticleSystem
  61298. * @param gradient defines the gradient to use (between 0 and 1)
  61299. * @param factor defines the life time factor to affect to the specified gradient
  61300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61301. * @returns the current particle system
  61302. */
  61303. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61304. /**
  61305. * Not supported by GPUParticleSystem
  61306. * @param gradient defines the gradient to remove
  61307. * @returns the current particle system
  61308. */
  61309. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61310. /**
  61311. * Instantiates a GPU particle system.
  61312. * 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.
  61313. * @param name The name of the particle system
  61314. * @param options The options used to create the system
  61315. * @param scene The scene the particle system belongs to
  61316. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61317. */
  61318. constructor(name: string, options: Partial<{
  61319. capacity: number;
  61320. randomTextureSize: number;
  61321. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61322. protected _reset(): void;
  61323. private _createUpdateVAO;
  61324. private _createRenderVAO;
  61325. private _initialize;
  61326. /** @hidden */
  61327. _recreateUpdateEffect(): void;
  61328. /** @hidden */
  61329. _recreateRenderEffect(): void;
  61330. /**
  61331. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61332. * @param preWarm defines if we are in the pre-warmimg phase
  61333. */
  61334. animate(preWarm?: boolean): void;
  61335. private _createFactorGradientTexture;
  61336. private _createSizeGradientTexture;
  61337. private _createAngularSpeedGradientTexture;
  61338. private _createVelocityGradientTexture;
  61339. private _createLimitVelocityGradientTexture;
  61340. private _createDragGradientTexture;
  61341. private _createColorGradientTexture;
  61342. /**
  61343. * Renders the particle system in its current state
  61344. * @param preWarm defines if the system should only update the particles but not render them
  61345. * @returns the current number of particles
  61346. */
  61347. render(preWarm?: boolean): number;
  61348. /**
  61349. * Rebuilds the particle system
  61350. */
  61351. rebuild(): void;
  61352. private _releaseBuffers;
  61353. private _releaseVAOs;
  61354. /**
  61355. * Disposes the particle system and free the associated resources
  61356. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61357. */
  61358. dispose(disposeTexture?: boolean): void;
  61359. /**
  61360. * Clones the particle system.
  61361. * @param name The name of the cloned object
  61362. * @param newEmitter The new emitter to use
  61363. * @returns the cloned particle system
  61364. */
  61365. clone(name: string, newEmitter: any): GPUParticleSystem;
  61366. /**
  61367. * Serializes the particle system to a JSON object.
  61368. * @returns the JSON object
  61369. */
  61370. serialize(): any;
  61371. /**
  61372. * Parses a JSON object to create a GPU particle system.
  61373. * @param parsedParticleSystem The JSON object to parse
  61374. * @param scene The scene to create the particle system in
  61375. * @param rootUrl The root url to use to load external dependencies like texture
  61376. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61377. * @returns the parsed GPU particle system
  61378. */
  61379. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61380. }
  61381. }
  61382. declare module "babylonjs/Particles/particleSystemSet" {
  61383. import { Nullable } from "babylonjs/types";
  61384. import { Color3 } from "babylonjs/Maths/math.color";
  61385. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61387. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61388. import { Scene, IDisposable } from "babylonjs/scene";
  61389. /**
  61390. * Represents a set of particle systems working together to create a specific effect
  61391. */
  61392. export class ParticleSystemSet implements IDisposable {
  61393. /**
  61394. * Gets or sets base Assets URL
  61395. */
  61396. static BaseAssetsUrl: string;
  61397. private _emitterCreationOptions;
  61398. private _emitterNode;
  61399. /**
  61400. * Gets the particle system list
  61401. */
  61402. systems: IParticleSystem[];
  61403. /**
  61404. * Gets the emitter node used with this set
  61405. */
  61406. readonly emitterNode: Nullable<TransformNode>;
  61407. /**
  61408. * Creates a new emitter mesh as a sphere
  61409. * @param options defines the options used to create the sphere
  61410. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61411. * @param scene defines the hosting scene
  61412. */
  61413. setEmitterAsSphere(options: {
  61414. diameter: number;
  61415. segments: number;
  61416. color: Color3;
  61417. }, renderingGroupId: number, scene: Scene): void;
  61418. /**
  61419. * Starts all particle systems of the set
  61420. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61421. */
  61422. start(emitter?: AbstractMesh): void;
  61423. /**
  61424. * Release all associated resources
  61425. */
  61426. dispose(): void;
  61427. /**
  61428. * Serialize the set into a JSON compatible object
  61429. * @returns a JSON compatible representation of the set
  61430. */
  61431. serialize(): any;
  61432. /**
  61433. * Parse a new ParticleSystemSet from a serialized source
  61434. * @param data defines a JSON compatible representation of the set
  61435. * @param scene defines the hosting scene
  61436. * @param gpu defines if we want GPU particles or CPU particles
  61437. * @returns a new ParticleSystemSet
  61438. */
  61439. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61440. }
  61441. }
  61442. declare module "babylonjs/Particles/particleHelper" {
  61443. import { Nullable } from "babylonjs/types";
  61444. import { Scene } from "babylonjs/scene";
  61445. import { Vector3 } from "babylonjs/Maths/math.vector";
  61446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61447. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61448. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61449. /**
  61450. * This class is made for on one-liner static method to help creating particle system set.
  61451. */
  61452. export class ParticleHelper {
  61453. /**
  61454. * Gets or sets base Assets URL
  61455. */
  61456. static BaseAssetsUrl: string;
  61457. /**
  61458. * Create a default particle system that you can tweak
  61459. * @param emitter defines the emitter to use
  61460. * @param capacity defines the system capacity (default is 500 particles)
  61461. * @param scene defines the hosting scene
  61462. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61463. * @returns the new Particle system
  61464. */
  61465. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61466. /**
  61467. * This is the main static method (one-liner) of this helper to create different particle systems
  61468. * @param type This string represents the type to the particle system to create
  61469. * @param scene The scene where the particle system should live
  61470. * @param gpu If the system will use gpu
  61471. * @returns the ParticleSystemSet created
  61472. */
  61473. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61474. /**
  61475. * Static function used to export a particle system to a ParticleSystemSet variable.
  61476. * Please note that the emitter shape is not exported
  61477. * @param systems defines the particle systems to export
  61478. * @returns the created particle system set
  61479. */
  61480. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61481. }
  61482. }
  61483. declare module "babylonjs/Particles/particleSystemComponent" {
  61484. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61485. import { Effect } from "babylonjs/Materials/effect";
  61486. import "babylonjs/Shaders/particles.vertex";
  61487. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61488. module "babylonjs/Engines/engine" {
  61489. interface Engine {
  61490. /**
  61491. * Create an effect to use with particle systems.
  61492. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61493. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61494. * @param uniformsNames defines a list of attribute names
  61495. * @param samplers defines an array of string used to represent textures
  61496. * @param defines defines the string containing the defines to use to compile the shaders
  61497. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61498. * @param onCompiled defines a function to call when the effect creation is successful
  61499. * @param onError defines a function to call when the effect creation has failed
  61500. * @returns the new Effect
  61501. */
  61502. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61503. }
  61504. }
  61505. module "babylonjs/Meshes/mesh" {
  61506. interface Mesh {
  61507. /**
  61508. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61509. * @returns an array of IParticleSystem
  61510. */
  61511. getEmittedParticleSystems(): IParticleSystem[];
  61512. /**
  61513. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61514. * @returns an array of IParticleSystem
  61515. */
  61516. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61517. }
  61518. }
  61519. /**
  61520. * @hidden
  61521. */
  61522. export var _IDoNeedToBeInTheBuild: number;
  61523. }
  61524. declare module "babylonjs/Particles/pointsCloudSystem" {
  61525. import { Color4 } from "babylonjs/Maths/math";
  61526. import { Mesh } from "babylonjs/Meshes/mesh";
  61527. import { Scene, IDisposable } from "babylonjs/scene";
  61528. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61529. /** Defines the 4 color options */
  61530. export enum PointColor {
  61531. /** color value */
  61532. Color = 2,
  61533. /** uv value */
  61534. UV = 1,
  61535. /** random value */
  61536. Random = 0,
  61537. /** stated value */
  61538. Stated = 3
  61539. }
  61540. /**
  61541. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61542. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61543. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61544. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61545. *
  61546. * Full documentation here : TO BE ENTERED
  61547. */
  61548. export class PointsCloudSystem implements IDisposable {
  61549. /**
  61550. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61551. * Example : var p = SPS.particles[i];
  61552. */
  61553. particles: CloudPoint[];
  61554. /**
  61555. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61556. */
  61557. nbParticles: number;
  61558. /**
  61559. * This a counter for your own usage. It's not set by any SPS functions.
  61560. */
  61561. counter: number;
  61562. /**
  61563. * The PCS name. This name is also given to the underlying mesh.
  61564. */
  61565. name: string;
  61566. /**
  61567. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61568. */
  61569. mesh: Mesh;
  61570. /**
  61571. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61572. * Please read :
  61573. */
  61574. vars: any;
  61575. /**
  61576. * @hidden
  61577. */
  61578. _size: number;
  61579. private _scene;
  61580. private _promises;
  61581. private _positions;
  61582. private _indices;
  61583. private _normals;
  61584. private _colors;
  61585. private _uvs;
  61586. private _indices32;
  61587. private _positions32;
  61588. private _colors32;
  61589. private _uvs32;
  61590. private _updatable;
  61591. private _isVisibilityBoxLocked;
  61592. private _alwaysVisible;
  61593. private _groups;
  61594. private _groupCounter;
  61595. private _computeParticleColor;
  61596. private _computeParticleTexture;
  61597. private _computeParticleRotation;
  61598. private _computeBoundingBox;
  61599. private _isReady;
  61600. /**
  61601. * Creates a PCS (Points Cloud System) object
  61602. * @param name (String) is the PCS name, this will be the underlying mesh name
  61603. * @param pointSize (number) is the size for each point
  61604. * @param scene (Scene) is the scene in which the PCS is added
  61605. * @param options defines the options of the PCS e.g.
  61606. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61607. */
  61608. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61609. updatable?: boolean;
  61610. });
  61611. /**
  61612. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61613. * If no points were added to the PCS, the returned mesh is just a single point.
  61614. * @returns a promise for the created mesh
  61615. */
  61616. buildMeshAsync(): Promise<Mesh>;
  61617. /**
  61618. * @hidden
  61619. */
  61620. private _buildMesh;
  61621. private _addParticle;
  61622. private _randomUnitVector;
  61623. private _getColorIndicesForCoord;
  61624. private _setPointsColorOrUV;
  61625. private _colorFromTexture;
  61626. private _calculateDensity;
  61627. /**
  61628. * Adds points to the PCS in random positions within a unit sphere
  61629. * @param nb (positive integer) the number of particles to be created from this model
  61630. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61631. * @returns the number of groups in the system
  61632. */
  61633. addPoints(nb: number, pointFunction?: any): number;
  61634. /**
  61635. * Adds points to the PCS from the surface of the model shape
  61636. * @param mesh is any Mesh object that will be used as a surface model for the points
  61637. * @param nb (positive integer) the number of particles to be created from this model
  61638. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61639. * @param color (color3) to be used when colorWith is stated
  61640. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61641. * @returns the number of groups in the system
  61642. */
  61643. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61644. /**
  61645. * Adds points to the PCS inside the model shape
  61646. * @param mesh is any Mesh object that will be used as a surface model for the points
  61647. * @param nb (positive integer) the number of particles to be created from this model
  61648. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61649. * @param color (color4) to be used when colorWith is stated
  61650. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61651. * @returns the number of groups in the system
  61652. */
  61653. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61654. /**
  61655. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61656. * This method calls `updateParticle()` for each particle of the SPS.
  61657. * For an animated SPS, it is usually called within the render loop.
  61658. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61659. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61660. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61661. * @returns the PCS.
  61662. */
  61663. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61664. /**
  61665. * Disposes the PCS.
  61666. */
  61667. dispose(): void;
  61668. /**
  61669. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61670. * doc :
  61671. * @returns the PCS.
  61672. */
  61673. refreshVisibleSize(): PointsCloudSystem;
  61674. /**
  61675. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61676. * @param size the size (float) of the visibility box
  61677. * note : this doesn't lock the PCS mesh bounding box.
  61678. * doc :
  61679. */
  61680. setVisibilityBox(size: number): void;
  61681. /**
  61682. * Gets whether the PCS is always visible or not
  61683. * doc :
  61684. */
  61685. /**
  61686. * Sets the PCS as always visible or not
  61687. * doc :
  61688. */
  61689. isAlwaysVisible: boolean;
  61690. /**
  61691. * Tells to `setParticles()` to compute the particle rotations or not
  61692. * Default value : false. The PCS is faster when it's set to false
  61693. * Note : particle rotations are only applied to parent particles
  61694. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61695. */
  61696. computeParticleRotation: boolean;
  61697. /**
  61698. * Tells to `setParticles()` to compute the particle colors or not.
  61699. * Default value : true. The PCS is faster when it's set to false.
  61700. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61701. */
  61702. /**
  61703. * Gets if `setParticles()` computes the particle colors or not.
  61704. * Default value : false. The PCS is faster when it's set to false.
  61705. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61706. */
  61707. computeParticleColor: boolean;
  61708. /**
  61709. * Gets if `setParticles()` computes the particle textures or not.
  61710. * Default value : false. The PCS is faster when it's set to false.
  61711. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61712. */
  61713. computeParticleTexture: boolean;
  61714. /**
  61715. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61716. */
  61717. /**
  61718. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61719. */
  61720. computeBoundingBox: boolean;
  61721. /**
  61722. * This function does nothing. It may be overwritten to set all the particle first values.
  61723. * The PCS doesn't call this function, you may have to call it by your own.
  61724. * doc :
  61725. */
  61726. initParticles(): void;
  61727. /**
  61728. * This function does nothing. It may be overwritten to recycle a particle
  61729. * The PCS doesn't call this function, you can to call it
  61730. * doc :
  61731. * @param particle The particle to recycle
  61732. * @returns the recycled particle
  61733. */
  61734. recycleParticle(particle: CloudPoint): CloudPoint;
  61735. /**
  61736. * Updates a particle : this function should be overwritten by the user.
  61737. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61738. * doc :
  61739. * @example : just set a particle position or velocity and recycle conditions
  61740. * @param particle The particle to update
  61741. * @returns the updated particle
  61742. */
  61743. updateParticle(particle: CloudPoint): CloudPoint;
  61744. /**
  61745. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61746. * This does nothing and may be overwritten by the user.
  61747. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61749. * @param update the boolean update value actually passed to setParticles()
  61750. */
  61751. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61752. /**
  61753. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61754. * This will be passed three parameters.
  61755. * This does nothing and may be overwritten by the user.
  61756. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61757. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61758. * @param update the boolean update value actually passed to setParticles()
  61759. */
  61760. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61761. }
  61762. }
  61763. declare module "babylonjs/Particles/cloudPoint" {
  61764. import { Nullable } from "babylonjs/types";
  61765. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61766. import { Mesh } from "babylonjs/Meshes/mesh";
  61767. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61768. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61769. /**
  61770. * Represents one particle of a points cloud system.
  61771. */
  61772. export class CloudPoint {
  61773. /**
  61774. * particle global index
  61775. */
  61776. idx: number;
  61777. /**
  61778. * The color of the particle
  61779. */
  61780. color: Nullable<Color4>;
  61781. /**
  61782. * The world space position of the particle.
  61783. */
  61784. position: Vector3;
  61785. /**
  61786. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61787. */
  61788. rotation: Vector3;
  61789. /**
  61790. * The world space rotation quaternion of the particle.
  61791. */
  61792. rotationQuaternion: Nullable<Quaternion>;
  61793. /**
  61794. * The uv of the particle.
  61795. */
  61796. uv: Nullable<Vector2>;
  61797. /**
  61798. * The current speed of the particle.
  61799. */
  61800. velocity: Vector3;
  61801. /**
  61802. * The pivot point in the particle local space.
  61803. */
  61804. pivot: Vector3;
  61805. /**
  61806. * Must the particle be translated from its pivot point in its local space ?
  61807. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61808. * Default : false
  61809. */
  61810. translateFromPivot: boolean;
  61811. /**
  61812. * Index of this particle in the global "positions" array (Internal use)
  61813. * @hidden
  61814. */
  61815. _pos: number;
  61816. /**
  61817. * @hidden Index of this particle in the global "indices" array (Internal use)
  61818. */
  61819. _ind: number;
  61820. /**
  61821. * Group this particle belongs to
  61822. */
  61823. _group: PointsGroup;
  61824. /**
  61825. * Group id of this particle
  61826. */
  61827. groupId: number;
  61828. /**
  61829. * Index of the particle in its group id (Internal use)
  61830. */
  61831. idxInGroup: number;
  61832. /**
  61833. * @hidden Particle BoundingInfo object (Internal use)
  61834. */
  61835. _boundingInfo: BoundingInfo;
  61836. /**
  61837. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61838. */
  61839. _pcs: PointsCloudSystem;
  61840. /**
  61841. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61842. */
  61843. _stillInvisible: boolean;
  61844. /**
  61845. * @hidden Last computed particle rotation matrix
  61846. */
  61847. _rotationMatrix: number[];
  61848. /**
  61849. * Parent particle Id, if any.
  61850. * Default null.
  61851. */
  61852. parentId: Nullable<number>;
  61853. /**
  61854. * @hidden Internal global position in the PCS.
  61855. */
  61856. _globalPosition: Vector3;
  61857. /**
  61858. * Creates a Point Cloud object.
  61859. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61860. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61861. * @param group (PointsGroup) is the group the particle belongs to
  61862. * @param groupId (integer) is the group identifier in the PCS.
  61863. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61864. * @param pcs defines the PCS it is associated to
  61865. */
  61866. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61867. /**
  61868. * get point size
  61869. */
  61870. /**
  61871. * Set point size
  61872. */
  61873. size: Vector3;
  61874. /**
  61875. * Legacy support, changed quaternion to rotationQuaternion
  61876. */
  61877. /**
  61878. * Legacy support, changed quaternion to rotationQuaternion
  61879. */
  61880. quaternion: Nullable<Quaternion>;
  61881. /**
  61882. * Returns a boolean. True if the particle intersects a mesh, else false
  61883. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61884. * @param target is the object (point or mesh) what the intersection is computed against
  61885. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61886. * @returns true if it intersects
  61887. */
  61888. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61889. /**
  61890. * get the rotation matrix of the particle
  61891. * @hidden
  61892. */
  61893. getRotationMatrix(m: Matrix): void;
  61894. }
  61895. /**
  61896. * Represents a group of points in a points cloud system
  61897. * * PCS internal tool, don't use it manually.
  61898. */
  61899. export class PointsGroup {
  61900. /**
  61901. * The group id
  61902. * @hidden
  61903. */
  61904. groupID: number;
  61905. /**
  61906. * image data for group (internal use)
  61907. * @hidden
  61908. */
  61909. _groupImageData: Nullable<ArrayBufferView>;
  61910. /**
  61911. * Image Width (internal use)
  61912. * @hidden
  61913. */
  61914. _groupImgWidth: number;
  61915. /**
  61916. * Image Height (internal use)
  61917. * @hidden
  61918. */
  61919. _groupImgHeight: number;
  61920. /**
  61921. * Custom position function (internal use)
  61922. * @hidden
  61923. */
  61924. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61925. /**
  61926. * density per facet for surface points
  61927. * @hidden
  61928. */
  61929. _groupDensity: number[];
  61930. /**
  61931. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61932. * PCS internal tool, don't use it manually.
  61933. * @hidden
  61934. */
  61935. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61936. }
  61937. }
  61938. declare module "babylonjs/Particles/index" {
  61939. export * from "babylonjs/Particles/baseParticleSystem";
  61940. export * from "babylonjs/Particles/EmitterTypes/index";
  61941. export * from "babylonjs/Particles/gpuParticleSystem";
  61942. export * from "babylonjs/Particles/IParticleSystem";
  61943. export * from "babylonjs/Particles/particle";
  61944. export * from "babylonjs/Particles/particleHelper";
  61945. export * from "babylonjs/Particles/particleSystem";
  61946. export * from "babylonjs/Particles/particleSystemComponent";
  61947. export * from "babylonjs/Particles/particleSystemSet";
  61948. export * from "babylonjs/Particles/solidParticle";
  61949. export * from "babylonjs/Particles/solidParticleSystem";
  61950. export * from "babylonjs/Particles/cloudPoint";
  61951. export * from "babylonjs/Particles/pointsCloudSystem";
  61952. export * from "babylonjs/Particles/subEmitter";
  61953. }
  61954. declare module "babylonjs/Physics/physicsEngineComponent" {
  61955. import { Nullable } from "babylonjs/types";
  61956. import { Observable, Observer } from "babylonjs/Misc/observable";
  61957. import { Vector3 } from "babylonjs/Maths/math.vector";
  61958. import { Mesh } from "babylonjs/Meshes/mesh";
  61959. import { ISceneComponent } from "babylonjs/sceneComponent";
  61960. import { Scene } from "babylonjs/scene";
  61961. import { Node } from "babylonjs/node";
  61962. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61963. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61964. module "babylonjs/scene" {
  61965. interface Scene {
  61966. /** @hidden (Backing field) */
  61967. _physicsEngine: Nullable<IPhysicsEngine>;
  61968. /**
  61969. * Gets the current physics engine
  61970. * @returns a IPhysicsEngine or null if none attached
  61971. */
  61972. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61973. /**
  61974. * Enables physics to the current scene
  61975. * @param gravity defines the scene's gravity for the physics engine
  61976. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61977. * @return a boolean indicating if the physics engine was initialized
  61978. */
  61979. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61980. /**
  61981. * Disables and disposes the physics engine associated with the scene
  61982. */
  61983. disablePhysicsEngine(): void;
  61984. /**
  61985. * Gets a boolean indicating if there is an active physics engine
  61986. * @returns a boolean indicating if there is an active physics engine
  61987. */
  61988. isPhysicsEnabled(): boolean;
  61989. /**
  61990. * Deletes a physics compound impostor
  61991. * @param compound defines the compound to delete
  61992. */
  61993. deleteCompoundImpostor(compound: any): void;
  61994. /**
  61995. * An event triggered when physic simulation is about to be run
  61996. */
  61997. onBeforePhysicsObservable: Observable<Scene>;
  61998. /**
  61999. * An event triggered when physic simulation has been done
  62000. */
  62001. onAfterPhysicsObservable: Observable<Scene>;
  62002. }
  62003. }
  62004. module "babylonjs/Meshes/abstractMesh" {
  62005. interface AbstractMesh {
  62006. /** @hidden */
  62007. _physicsImpostor: Nullable<PhysicsImpostor>;
  62008. /**
  62009. * Gets or sets impostor used for physic simulation
  62010. * @see http://doc.babylonjs.com/features/physics_engine
  62011. */
  62012. physicsImpostor: Nullable<PhysicsImpostor>;
  62013. /**
  62014. * Gets the current physics impostor
  62015. * @see http://doc.babylonjs.com/features/physics_engine
  62016. * @returns a physics impostor or null
  62017. */
  62018. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62019. /** Apply a physic impulse to the mesh
  62020. * @param force defines the force to apply
  62021. * @param contactPoint defines where to apply the force
  62022. * @returns the current mesh
  62023. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62024. */
  62025. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62026. /**
  62027. * Creates a physic joint between two meshes
  62028. * @param otherMesh defines the other mesh to use
  62029. * @param pivot1 defines the pivot to use on this mesh
  62030. * @param pivot2 defines the pivot to use on the other mesh
  62031. * @param options defines additional options (can be plugin dependent)
  62032. * @returns the current mesh
  62033. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62034. */
  62035. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62036. /** @hidden */
  62037. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62038. }
  62039. }
  62040. /**
  62041. * Defines the physics engine scene component responsible to manage a physics engine
  62042. */
  62043. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62044. /**
  62045. * The component name helpful to identify the component in the list of scene components.
  62046. */
  62047. readonly name: string;
  62048. /**
  62049. * The scene the component belongs to.
  62050. */
  62051. scene: Scene;
  62052. /**
  62053. * Creates a new instance of the component for the given scene
  62054. * @param scene Defines the scene to register the component in
  62055. */
  62056. constructor(scene: Scene);
  62057. /**
  62058. * Registers the component in a given scene
  62059. */
  62060. register(): void;
  62061. /**
  62062. * Rebuilds the elements related to this component in case of
  62063. * context lost for instance.
  62064. */
  62065. rebuild(): void;
  62066. /**
  62067. * Disposes the component and the associated ressources
  62068. */
  62069. dispose(): void;
  62070. }
  62071. }
  62072. declare module "babylonjs/Physics/physicsHelper" {
  62073. import { Nullable } from "babylonjs/types";
  62074. import { Vector3 } from "babylonjs/Maths/math.vector";
  62075. import { Mesh } from "babylonjs/Meshes/mesh";
  62076. import { Scene } from "babylonjs/scene";
  62077. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62078. /**
  62079. * A helper for physics simulations
  62080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62081. */
  62082. export class PhysicsHelper {
  62083. private _scene;
  62084. private _physicsEngine;
  62085. /**
  62086. * Initializes the Physics helper
  62087. * @param scene Babylon.js scene
  62088. */
  62089. constructor(scene: Scene);
  62090. /**
  62091. * Applies a radial explosion impulse
  62092. * @param origin the origin of the explosion
  62093. * @param radiusOrEventOptions the radius or the options of radial explosion
  62094. * @param strength the explosion strength
  62095. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62096. * @returns A physics radial explosion event, or null
  62097. */
  62098. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62099. /**
  62100. * Applies a radial explosion force
  62101. * @param origin the origin of the explosion
  62102. * @param radiusOrEventOptions the radius or the options of radial explosion
  62103. * @param strength the explosion strength
  62104. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62105. * @returns A physics radial explosion event, or null
  62106. */
  62107. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62108. /**
  62109. * Creates a gravitational field
  62110. * @param origin the origin of the explosion
  62111. * @param radiusOrEventOptions the radius or the options of radial explosion
  62112. * @param strength the explosion strength
  62113. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62114. * @returns A physics gravitational field event, or null
  62115. */
  62116. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62117. /**
  62118. * Creates a physics updraft event
  62119. * @param origin the origin of the updraft
  62120. * @param radiusOrEventOptions the radius or the options of the updraft
  62121. * @param strength the strength of the updraft
  62122. * @param height the height of the updraft
  62123. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62124. * @returns A physics updraft event, or null
  62125. */
  62126. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62127. /**
  62128. * Creates a physics vortex event
  62129. * @param origin the of the vortex
  62130. * @param radiusOrEventOptions the radius or the options of the vortex
  62131. * @param strength the strength of the vortex
  62132. * @param height the height of the vortex
  62133. * @returns a Physics vortex event, or null
  62134. * A physics vortex event or null
  62135. */
  62136. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62137. }
  62138. /**
  62139. * Represents a physics radial explosion event
  62140. */
  62141. class PhysicsRadialExplosionEvent {
  62142. private _scene;
  62143. private _options;
  62144. private _sphere;
  62145. private _dataFetched;
  62146. /**
  62147. * Initializes a radial explosioin event
  62148. * @param _scene BabylonJS scene
  62149. * @param _options The options for the vortex event
  62150. */
  62151. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62152. /**
  62153. * Returns the data related to the radial explosion event (sphere).
  62154. * @returns The radial explosion event data
  62155. */
  62156. getData(): PhysicsRadialExplosionEventData;
  62157. /**
  62158. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62159. * @param impostor A physics imposter
  62160. * @param origin the origin of the explosion
  62161. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62162. */
  62163. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62164. /**
  62165. * Triggers affecterd impostors callbacks
  62166. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62167. */
  62168. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62169. /**
  62170. * Disposes the sphere.
  62171. * @param force Specifies if the sphere should be disposed by force
  62172. */
  62173. dispose(force?: boolean): void;
  62174. /*** Helpers ***/
  62175. private _prepareSphere;
  62176. private _intersectsWithSphere;
  62177. }
  62178. /**
  62179. * Represents a gravitational field event
  62180. */
  62181. class PhysicsGravitationalFieldEvent {
  62182. private _physicsHelper;
  62183. private _scene;
  62184. private _origin;
  62185. private _options;
  62186. private _tickCallback;
  62187. private _sphere;
  62188. private _dataFetched;
  62189. /**
  62190. * Initializes the physics gravitational field event
  62191. * @param _physicsHelper A physics helper
  62192. * @param _scene BabylonJS scene
  62193. * @param _origin The origin position of the gravitational field event
  62194. * @param _options The options for the vortex event
  62195. */
  62196. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62197. /**
  62198. * Returns the data related to the gravitational field event (sphere).
  62199. * @returns A gravitational field event
  62200. */
  62201. getData(): PhysicsGravitationalFieldEventData;
  62202. /**
  62203. * Enables the gravitational field.
  62204. */
  62205. enable(): void;
  62206. /**
  62207. * Disables the gravitational field.
  62208. */
  62209. disable(): void;
  62210. /**
  62211. * Disposes the sphere.
  62212. * @param force The force to dispose from the gravitational field event
  62213. */
  62214. dispose(force?: boolean): void;
  62215. private _tick;
  62216. }
  62217. /**
  62218. * Represents a physics updraft event
  62219. */
  62220. class PhysicsUpdraftEvent {
  62221. private _scene;
  62222. private _origin;
  62223. private _options;
  62224. private _physicsEngine;
  62225. private _originTop;
  62226. private _originDirection;
  62227. private _tickCallback;
  62228. private _cylinder;
  62229. private _cylinderPosition;
  62230. private _dataFetched;
  62231. /**
  62232. * Initializes the physics updraft event
  62233. * @param _scene BabylonJS scene
  62234. * @param _origin The origin position of the updraft
  62235. * @param _options The options for the updraft event
  62236. */
  62237. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62238. /**
  62239. * Returns the data related to the updraft event (cylinder).
  62240. * @returns A physics updraft event
  62241. */
  62242. getData(): PhysicsUpdraftEventData;
  62243. /**
  62244. * Enables the updraft.
  62245. */
  62246. enable(): void;
  62247. /**
  62248. * Disables the updraft.
  62249. */
  62250. disable(): void;
  62251. /**
  62252. * Disposes the cylinder.
  62253. * @param force Specifies if the updraft should be disposed by force
  62254. */
  62255. dispose(force?: boolean): void;
  62256. private getImpostorHitData;
  62257. private _tick;
  62258. /*** Helpers ***/
  62259. private _prepareCylinder;
  62260. private _intersectsWithCylinder;
  62261. }
  62262. /**
  62263. * Represents a physics vortex event
  62264. */
  62265. class PhysicsVortexEvent {
  62266. private _scene;
  62267. private _origin;
  62268. private _options;
  62269. private _physicsEngine;
  62270. private _originTop;
  62271. private _tickCallback;
  62272. private _cylinder;
  62273. private _cylinderPosition;
  62274. private _dataFetched;
  62275. /**
  62276. * Initializes the physics vortex event
  62277. * @param _scene The BabylonJS scene
  62278. * @param _origin The origin position of the vortex
  62279. * @param _options The options for the vortex event
  62280. */
  62281. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62282. /**
  62283. * Returns the data related to the vortex event (cylinder).
  62284. * @returns The physics vortex event data
  62285. */
  62286. getData(): PhysicsVortexEventData;
  62287. /**
  62288. * Enables the vortex.
  62289. */
  62290. enable(): void;
  62291. /**
  62292. * Disables the cortex.
  62293. */
  62294. disable(): void;
  62295. /**
  62296. * Disposes the sphere.
  62297. * @param force
  62298. */
  62299. dispose(force?: boolean): void;
  62300. private getImpostorHitData;
  62301. private _tick;
  62302. /*** Helpers ***/
  62303. private _prepareCylinder;
  62304. private _intersectsWithCylinder;
  62305. }
  62306. /**
  62307. * Options fot the radial explosion event
  62308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62309. */
  62310. export class PhysicsRadialExplosionEventOptions {
  62311. /**
  62312. * The radius of the sphere for the radial explosion.
  62313. */
  62314. radius: number;
  62315. /**
  62316. * The strenth of the explosion.
  62317. */
  62318. strength: number;
  62319. /**
  62320. * The strenght of the force in correspondence to the distance of the affected object
  62321. */
  62322. falloff: PhysicsRadialImpulseFalloff;
  62323. /**
  62324. * Sphere options for the radial explosion.
  62325. */
  62326. sphere: {
  62327. segments: number;
  62328. diameter: number;
  62329. };
  62330. /**
  62331. * Sphere options for the radial explosion.
  62332. */
  62333. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62334. }
  62335. /**
  62336. * Options fot the updraft event
  62337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62338. */
  62339. export class PhysicsUpdraftEventOptions {
  62340. /**
  62341. * The radius of the cylinder for the vortex
  62342. */
  62343. radius: number;
  62344. /**
  62345. * The strenth of the updraft.
  62346. */
  62347. strength: number;
  62348. /**
  62349. * The height of the cylinder for the updraft.
  62350. */
  62351. height: number;
  62352. /**
  62353. * The mode for the the updraft.
  62354. */
  62355. updraftMode: PhysicsUpdraftMode;
  62356. }
  62357. /**
  62358. * Options fot the vortex event
  62359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62360. */
  62361. export class PhysicsVortexEventOptions {
  62362. /**
  62363. * The radius of the cylinder for the vortex
  62364. */
  62365. radius: number;
  62366. /**
  62367. * The strenth of the vortex.
  62368. */
  62369. strength: number;
  62370. /**
  62371. * The height of the cylinder for the vortex.
  62372. */
  62373. height: number;
  62374. /**
  62375. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62376. */
  62377. centripetalForceThreshold: number;
  62378. /**
  62379. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62380. */
  62381. centripetalForceMultiplier: number;
  62382. /**
  62383. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62384. */
  62385. centrifugalForceMultiplier: number;
  62386. /**
  62387. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62388. */
  62389. updraftForceMultiplier: number;
  62390. }
  62391. /**
  62392. * The strenght of the force in correspondence to the distance of the affected object
  62393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62394. */
  62395. export enum PhysicsRadialImpulseFalloff {
  62396. /** Defines that impulse is constant in strength across it's whole radius */
  62397. Constant = 0,
  62398. /** Defines that impulse gets weaker if it's further from the origin */
  62399. Linear = 1
  62400. }
  62401. /**
  62402. * The strength of the force in correspondence to the distance of the affected object
  62403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62404. */
  62405. export enum PhysicsUpdraftMode {
  62406. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62407. Center = 0,
  62408. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62409. Perpendicular = 1
  62410. }
  62411. /**
  62412. * Interface for a physics hit data
  62413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62414. */
  62415. export interface PhysicsHitData {
  62416. /**
  62417. * The force applied at the contact point
  62418. */
  62419. force: Vector3;
  62420. /**
  62421. * The contact point
  62422. */
  62423. contactPoint: Vector3;
  62424. /**
  62425. * The distance from the origin to the contact point
  62426. */
  62427. distanceFromOrigin: number;
  62428. }
  62429. /**
  62430. * Interface for radial explosion event data
  62431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62432. */
  62433. export interface PhysicsRadialExplosionEventData {
  62434. /**
  62435. * A sphere used for the radial explosion event
  62436. */
  62437. sphere: Mesh;
  62438. }
  62439. /**
  62440. * Interface for gravitational field event data
  62441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62442. */
  62443. export interface PhysicsGravitationalFieldEventData {
  62444. /**
  62445. * A sphere mesh used for the gravitational field event
  62446. */
  62447. sphere: Mesh;
  62448. }
  62449. /**
  62450. * Interface for updraft event data
  62451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62452. */
  62453. export interface PhysicsUpdraftEventData {
  62454. /**
  62455. * A cylinder used for the updraft event
  62456. */
  62457. cylinder: Mesh;
  62458. }
  62459. /**
  62460. * Interface for vortex event data
  62461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62462. */
  62463. export interface PhysicsVortexEventData {
  62464. /**
  62465. * A cylinder used for the vortex event
  62466. */
  62467. cylinder: Mesh;
  62468. }
  62469. /**
  62470. * Interface for an affected physics impostor
  62471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62472. */
  62473. export interface PhysicsAffectedImpostorWithData {
  62474. /**
  62475. * The impostor affected by the effect
  62476. */
  62477. impostor: PhysicsImpostor;
  62478. /**
  62479. * The data about the hit/horce from the explosion
  62480. */
  62481. hitData: PhysicsHitData;
  62482. }
  62483. }
  62484. declare module "babylonjs/Physics/Plugins/index" {
  62485. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62486. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62487. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62488. }
  62489. declare module "babylonjs/Physics/index" {
  62490. export * from "babylonjs/Physics/IPhysicsEngine";
  62491. export * from "babylonjs/Physics/physicsEngine";
  62492. export * from "babylonjs/Physics/physicsEngineComponent";
  62493. export * from "babylonjs/Physics/physicsHelper";
  62494. export * from "babylonjs/Physics/physicsImpostor";
  62495. export * from "babylonjs/Physics/physicsJoint";
  62496. export * from "babylonjs/Physics/Plugins/index";
  62497. }
  62498. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62499. /** @hidden */
  62500. export var blackAndWhitePixelShader: {
  62501. name: string;
  62502. shader: string;
  62503. };
  62504. }
  62505. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62506. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62507. import { Camera } from "babylonjs/Cameras/camera";
  62508. import { Engine } from "babylonjs/Engines/engine";
  62509. import "babylonjs/Shaders/blackAndWhite.fragment";
  62510. /**
  62511. * Post process used to render in black and white
  62512. */
  62513. export class BlackAndWhitePostProcess extends PostProcess {
  62514. /**
  62515. * Linear about to convert he result to black and white (default: 1)
  62516. */
  62517. degree: number;
  62518. /**
  62519. * Creates a black and white post process
  62520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62521. * @param name The name of the effect.
  62522. * @param options The required width/height ratio to downsize to before computing the render pass.
  62523. * @param camera The camera to apply the render pass to.
  62524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62525. * @param engine The engine which the post process will be applied. (default: current engine)
  62526. * @param reusable If the post process can be reused on the same frame. (default: false)
  62527. */
  62528. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62529. }
  62530. }
  62531. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62532. import { Nullable } from "babylonjs/types";
  62533. import { Camera } from "babylonjs/Cameras/camera";
  62534. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62535. import { Engine } from "babylonjs/Engines/engine";
  62536. /**
  62537. * This represents a set of one or more post processes in Babylon.
  62538. * A post process can be used to apply a shader to a texture after it is rendered.
  62539. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62540. */
  62541. export class PostProcessRenderEffect {
  62542. private _postProcesses;
  62543. private _getPostProcesses;
  62544. private _singleInstance;
  62545. private _cameras;
  62546. private _indicesForCamera;
  62547. /**
  62548. * Name of the effect
  62549. * @hidden
  62550. */
  62551. _name: string;
  62552. /**
  62553. * Instantiates a post process render effect.
  62554. * A post process can be used to apply a shader to a texture after it is rendered.
  62555. * @param engine The engine the effect is tied to
  62556. * @param name The name of the effect
  62557. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62558. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62559. */
  62560. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62561. /**
  62562. * Checks if all the post processes in the effect are supported.
  62563. */
  62564. readonly isSupported: boolean;
  62565. /**
  62566. * Updates the current state of the effect
  62567. * @hidden
  62568. */
  62569. _update(): void;
  62570. /**
  62571. * Attaches the effect on cameras
  62572. * @param cameras The camera to attach to.
  62573. * @hidden
  62574. */
  62575. _attachCameras(cameras: Camera): void;
  62576. /**
  62577. * Attaches the effect on cameras
  62578. * @param cameras The camera to attach to.
  62579. * @hidden
  62580. */
  62581. _attachCameras(cameras: Camera[]): void;
  62582. /**
  62583. * Detaches the effect on cameras
  62584. * @param cameras The camera to detatch from.
  62585. * @hidden
  62586. */
  62587. _detachCameras(cameras: Camera): void;
  62588. /**
  62589. * Detatches the effect on cameras
  62590. * @param cameras The camera to detatch from.
  62591. * @hidden
  62592. */
  62593. _detachCameras(cameras: Camera[]): void;
  62594. /**
  62595. * Enables the effect on given cameras
  62596. * @param cameras The camera to enable.
  62597. * @hidden
  62598. */
  62599. _enable(cameras: Camera): void;
  62600. /**
  62601. * Enables the effect on given cameras
  62602. * @param cameras The camera to enable.
  62603. * @hidden
  62604. */
  62605. _enable(cameras: Nullable<Camera[]>): void;
  62606. /**
  62607. * Disables the effect on the given cameras
  62608. * @param cameras The camera to disable.
  62609. * @hidden
  62610. */
  62611. _disable(cameras: Camera): void;
  62612. /**
  62613. * Disables the effect on the given cameras
  62614. * @param cameras The camera to disable.
  62615. * @hidden
  62616. */
  62617. _disable(cameras: Nullable<Camera[]>): void;
  62618. /**
  62619. * Gets a list of the post processes contained in the effect.
  62620. * @param camera The camera to get the post processes on.
  62621. * @returns The list of the post processes in the effect.
  62622. */
  62623. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62624. }
  62625. }
  62626. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62627. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62628. /** @hidden */
  62629. export var extractHighlightsPixelShader: {
  62630. name: string;
  62631. shader: string;
  62632. };
  62633. }
  62634. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62635. import { Nullable } from "babylonjs/types";
  62636. import { Camera } from "babylonjs/Cameras/camera";
  62637. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62638. import { Engine } from "babylonjs/Engines/engine";
  62639. import "babylonjs/Shaders/extractHighlights.fragment";
  62640. /**
  62641. * 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.
  62642. */
  62643. export class ExtractHighlightsPostProcess extends PostProcess {
  62644. /**
  62645. * The luminance threshold, pixels below this value will be set to black.
  62646. */
  62647. threshold: number;
  62648. /** @hidden */
  62649. _exposure: number;
  62650. /**
  62651. * Post process which has the input texture to be used when performing highlight extraction
  62652. * @hidden
  62653. */
  62654. _inputPostProcess: Nullable<PostProcess>;
  62655. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62656. }
  62657. }
  62658. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62659. /** @hidden */
  62660. export var bloomMergePixelShader: {
  62661. name: string;
  62662. shader: string;
  62663. };
  62664. }
  62665. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62667. import { Nullable } from "babylonjs/types";
  62668. import { Engine } from "babylonjs/Engines/engine";
  62669. import { Camera } from "babylonjs/Cameras/camera";
  62670. import "babylonjs/Shaders/bloomMerge.fragment";
  62671. /**
  62672. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62673. */
  62674. export class BloomMergePostProcess extends PostProcess {
  62675. /** Weight of the bloom to be added to the original input. */
  62676. weight: number;
  62677. /**
  62678. * Creates a new instance of @see BloomMergePostProcess
  62679. * @param name The name of the effect.
  62680. * @param originalFromInput Post process which's input will be used for the merge.
  62681. * @param blurred Blurred highlights post process which's output will be used.
  62682. * @param weight Weight of the bloom to be added to the original input.
  62683. * @param options The required width/height ratio to downsize to before computing the render pass.
  62684. * @param camera The camera to apply the render pass to.
  62685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62686. * @param engine The engine which the post process will be applied. (default: current engine)
  62687. * @param reusable If the post process can be reused on the same frame. (default: false)
  62688. * @param textureType Type of textures used when performing the post process. (default: 0)
  62689. * @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)
  62690. */
  62691. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62692. /** Weight of the bloom to be added to the original input. */
  62693. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62694. }
  62695. }
  62696. declare module "babylonjs/PostProcesses/bloomEffect" {
  62697. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62698. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62699. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62700. import { Camera } from "babylonjs/Cameras/camera";
  62701. import { Scene } from "babylonjs/scene";
  62702. /**
  62703. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62704. */
  62705. export class BloomEffect extends PostProcessRenderEffect {
  62706. private bloomScale;
  62707. /**
  62708. * @hidden Internal
  62709. */
  62710. _effects: Array<PostProcess>;
  62711. /**
  62712. * @hidden Internal
  62713. */
  62714. _downscale: ExtractHighlightsPostProcess;
  62715. private _blurX;
  62716. private _blurY;
  62717. private _merge;
  62718. /**
  62719. * The luminance threshold to find bright areas of the image to bloom.
  62720. */
  62721. threshold: number;
  62722. /**
  62723. * The strength of the bloom.
  62724. */
  62725. weight: number;
  62726. /**
  62727. * Specifies the size of the bloom blur kernel, relative to the final output size
  62728. */
  62729. kernel: number;
  62730. /**
  62731. * Creates a new instance of @see BloomEffect
  62732. * @param scene The scene the effect belongs to.
  62733. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62734. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62735. * @param bloomWeight The the strength of bloom.
  62736. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62737. * @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)
  62738. */
  62739. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62740. /**
  62741. * Disposes each of the internal effects for a given camera.
  62742. * @param camera The camera to dispose the effect on.
  62743. */
  62744. disposeEffects(camera: Camera): void;
  62745. /**
  62746. * @hidden Internal
  62747. */
  62748. _updateEffects(): void;
  62749. /**
  62750. * Internal
  62751. * @returns if all the contained post processes are ready.
  62752. * @hidden
  62753. */
  62754. _isReady(): boolean;
  62755. }
  62756. }
  62757. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62758. /** @hidden */
  62759. export var chromaticAberrationPixelShader: {
  62760. name: string;
  62761. shader: string;
  62762. };
  62763. }
  62764. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62765. import { Vector2 } from "babylonjs/Maths/math.vector";
  62766. import { Nullable } from "babylonjs/types";
  62767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62768. import { Camera } from "babylonjs/Cameras/camera";
  62769. import { Engine } from "babylonjs/Engines/engine";
  62770. import "babylonjs/Shaders/chromaticAberration.fragment";
  62771. /**
  62772. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62773. */
  62774. export class ChromaticAberrationPostProcess extends PostProcess {
  62775. /**
  62776. * The amount of seperation of rgb channels (default: 30)
  62777. */
  62778. aberrationAmount: number;
  62779. /**
  62780. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62781. */
  62782. radialIntensity: number;
  62783. /**
  62784. * 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))
  62785. */
  62786. direction: Vector2;
  62787. /**
  62788. * 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))
  62789. */
  62790. centerPosition: Vector2;
  62791. /**
  62792. * Creates a new instance ChromaticAberrationPostProcess
  62793. * @param name The name of the effect.
  62794. * @param screenWidth The width of the screen to apply the effect on.
  62795. * @param screenHeight The height of the screen to apply the effect on.
  62796. * @param options The required width/height ratio to downsize to before computing the render pass.
  62797. * @param camera The camera to apply the render pass to.
  62798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62799. * @param engine The engine which the post process will be applied. (default: current engine)
  62800. * @param reusable If the post process can be reused on the same frame. (default: false)
  62801. * @param textureType Type of textures used when performing the post process. (default: 0)
  62802. * @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)
  62803. */
  62804. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62805. }
  62806. }
  62807. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62808. /** @hidden */
  62809. export var circleOfConfusionPixelShader: {
  62810. name: string;
  62811. shader: string;
  62812. };
  62813. }
  62814. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62815. import { Nullable } from "babylonjs/types";
  62816. import { Engine } from "babylonjs/Engines/engine";
  62817. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62818. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62819. import { Camera } from "babylonjs/Cameras/camera";
  62820. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62821. /**
  62822. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62823. */
  62824. export class CircleOfConfusionPostProcess extends PostProcess {
  62825. /**
  62826. * 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.
  62827. */
  62828. lensSize: number;
  62829. /**
  62830. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62831. */
  62832. fStop: number;
  62833. /**
  62834. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62835. */
  62836. focusDistance: number;
  62837. /**
  62838. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62839. */
  62840. focalLength: number;
  62841. private _depthTexture;
  62842. /**
  62843. * Creates a new instance CircleOfConfusionPostProcess
  62844. * @param name The name of the effect.
  62845. * @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.
  62846. * @param options The required width/height ratio to downsize to before computing the render pass.
  62847. * @param camera The camera to apply the render pass to.
  62848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62849. * @param engine The engine which the post process will be applied. (default: current engine)
  62850. * @param reusable If the post process can be reused on the same frame. (default: false)
  62851. * @param textureType Type of textures used when performing the post process. (default: 0)
  62852. * @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)
  62853. */
  62854. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62855. /**
  62856. * 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.
  62857. */
  62858. depthTexture: RenderTargetTexture;
  62859. }
  62860. }
  62861. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62862. /** @hidden */
  62863. export var colorCorrectionPixelShader: {
  62864. name: string;
  62865. shader: string;
  62866. };
  62867. }
  62868. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62869. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62870. import { Engine } from "babylonjs/Engines/engine";
  62871. import { Camera } from "babylonjs/Cameras/camera";
  62872. import "babylonjs/Shaders/colorCorrection.fragment";
  62873. /**
  62874. *
  62875. * This post-process allows the modification of rendered colors by using
  62876. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62877. *
  62878. * The object needs to be provided an url to a texture containing the color
  62879. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62880. * Use an image editing software to tweak the LUT to match your needs.
  62881. *
  62882. * For an example of a color LUT, see here:
  62883. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62884. * For explanations on color grading, see here:
  62885. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62886. *
  62887. */
  62888. export class ColorCorrectionPostProcess extends PostProcess {
  62889. private _colorTableTexture;
  62890. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62891. }
  62892. }
  62893. declare module "babylonjs/Shaders/convolution.fragment" {
  62894. /** @hidden */
  62895. export var convolutionPixelShader: {
  62896. name: string;
  62897. shader: string;
  62898. };
  62899. }
  62900. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62902. import { Nullable } from "babylonjs/types";
  62903. import { Camera } from "babylonjs/Cameras/camera";
  62904. import { Engine } from "babylonjs/Engines/engine";
  62905. import "babylonjs/Shaders/convolution.fragment";
  62906. /**
  62907. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62908. * input texture to perform effects such as edge detection or sharpening
  62909. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62910. */
  62911. export class ConvolutionPostProcess extends PostProcess {
  62912. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62913. kernel: number[];
  62914. /**
  62915. * Creates a new instance ConvolutionPostProcess
  62916. * @param name The name of the effect.
  62917. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62918. * @param options The required width/height ratio to downsize to before computing the render pass.
  62919. * @param camera The camera to apply the render pass to.
  62920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62921. * @param engine The engine which the post process will be applied. (default: current engine)
  62922. * @param reusable If the post process can be reused on the same frame. (default: false)
  62923. * @param textureType Type of textures used when performing the post process. (default: 0)
  62924. */
  62925. constructor(name: string,
  62926. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62927. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62928. /**
  62929. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62930. */
  62931. static EdgeDetect0Kernel: number[];
  62932. /**
  62933. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62934. */
  62935. static EdgeDetect1Kernel: number[];
  62936. /**
  62937. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62938. */
  62939. static EdgeDetect2Kernel: number[];
  62940. /**
  62941. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62942. */
  62943. static SharpenKernel: number[];
  62944. /**
  62945. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62946. */
  62947. static EmbossKernel: number[];
  62948. /**
  62949. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62950. */
  62951. static GaussianKernel: number[];
  62952. }
  62953. }
  62954. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62955. import { Nullable } from "babylonjs/types";
  62956. import { Vector2 } from "babylonjs/Maths/math.vector";
  62957. import { Camera } from "babylonjs/Cameras/camera";
  62958. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62959. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62960. import { Engine } from "babylonjs/Engines/engine";
  62961. import { Scene } from "babylonjs/scene";
  62962. /**
  62963. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62964. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62965. * based on samples that have a large difference in distance than the center pixel.
  62966. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62967. */
  62968. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62969. direction: Vector2;
  62970. /**
  62971. * Creates a new instance CircleOfConfusionPostProcess
  62972. * @param name The name of the effect.
  62973. * @param scene The scene the effect belongs to.
  62974. * @param direction The direction the blur should be applied.
  62975. * @param kernel The size of the kernel used to blur.
  62976. * @param options The required width/height ratio to downsize to before computing the render pass.
  62977. * @param camera The camera to apply the render pass to.
  62978. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62979. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62981. * @param engine The engine which the post process will be applied. (default: current engine)
  62982. * @param reusable If the post process can be reused on the same frame. (default: false)
  62983. * @param textureType Type of textures used when performing the post process. (default: 0)
  62984. * @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)
  62985. */
  62986. 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);
  62987. }
  62988. }
  62989. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62990. /** @hidden */
  62991. export var depthOfFieldMergePixelShader: {
  62992. name: string;
  62993. shader: string;
  62994. };
  62995. }
  62996. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62997. import { Nullable } from "babylonjs/types";
  62998. import { Camera } from "babylonjs/Cameras/camera";
  62999. import { Effect } from "babylonjs/Materials/effect";
  63000. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63001. import { Engine } from "babylonjs/Engines/engine";
  63002. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63003. /**
  63004. * Options to be set when merging outputs from the default pipeline.
  63005. */
  63006. export class DepthOfFieldMergePostProcessOptions {
  63007. /**
  63008. * The original image to merge on top of
  63009. */
  63010. originalFromInput: PostProcess;
  63011. /**
  63012. * Parameters to perform the merge of the depth of field effect
  63013. */
  63014. depthOfField?: {
  63015. circleOfConfusion: PostProcess;
  63016. blurSteps: Array<PostProcess>;
  63017. };
  63018. /**
  63019. * Parameters to perform the merge of bloom effect
  63020. */
  63021. bloom?: {
  63022. blurred: PostProcess;
  63023. weight: number;
  63024. };
  63025. }
  63026. /**
  63027. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63028. */
  63029. export class DepthOfFieldMergePostProcess extends PostProcess {
  63030. private blurSteps;
  63031. /**
  63032. * Creates a new instance of DepthOfFieldMergePostProcess
  63033. * @param name The name of the effect.
  63034. * @param originalFromInput Post process which's input will be used for the merge.
  63035. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63036. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63037. * @param options The required width/height ratio to downsize to before computing the render pass.
  63038. * @param camera The camera to apply the render pass to.
  63039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63040. * @param engine The engine which the post process will be applied. (default: current engine)
  63041. * @param reusable If the post process can be reused on the same frame. (default: false)
  63042. * @param textureType Type of textures used when performing the post process. (default: 0)
  63043. * @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)
  63044. */
  63045. 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);
  63046. /**
  63047. * Updates the effect with the current post process compile time values and recompiles the shader.
  63048. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63049. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63050. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63051. * @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
  63052. * @param onCompiled Called when the shader has been compiled.
  63053. * @param onError Called if there is an error when compiling a shader.
  63054. */
  63055. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63056. }
  63057. }
  63058. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63059. import { Nullable } from "babylonjs/types";
  63060. import { Camera } from "babylonjs/Cameras/camera";
  63061. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63062. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63063. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63064. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63065. import { Scene } from "babylonjs/scene";
  63066. /**
  63067. * Specifies the level of max blur that should be applied when using the depth of field effect
  63068. */
  63069. export enum DepthOfFieldEffectBlurLevel {
  63070. /**
  63071. * Subtle blur
  63072. */
  63073. Low = 0,
  63074. /**
  63075. * Medium blur
  63076. */
  63077. Medium = 1,
  63078. /**
  63079. * Large blur
  63080. */
  63081. High = 2
  63082. }
  63083. /**
  63084. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63085. */
  63086. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63087. private _circleOfConfusion;
  63088. /**
  63089. * @hidden Internal, blurs from high to low
  63090. */
  63091. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63092. private _depthOfFieldBlurY;
  63093. private _dofMerge;
  63094. /**
  63095. * @hidden Internal post processes in depth of field effect
  63096. */
  63097. _effects: Array<PostProcess>;
  63098. /**
  63099. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63100. */
  63101. focalLength: number;
  63102. /**
  63103. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63104. */
  63105. fStop: number;
  63106. /**
  63107. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63108. */
  63109. focusDistance: number;
  63110. /**
  63111. * 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.
  63112. */
  63113. lensSize: number;
  63114. /**
  63115. * Creates a new instance DepthOfFieldEffect
  63116. * @param scene The scene the effect belongs to.
  63117. * @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.
  63118. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63119. * @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)
  63120. */
  63121. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63122. /**
  63123. * Get the current class name of the current effet
  63124. * @returns "DepthOfFieldEffect"
  63125. */
  63126. getClassName(): string;
  63127. /**
  63128. * 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.
  63129. */
  63130. depthTexture: RenderTargetTexture;
  63131. /**
  63132. * Disposes each of the internal effects for a given camera.
  63133. * @param camera The camera to dispose the effect on.
  63134. */
  63135. disposeEffects(camera: Camera): void;
  63136. /**
  63137. * @hidden Internal
  63138. */
  63139. _updateEffects(): void;
  63140. /**
  63141. * Internal
  63142. * @returns if all the contained post processes are ready.
  63143. * @hidden
  63144. */
  63145. _isReady(): boolean;
  63146. }
  63147. }
  63148. declare module "babylonjs/Shaders/displayPass.fragment" {
  63149. /** @hidden */
  63150. export var displayPassPixelShader: {
  63151. name: string;
  63152. shader: string;
  63153. };
  63154. }
  63155. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63156. import { Nullable } from "babylonjs/types";
  63157. import { Camera } from "babylonjs/Cameras/camera";
  63158. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63159. import { Engine } from "babylonjs/Engines/engine";
  63160. import "babylonjs/Shaders/displayPass.fragment";
  63161. /**
  63162. * DisplayPassPostProcess which produces an output the same as it's input
  63163. */
  63164. export class DisplayPassPostProcess extends PostProcess {
  63165. /**
  63166. * Creates the DisplayPassPostProcess
  63167. * @param name The name of the effect.
  63168. * @param options The required width/height ratio to downsize to before computing the render pass.
  63169. * @param camera The camera to apply the render pass to.
  63170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63171. * @param engine The engine which the post process will be applied. (default: current engine)
  63172. * @param reusable If the post process can be reused on the same frame. (default: false)
  63173. */
  63174. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63175. }
  63176. }
  63177. declare module "babylonjs/Shaders/filter.fragment" {
  63178. /** @hidden */
  63179. export var filterPixelShader: {
  63180. name: string;
  63181. shader: string;
  63182. };
  63183. }
  63184. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63185. import { Nullable } from "babylonjs/types";
  63186. import { Matrix } from "babylonjs/Maths/math.vector";
  63187. import { Camera } from "babylonjs/Cameras/camera";
  63188. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63189. import { Engine } from "babylonjs/Engines/engine";
  63190. import "babylonjs/Shaders/filter.fragment";
  63191. /**
  63192. * Applies a kernel filter to the image
  63193. */
  63194. export class FilterPostProcess extends PostProcess {
  63195. /** The matrix to be applied to the image */
  63196. kernelMatrix: Matrix;
  63197. /**
  63198. *
  63199. * @param name The name of the effect.
  63200. * @param kernelMatrix The matrix to be applied to the image
  63201. * @param options The required width/height ratio to downsize to before computing the render pass.
  63202. * @param camera The camera to apply the render pass to.
  63203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63204. * @param engine The engine which the post process will be applied. (default: current engine)
  63205. * @param reusable If the post process can be reused on the same frame. (default: false)
  63206. */
  63207. constructor(name: string,
  63208. /** The matrix to be applied to the image */
  63209. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63210. }
  63211. }
  63212. declare module "babylonjs/Shaders/fxaa.fragment" {
  63213. /** @hidden */
  63214. export var fxaaPixelShader: {
  63215. name: string;
  63216. shader: string;
  63217. };
  63218. }
  63219. declare module "babylonjs/Shaders/fxaa.vertex" {
  63220. /** @hidden */
  63221. export var fxaaVertexShader: {
  63222. name: string;
  63223. shader: string;
  63224. };
  63225. }
  63226. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63227. import { Nullable } from "babylonjs/types";
  63228. import { Camera } from "babylonjs/Cameras/camera";
  63229. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63230. import { Engine } from "babylonjs/Engines/engine";
  63231. import "babylonjs/Shaders/fxaa.fragment";
  63232. import "babylonjs/Shaders/fxaa.vertex";
  63233. /**
  63234. * Fxaa post process
  63235. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63236. */
  63237. export class FxaaPostProcess extends PostProcess {
  63238. /** @hidden */
  63239. texelWidth: number;
  63240. /** @hidden */
  63241. texelHeight: number;
  63242. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63243. private _getDefines;
  63244. }
  63245. }
  63246. declare module "babylonjs/Shaders/grain.fragment" {
  63247. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63248. /** @hidden */
  63249. export var grainPixelShader: {
  63250. name: string;
  63251. shader: string;
  63252. };
  63253. }
  63254. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63255. import { Nullable } from "babylonjs/types";
  63256. import { Camera } from "babylonjs/Cameras/camera";
  63257. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63258. import { Engine } from "babylonjs/Engines/engine";
  63259. import "babylonjs/Shaders/grain.fragment";
  63260. /**
  63261. * The GrainPostProcess adds noise to the image at mid luminance levels
  63262. */
  63263. export class GrainPostProcess extends PostProcess {
  63264. /**
  63265. * The intensity of the grain added (default: 30)
  63266. */
  63267. intensity: number;
  63268. /**
  63269. * If the grain should be randomized on every frame
  63270. */
  63271. animated: boolean;
  63272. /**
  63273. * Creates a new instance of @see GrainPostProcess
  63274. * @param name The name of the effect.
  63275. * @param options The required width/height ratio to downsize to before computing the render pass.
  63276. * @param camera The camera to apply the render pass to.
  63277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63278. * @param engine The engine which the post process will be applied. (default: current engine)
  63279. * @param reusable If the post process can be reused on the same frame. (default: false)
  63280. * @param textureType Type of textures used when performing the post process. (default: 0)
  63281. * @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)
  63282. */
  63283. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63284. }
  63285. }
  63286. declare module "babylonjs/Shaders/highlights.fragment" {
  63287. /** @hidden */
  63288. export var highlightsPixelShader: {
  63289. name: string;
  63290. shader: string;
  63291. };
  63292. }
  63293. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63294. import { Nullable } from "babylonjs/types";
  63295. import { Camera } from "babylonjs/Cameras/camera";
  63296. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63297. import { Engine } from "babylonjs/Engines/engine";
  63298. import "babylonjs/Shaders/highlights.fragment";
  63299. /**
  63300. * Extracts highlights from the image
  63301. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63302. */
  63303. export class HighlightsPostProcess extends PostProcess {
  63304. /**
  63305. * Extracts highlights from the image
  63306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63307. * @param name The name of the effect.
  63308. * @param options The required width/height ratio to downsize to before computing the render pass.
  63309. * @param camera The camera to apply the render pass to.
  63310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63311. * @param engine The engine which the post process will be applied. (default: current engine)
  63312. * @param reusable If the post process can be reused on the same frame. (default: false)
  63313. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63314. */
  63315. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63316. }
  63317. }
  63318. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63319. /** @hidden */
  63320. export var mrtFragmentDeclaration: {
  63321. name: string;
  63322. shader: string;
  63323. };
  63324. }
  63325. declare module "babylonjs/Shaders/geometry.fragment" {
  63326. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63327. /** @hidden */
  63328. export var geometryPixelShader: {
  63329. name: string;
  63330. shader: string;
  63331. };
  63332. }
  63333. declare module "babylonjs/Shaders/geometry.vertex" {
  63334. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63335. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63336. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63337. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63338. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63341. /** @hidden */
  63342. export var geometryVertexShader: {
  63343. name: string;
  63344. shader: string;
  63345. };
  63346. }
  63347. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63348. import { Matrix } from "babylonjs/Maths/math.vector";
  63349. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63350. import { Mesh } from "babylonjs/Meshes/mesh";
  63351. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63352. import { Effect } from "babylonjs/Materials/effect";
  63353. import { Scene } from "babylonjs/scene";
  63354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63355. import "babylonjs/Shaders/geometry.fragment";
  63356. import "babylonjs/Shaders/geometry.vertex";
  63357. /** @hidden */
  63358. interface ISavedTransformationMatrix {
  63359. world: Matrix;
  63360. viewProjection: Matrix;
  63361. }
  63362. /**
  63363. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63364. */
  63365. export class GeometryBufferRenderer {
  63366. /**
  63367. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63368. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63369. */
  63370. static readonly POSITION_TEXTURE_TYPE: number;
  63371. /**
  63372. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63373. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63374. */
  63375. static readonly VELOCITY_TEXTURE_TYPE: number;
  63376. /**
  63377. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63378. * in order to compute objects velocities when enableVelocity is set to "true"
  63379. * @hidden
  63380. */
  63381. _previousTransformationMatrices: {
  63382. [index: number]: ISavedTransformationMatrix;
  63383. };
  63384. /**
  63385. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63386. * in order to compute objects velocities when enableVelocity is set to "true"
  63387. * @hidden
  63388. */
  63389. _previousBonesTransformationMatrices: {
  63390. [index: number]: Float32Array;
  63391. };
  63392. /**
  63393. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63394. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63395. */
  63396. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63397. private _scene;
  63398. private _multiRenderTarget;
  63399. private _ratio;
  63400. private _enablePosition;
  63401. private _enableVelocity;
  63402. private _positionIndex;
  63403. private _velocityIndex;
  63404. protected _effect: Effect;
  63405. protected _cachedDefines: string;
  63406. /**
  63407. * Set the render list (meshes to be rendered) used in the G buffer.
  63408. */
  63409. renderList: Mesh[];
  63410. /**
  63411. * Gets wether or not G buffer are supported by the running hardware.
  63412. * This requires draw buffer supports
  63413. */
  63414. readonly isSupported: boolean;
  63415. /**
  63416. * Returns the index of the given texture type in the G-Buffer textures array
  63417. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63418. * @returns the index of the given texture type in the G-Buffer textures array
  63419. */
  63420. getTextureIndex(textureType: number): number;
  63421. /**
  63422. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63423. */
  63424. /**
  63425. * Sets whether or not objects positions are enabled for the G buffer.
  63426. */
  63427. enablePosition: boolean;
  63428. /**
  63429. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63430. */
  63431. /**
  63432. * Sets wether or not objects velocities are enabled for the G buffer.
  63433. */
  63434. enableVelocity: boolean;
  63435. /**
  63436. * Gets the scene associated with the buffer.
  63437. */
  63438. readonly scene: Scene;
  63439. /**
  63440. * Gets the ratio used by the buffer during its creation.
  63441. * How big is the buffer related to the main canvas.
  63442. */
  63443. readonly ratio: number;
  63444. /** @hidden */
  63445. static _SceneComponentInitialization: (scene: Scene) => void;
  63446. /**
  63447. * Creates a new G Buffer for the scene
  63448. * @param scene The scene the buffer belongs to
  63449. * @param ratio How big is the buffer related to the main canvas.
  63450. */
  63451. constructor(scene: Scene, ratio?: number);
  63452. /**
  63453. * Checks wether everything is ready to render a submesh to the G buffer.
  63454. * @param subMesh the submesh to check readiness for
  63455. * @param useInstances is the mesh drawn using instance or not
  63456. * @returns true if ready otherwise false
  63457. */
  63458. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63459. /**
  63460. * Gets the current underlying G Buffer.
  63461. * @returns the buffer
  63462. */
  63463. getGBuffer(): MultiRenderTarget;
  63464. /**
  63465. * Gets the number of samples used to render the buffer (anti aliasing).
  63466. */
  63467. /**
  63468. * Sets the number of samples used to render the buffer (anti aliasing).
  63469. */
  63470. samples: number;
  63471. /**
  63472. * Disposes the renderer and frees up associated resources.
  63473. */
  63474. dispose(): void;
  63475. protected _createRenderTargets(): void;
  63476. private _copyBonesTransformationMatrices;
  63477. }
  63478. }
  63479. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63480. import { Nullable } from "babylonjs/types";
  63481. import { Scene } from "babylonjs/scene";
  63482. import { ISceneComponent } from "babylonjs/sceneComponent";
  63483. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63484. module "babylonjs/scene" {
  63485. interface Scene {
  63486. /** @hidden (Backing field) */
  63487. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63488. /**
  63489. * Gets or Sets the current geometry buffer associated to the scene.
  63490. */
  63491. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63492. /**
  63493. * Enables a GeometryBufferRender and associates it with the scene
  63494. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63495. * @returns the GeometryBufferRenderer
  63496. */
  63497. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63498. /**
  63499. * Disables the GeometryBufferRender associated with the scene
  63500. */
  63501. disableGeometryBufferRenderer(): void;
  63502. }
  63503. }
  63504. /**
  63505. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63506. * in several rendering techniques.
  63507. */
  63508. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63509. /**
  63510. * The component name helpful to identify the component in the list of scene components.
  63511. */
  63512. readonly name: string;
  63513. /**
  63514. * The scene the component belongs to.
  63515. */
  63516. scene: Scene;
  63517. /**
  63518. * Creates a new instance of the component for the given scene
  63519. * @param scene Defines the scene to register the component in
  63520. */
  63521. constructor(scene: Scene);
  63522. /**
  63523. * Registers the component in a given scene
  63524. */
  63525. register(): void;
  63526. /**
  63527. * Rebuilds the elements related to this component in case of
  63528. * context lost for instance.
  63529. */
  63530. rebuild(): void;
  63531. /**
  63532. * Disposes the component and the associated ressources
  63533. */
  63534. dispose(): void;
  63535. private _gatherRenderTargets;
  63536. }
  63537. }
  63538. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63539. /** @hidden */
  63540. export var motionBlurPixelShader: {
  63541. name: string;
  63542. shader: string;
  63543. };
  63544. }
  63545. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63546. import { Nullable } from "babylonjs/types";
  63547. import { Camera } from "babylonjs/Cameras/camera";
  63548. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63549. import { Scene } from "babylonjs/scene";
  63550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63551. import "babylonjs/Animations/animatable";
  63552. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63553. import "babylonjs/Shaders/motionBlur.fragment";
  63554. import { Engine } from "babylonjs/Engines/engine";
  63555. /**
  63556. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63557. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63558. * As an example, all you have to do is to create the post-process:
  63559. * var mb = new BABYLON.MotionBlurPostProcess(
  63560. * 'mb', // The name of the effect.
  63561. * scene, // The scene containing the objects to blur according to their velocity.
  63562. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63563. * camera // The camera to apply the render pass to.
  63564. * );
  63565. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63566. */
  63567. export class MotionBlurPostProcess extends PostProcess {
  63568. /**
  63569. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63570. */
  63571. motionStrength: number;
  63572. /**
  63573. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63574. */
  63575. /**
  63576. * Sets the number of iterations to be used for motion blur quality
  63577. */
  63578. motionBlurSamples: number;
  63579. private _motionBlurSamples;
  63580. private _geometryBufferRenderer;
  63581. /**
  63582. * Creates a new instance MotionBlurPostProcess
  63583. * @param name The name of the effect.
  63584. * @param scene The scene containing the objects to blur according to their velocity.
  63585. * @param options The required width/height ratio to downsize to before computing the render pass.
  63586. * @param camera The camera to apply the render pass to.
  63587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63588. * @param engine The engine which the post process will be applied. (default: current engine)
  63589. * @param reusable If the post process can be reused on the same frame. (default: false)
  63590. * @param textureType Type of textures used when performing the post process. (default: 0)
  63591. * @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)
  63592. */
  63593. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63594. /**
  63595. * Excludes the given skinned mesh from computing bones velocities.
  63596. * 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.
  63597. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63598. */
  63599. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63600. /**
  63601. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63602. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63603. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63604. */
  63605. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63606. /**
  63607. * Disposes the post process.
  63608. * @param camera The camera to dispose the post process on.
  63609. */
  63610. dispose(camera?: Camera): void;
  63611. }
  63612. }
  63613. declare module "babylonjs/Shaders/refraction.fragment" {
  63614. /** @hidden */
  63615. export var refractionPixelShader: {
  63616. name: string;
  63617. shader: string;
  63618. };
  63619. }
  63620. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63621. import { Color3 } from "babylonjs/Maths/math.color";
  63622. import { Camera } from "babylonjs/Cameras/camera";
  63623. import { Texture } from "babylonjs/Materials/Textures/texture";
  63624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63625. import { Engine } from "babylonjs/Engines/engine";
  63626. import "babylonjs/Shaders/refraction.fragment";
  63627. /**
  63628. * Post process which applies a refractin texture
  63629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63630. */
  63631. export class RefractionPostProcess extends PostProcess {
  63632. /** the base color of the refraction (used to taint the rendering) */
  63633. color: Color3;
  63634. /** simulated refraction depth */
  63635. depth: number;
  63636. /** the coefficient of the base color (0 to remove base color tainting) */
  63637. colorLevel: number;
  63638. private _refTexture;
  63639. private _ownRefractionTexture;
  63640. /**
  63641. * Gets or sets the refraction texture
  63642. * Please note that you are responsible for disposing the texture if you set it manually
  63643. */
  63644. refractionTexture: Texture;
  63645. /**
  63646. * Initializes the RefractionPostProcess
  63647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63648. * @param name The name of the effect.
  63649. * @param refractionTextureUrl Url of the refraction texture to use
  63650. * @param color the base color of the refraction (used to taint the rendering)
  63651. * @param depth simulated refraction depth
  63652. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63653. * @param camera The camera to apply the render pass to.
  63654. * @param options The required width/height ratio to downsize to before computing the render pass.
  63655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63656. * @param engine The engine which the post process will be applied. (default: current engine)
  63657. * @param reusable If the post process can be reused on the same frame. (default: false)
  63658. */
  63659. constructor(name: string, refractionTextureUrl: string,
  63660. /** the base color of the refraction (used to taint the rendering) */
  63661. color: Color3,
  63662. /** simulated refraction depth */
  63663. depth: number,
  63664. /** the coefficient of the base color (0 to remove base color tainting) */
  63665. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63666. /**
  63667. * Disposes of the post process
  63668. * @param camera Camera to dispose post process on
  63669. */
  63670. dispose(camera: Camera): void;
  63671. }
  63672. }
  63673. declare module "babylonjs/Shaders/sharpen.fragment" {
  63674. /** @hidden */
  63675. export var sharpenPixelShader: {
  63676. name: string;
  63677. shader: string;
  63678. };
  63679. }
  63680. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63681. import { Nullable } from "babylonjs/types";
  63682. import { Camera } from "babylonjs/Cameras/camera";
  63683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63684. import "babylonjs/Shaders/sharpen.fragment";
  63685. import { Engine } from "babylonjs/Engines/engine";
  63686. /**
  63687. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63688. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63689. */
  63690. export class SharpenPostProcess extends PostProcess {
  63691. /**
  63692. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63693. */
  63694. colorAmount: number;
  63695. /**
  63696. * How much sharpness should be applied (default: 0.3)
  63697. */
  63698. edgeAmount: number;
  63699. /**
  63700. * Creates a new instance ConvolutionPostProcess
  63701. * @param name The name of the effect.
  63702. * @param options The required width/height ratio to downsize to before computing the render pass.
  63703. * @param camera The camera to apply the render pass to.
  63704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63705. * @param engine The engine which the post process will be applied. (default: current engine)
  63706. * @param reusable If the post process can be reused on the same frame. (default: false)
  63707. * @param textureType Type of textures used when performing the post process. (default: 0)
  63708. * @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)
  63709. */
  63710. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63711. }
  63712. }
  63713. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63714. import { Nullable } from "babylonjs/types";
  63715. import { Camera } from "babylonjs/Cameras/camera";
  63716. import { Engine } from "babylonjs/Engines/engine";
  63717. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63718. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63719. /**
  63720. * PostProcessRenderPipeline
  63721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63722. */
  63723. export class PostProcessRenderPipeline {
  63724. private engine;
  63725. private _renderEffects;
  63726. private _renderEffectsForIsolatedPass;
  63727. /**
  63728. * List of inspectable custom properties (used by the Inspector)
  63729. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63730. */
  63731. inspectableCustomProperties: IInspectable[];
  63732. /**
  63733. * @hidden
  63734. */
  63735. protected _cameras: Camera[];
  63736. /** @hidden */
  63737. _name: string;
  63738. /**
  63739. * Gets pipeline name
  63740. */
  63741. readonly name: string;
  63742. /**
  63743. * Initializes a PostProcessRenderPipeline
  63744. * @param engine engine to add the pipeline to
  63745. * @param name name of the pipeline
  63746. */
  63747. constructor(engine: Engine, name: string);
  63748. /**
  63749. * Gets the class name
  63750. * @returns "PostProcessRenderPipeline"
  63751. */
  63752. getClassName(): string;
  63753. /**
  63754. * If all the render effects in the pipeline are supported
  63755. */
  63756. readonly isSupported: boolean;
  63757. /**
  63758. * Adds an effect to the pipeline
  63759. * @param renderEffect the effect to add
  63760. */
  63761. addEffect(renderEffect: PostProcessRenderEffect): void;
  63762. /** @hidden */
  63763. _rebuild(): void;
  63764. /** @hidden */
  63765. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63766. /** @hidden */
  63767. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63768. /** @hidden */
  63769. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63770. /** @hidden */
  63771. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63772. /** @hidden */
  63773. _attachCameras(cameras: Camera, unique: boolean): void;
  63774. /** @hidden */
  63775. _attachCameras(cameras: Camera[], unique: boolean): void;
  63776. /** @hidden */
  63777. _detachCameras(cameras: Camera): void;
  63778. /** @hidden */
  63779. _detachCameras(cameras: Nullable<Camera[]>): void;
  63780. /** @hidden */
  63781. _update(): void;
  63782. /** @hidden */
  63783. _reset(): void;
  63784. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63785. /**
  63786. * Disposes of the pipeline
  63787. */
  63788. dispose(): void;
  63789. }
  63790. }
  63791. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63792. import { Camera } from "babylonjs/Cameras/camera";
  63793. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63794. /**
  63795. * PostProcessRenderPipelineManager class
  63796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63797. */
  63798. export class PostProcessRenderPipelineManager {
  63799. private _renderPipelines;
  63800. /**
  63801. * Initializes a PostProcessRenderPipelineManager
  63802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63803. */
  63804. constructor();
  63805. /**
  63806. * Gets the list of supported render pipelines
  63807. */
  63808. readonly supportedPipelines: PostProcessRenderPipeline[];
  63809. /**
  63810. * Adds a pipeline to the manager
  63811. * @param renderPipeline The pipeline to add
  63812. */
  63813. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63814. /**
  63815. * Attaches a camera to the pipeline
  63816. * @param renderPipelineName The name of the pipeline to attach to
  63817. * @param cameras the camera to attach
  63818. * @param unique if the camera can be attached multiple times to the pipeline
  63819. */
  63820. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63821. /**
  63822. * Detaches a camera from the pipeline
  63823. * @param renderPipelineName The name of the pipeline to detach from
  63824. * @param cameras the camera to detach
  63825. */
  63826. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63827. /**
  63828. * Enables an effect by name on a pipeline
  63829. * @param renderPipelineName the name of the pipeline to enable the effect in
  63830. * @param renderEffectName the name of the effect to enable
  63831. * @param cameras the cameras that the effect should be enabled on
  63832. */
  63833. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63834. /**
  63835. * Disables an effect by name on a pipeline
  63836. * @param renderPipelineName the name of the pipeline to disable the effect in
  63837. * @param renderEffectName the name of the effect to disable
  63838. * @param cameras the cameras that the effect should be disabled on
  63839. */
  63840. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63841. /**
  63842. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63843. */
  63844. update(): void;
  63845. /** @hidden */
  63846. _rebuild(): void;
  63847. /**
  63848. * Disposes of the manager and pipelines
  63849. */
  63850. dispose(): void;
  63851. }
  63852. }
  63853. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63854. import { ISceneComponent } from "babylonjs/sceneComponent";
  63855. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63856. import { Scene } from "babylonjs/scene";
  63857. module "babylonjs/scene" {
  63858. interface Scene {
  63859. /** @hidden (Backing field) */
  63860. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63861. /**
  63862. * Gets the postprocess render pipeline manager
  63863. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63864. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63865. */
  63866. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63867. }
  63868. }
  63869. /**
  63870. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63871. */
  63872. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63873. /**
  63874. * The component name helpfull to identify the component in the list of scene components.
  63875. */
  63876. readonly name: string;
  63877. /**
  63878. * The scene the component belongs to.
  63879. */
  63880. scene: Scene;
  63881. /**
  63882. * Creates a new instance of the component for the given scene
  63883. * @param scene Defines the scene to register the component in
  63884. */
  63885. constructor(scene: Scene);
  63886. /**
  63887. * Registers the component in a given scene
  63888. */
  63889. register(): void;
  63890. /**
  63891. * Rebuilds the elements related to this component in case of
  63892. * context lost for instance.
  63893. */
  63894. rebuild(): void;
  63895. /**
  63896. * Disposes the component and the associated ressources
  63897. */
  63898. dispose(): void;
  63899. private _gatherRenderTargets;
  63900. }
  63901. }
  63902. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63903. import { Nullable } from "babylonjs/types";
  63904. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63905. import { Camera } from "babylonjs/Cameras/camera";
  63906. import { IDisposable } from "babylonjs/scene";
  63907. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63908. import { Scene } from "babylonjs/scene";
  63909. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63910. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63911. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63912. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63913. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63914. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63915. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63916. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63917. import { Animation } from "babylonjs/Animations/animation";
  63918. /**
  63919. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63920. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63921. */
  63922. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63923. private _scene;
  63924. private _camerasToBeAttached;
  63925. /**
  63926. * ID of the sharpen post process,
  63927. */
  63928. private readonly SharpenPostProcessId;
  63929. /**
  63930. * @ignore
  63931. * ID of the image processing post process;
  63932. */
  63933. readonly ImageProcessingPostProcessId: string;
  63934. /**
  63935. * @ignore
  63936. * ID of the Fast Approximate Anti-Aliasing post process;
  63937. */
  63938. readonly FxaaPostProcessId: string;
  63939. /**
  63940. * ID of the chromatic aberration post process,
  63941. */
  63942. private readonly ChromaticAberrationPostProcessId;
  63943. /**
  63944. * ID of the grain post process
  63945. */
  63946. private readonly GrainPostProcessId;
  63947. /**
  63948. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63949. */
  63950. sharpen: SharpenPostProcess;
  63951. private _sharpenEffect;
  63952. private bloom;
  63953. /**
  63954. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63955. */
  63956. depthOfField: DepthOfFieldEffect;
  63957. /**
  63958. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63959. */
  63960. fxaa: FxaaPostProcess;
  63961. /**
  63962. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63963. */
  63964. imageProcessing: ImageProcessingPostProcess;
  63965. /**
  63966. * Chromatic aberration post process which will shift rgb colors in the image
  63967. */
  63968. chromaticAberration: ChromaticAberrationPostProcess;
  63969. private _chromaticAberrationEffect;
  63970. /**
  63971. * Grain post process which add noise to the image
  63972. */
  63973. grain: GrainPostProcess;
  63974. private _grainEffect;
  63975. /**
  63976. * Glow post process which adds a glow to emissive areas of the image
  63977. */
  63978. private _glowLayer;
  63979. /**
  63980. * Animations which can be used to tweak settings over a period of time
  63981. */
  63982. animations: Animation[];
  63983. private _imageProcessingConfigurationObserver;
  63984. private _sharpenEnabled;
  63985. private _bloomEnabled;
  63986. private _depthOfFieldEnabled;
  63987. private _depthOfFieldBlurLevel;
  63988. private _fxaaEnabled;
  63989. private _imageProcessingEnabled;
  63990. private _defaultPipelineTextureType;
  63991. private _bloomScale;
  63992. private _chromaticAberrationEnabled;
  63993. private _grainEnabled;
  63994. private _buildAllowed;
  63995. /**
  63996. * Gets active scene
  63997. */
  63998. readonly scene: Scene;
  63999. /**
  64000. * Enable or disable the sharpen process from the pipeline
  64001. */
  64002. sharpenEnabled: boolean;
  64003. private _resizeObserver;
  64004. private _hardwareScaleLevel;
  64005. private _bloomKernel;
  64006. /**
  64007. * Specifies the size of the bloom blur kernel, relative to the final output size
  64008. */
  64009. bloomKernel: number;
  64010. /**
  64011. * Specifies the weight of the bloom in the final rendering
  64012. */
  64013. private _bloomWeight;
  64014. /**
  64015. * Specifies the luma threshold for the area that will be blurred by the bloom
  64016. */
  64017. private _bloomThreshold;
  64018. private _hdr;
  64019. /**
  64020. * The strength of the bloom.
  64021. */
  64022. bloomWeight: number;
  64023. /**
  64024. * The strength of the bloom.
  64025. */
  64026. bloomThreshold: number;
  64027. /**
  64028. * The scale of the bloom, lower value will provide better performance.
  64029. */
  64030. bloomScale: number;
  64031. /**
  64032. * Enable or disable the bloom from the pipeline
  64033. */
  64034. bloomEnabled: boolean;
  64035. private _rebuildBloom;
  64036. /**
  64037. * If the depth of field is enabled.
  64038. */
  64039. depthOfFieldEnabled: boolean;
  64040. /**
  64041. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64042. */
  64043. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64044. /**
  64045. * If the anti aliasing is enabled.
  64046. */
  64047. fxaaEnabled: boolean;
  64048. private _samples;
  64049. /**
  64050. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64051. */
  64052. samples: number;
  64053. /**
  64054. * If image processing is enabled.
  64055. */
  64056. imageProcessingEnabled: boolean;
  64057. /**
  64058. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64059. */
  64060. glowLayerEnabled: boolean;
  64061. /**
  64062. * Gets the glow layer (or null if not defined)
  64063. */
  64064. readonly glowLayer: Nullable<GlowLayer>;
  64065. /**
  64066. * Enable or disable the chromaticAberration process from the pipeline
  64067. */
  64068. chromaticAberrationEnabled: boolean;
  64069. /**
  64070. * Enable or disable the grain process from the pipeline
  64071. */
  64072. grainEnabled: boolean;
  64073. /**
  64074. * @constructor
  64075. * @param name - The rendering pipeline name (default: "")
  64076. * @param hdr - If high dynamic range textures should be used (default: true)
  64077. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64078. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64079. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64080. */
  64081. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64082. /**
  64083. * Get the class name
  64084. * @returns "DefaultRenderingPipeline"
  64085. */
  64086. getClassName(): string;
  64087. /**
  64088. * Force the compilation of the entire pipeline.
  64089. */
  64090. prepare(): void;
  64091. private _hasCleared;
  64092. private _prevPostProcess;
  64093. private _prevPrevPostProcess;
  64094. private _setAutoClearAndTextureSharing;
  64095. private _depthOfFieldSceneObserver;
  64096. private _buildPipeline;
  64097. private _disposePostProcesses;
  64098. /**
  64099. * Adds a camera to the pipeline
  64100. * @param camera the camera to be added
  64101. */
  64102. addCamera(camera: Camera): void;
  64103. /**
  64104. * Removes a camera from the pipeline
  64105. * @param camera the camera to remove
  64106. */
  64107. removeCamera(camera: Camera): void;
  64108. /**
  64109. * Dispose of the pipeline and stop all post processes
  64110. */
  64111. dispose(): void;
  64112. /**
  64113. * Serialize the rendering pipeline (Used when exporting)
  64114. * @returns the serialized object
  64115. */
  64116. serialize(): any;
  64117. /**
  64118. * Parse the serialized pipeline
  64119. * @param source Source pipeline.
  64120. * @param scene The scene to load the pipeline to.
  64121. * @param rootUrl The URL of the serialized pipeline.
  64122. * @returns An instantiated pipeline from the serialized object.
  64123. */
  64124. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64125. }
  64126. }
  64127. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64128. /** @hidden */
  64129. export var lensHighlightsPixelShader: {
  64130. name: string;
  64131. shader: string;
  64132. };
  64133. }
  64134. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64135. /** @hidden */
  64136. export var depthOfFieldPixelShader: {
  64137. name: string;
  64138. shader: string;
  64139. };
  64140. }
  64141. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64142. import { Camera } from "babylonjs/Cameras/camera";
  64143. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64144. import { Scene } from "babylonjs/scene";
  64145. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64146. import "babylonjs/Shaders/chromaticAberration.fragment";
  64147. import "babylonjs/Shaders/lensHighlights.fragment";
  64148. import "babylonjs/Shaders/depthOfField.fragment";
  64149. /**
  64150. * BABYLON.JS Chromatic Aberration GLSL Shader
  64151. * Author: Olivier Guyot
  64152. * Separates very slightly R, G and B colors on the edges of the screen
  64153. * Inspired by Francois Tarlier & Martins Upitis
  64154. */
  64155. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64156. /**
  64157. * @ignore
  64158. * The chromatic aberration PostProcess id in the pipeline
  64159. */
  64160. LensChromaticAberrationEffect: string;
  64161. /**
  64162. * @ignore
  64163. * The highlights enhancing PostProcess id in the pipeline
  64164. */
  64165. HighlightsEnhancingEffect: string;
  64166. /**
  64167. * @ignore
  64168. * The depth-of-field PostProcess id in the pipeline
  64169. */
  64170. LensDepthOfFieldEffect: string;
  64171. private _scene;
  64172. private _depthTexture;
  64173. private _grainTexture;
  64174. private _chromaticAberrationPostProcess;
  64175. private _highlightsPostProcess;
  64176. private _depthOfFieldPostProcess;
  64177. private _edgeBlur;
  64178. private _grainAmount;
  64179. private _chromaticAberration;
  64180. private _distortion;
  64181. private _highlightsGain;
  64182. private _highlightsThreshold;
  64183. private _dofDistance;
  64184. private _dofAperture;
  64185. private _dofDarken;
  64186. private _dofPentagon;
  64187. private _blurNoise;
  64188. /**
  64189. * @constructor
  64190. *
  64191. * Effect parameters are as follow:
  64192. * {
  64193. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64194. * edge_blur: number; // from 0 to x (1 for realism)
  64195. * distortion: number; // from 0 to x (1 for realism)
  64196. * grain_amount: number; // from 0 to 1
  64197. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64198. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64199. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64200. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64201. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64202. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64203. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64204. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64205. * }
  64206. * Note: if an effect parameter is unset, effect is disabled
  64207. *
  64208. * @param name The rendering pipeline name
  64209. * @param parameters - An object containing all parameters (see above)
  64210. * @param scene The scene linked to this pipeline
  64211. * @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)
  64212. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64213. */
  64214. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64215. /**
  64216. * Get the class name
  64217. * @returns "LensRenderingPipeline"
  64218. */
  64219. getClassName(): string;
  64220. /**
  64221. * Gets associated scene
  64222. */
  64223. readonly scene: Scene;
  64224. /**
  64225. * Gets or sets the edge blur
  64226. */
  64227. edgeBlur: number;
  64228. /**
  64229. * Gets or sets the grain amount
  64230. */
  64231. grainAmount: number;
  64232. /**
  64233. * Gets or sets the chromatic aberration amount
  64234. */
  64235. chromaticAberration: number;
  64236. /**
  64237. * Gets or sets the depth of field aperture
  64238. */
  64239. dofAperture: number;
  64240. /**
  64241. * Gets or sets the edge distortion
  64242. */
  64243. edgeDistortion: number;
  64244. /**
  64245. * Gets or sets the depth of field distortion
  64246. */
  64247. dofDistortion: number;
  64248. /**
  64249. * Gets or sets the darken out of focus amount
  64250. */
  64251. darkenOutOfFocus: number;
  64252. /**
  64253. * Gets or sets a boolean indicating if blur noise is enabled
  64254. */
  64255. blurNoise: boolean;
  64256. /**
  64257. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64258. */
  64259. pentagonBokeh: boolean;
  64260. /**
  64261. * Gets or sets the highlight grain amount
  64262. */
  64263. highlightsGain: number;
  64264. /**
  64265. * Gets or sets the highlight threshold
  64266. */
  64267. highlightsThreshold: number;
  64268. /**
  64269. * Sets the amount of blur at the edges
  64270. * @param amount blur amount
  64271. */
  64272. setEdgeBlur(amount: number): void;
  64273. /**
  64274. * Sets edge blur to 0
  64275. */
  64276. disableEdgeBlur(): void;
  64277. /**
  64278. * Sets the amout of grain
  64279. * @param amount Amount of grain
  64280. */
  64281. setGrainAmount(amount: number): void;
  64282. /**
  64283. * Set grain amount to 0
  64284. */
  64285. disableGrain(): void;
  64286. /**
  64287. * Sets the chromatic aberration amount
  64288. * @param amount amount of chromatic aberration
  64289. */
  64290. setChromaticAberration(amount: number): void;
  64291. /**
  64292. * Sets chromatic aberration amount to 0
  64293. */
  64294. disableChromaticAberration(): void;
  64295. /**
  64296. * Sets the EdgeDistortion amount
  64297. * @param amount amount of EdgeDistortion
  64298. */
  64299. setEdgeDistortion(amount: number): void;
  64300. /**
  64301. * Sets edge distortion to 0
  64302. */
  64303. disableEdgeDistortion(): void;
  64304. /**
  64305. * Sets the FocusDistance amount
  64306. * @param amount amount of FocusDistance
  64307. */
  64308. setFocusDistance(amount: number): void;
  64309. /**
  64310. * Disables depth of field
  64311. */
  64312. disableDepthOfField(): void;
  64313. /**
  64314. * Sets the Aperture amount
  64315. * @param amount amount of Aperture
  64316. */
  64317. setAperture(amount: number): void;
  64318. /**
  64319. * Sets the DarkenOutOfFocus amount
  64320. * @param amount amount of DarkenOutOfFocus
  64321. */
  64322. setDarkenOutOfFocus(amount: number): void;
  64323. private _pentagonBokehIsEnabled;
  64324. /**
  64325. * Creates a pentagon bokeh effect
  64326. */
  64327. enablePentagonBokeh(): void;
  64328. /**
  64329. * Disables the pentagon bokeh effect
  64330. */
  64331. disablePentagonBokeh(): void;
  64332. /**
  64333. * Enables noise blur
  64334. */
  64335. enableNoiseBlur(): void;
  64336. /**
  64337. * Disables noise blur
  64338. */
  64339. disableNoiseBlur(): void;
  64340. /**
  64341. * Sets the HighlightsGain amount
  64342. * @param amount amount of HighlightsGain
  64343. */
  64344. setHighlightsGain(amount: number): void;
  64345. /**
  64346. * Sets the HighlightsThreshold amount
  64347. * @param amount amount of HighlightsThreshold
  64348. */
  64349. setHighlightsThreshold(amount: number): void;
  64350. /**
  64351. * Disables highlights
  64352. */
  64353. disableHighlights(): void;
  64354. /**
  64355. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64356. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64357. */
  64358. dispose(disableDepthRender?: boolean): void;
  64359. private _createChromaticAberrationPostProcess;
  64360. private _createHighlightsPostProcess;
  64361. private _createDepthOfFieldPostProcess;
  64362. private _createGrainTexture;
  64363. }
  64364. }
  64365. declare module "babylonjs/Shaders/ssao2.fragment" {
  64366. /** @hidden */
  64367. export var ssao2PixelShader: {
  64368. name: string;
  64369. shader: string;
  64370. };
  64371. }
  64372. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64373. /** @hidden */
  64374. export var ssaoCombinePixelShader: {
  64375. name: string;
  64376. shader: string;
  64377. };
  64378. }
  64379. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64380. import { Camera } from "babylonjs/Cameras/camera";
  64381. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64382. import { Scene } from "babylonjs/scene";
  64383. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64384. import "babylonjs/Shaders/ssao2.fragment";
  64385. import "babylonjs/Shaders/ssaoCombine.fragment";
  64386. /**
  64387. * Render pipeline to produce ssao effect
  64388. */
  64389. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64390. /**
  64391. * @ignore
  64392. * The PassPostProcess id in the pipeline that contains the original scene color
  64393. */
  64394. SSAOOriginalSceneColorEffect: string;
  64395. /**
  64396. * @ignore
  64397. * The SSAO PostProcess id in the pipeline
  64398. */
  64399. SSAORenderEffect: string;
  64400. /**
  64401. * @ignore
  64402. * The horizontal blur PostProcess id in the pipeline
  64403. */
  64404. SSAOBlurHRenderEffect: string;
  64405. /**
  64406. * @ignore
  64407. * The vertical blur PostProcess id in the pipeline
  64408. */
  64409. SSAOBlurVRenderEffect: string;
  64410. /**
  64411. * @ignore
  64412. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64413. */
  64414. SSAOCombineRenderEffect: string;
  64415. /**
  64416. * The output strength of the SSAO post-process. Default value is 1.0.
  64417. */
  64418. totalStrength: number;
  64419. /**
  64420. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64421. */
  64422. maxZ: number;
  64423. /**
  64424. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64425. */
  64426. minZAspect: number;
  64427. private _samples;
  64428. /**
  64429. * Number of samples used for the SSAO calculations. Default value is 8
  64430. */
  64431. samples: number;
  64432. private _textureSamples;
  64433. /**
  64434. * Number of samples to use for antialiasing
  64435. */
  64436. textureSamples: number;
  64437. /**
  64438. * Ratio object used for SSAO ratio and blur ratio
  64439. */
  64440. private _ratio;
  64441. /**
  64442. * Dynamically generated sphere sampler.
  64443. */
  64444. private _sampleSphere;
  64445. /**
  64446. * Blur filter offsets
  64447. */
  64448. private _samplerOffsets;
  64449. private _expensiveBlur;
  64450. /**
  64451. * If bilateral blur should be used
  64452. */
  64453. expensiveBlur: boolean;
  64454. /**
  64455. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64456. */
  64457. radius: number;
  64458. /**
  64459. * The base color of the SSAO post-process
  64460. * The final result is "base + ssao" between [0, 1]
  64461. */
  64462. base: number;
  64463. /**
  64464. * Support test.
  64465. */
  64466. static readonly IsSupported: boolean;
  64467. private _scene;
  64468. private _depthTexture;
  64469. private _normalTexture;
  64470. private _randomTexture;
  64471. private _originalColorPostProcess;
  64472. private _ssaoPostProcess;
  64473. private _blurHPostProcess;
  64474. private _blurVPostProcess;
  64475. private _ssaoCombinePostProcess;
  64476. private _firstUpdate;
  64477. /**
  64478. * Gets active scene
  64479. */
  64480. readonly scene: Scene;
  64481. /**
  64482. * @constructor
  64483. * @param name The rendering pipeline name
  64484. * @param scene The scene linked to this pipeline
  64485. * @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 }
  64486. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64487. */
  64488. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64489. /**
  64490. * Get the class name
  64491. * @returns "SSAO2RenderingPipeline"
  64492. */
  64493. getClassName(): string;
  64494. /**
  64495. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64496. */
  64497. dispose(disableGeometryBufferRenderer?: boolean): void;
  64498. private _createBlurPostProcess;
  64499. /** @hidden */
  64500. _rebuild(): void;
  64501. private _bits;
  64502. private _radicalInverse_VdC;
  64503. private _hammersley;
  64504. private _hemisphereSample_uniform;
  64505. private _generateHemisphere;
  64506. private _createSSAOPostProcess;
  64507. private _createSSAOCombinePostProcess;
  64508. private _createRandomTexture;
  64509. /**
  64510. * Serialize the rendering pipeline (Used when exporting)
  64511. * @returns the serialized object
  64512. */
  64513. serialize(): any;
  64514. /**
  64515. * Parse the serialized pipeline
  64516. * @param source Source pipeline.
  64517. * @param scene The scene to load the pipeline to.
  64518. * @param rootUrl The URL of the serialized pipeline.
  64519. * @returns An instantiated pipeline from the serialized object.
  64520. */
  64521. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64522. }
  64523. }
  64524. declare module "babylonjs/Shaders/ssao.fragment" {
  64525. /** @hidden */
  64526. export var ssaoPixelShader: {
  64527. name: string;
  64528. shader: string;
  64529. };
  64530. }
  64531. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64532. import { Camera } from "babylonjs/Cameras/camera";
  64533. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64534. import { Scene } from "babylonjs/scene";
  64535. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64536. import "babylonjs/Shaders/ssao.fragment";
  64537. import "babylonjs/Shaders/ssaoCombine.fragment";
  64538. /**
  64539. * Render pipeline to produce ssao effect
  64540. */
  64541. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64542. /**
  64543. * @ignore
  64544. * The PassPostProcess id in the pipeline that contains the original scene color
  64545. */
  64546. SSAOOriginalSceneColorEffect: string;
  64547. /**
  64548. * @ignore
  64549. * The SSAO PostProcess id in the pipeline
  64550. */
  64551. SSAORenderEffect: string;
  64552. /**
  64553. * @ignore
  64554. * The horizontal blur PostProcess id in the pipeline
  64555. */
  64556. SSAOBlurHRenderEffect: string;
  64557. /**
  64558. * @ignore
  64559. * The vertical blur PostProcess id in the pipeline
  64560. */
  64561. SSAOBlurVRenderEffect: string;
  64562. /**
  64563. * @ignore
  64564. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64565. */
  64566. SSAOCombineRenderEffect: string;
  64567. /**
  64568. * The output strength of the SSAO post-process. Default value is 1.0.
  64569. */
  64570. totalStrength: number;
  64571. /**
  64572. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64573. */
  64574. radius: number;
  64575. /**
  64576. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64577. * Must not be equal to fallOff and superior to fallOff.
  64578. * Default value is 0.0075
  64579. */
  64580. area: number;
  64581. /**
  64582. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64583. * Must not be equal to area and inferior to area.
  64584. * Default value is 0.000001
  64585. */
  64586. fallOff: number;
  64587. /**
  64588. * The base color of the SSAO post-process
  64589. * The final result is "base + ssao" between [0, 1]
  64590. */
  64591. base: number;
  64592. private _scene;
  64593. private _depthTexture;
  64594. private _randomTexture;
  64595. private _originalColorPostProcess;
  64596. private _ssaoPostProcess;
  64597. private _blurHPostProcess;
  64598. private _blurVPostProcess;
  64599. private _ssaoCombinePostProcess;
  64600. private _firstUpdate;
  64601. /**
  64602. * Gets active scene
  64603. */
  64604. readonly scene: Scene;
  64605. /**
  64606. * @constructor
  64607. * @param name - The rendering pipeline name
  64608. * @param scene - The scene linked to this pipeline
  64609. * @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 }
  64610. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64611. */
  64612. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64613. /**
  64614. * Get the class name
  64615. * @returns "SSAORenderingPipeline"
  64616. */
  64617. getClassName(): string;
  64618. /**
  64619. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64620. */
  64621. dispose(disableDepthRender?: boolean): void;
  64622. private _createBlurPostProcess;
  64623. /** @hidden */
  64624. _rebuild(): void;
  64625. private _createSSAOPostProcess;
  64626. private _createSSAOCombinePostProcess;
  64627. private _createRandomTexture;
  64628. }
  64629. }
  64630. declare module "babylonjs/Shaders/standard.fragment" {
  64631. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64632. /** @hidden */
  64633. export var standardPixelShader: {
  64634. name: string;
  64635. shader: string;
  64636. };
  64637. }
  64638. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64639. import { Nullable } from "babylonjs/types";
  64640. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64641. import { Camera } from "babylonjs/Cameras/camera";
  64642. import { Texture } from "babylonjs/Materials/Textures/texture";
  64643. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64644. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64645. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64646. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64647. import { IDisposable } from "babylonjs/scene";
  64648. import { SpotLight } from "babylonjs/Lights/spotLight";
  64649. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64650. import { Scene } from "babylonjs/scene";
  64651. import { Animation } from "babylonjs/Animations/animation";
  64652. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64653. import "babylonjs/Shaders/standard.fragment";
  64654. /**
  64655. * Standard rendering pipeline
  64656. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64657. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64658. */
  64659. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64660. /**
  64661. * Public members
  64662. */
  64663. /**
  64664. * Post-process which contains the original scene color before the pipeline applies all the effects
  64665. */
  64666. originalPostProcess: Nullable<PostProcess>;
  64667. /**
  64668. * Post-process used to down scale an image x4
  64669. */
  64670. downSampleX4PostProcess: Nullable<PostProcess>;
  64671. /**
  64672. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64673. */
  64674. brightPassPostProcess: Nullable<PostProcess>;
  64675. /**
  64676. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64677. */
  64678. blurHPostProcesses: PostProcess[];
  64679. /**
  64680. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64681. */
  64682. blurVPostProcesses: PostProcess[];
  64683. /**
  64684. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64685. */
  64686. textureAdderPostProcess: Nullable<PostProcess>;
  64687. /**
  64688. * Post-process used to create volumetric lighting effect
  64689. */
  64690. volumetricLightPostProcess: Nullable<PostProcess>;
  64691. /**
  64692. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64693. */
  64694. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64695. /**
  64696. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64697. */
  64698. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64699. /**
  64700. * Post-process used to merge the volumetric light effect and the real scene color
  64701. */
  64702. volumetricLightMergePostProces: Nullable<PostProcess>;
  64703. /**
  64704. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64705. */
  64706. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64707. /**
  64708. * Base post-process used to calculate the average luminance of the final image for HDR
  64709. */
  64710. luminancePostProcess: Nullable<PostProcess>;
  64711. /**
  64712. * Post-processes used to create down sample post-processes in order to get
  64713. * the average luminance of the final image for HDR
  64714. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64715. */
  64716. luminanceDownSamplePostProcesses: PostProcess[];
  64717. /**
  64718. * Post-process used to create a HDR effect (light adaptation)
  64719. */
  64720. hdrPostProcess: Nullable<PostProcess>;
  64721. /**
  64722. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64723. */
  64724. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64725. /**
  64726. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64727. */
  64728. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64729. /**
  64730. * Post-process used to merge the final HDR post-process and the real scene color
  64731. */
  64732. hdrFinalPostProcess: Nullable<PostProcess>;
  64733. /**
  64734. * Post-process used to create a lens flare effect
  64735. */
  64736. lensFlarePostProcess: Nullable<PostProcess>;
  64737. /**
  64738. * Post-process that merges the result of the lens flare post-process and the real scene color
  64739. */
  64740. lensFlareComposePostProcess: Nullable<PostProcess>;
  64741. /**
  64742. * Post-process used to create a motion blur effect
  64743. */
  64744. motionBlurPostProcess: Nullable<PostProcess>;
  64745. /**
  64746. * Post-process used to create a depth of field effect
  64747. */
  64748. depthOfFieldPostProcess: Nullable<PostProcess>;
  64749. /**
  64750. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64751. */
  64752. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64753. /**
  64754. * Represents the brightness threshold in order to configure the illuminated surfaces
  64755. */
  64756. brightThreshold: number;
  64757. /**
  64758. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64759. */
  64760. blurWidth: number;
  64761. /**
  64762. * Sets if the blur for highlighted surfaces must be only horizontal
  64763. */
  64764. horizontalBlur: boolean;
  64765. /**
  64766. * Gets the overall exposure used by the pipeline
  64767. */
  64768. /**
  64769. * Sets the overall exposure used by the pipeline
  64770. */
  64771. exposure: number;
  64772. /**
  64773. * Texture used typically to simulate "dirty" on camera lens
  64774. */
  64775. lensTexture: Nullable<Texture>;
  64776. /**
  64777. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64778. */
  64779. volumetricLightCoefficient: number;
  64780. /**
  64781. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64782. */
  64783. volumetricLightPower: number;
  64784. /**
  64785. * Used the set the blur intensity to smooth the volumetric lights
  64786. */
  64787. volumetricLightBlurScale: number;
  64788. /**
  64789. * Light (spot or directional) used to generate the volumetric lights rays
  64790. * The source light must have a shadow generate so the pipeline can get its
  64791. * depth map
  64792. */
  64793. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64794. /**
  64795. * For eye adaptation, represents the minimum luminance the eye can see
  64796. */
  64797. hdrMinimumLuminance: number;
  64798. /**
  64799. * For eye adaptation, represents the decrease luminance speed
  64800. */
  64801. hdrDecreaseRate: number;
  64802. /**
  64803. * For eye adaptation, represents the increase luminance speed
  64804. */
  64805. hdrIncreaseRate: number;
  64806. /**
  64807. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64808. */
  64809. /**
  64810. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64811. */
  64812. hdrAutoExposure: boolean;
  64813. /**
  64814. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64815. */
  64816. lensColorTexture: Nullable<Texture>;
  64817. /**
  64818. * The overall strengh for the lens flare effect
  64819. */
  64820. lensFlareStrength: number;
  64821. /**
  64822. * Dispersion coefficient for lens flare ghosts
  64823. */
  64824. lensFlareGhostDispersal: number;
  64825. /**
  64826. * Main lens flare halo width
  64827. */
  64828. lensFlareHaloWidth: number;
  64829. /**
  64830. * Based on the lens distortion effect, defines how much the lens flare result
  64831. * is distorted
  64832. */
  64833. lensFlareDistortionStrength: number;
  64834. /**
  64835. * Configures the blur intensity used for for lens flare (halo)
  64836. */
  64837. lensFlareBlurWidth: number;
  64838. /**
  64839. * Lens star texture must be used to simulate rays on the flares and is available
  64840. * in the documentation
  64841. */
  64842. lensStarTexture: Nullable<Texture>;
  64843. /**
  64844. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64845. * flare effect by taking account of the dirt texture
  64846. */
  64847. lensFlareDirtTexture: Nullable<Texture>;
  64848. /**
  64849. * Represents the focal length for the depth of field effect
  64850. */
  64851. depthOfFieldDistance: number;
  64852. /**
  64853. * Represents the blur intensity for the blurred part of the depth of field effect
  64854. */
  64855. depthOfFieldBlurWidth: number;
  64856. /**
  64857. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64858. */
  64859. /**
  64860. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64861. */
  64862. motionStrength: number;
  64863. /**
  64864. * Gets wether or not the motion blur post-process is object based or screen based.
  64865. */
  64866. /**
  64867. * Sets wether or not the motion blur post-process should be object based or screen based
  64868. */
  64869. objectBasedMotionBlur: boolean;
  64870. /**
  64871. * List of animations for the pipeline (IAnimatable implementation)
  64872. */
  64873. animations: Animation[];
  64874. /**
  64875. * Private members
  64876. */
  64877. private _scene;
  64878. private _currentDepthOfFieldSource;
  64879. private _basePostProcess;
  64880. private _fixedExposure;
  64881. private _currentExposure;
  64882. private _hdrAutoExposure;
  64883. private _hdrCurrentLuminance;
  64884. private _motionStrength;
  64885. private _isObjectBasedMotionBlur;
  64886. private _floatTextureType;
  64887. private _camerasToBeAttached;
  64888. private _ratio;
  64889. private _bloomEnabled;
  64890. private _depthOfFieldEnabled;
  64891. private _vlsEnabled;
  64892. private _lensFlareEnabled;
  64893. private _hdrEnabled;
  64894. private _motionBlurEnabled;
  64895. private _fxaaEnabled;
  64896. private _motionBlurSamples;
  64897. private _volumetricLightStepsCount;
  64898. private _samples;
  64899. /**
  64900. * @ignore
  64901. * Specifies if the bloom pipeline is enabled
  64902. */
  64903. BloomEnabled: boolean;
  64904. /**
  64905. * @ignore
  64906. * Specifies if the depth of field pipeline is enabed
  64907. */
  64908. DepthOfFieldEnabled: boolean;
  64909. /**
  64910. * @ignore
  64911. * Specifies if the lens flare pipeline is enabed
  64912. */
  64913. LensFlareEnabled: boolean;
  64914. /**
  64915. * @ignore
  64916. * Specifies if the HDR pipeline is enabled
  64917. */
  64918. HDREnabled: boolean;
  64919. /**
  64920. * @ignore
  64921. * Specifies if the volumetric lights scattering effect is enabled
  64922. */
  64923. VLSEnabled: boolean;
  64924. /**
  64925. * @ignore
  64926. * Specifies if the motion blur effect is enabled
  64927. */
  64928. MotionBlurEnabled: boolean;
  64929. /**
  64930. * Specifies if anti-aliasing is enabled
  64931. */
  64932. fxaaEnabled: boolean;
  64933. /**
  64934. * Specifies the number of steps used to calculate the volumetric lights
  64935. * Typically in interval [50, 200]
  64936. */
  64937. volumetricLightStepsCount: number;
  64938. /**
  64939. * Specifies the number of samples used for the motion blur effect
  64940. * Typically in interval [16, 64]
  64941. */
  64942. motionBlurSamples: number;
  64943. /**
  64944. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64945. */
  64946. samples: number;
  64947. /**
  64948. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64949. * @constructor
  64950. * @param name The rendering pipeline name
  64951. * @param scene The scene linked to this pipeline
  64952. * @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)
  64953. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64954. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64955. */
  64956. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64957. private _buildPipeline;
  64958. private _createDownSampleX4PostProcess;
  64959. private _createBrightPassPostProcess;
  64960. private _createBlurPostProcesses;
  64961. private _createTextureAdderPostProcess;
  64962. private _createVolumetricLightPostProcess;
  64963. private _createLuminancePostProcesses;
  64964. private _createHdrPostProcess;
  64965. private _createLensFlarePostProcess;
  64966. private _createDepthOfFieldPostProcess;
  64967. private _createMotionBlurPostProcess;
  64968. private _getDepthTexture;
  64969. private _disposePostProcesses;
  64970. /**
  64971. * Dispose of the pipeline and stop all post processes
  64972. */
  64973. dispose(): void;
  64974. /**
  64975. * Serialize the rendering pipeline (Used when exporting)
  64976. * @returns the serialized object
  64977. */
  64978. serialize(): any;
  64979. /**
  64980. * Parse the serialized pipeline
  64981. * @param source Source pipeline.
  64982. * @param scene The scene to load the pipeline to.
  64983. * @param rootUrl The URL of the serialized pipeline.
  64984. * @returns An instantiated pipeline from the serialized object.
  64985. */
  64986. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64987. /**
  64988. * Luminance steps
  64989. */
  64990. static LuminanceSteps: number;
  64991. }
  64992. }
  64993. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64994. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64995. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64996. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64997. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64998. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64999. }
  65000. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65001. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65002. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65003. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65004. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65005. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65006. }
  65007. declare module "babylonjs/Shaders/tonemap.fragment" {
  65008. /** @hidden */
  65009. export var tonemapPixelShader: {
  65010. name: string;
  65011. shader: string;
  65012. };
  65013. }
  65014. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65015. import { Camera } from "babylonjs/Cameras/camera";
  65016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65017. import "babylonjs/Shaders/tonemap.fragment";
  65018. import { Engine } from "babylonjs/Engines/engine";
  65019. /** Defines operator used for tonemapping */
  65020. export enum TonemappingOperator {
  65021. /** Hable */
  65022. Hable = 0,
  65023. /** Reinhard */
  65024. Reinhard = 1,
  65025. /** HejiDawson */
  65026. HejiDawson = 2,
  65027. /** Photographic */
  65028. Photographic = 3
  65029. }
  65030. /**
  65031. * Defines a post process to apply tone mapping
  65032. */
  65033. export class TonemapPostProcess extends PostProcess {
  65034. private _operator;
  65035. /** Defines the required exposure adjustement */
  65036. exposureAdjustment: number;
  65037. /**
  65038. * Creates a new TonemapPostProcess
  65039. * @param name defines the name of the postprocess
  65040. * @param _operator defines the operator to use
  65041. * @param exposureAdjustment defines the required exposure adjustement
  65042. * @param camera defines the camera to use (can be null)
  65043. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65044. * @param engine defines the hosting engine (can be ignore if camera is set)
  65045. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65046. */
  65047. constructor(name: string, _operator: TonemappingOperator,
  65048. /** Defines the required exposure adjustement */
  65049. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65050. }
  65051. }
  65052. declare module "babylonjs/Shaders/depth.vertex" {
  65053. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65054. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65055. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65056. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65057. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65058. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65059. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65060. /** @hidden */
  65061. export var depthVertexShader: {
  65062. name: string;
  65063. shader: string;
  65064. };
  65065. }
  65066. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65067. /** @hidden */
  65068. export var volumetricLightScatteringPixelShader: {
  65069. name: string;
  65070. shader: string;
  65071. };
  65072. }
  65073. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65074. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65075. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65076. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65077. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65078. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65079. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65080. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65081. /** @hidden */
  65082. export var volumetricLightScatteringPassVertexShader: {
  65083. name: string;
  65084. shader: string;
  65085. };
  65086. }
  65087. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65088. /** @hidden */
  65089. export var volumetricLightScatteringPassPixelShader: {
  65090. name: string;
  65091. shader: string;
  65092. };
  65093. }
  65094. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65095. import { Vector3 } from "babylonjs/Maths/math.vector";
  65096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65097. import { Mesh } from "babylonjs/Meshes/mesh";
  65098. import { Camera } from "babylonjs/Cameras/camera";
  65099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65100. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65101. import { Scene } from "babylonjs/scene";
  65102. import "babylonjs/Meshes/Builders/planeBuilder";
  65103. import "babylonjs/Shaders/depth.vertex";
  65104. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65105. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65106. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65107. import { Engine } from "babylonjs/Engines/engine";
  65108. /**
  65109. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65110. */
  65111. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65112. private _volumetricLightScatteringPass;
  65113. private _volumetricLightScatteringRTT;
  65114. private _viewPort;
  65115. private _screenCoordinates;
  65116. private _cachedDefines;
  65117. /**
  65118. * If not undefined, the mesh position is computed from the attached node position
  65119. */
  65120. attachedNode: {
  65121. position: Vector3;
  65122. };
  65123. /**
  65124. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65125. */
  65126. customMeshPosition: Vector3;
  65127. /**
  65128. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65129. */
  65130. useCustomMeshPosition: boolean;
  65131. /**
  65132. * If the post-process should inverse the light scattering direction
  65133. */
  65134. invert: boolean;
  65135. /**
  65136. * The internal mesh used by the post-process
  65137. */
  65138. mesh: Mesh;
  65139. /**
  65140. * @hidden
  65141. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65142. */
  65143. useDiffuseColor: boolean;
  65144. /**
  65145. * Array containing the excluded meshes not rendered in the internal pass
  65146. */
  65147. excludedMeshes: AbstractMesh[];
  65148. /**
  65149. * Controls the overall intensity of the post-process
  65150. */
  65151. exposure: number;
  65152. /**
  65153. * Dissipates each sample's contribution in range [0, 1]
  65154. */
  65155. decay: number;
  65156. /**
  65157. * Controls the overall intensity of each sample
  65158. */
  65159. weight: number;
  65160. /**
  65161. * Controls the density of each sample
  65162. */
  65163. density: number;
  65164. /**
  65165. * @constructor
  65166. * @param name The post-process name
  65167. * @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)
  65168. * @param camera The camera that the post-process will be attached to
  65169. * @param mesh The mesh used to create the light scattering
  65170. * @param samples The post-process quality, default 100
  65171. * @param samplingModeThe post-process filtering mode
  65172. * @param engine The babylon engine
  65173. * @param reusable If the post-process is reusable
  65174. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65175. */
  65176. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65177. /**
  65178. * Returns the string "VolumetricLightScatteringPostProcess"
  65179. * @returns "VolumetricLightScatteringPostProcess"
  65180. */
  65181. getClassName(): string;
  65182. private _isReady;
  65183. /**
  65184. * Sets the new light position for light scattering effect
  65185. * @param position The new custom light position
  65186. */
  65187. setCustomMeshPosition(position: Vector3): void;
  65188. /**
  65189. * Returns the light position for light scattering effect
  65190. * @return Vector3 The custom light position
  65191. */
  65192. getCustomMeshPosition(): Vector3;
  65193. /**
  65194. * Disposes the internal assets and detaches the post-process from the camera
  65195. */
  65196. dispose(camera: Camera): void;
  65197. /**
  65198. * Returns the render target texture used by the post-process
  65199. * @return the render target texture used by the post-process
  65200. */
  65201. getPass(): RenderTargetTexture;
  65202. private _meshExcluded;
  65203. private _createPass;
  65204. private _updateMeshScreenCoordinates;
  65205. /**
  65206. * Creates a default mesh for the Volumeric Light Scattering post-process
  65207. * @param name The mesh name
  65208. * @param scene The scene where to create the mesh
  65209. * @return the default mesh
  65210. */
  65211. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65212. }
  65213. }
  65214. declare module "babylonjs/PostProcesses/index" {
  65215. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65216. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65217. export * from "babylonjs/PostProcesses/bloomEffect";
  65218. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65219. export * from "babylonjs/PostProcesses/blurPostProcess";
  65220. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65221. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65222. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65223. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65224. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65225. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65226. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65227. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65228. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65229. export * from "babylonjs/PostProcesses/filterPostProcess";
  65230. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65231. export * from "babylonjs/PostProcesses/grainPostProcess";
  65232. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65233. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65234. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65235. export * from "babylonjs/PostProcesses/passPostProcess";
  65236. export * from "babylonjs/PostProcesses/postProcess";
  65237. export * from "babylonjs/PostProcesses/postProcessManager";
  65238. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65239. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65240. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65241. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65242. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65243. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65244. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65245. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65246. }
  65247. declare module "babylonjs/Probes/index" {
  65248. export * from "babylonjs/Probes/reflectionProbe";
  65249. }
  65250. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65251. import { Scene } from "babylonjs/scene";
  65252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65253. import { SmartArray } from "babylonjs/Misc/smartArray";
  65254. import { ISceneComponent } from "babylonjs/sceneComponent";
  65255. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65256. import "babylonjs/Meshes/Builders/boxBuilder";
  65257. import "babylonjs/Shaders/color.fragment";
  65258. import "babylonjs/Shaders/color.vertex";
  65259. import { Color3 } from "babylonjs/Maths/math.color";
  65260. module "babylonjs/scene" {
  65261. interface Scene {
  65262. /** @hidden (Backing field) */
  65263. _boundingBoxRenderer: BoundingBoxRenderer;
  65264. /** @hidden (Backing field) */
  65265. _forceShowBoundingBoxes: boolean;
  65266. /**
  65267. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65268. */
  65269. forceShowBoundingBoxes: boolean;
  65270. /**
  65271. * Gets the bounding box renderer associated with the scene
  65272. * @returns a BoundingBoxRenderer
  65273. */
  65274. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65275. }
  65276. }
  65277. module "babylonjs/Meshes/abstractMesh" {
  65278. interface AbstractMesh {
  65279. /** @hidden (Backing field) */
  65280. _showBoundingBox: boolean;
  65281. /**
  65282. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65283. */
  65284. showBoundingBox: boolean;
  65285. }
  65286. }
  65287. /**
  65288. * Component responsible of rendering the bounding box of the meshes in a scene.
  65289. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65290. */
  65291. export class BoundingBoxRenderer implements ISceneComponent {
  65292. /**
  65293. * The component name helpfull to identify the component in the list of scene components.
  65294. */
  65295. readonly name: string;
  65296. /**
  65297. * The scene the component belongs to.
  65298. */
  65299. scene: Scene;
  65300. /**
  65301. * Color of the bounding box lines placed in front of an object
  65302. */
  65303. frontColor: Color3;
  65304. /**
  65305. * Color of the bounding box lines placed behind an object
  65306. */
  65307. backColor: Color3;
  65308. /**
  65309. * Defines if the renderer should show the back lines or not
  65310. */
  65311. showBackLines: boolean;
  65312. /**
  65313. * @hidden
  65314. */
  65315. renderList: SmartArray<BoundingBox>;
  65316. private _colorShader;
  65317. private _vertexBuffers;
  65318. private _indexBuffer;
  65319. private _fillIndexBuffer;
  65320. private _fillIndexData;
  65321. /**
  65322. * Instantiates a new bounding box renderer in a scene.
  65323. * @param scene the scene the renderer renders in
  65324. */
  65325. constructor(scene: Scene);
  65326. /**
  65327. * Registers the component in a given scene
  65328. */
  65329. register(): void;
  65330. private _evaluateSubMesh;
  65331. private _activeMesh;
  65332. private _prepareRessources;
  65333. private _createIndexBuffer;
  65334. /**
  65335. * Rebuilds the elements related to this component in case of
  65336. * context lost for instance.
  65337. */
  65338. rebuild(): void;
  65339. /**
  65340. * @hidden
  65341. */
  65342. reset(): void;
  65343. /**
  65344. * Render the bounding boxes of a specific rendering group
  65345. * @param renderingGroupId defines the rendering group to render
  65346. */
  65347. render(renderingGroupId: number): void;
  65348. /**
  65349. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65350. * @param mesh Define the mesh to render the occlusion bounding box for
  65351. */
  65352. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65353. /**
  65354. * Dispose and release the resources attached to this renderer.
  65355. */
  65356. dispose(): void;
  65357. }
  65358. }
  65359. declare module "babylonjs/Shaders/depth.fragment" {
  65360. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65361. /** @hidden */
  65362. export var depthPixelShader: {
  65363. name: string;
  65364. shader: string;
  65365. };
  65366. }
  65367. declare module "babylonjs/Rendering/depthRenderer" {
  65368. import { Nullable } from "babylonjs/types";
  65369. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65370. import { Scene } from "babylonjs/scene";
  65371. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65372. import { Camera } from "babylonjs/Cameras/camera";
  65373. import "babylonjs/Shaders/depth.fragment";
  65374. import "babylonjs/Shaders/depth.vertex";
  65375. /**
  65376. * This represents a depth renderer in Babylon.
  65377. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65378. */
  65379. export class DepthRenderer {
  65380. private _scene;
  65381. private _depthMap;
  65382. private _effect;
  65383. private readonly _storeNonLinearDepth;
  65384. private readonly _clearColor;
  65385. /** Get if the depth renderer is using packed depth or not */
  65386. readonly isPacked: boolean;
  65387. private _cachedDefines;
  65388. private _camera;
  65389. /**
  65390. * Specifiess that the depth renderer will only be used within
  65391. * the camera it is created for.
  65392. * This can help forcing its rendering during the camera processing.
  65393. */
  65394. useOnlyInActiveCamera: boolean;
  65395. /** @hidden */
  65396. static _SceneComponentInitialization: (scene: Scene) => void;
  65397. /**
  65398. * Instantiates a depth renderer
  65399. * @param scene The scene the renderer belongs to
  65400. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65401. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65402. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65403. */
  65404. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65405. /**
  65406. * Creates the depth rendering effect and checks if the effect is ready.
  65407. * @param subMesh The submesh to be used to render the depth map of
  65408. * @param useInstances If multiple world instances should be used
  65409. * @returns if the depth renderer is ready to render the depth map
  65410. */
  65411. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65412. /**
  65413. * Gets the texture which the depth map will be written to.
  65414. * @returns The depth map texture
  65415. */
  65416. getDepthMap(): RenderTargetTexture;
  65417. /**
  65418. * Disposes of the depth renderer.
  65419. */
  65420. dispose(): void;
  65421. }
  65422. }
  65423. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65424. import { Nullable } from "babylonjs/types";
  65425. import { Scene } from "babylonjs/scene";
  65426. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65427. import { Camera } from "babylonjs/Cameras/camera";
  65428. import { ISceneComponent } from "babylonjs/sceneComponent";
  65429. module "babylonjs/scene" {
  65430. interface Scene {
  65431. /** @hidden (Backing field) */
  65432. _depthRenderer: {
  65433. [id: string]: DepthRenderer;
  65434. };
  65435. /**
  65436. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65437. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65438. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65439. * @returns the created depth renderer
  65440. */
  65441. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65442. /**
  65443. * Disables a depth renderer for a given camera
  65444. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65445. */
  65446. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65447. }
  65448. }
  65449. /**
  65450. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65451. * in several rendering techniques.
  65452. */
  65453. export class DepthRendererSceneComponent implements ISceneComponent {
  65454. /**
  65455. * The component name helpfull to identify the component in the list of scene components.
  65456. */
  65457. readonly name: string;
  65458. /**
  65459. * The scene the component belongs to.
  65460. */
  65461. scene: Scene;
  65462. /**
  65463. * Creates a new instance of the component for the given scene
  65464. * @param scene Defines the scene to register the component in
  65465. */
  65466. constructor(scene: Scene);
  65467. /**
  65468. * Registers the component in a given scene
  65469. */
  65470. register(): void;
  65471. /**
  65472. * Rebuilds the elements related to this component in case of
  65473. * context lost for instance.
  65474. */
  65475. rebuild(): void;
  65476. /**
  65477. * Disposes the component and the associated ressources
  65478. */
  65479. dispose(): void;
  65480. private _gatherRenderTargets;
  65481. private _gatherActiveCameraRenderTargets;
  65482. }
  65483. }
  65484. declare module "babylonjs/Shaders/outline.fragment" {
  65485. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65486. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65487. /** @hidden */
  65488. export var outlinePixelShader: {
  65489. name: string;
  65490. shader: string;
  65491. };
  65492. }
  65493. declare module "babylonjs/Shaders/outline.vertex" {
  65494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65498. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65499. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65500. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65501. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65502. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65503. /** @hidden */
  65504. export var outlineVertexShader: {
  65505. name: string;
  65506. shader: string;
  65507. };
  65508. }
  65509. declare module "babylonjs/Rendering/outlineRenderer" {
  65510. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65511. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65512. import { Scene } from "babylonjs/scene";
  65513. import { ISceneComponent } from "babylonjs/sceneComponent";
  65514. import "babylonjs/Shaders/outline.fragment";
  65515. import "babylonjs/Shaders/outline.vertex";
  65516. module "babylonjs/scene" {
  65517. interface Scene {
  65518. /** @hidden */
  65519. _outlineRenderer: OutlineRenderer;
  65520. /**
  65521. * Gets the outline renderer associated with the scene
  65522. * @returns a OutlineRenderer
  65523. */
  65524. getOutlineRenderer(): OutlineRenderer;
  65525. }
  65526. }
  65527. module "babylonjs/Meshes/abstractMesh" {
  65528. interface AbstractMesh {
  65529. /** @hidden (Backing field) */
  65530. _renderOutline: boolean;
  65531. /**
  65532. * Gets or sets a boolean indicating if the outline must be rendered as well
  65533. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65534. */
  65535. renderOutline: boolean;
  65536. /** @hidden (Backing field) */
  65537. _renderOverlay: boolean;
  65538. /**
  65539. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65540. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65541. */
  65542. renderOverlay: boolean;
  65543. }
  65544. }
  65545. /**
  65546. * This class is responsible to draw bothe outline/overlay of meshes.
  65547. * It should not be used directly but through the available method on mesh.
  65548. */
  65549. export class OutlineRenderer implements ISceneComponent {
  65550. /**
  65551. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65552. */
  65553. private static _StencilReference;
  65554. /**
  65555. * The name of the component. Each component must have a unique name.
  65556. */
  65557. name: string;
  65558. /**
  65559. * The scene the component belongs to.
  65560. */
  65561. scene: Scene;
  65562. /**
  65563. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65564. */
  65565. zOffset: number;
  65566. private _engine;
  65567. private _effect;
  65568. private _cachedDefines;
  65569. private _savedDepthWrite;
  65570. /**
  65571. * Instantiates a new outline renderer. (There could be only one per scene).
  65572. * @param scene Defines the scene it belongs to
  65573. */
  65574. constructor(scene: Scene);
  65575. /**
  65576. * Register the component to one instance of a scene.
  65577. */
  65578. register(): void;
  65579. /**
  65580. * Rebuilds the elements related to this component in case of
  65581. * context lost for instance.
  65582. */
  65583. rebuild(): void;
  65584. /**
  65585. * Disposes the component and the associated ressources.
  65586. */
  65587. dispose(): void;
  65588. /**
  65589. * Renders the outline in the canvas.
  65590. * @param subMesh Defines the sumesh to render
  65591. * @param batch Defines the batch of meshes in case of instances
  65592. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65593. */
  65594. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65595. /**
  65596. * Returns whether or not the outline renderer is ready for a given submesh.
  65597. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65598. * @param subMesh Defines the submesh to check readyness for
  65599. * @param useInstances Defines wheter wee are trying to render instances or not
  65600. * @returns true if ready otherwise false
  65601. */
  65602. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65603. private _beforeRenderingMesh;
  65604. private _afterRenderingMesh;
  65605. }
  65606. }
  65607. declare module "babylonjs/Rendering/index" {
  65608. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65609. export * from "babylonjs/Rendering/depthRenderer";
  65610. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65611. export * from "babylonjs/Rendering/edgesRenderer";
  65612. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65613. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65614. export * from "babylonjs/Rendering/outlineRenderer";
  65615. export * from "babylonjs/Rendering/renderingGroup";
  65616. export * from "babylonjs/Rendering/renderingManager";
  65617. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65618. }
  65619. declare module "babylonjs/Sprites/spritePackedManager" {
  65620. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65621. import { Scene } from "babylonjs/scene";
  65622. /**
  65623. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65624. * @see http://doc.babylonjs.com/babylon101/sprites
  65625. */
  65626. export class SpritePackedManager extends SpriteManager {
  65627. /** defines the packed manager's name */
  65628. name: string;
  65629. /**
  65630. * Creates a new sprite manager from a packed sprite sheet
  65631. * @param name defines the manager's name
  65632. * @param imgUrl defines the sprite sheet url
  65633. * @param capacity defines the maximum allowed number of sprites
  65634. * @param scene defines the hosting scene
  65635. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65636. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65637. * @param samplingMode defines the smapling mode to use with spritesheet
  65638. * @param fromPacked set to true; do not alter
  65639. */
  65640. constructor(
  65641. /** defines the packed manager's name */
  65642. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65643. }
  65644. }
  65645. declare module "babylonjs/Sprites/index" {
  65646. export * from "babylonjs/Sprites/sprite";
  65647. export * from "babylonjs/Sprites/spriteManager";
  65648. export * from "babylonjs/Sprites/spritePackedManager";
  65649. export * from "babylonjs/Sprites/spriteSceneComponent";
  65650. }
  65651. declare module "babylonjs/States/index" {
  65652. export * from "babylonjs/States/alphaCullingState";
  65653. export * from "babylonjs/States/depthCullingState";
  65654. export * from "babylonjs/States/stencilState";
  65655. }
  65656. declare module "babylonjs/Misc/assetsManager" {
  65657. import { Scene } from "babylonjs/scene";
  65658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65659. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65660. import { Skeleton } from "babylonjs/Bones/skeleton";
  65661. import { Observable } from "babylonjs/Misc/observable";
  65662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65663. import { Texture } from "babylonjs/Materials/Textures/texture";
  65664. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65665. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65666. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65667. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65668. /**
  65669. * Defines the list of states available for a task inside a AssetsManager
  65670. */
  65671. export enum AssetTaskState {
  65672. /**
  65673. * Initialization
  65674. */
  65675. INIT = 0,
  65676. /**
  65677. * Running
  65678. */
  65679. RUNNING = 1,
  65680. /**
  65681. * Done
  65682. */
  65683. DONE = 2,
  65684. /**
  65685. * Error
  65686. */
  65687. ERROR = 3
  65688. }
  65689. /**
  65690. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65691. */
  65692. export abstract class AbstractAssetTask {
  65693. /**
  65694. * Task name
  65695. */ name: string;
  65696. /**
  65697. * Callback called when the task is successful
  65698. */
  65699. onSuccess: (task: any) => void;
  65700. /**
  65701. * Callback called when the task is not successful
  65702. */
  65703. onError: (task: any, message?: string, exception?: any) => void;
  65704. /**
  65705. * Creates a new AssetsManager
  65706. * @param name defines the name of the task
  65707. */
  65708. constructor(
  65709. /**
  65710. * Task name
  65711. */ name: string);
  65712. private _isCompleted;
  65713. private _taskState;
  65714. private _errorObject;
  65715. /**
  65716. * Get if the task is completed
  65717. */
  65718. readonly isCompleted: boolean;
  65719. /**
  65720. * Gets the current state of the task
  65721. */
  65722. readonly taskState: AssetTaskState;
  65723. /**
  65724. * Gets the current error object (if task is in error)
  65725. */
  65726. readonly errorObject: {
  65727. message?: string;
  65728. exception?: any;
  65729. };
  65730. /**
  65731. * Internal only
  65732. * @hidden
  65733. */
  65734. _setErrorObject(message?: string, exception?: any): void;
  65735. /**
  65736. * Execute the current task
  65737. * @param scene defines the scene where you want your assets to be loaded
  65738. * @param onSuccess is a callback called when the task is successfully executed
  65739. * @param onError is a callback called if an error occurs
  65740. */
  65741. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65742. /**
  65743. * Execute the current task
  65744. * @param scene defines the scene where you want your assets to be loaded
  65745. * @param onSuccess is a callback called when the task is successfully executed
  65746. * @param onError is a callback called if an error occurs
  65747. */
  65748. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65749. /**
  65750. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65751. * This can be used with failed tasks that have the reason for failure fixed.
  65752. */
  65753. reset(): void;
  65754. private onErrorCallback;
  65755. private onDoneCallback;
  65756. }
  65757. /**
  65758. * Define the interface used by progress events raised during assets loading
  65759. */
  65760. export interface IAssetsProgressEvent {
  65761. /**
  65762. * Defines the number of remaining tasks to process
  65763. */
  65764. remainingCount: number;
  65765. /**
  65766. * Defines the total number of tasks
  65767. */
  65768. totalCount: number;
  65769. /**
  65770. * Defines the task that was just processed
  65771. */
  65772. task: AbstractAssetTask;
  65773. }
  65774. /**
  65775. * Class used to share progress information about assets loading
  65776. */
  65777. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65778. /**
  65779. * Defines the number of remaining tasks to process
  65780. */
  65781. remainingCount: number;
  65782. /**
  65783. * Defines the total number of tasks
  65784. */
  65785. totalCount: number;
  65786. /**
  65787. * Defines the task that was just processed
  65788. */
  65789. task: AbstractAssetTask;
  65790. /**
  65791. * Creates a AssetsProgressEvent
  65792. * @param remainingCount defines the number of remaining tasks to process
  65793. * @param totalCount defines the total number of tasks
  65794. * @param task defines the task that was just processed
  65795. */
  65796. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65797. }
  65798. /**
  65799. * Define a task used by AssetsManager to load meshes
  65800. */
  65801. export class MeshAssetTask extends AbstractAssetTask {
  65802. /**
  65803. * Defines the name of the task
  65804. */
  65805. name: string;
  65806. /**
  65807. * Defines the list of mesh's names you want to load
  65808. */
  65809. meshesNames: any;
  65810. /**
  65811. * Defines the root url to use as a base to load your meshes and associated resources
  65812. */
  65813. rootUrl: string;
  65814. /**
  65815. * Defines the filename of the scene to load from
  65816. */
  65817. sceneFilename: string;
  65818. /**
  65819. * Gets the list of loaded meshes
  65820. */
  65821. loadedMeshes: Array<AbstractMesh>;
  65822. /**
  65823. * Gets the list of loaded particle systems
  65824. */
  65825. loadedParticleSystems: Array<IParticleSystem>;
  65826. /**
  65827. * Gets the list of loaded skeletons
  65828. */
  65829. loadedSkeletons: Array<Skeleton>;
  65830. /**
  65831. * Gets the list of loaded animation groups
  65832. */
  65833. loadedAnimationGroups: Array<AnimationGroup>;
  65834. /**
  65835. * Callback called when the task is successful
  65836. */
  65837. onSuccess: (task: MeshAssetTask) => void;
  65838. /**
  65839. * Callback called when the task is successful
  65840. */
  65841. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65842. /**
  65843. * Creates a new MeshAssetTask
  65844. * @param name defines the name of the task
  65845. * @param meshesNames defines the list of mesh's names you want to load
  65846. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65847. * @param sceneFilename defines the filename of the scene to load from
  65848. */
  65849. constructor(
  65850. /**
  65851. * Defines the name of the task
  65852. */
  65853. name: string,
  65854. /**
  65855. * Defines the list of mesh's names you want to load
  65856. */
  65857. meshesNames: any,
  65858. /**
  65859. * Defines the root url to use as a base to load your meshes and associated resources
  65860. */
  65861. rootUrl: string,
  65862. /**
  65863. * Defines the filename of the scene to load from
  65864. */
  65865. sceneFilename: string);
  65866. /**
  65867. * Execute the current task
  65868. * @param scene defines the scene where you want your assets to be loaded
  65869. * @param onSuccess is a callback called when the task is successfully executed
  65870. * @param onError is a callback called if an error occurs
  65871. */
  65872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65873. }
  65874. /**
  65875. * Define a task used by AssetsManager to load text content
  65876. */
  65877. export class TextFileAssetTask extends AbstractAssetTask {
  65878. /**
  65879. * Defines the name of the task
  65880. */
  65881. name: string;
  65882. /**
  65883. * Defines the location of the file to load
  65884. */
  65885. url: string;
  65886. /**
  65887. * Gets the loaded text string
  65888. */
  65889. text: string;
  65890. /**
  65891. * Callback called when the task is successful
  65892. */
  65893. onSuccess: (task: TextFileAssetTask) => void;
  65894. /**
  65895. * Callback called when the task is successful
  65896. */
  65897. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65898. /**
  65899. * Creates a new TextFileAssetTask object
  65900. * @param name defines the name of the task
  65901. * @param url defines the location of the file to load
  65902. */
  65903. constructor(
  65904. /**
  65905. * Defines the name of the task
  65906. */
  65907. name: string,
  65908. /**
  65909. * Defines the location of the file to load
  65910. */
  65911. url: string);
  65912. /**
  65913. * Execute the current task
  65914. * @param scene defines the scene where you want your assets to be loaded
  65915. * @param onSuccess is a callback called when the task is successfully executed
  65916. * @param onError is a callback called if an error occurs
  65917. */
  65918. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65919. }
  65920. /**
  65921. * Define a task used by AssetsManager to load binary data
  65922. */
  65923. export class BinaryFileAssetTask extends AbstractAssetTask {
  65924. /**
  65925. * Defines the name of the task
  65926. */
  65927. name: string;
  65928. /**
  65929. * Defines the location of the file to load
  65930. */
  65931. url: string;
  65932. /**
  65933. * Gets the lodaded data (as an array buffer)
  65934. */
  65935. data: ArrayBuffer;
  65936. /**
  65937. * Callback called when the task is successful
  65938. */
  65939. onSuccess: (task: BinaryFileAssetTask) => void;
  65940. /**
  65941. * Callback called when the task is successful
  65942. */
  65943. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65944. /**
  65945. * Creates a new BinaryFileAssetTask object
  65946. * @param name defines the name of the new task
  65947. * @param url defines the location of the file to load
  65948. */
  65949. constructor(
  65950. /**
  65951. * Defines the name of the task
  65952. */
  65953. name: string,
  65954. /**
  65955. * Defines the location of the file to load
  65956. */
  65957. url: string);
  65958. /**
  65959. * Execute the current task
  65960. * @param scene defines the scene where you want your assets to be loaded
  65961. * @param onSuccess is a callback called when the task is successfully executed
  65962. * @param onError is a callback called if an error occurs
  65963. */
  65964. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65965. }
  65966. /**
  65967. * Define a task used by AssetsManager to load images
  65968. */
  65969. export class ImageAssetTask extends AbstractAssetTask {
  65970. /**
  65971. * Defines the name of the task
  65972. */
  65973. name: string;
  65974. /**
  65975. * Defines the location of the image to load
  65976. */
  65977. url: string;
  65978. /**
  65979. * Gets the loaded images
  65980. */
  65981. image: HTMLImageElement;
  65982. /**
  65983. * Callback called when the task is successful
  65984. */
  65985. onSuccess: (task: ImageAssetTask) => void;
  65986. /**
  65987. * Callback called when the task is successful
  65988. */
  65989. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65990. /**
  65991. * Creates a new ImageAssetTask
  65992. * @param name defines the name of the task
  65993. * @param url defines the location of the image to load
  65994. */
  65995. constructor(
  65996. /**
  65997. * Defines the name of the task
  65998. */
  65999. name: string,
  66000. /**
  66001. * Defines the location of the image to load
  66002. */
  66003. url: string);
  66004. /**
  66005. * Execute the current task
  66006. * @param scene defines the scene where you want your assets to be loaded
  66007. * @param onSuccess is a callback called when the task is successfully executed
  66008. * @param onError is a callback called if an error occurs
  66009. */
  66010. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66011. }
  66012. /**
  66013. * Defines the interface used by texture loading tasks
  66014. */
  66015. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66016. /**
  66017. * Gets the loaded texture
  66018. */
  66019. texture: TEX;
  66020. }
  66021. /**
  66022. * Define a task used by AssetsManager to load 2D textures
  66023. */
  66024. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66025. /**
  66026. * Defines the name of the task
  66027. */
  66028. name: string;
  66029. /**
  66030. * Defines the location of the file to load
  66031. */
  66032. url: string;
  66033. /**
  66034. * Defines if mipmap should not be generated (default is false)
  66035. */
  66036. noMipmap?: boolean | undefined;
  66037. /**
  66038. * Defines if texture must be inverted on Y axis (default is false)
  66039. */
  66040. invertY?: boolean | undefined;
  66041. /**
  66042. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66043. */
  66044. samplingMode: number;
  66045. /**
  66046. * Gets the loaded texture
  66047. */
  66048. texture: Texture;
  66049. /**
  66050. * Callback called when the task is successful
  66051. */
  66052. onSuccess: (task: TextureAssetTask) => void;
  66053. /**
  66054. * Callback called when the task is successful
  66055. */
  66056. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66057. /**
  66058. * Creates a new TextureAssetTask object
  66059. * @param name defines the name of the task
  66060. * @param url defines the location of the file to load
  66061. * @param noMipmap defines if mipmap should not be generated (default is false)
  66062. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66063. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66064. */
  66065. constructor(
  66066. /**
  66067. * Defines the name of the task
  66068. */
  66069. name: string,
  66070. /**
  66071. * Defines the location of the file to load
  66072. */
  66073. url: string,
  66074. /**
  66075. * Defines if mipmap should not be generated (default is false)
  66076. */
  66077. noMipmap?: boolean | undefined,
  66078. /**
  66079. * Defines if texture must be inverted on Y axis (default is false)
  66080. */
  66081. invertY?: boolean | undefined,
  66082. /**
  66083. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66084. */
  66085. samplingMode?: number);
  66086. /**
  66087. * Execute the current task
  66088. * @param scene defines the scene where you want your assets to be loaded
  66089. * @param onSuccess is a callback called when the task is successfully executed
  66090. * @param onError is a callback called if an error occurs
  66091. */
  66092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66093. }
  66094. /**
  66095. * Define a task used by AssetsManager to load cube textures
  66096. */
  66097. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66098. /**
  66099. * Defines the name of the task
  66100. */
  66101. name: string;
  66102. /**
  66103. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66104. */
  66105. url: string;
  66106. /**
  66107. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66108. */
  66109. extensions?: string[] | undefined;
  66110. /**
  66111. * Defines if mipmaps should not be generated (default is false)
  66112. */
  66113. noMipmap?: boolean | undefined;
  66114. /**
  66115. * Defines the explicit list of files (undefined by default)
  66116. */
  66117. files?: string[] | undefined;
  66118. /**
  66119. * Gets the loaded texture
  66120. */
  66121. texture: CubeTexture;
  66122. /**
  66123. * Callback called when the task is successful
  66124. */
  66125. onSuccess: (task: CubeTextureAssetTask) => void;
  66126. /**
  66127. * Callback called when the task is successful
  66128. */
  66129. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66130. /**
  66131. * Creates a new CubeTextureAssetTask
  66132. * @param name defines the name of the task
  66133. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66134. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66135. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66136. * @param files defines the explicit list of files (undefined by default)
  66137. */
  66138. constructor(
  66139. /**
  66140. * Defines the name of the task
  66141. */
  66142. name: string,
  66143. /**
  66144. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66145. */
  66146. url: string,
  66147. /**
  66148. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66149. */
  66150. extensions?: string[] | undefined,
  66151. /**
  66152. * Defines if mipmaps should not be generated (default is false)
  66153. */
  66154. noMipmap?: boolean | undefined,
  66155. /**
  66156. * Defines the explicit list of files (undefined by default)
  66157. */
  66158. files?: string[] | undefined);
  66159. /**
  66160. * Execute the current task
  66161. * @param scene defines the scene where you want your assets to be loaded
  66162. * @param onSuccess is a callback called when the task is successfully executed
  66163. * @param onError is a callback called if an error occurs
  66164. */
  66165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66166. }
  66167. /**
  66168. * Define a task used by AssetsManager to load HDR cube textures
  66169. */
  66170. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66171. /**
  66172. * Defines the name of the task
  66173. */
  66174. name: string;
  66175. /**
  66176. * Defines the location of the file to load
  66177. */
  66178. url: string;
  66179. /**
  66180. * Defines the desired size (the more it increases the longer the generation will be)
  66181. */
  66182. size: number;
  66183. /**
  66184. * Defines if mipmaps should not be generated (default is false)
  66185. */
  66186. noMipmap: boolean;
  66187. /**
  66188. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66189. */
  66190. generateHarmonics: boolean;
  66191. /**
  66192. * 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)
  66193. */
  66194. gammaSpace: boolean;
  66195. /**
  66196. * Internal Use Only
  66197. */
  66198. reserved: boolean;
  66199. /**
  66200. * Gets the loaded texture
  66201. */
  66202. texture: HDRCubeTexture;
  66203. /**
  66204. * Callback called when the task is successful
  66205. */
  66206. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66207. /**
  66208. * Callback called when the task is successful
  66209. */
  66210. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66211. /**
  66212. * Creates a new HDRCubeTextureAssetTask object
  66213. * @param name defines the name of the task
  66214. * @param url defines the location of the file to load
  66215. * @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.
  66216. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66217. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66218. * @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)
  66219. * @param reserved Internal use only
  66220. */
  66221. constructor(
  66222. /**
  66223. * Defines the name of the task
  66224. */
  66225. name: string,
  66226. /**
  66227. * Defines the location of the file to load
  66228. */
  66229. url: string,
  66230. /**
  66231. * Defines the desired size (the more it increases the longer the generation will be)
  66232. */
  66233. size: number,
  66234. /**
  66235. * Defines if mipmaps should not be generated (default is false)
  66236. */
  66237. noMipmap?: boolean,
  66238. /**
  66239. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66240. */
  66241. generateHarmonics?: boolean,
  66242. /**
  66243. * 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)
  66244. */
  66245. gammaSpace?: boolean,
  66246. /**
  66247. * Internal Use Only
  66248. */
  66249. reserved?: boolean);
  66250. /**
  66251. * Execute the current task
  66252. * @param scene defines the scene where you want your assets to be loaded
  66253. * @param onSuccess is a callback called when the task is successfully executed
  66254. * @param onError is a callback called if an error occurs
  66255. */
  66256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66257. }
  66258. /**
  66259. * Define a task used by AssetsManager to load Equirectangular cube textures
  66260. */
  66261. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66262. /**
  66263. * Defines the name of the task
  66264. */
  66265. name: string;
  66266. /**
  66267. * Defines the location of the file to load
  66268. */
  66269. url: string;
  66270. /**
  66271. * Defines the desired size (the more it increases the longer the generation will be)
  66272. */
  66273. size: number;
  66274. /**
  66275. * Defines if mipmaps should not be generated (default is false)
  66276. */
  66277. noMipmap: boolean;
  66278. /**
  66279. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66280. * but the standard material would require them in Gamma space) (default is true)
  66281. */
  66282. gammaSpace: boolean;
  66283. /**
  66284. * Gets the loaded texture
  66285. */
  66286. texture: EquiRectangularCubeTexture;
  66287. /**
  66288. * Callback called when the task is successful
  66289. */
  66290. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66291. /**
  66292. * Callback called when the task is successful
  66293. */
  66294. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66295. /**
  66296. * Creates a new EquiRectangularCubeTextureAssetTask object
  66297. * @param name defines the name of the task
  66298. * @param url defines the location of the file to load
  66299. * @param size defines the desired size (the more it increases the longer the generation will be)
  66300. * If the size is omitted this implies you are using a preprocessed cubemap.
  66301. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66302. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66303. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66304. * (default is true)
  66305. */
  66306. constructor(
  66307. /**
  66308. * Defines the name of the task
  66309. */
  66310. name: string,
  66311. /**
  66312. * Defines the location of the file to load
  66313. */
  66314. url: string,
  66315. /**
  66316. * Defines the desired size (the more it increases the longer the generation will be)
  66317. */
  66318. size: number,
  66319. /**
  66320. * Defines if mipmaps should not be generated (default is false)
  66321. */
  66322. noMipmap?: boolean,
  66323. /**
  66324. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66325. * but the standard material would require them in Gamma space) (default is true)
  66326. */
  66327. gammaSpace?: boolean);
  66328. /**
  66329. * Execute the current task
  66330. * @param scene defines the scene where you want your assets to be loaded
  66331. * @param onSuccess is a callback called when the task is successfully executed
  66332. * @param onError is a callback called if an error occurs
  66333. */
  66334. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66335. }
  66336. /**
  66337. * This class can be used to easily import assets into a scene
  66338. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66339. */
  66340. export class AssetsManager {
  66341. private _scene;
  66342. private _isLoading;
  66343. protected _tasks: AbstractAssetTask[];
  66344. protected _waitingTasksCount: number;
  66345. protected _totalTasksCount: number;
  66346. /**
  66347. * Callback called when all tasks are processed
  66348. */
  66349. onFinish: (tasks: AbstractAssetTask[]) => void;
  66350. /**
  66351. * Callback called when a task is successful
  66352. */
  66353. onTaskSuccess: (task: AbstractAssetTask) => void;
  66354. /**
  66355. * Callback called when a task had an error
  66356. */
  66357. onTaskError: (task: AbstractAssetTask) => void;
  66358. /**
  66359. * Callback called when a task is done (whatever the result is)
  66360. */
  66361. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66362. /**
  66363. * Observable called when all tasks are processed
  66364. */
  66365. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66366. /**
  66367. * Observable called when a task had an error
  66368. */
  66369. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66370. /**
  66371. * Observable called when all tasks were executed
  66372. */
  66373. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66374. /**
  66375. * Observable called when a task is done (whatever the result is)
  66376. */
  66377. onProgressObservable: Observable<IAssetsProgressEvent>;
  66378. /**
  66379. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66381. */
  66382. useDefaultLoadingScreen: boolean;
  66383. /**
  66384. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66385. * when all assets have been downloaded.
  66386. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66387. */
  66388. autoHideLoadingUI: boolean;
  66389. /**
  66390. * Creates a new AssetsManager
  66391. * @param scene defines the scene to work on
  66392. */
  66393. constructor(scene: Scene);
  66394. /**
  66395. * Add a MeshAssetTask to the list of active tasks
  66396. * @param taskName defines the name of the new task
  66397. * @param meshesNames defines the name of meshes to load
  66398. * @param rootUrl defines the root url to use to locate files
  66399. * @param sceneFilename defines the filename of the scene file
  66400. * @returns a new MeshAssetTask object
  66401. */
  66402. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66403. /**
  66404. * Add a TextFileAssetTask to the list of active tasks
  66405. * @param taskName defines the name of the new task
  66406. * @param url defines the url of the file to load
  66407. * @returns a new TextFileAssetTask object
  66408. */
  66409. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66410. /**
  66411. * Add a BinaryFileAssetTask to the list of active tasks
  66412. * @param taskName defines the name of the new task
  66413. * @param url defines the url of the file to load
  66414. * @returns a new BinaryFileAssetTask object
  66415. */
  66416. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66417. /**
  66418. * Add a ImageAssetTask to the list of active tasks
  66419. * @param taskName defines the name of the new task
  66420. * @param url defines the url of the file to load
  66421. * @returns a new ImageAssetTask object
  66422. */
  66423. addImageTask(taskName: string, url: string): ImageAssetTask;
  66424. /**
  66425. * Add a TextureAssetTask to the list of active tasks
  66426. * @param taskName defines the name of the new task
  66427. * @param url defines the url of the file to load
  66428. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66429. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66430. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66431. * @returns a new TextureAssetTask object
  66432. */
  66433. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66434. /**
  66435. * Add a CubeTextureAssetTask to the list of active tasks
  66436. * @param taskName defines the name of the new task
  66437. * @param url defines the url of the file to load
  66438. * @param extensions defines the extension to use to load the cube map (can be null)
  66439. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66440. * @param files defines the list of files to load (can be null)
  66441. * @returns a new CubeTextureAssetTask object
  66442. */
  66443. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66444. /**
  66445. *
  66446. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66447. * @param taskName defines the name of the new task
  66448. * @param url defines the url of the file to load
  66449. * @param size defines the size you want for the cubemap (can be null)
  66450. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66451. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66452. * @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)
  66453. * @param reserved Internal use only
  66454. * @returns a new HDRCubeTextureAssetTask object
  66455. */
  66456. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66457. /**
  66458. *
  66459. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66460. * @param taskName defines the name of the new task
  66461. * @param url defines the url of the file to load
  66462. * @param size defines the size you want for the cubemap (can be null)
  66463. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66464. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66465. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66466. * @returns a new EquiRectangularCubeTextureAssetTask object
  66467. */
  66468. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66469. /**
  66470. * Remove a task from the assets manager.
  66471. * @param task the task to remove
  66472. */
  66473. removeTask(task: AbstractAssetTask): void;
  66474. private _decreaseWaitingTasksCount;
  66475. private _runTask;
  66476. /**
  66477. * Reset the AssetsManager and remove all tasks
  66478. * @return the current instance of the AssetsManager
  66479. */
  66480. reset(): AssetsManager;
  66481. /**
  66482. * Start the loading process
  66483. * @return the current instance of the AssetsManager
  66484. */
  66485. load(): AssetsManager;
  66486. /**
  66487. * Start the loading process as an async operation
  66488. * @return a promise returning the list of failed tasks
  66489. */
  66490. loadAsync(): Promise<void>;
  66491. }
  66492. }
  66493. declare module "babylonjs/Misc/deferred" {
  66494. /**
  66495. * Wrapper class for promise with external resolve and reject.
  66496. */
  66497. export class Deferred<T> {
  66498. /**
  66499. * The promise associated with this deferred object.
  66500. */
  66501. readonly promise: Promise<T>;
  66502. private _resolve;
  66503. private _reject;
  66504. /**
  66505. * The resolve method of the promise associated with this deferred object.
  66506. */
  66507. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66508. /**
  66509. * The reject method of the promise associated with this deferred object.
  66510. */
  66511. readonly reject: (reason?: any) => void;
  66512. /**
  66513. * Constructor for this deferred object.
  66514. */
  66515. constructor();
  66516. }
  66517. }
  66518. declare module "babylonjs/Misc/meshExploder" {
  66519. import { Mesh } from "babylonjs/Meshes/mesh";
  66520. /**
  66521. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66522. */
  66523. export class MeshExploder {
  66524. private _centerMesh;
  66525. private _meshes;
  66526. private _meshesOrigins;
  66527. private _toCenterVectors;
  66528. private _scaledDirection;
  66529. private _newPosition;
  66530. private _centerPosition;
  66531. /**
  66532. * Explodes meshes from a center mesh.
  66533. * @param meshes The meshes to explode.
  66534. * @param centerMesh The mesh to be center of explosion.
  66535. */
  66536. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66537. private _setCenterMesh;
  66538. /**
  66539. * Get class name
  66540. * @returns "MeshExploder"
  66541. */
  66542. getClassName(): string;
  66543. /**
  66544. * "Exploded meshes"
  66545. * @returns Array of meshes with the centerMesh at index 0.
  66546. */
  66547. getMeshes(): Array<Mesh>;
  66548. /**
  66549. * Explodes meshes giving a specific direction
  66550. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66551. */
  66552. explode(direction?: number): void;
  66553. }
  66554. }
  66555. declare module "babylonjs/Misc/filesInput" {
  66556. import { Engine } from "babylonjs/Engines/engine";
  66557. import { Scene } from "babylonjs/scene";
  66558. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66559. /**
  66560. * Class used to help managing file picking and drag'n'drop
  66561. */
  66562. export class FilesInput {
  66563. /**
  66564. * List of files ready to be loaded
  66565. */
  66566. static readonly FilesToLoad: {
  66567. [key: string]: File;
  66568. };
  66569. /**
  66570. * Callback called when a file is processed
  66571. */
  66572. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66573. private _engine;
  66574. private _currentScene;
  66575. private _sceneLoadedCallback;
  66576. private _progressCallback;
  66577. private _additionalRenderLoopLogicCallback;
  66578. private _textureLoadingCallback;
  66579. private _startingProcessingFilesCallback;
  66580. private _onReloadCallback;
  66581. private _errorCallback;
  66582. private _elementToMonitor;
  66583. private _sceneFileToLoad;
  66584. private _filesToLoad;
  66585. /**
  66586. * Creates a new FilesInput
  66587. * @param engine defines the rendering engine
  66588. * @param scene defines the hosting scene
  66589. * @param sceneLoadedCallback callback called when scene is loaded
  66590. * @param progressCallback callback called to track progress
  66591. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66592. * @param textureLoadingCallback callback called when a texture is loading
  66593. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66594. * @param onReloadCallback callback called when a reload is requested
  66595. * @param errorCallback callback call if an error occurs
  66596. */
  66597. 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);
  66598. private _dragEnterHandler;
  66599. private _dragOverHandler;
  66600. private _dropHandler;
  66601. /**
  66602. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66603. * @param elementToMonitor defines the DOM element to track
  66604. */
  66605. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66606. /**
  66607. * Release all associated resources
  66608. */
  66609. dispose(): void;
  66610. private renderFunction;
  66611. private drag;
  66612. private drop;
  66613. private _traverseFolder;
  66614. private _processFiles;
  66615. /**
  66616. * Load files from a drop event
  66617. * @param event defines the drop event to use as source
  66618. */
  66619. loadFiles(event: any): void;
  66620. private _processReload;
  66621. /**
  66622. * Reload the current scene from the loaded files
  66623. */
  66624. reload(): void;
  66625. }
  66626. }
  66627. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66628. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66629. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66630. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66631. }
  66632. declare module "babylonjs/Misc/sceneOptimizer" {
  66633. import { Scene, IDisposable } from "babylonjs/scene";
  66634. import { Observable } from "babylonjs/Misc/observable";
  66635. /**
  66636. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66638. */
  66639. export class SceneOptimization {
  66640. /**
  66641. * Defines the priority of this optimization (0 by default which means first in the list)
  66642. */
  66643. priority: number;
  66644. /**
  66645. * Gets a string describing the action executed by the current optimization
  66646. * @returns description string
  66647. */
  66648. getDescription(): string;
  66649. /**
  66650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66651. * @param scene defines the current scene where to apply this optimization
  66652. * @param optimizer defines the current optimizer
  66653. * @returns true if everything that can be done was applied
  66654. */
  66655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66656. /**
  66657. * Creates the SceneOptimization object
  66658. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66659. * @param desc defines the description associated with the optimization
  66660. */
  66661. constructor(
  66662. /**
  66663. * Defines the priority of this optimization (0 by default which means first in the list)
  66664. */
  66665. priority?: number);
  66666. }
  66667. /**
  66668. * Defines an optimization used to reduce the size of render target textures
  66669. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66670. */
  66671. export class TextureOptimization extends SceneOptimization {
  66672. /**
  66673. * Defines the priority of this optimization (0 by default which means first in the list)
  66674. */
  66675. priority: number;
  66676. /**
  66677. * 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
  66678. */
  66679. maximumSize: number;
  66680. /**
  66681. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66682. */
  66683. step: number;
  66684. /**
  66685. * Gets a string describing the action executed by the current optimization
  66686. * @returns description string
  66687. */
  66688. getDescription(): string;
  66689. /**
  66690. * Creates the TextureOptimization object
  66691. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66692. * @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
  66693. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66694. */
  66695. constructor(
  66696. /**
  66697. * Defines the priority of this optimization (0 by default which means first in the list)
  66698. */
  66699. priority?: number,
  66700. /**
  66701. * 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
  66702. */
  66703. maximumSize?: number,
  66704. /**
  66705. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66706. */
  66707. step?: number);
  66708. /**
  66709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66710. * @param scene defines the current scene where to apply this optimization
  66711. * @param optimizer defines the current optimizer
  66712. * @returns true if everything that can be done was applied
  66713. */
  66714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66715. }
  66716. /**
  66717. * Defines an optimization used to increase or decrease the rendering resolution
  66718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66719. */
  66720. export class HardwareScalingOptimization extends SceneOptimization {
  66721. /**
  66722. * Defines the priority of this optimization (0 by default which means first in the list)
  66723. */
  66724. priority: number;
  66725. /**
  66726. * Defines the maximum scale to use (2 by default)
  66727. */
  66728. maximumScale: number;
  66729. /**
  66730. * Defines the step to use between two passes (0.5 by default)
  66731. */
  66732. step: number;
  66733. private _currentScale;
  66734. private _directionOffset;
  66735. /**
  66736. * Gets a string describing the action executed by the current optimization
  66737. * @return description string
  66738. */
  66739. getDescription(): string;
  66740. /**
  66741. * Creates the HardwareScalingOptimization object
  66742. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66743. * @param maximumScale defines the maximum scale to use (2 by default)
  66744. * @param step defines the step to use between two passes (0.5 by default)
  66745. */
  66746. constructor(
  66747. /**
  66748. * Defines the priority of this optimization (0 by default which means first in the list)
  66749. */
  66750. priority?: number,
  66751. /**
  66752. * Defines the maximum scale to use (2 by default)
  66753. */
  66754. maximumScale?: number,
  66755. /**
  66756. * Defines the step to use between two passes (0.5 by default)
  66757. */
  66758. step?: number);
  66759. /**
  66760. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66761. * @param scene defines the current scene where to apply this optimization
  66762. * @param optimizer defines the current optimizer
  66763. * @returns true if everything that can be done was applied
  66764. */
  66765. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66766. }
  66767. /**
  66768. * Defines an optimization used to remove shadows
  66769. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66770. */
  66771. export class ShadowsOptimization extends SceneOptimization {
  66772. /**
  66773. * Gets a string describing the action executed by the current optimization
  66774. * @return description string
  66775. */
  66776. getDescription(): string;
  66777. /**
  66778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66779. * @param scene defines the current scene where to apply this optimization
  66780. * @param optimizer defines the current optimizer
  66781. * @returns true if everything that can be done was applied
  66782. */
  66783. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66784. }
  66785. /**
  66786. * Defines an optimization used to turn post-processes off
  66787. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66788. */
  66789. export class PostProcessesOptimization extends SceneOptimization {
  66790. /**
  66791. * Gets a string describing the action executed by the current optimization
  66792. * @return description string
  66793. */
  66794. getDescription(): string;
  66795. /**
  66796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66797. * @param scene defines the current scene where to apply this optimization
  66798. * @param optimizer defines the current optimizer
  66799. * @returns true if everything that can be done was applied
  66800. */
  66801. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66802. }
  66803. /**
  66804. * Defines an optimization used to turn lens flares off
  66805. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66806. */
  66807. export class LensFlaresOptimization extends SceneOptimization {
  66808. /**
  66809. * Gets a string describing the action executed by the current optimization
  66810. * @return description string
  66811. */
  66812. getDescription(): string;
  66813. /**
  66814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66815. * @param scene defines the current scene where to apply this optimization
  66816. * @param optimizer defines the current optimizer
  66817. * @returns true if everything that can be done was applied
  66818. */
  66819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66820. }
  66821. /**
  66822. * Defines an optimization based on user defined callback.
  66823. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66824. */
  66825. export class CustomOptimization extends SceneOptimization {
  66826. /**
  66827. * Callback called to apply the custom optimization.
  66828. */
  66829. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66830. /**
  66831. * Callback called to get custom description
  66832. */
  66833. onGetDescription: () => string;
  66834. /**
  66835. * Gets a string describing the action executed by the current optimization
  66836. * @returns description string
  66837. */
  66838. getDescription(): string;
  66839. /**
  66840. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66841. * @param scene defines the current scene where to apply this optimization
  66842. * @param optimizer defines the current optimizer
  66843. * @returns true if everything that can be done was applied
  66844. */
  66845. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66846. }
  66847. /**
  66848. * Defines an optimization used to turn particles off
  66849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66850. */
  66851. export class ParticlesOptimization extends SceneOptimization {
  66852. /**
  66853. * Gets a string describing the action executed by the current optimization
  66854. * @return description string
  66855. */
  66856. getDescription(): string;
  66857. /**
  66858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66859. * @param scene defines the current scene where to apply this optimization
  66860. * @param optimizer defines the current optimizer
  66861. * @returns true if everything that can be done was applied
  66862. */
  66863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66864. }
  66865. /**
  66866. * Defines an optimization used to turn render targets off
  66867. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66868. */
  66869. export class RenderTargetsOptimization extends SceneOptimization {
  66870. /**
  66871. * Gets a string describing the action executed by the current optimization
  66872. * @return description string
  66873. */
  66874. getDescription(): string;
  66875. /**
  66876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66877. * @param scene defines the current scene where to apply this optimization
  66878. * @param optimizer defines the current optimizer
  66879. * @returns true if everything that can be done was applied
  66880. */
  66881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66882. }
  66883. /**
  66884. * Defines an optimization used to merge meshes with compatible materials
  66885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66886. */
  66887. export class MergeMeshesOptimization extends SceneOptimization {
  66888. private static _UpdateSelectionTree;
  66889. /**
  66890. * Gets or sets a boolean which defines if optimization octree has to be updated
  66891. */
  66892. /**
  66893. * Gets or sets a boolean which defines if optimization octree has to be updated
  66894. */
  66895. static UpdateSelectionTree: boolean;
  66896. /**
  66897. * Gets a string describing the action executed by the current optimization
  66898. * @return description string
  66899. */
  66900. getDescription(): string;
  66901. private _canBeMerged;
  66902. /**
  66903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66904. * @param scene defines the current scene where to apply this optimization
  66905. * @param optimizer defines the current optimizer
  66906. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66907. * @returns true if everything that can be done was applied
  66908. */
  66909. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66910. }
  66911. /**
  66912. * Defines a list of options used by SceneOptimizer
  66913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66914. */
  66915. export class SceneOptimizerOptions {
  66916. /**
  66917. * Defines the target frame rate to reach (60 by default)
  66918. */
  66919. targetFrameRate: number;
  66920. /**
  66921. * Defines the interval between two checkes (2000ms by default)
  66922. */
  66923. trackerDuration: number;
  66924. /**
  66925. * Gets the list of optimizations to apply
  66926. */
  66927. optimizations: SceneOptimization[];
  66928. /**
  66929. * Creates a new list of options used by SceneOptimizer
  66930. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66931. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66932. */
  66933. constructor(
  66934. /**
  66935. * Defines the target frame rate to reach (60 by default)
  66936. */
  66937. targetFrameRate?: number,
  66938. /**
  66939. * Defines the interval between two checkes (2000ms by default)
  66940. */
  66941. trackerDuration?: number);
  66942. /**
  66943. * Add a new optimization
  66944. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66945. * @returns the current SceneOptimizerOptions
  66946. */
  66947. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66948. /**
  66949. * Add a new custom optimization
  66950. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66951. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66952. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66953. * @returns the current SceneOptimizerOptions
  66954. */
  66955. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66956. /**
  66957. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66958. * @param targetFrameRate defines the target frame rate (60 by default)
  66959. * @returns a SceneOptimizerOptions object
  66960. */
  66961. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66962. /**
  66963. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66964. * @param targetFrameRate defines the target frame rate (60 by default)
  66965. * @returns a SceneOptimizerOptions object
  66966. */
  66967. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66968. /**
  66969. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66970. * @param targetFrameRate defines the target frame rate (60 by default)
  66971. * @returns a SceneOptimizerOptions object
  66972. */
  66973. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66974. }
  66975. /**
  66976. * Class used to run optimizations in order to reach a target frame rate
  66977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66978. */
  66979. export class SceneOptimizer implements IDisposable {
  66980. private _isRunning;
  66981. private _options;
  66982. private _scene;
  66983. private _currentPriorityLevel;
  66984. private _targetFrameRate;
  66985. private _trackerDuration;
  66986. private _currentFrameRate;
  66987. private _sceneDisposeObserver;
  66988. private _improvementMode;
  66989. /**
  66990. * Defines an observable called when the optimizer reaches the target frame rate
  66991. */
  66992. onSuccessObservable: Observable<SceneOptimizer>;
  66993. /**
  66994. * Defines an observable called when the optimizer enables an optimization
  66995. */
  66996. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66997. /**
  66998. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66999. */
  67000. onFailureObservable: Observable<SceneOptimizer>;
  67001. /**
  67002. * Gets a boolean indicating if the optimizer is in improvement mode
  67003. */
  67004. readonly isInImprovementMode: boolean;
  67005. /**
  67006. * Gets the current priority level (0 at start)
  67007. */
  67008. readonly currentPriorityLevel: number;
  67009. /**
  67010. * Gets the current frame rate checked by the SceneOptimizer
  67011. */
  67012. readonly currentFrameRate: number;
  67013. /**
  67014. * Gets or sets the current target frame rate (60 by default)
  67015. */
  67016. /**
  67017. * Gets or sets the current target frame rate (60 by default)
  67018. */
  67019. targetFrameRate: number;
  67020. /**
  67021. * Gets or sets the current interval between two checks (every 2000ms by default)
  67022. */
  67023. /**
  67024. * Gets or sets the current interval between two checks (every 2000ms by default)
  67025. */
  67026. trackerDuration: number;
  67027. /**
  67028. * Gets the list of active optimizations
  67029. */
  67030. readonly optimizations: SceneOptimization[];
  67031. /**
  67032. * Creates a new SceneOptimizer
  67033. * @param scene defines the scene to work on
  67034. * @param options defines the options to use with the SceneOptimizer
  67035. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67036. * @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)
  67037. */
  67038. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67039. /**
  67040. * Stops the current optimizer
  67041. */
  67042. stop(): void;
  67043. /**
  67044. * Reset the optimizer to initial step (current priority level = 0)
  67045. */
  67046. reset(): void;
  67047. /**
  67048. * Start the optimizer. By default it will try to reach a specific framerate
  67049. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67050. */
  67051. start(): void;
  67052. private _checkCurrentState;
  67053. /**
  67054. * Release all resources
  67055. */
  67056. dispose(): void;
  67057. /**
  67058. * Helper function to create a SceneOptimizer with one single line of code
  67059. * @param scene defines the scene to work on
  67060. * @param options defines the options to use with the SceneOptimizer
  67061. * @param onSuccess defines a callback to call on success
  67062. * @param onFailure defines a callback to call on failure
  67063. * @returns the new SceneOptimizer object
  67064. */
  67065. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67066. }
  67067. }
  67068. declare module "babylonjs/Misc/sceneSerializer" {
  67069. import { Scene } from "babylonjs/scene";
  67070. /**
  67071. * Class used to serialize a scene into a string
  67072. */
  67073. export class SceneSerializer {
  67074. /**
  67075. * Clear cache used by a previous serialization
  67076. */
  67077. static ClearCache(): void;
  67078. /**
  67079. * Serialize a scene into a JSON compatible object
  67080. * @param scene defines the scene to serialize
  67081. * @returns a JSON compatible object
  67082. */
  67083. static Serialize(scene: Scene): any;
  67084. /**
  67085. * Serialize a mesh into a JSON compatible object
  67086. * @param toSerialize defines the mesh to serialize
  67087. * @param withParents defines if parents must be serialized as well
  67088. * @param withChildren defines if children must be serialized as well
  67089. * @returns a JSON compatible object
  67090. */
  67091. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67092. }
  67093. }
  67094. declare module "babylonjs/Misc/textureTools" {
  67095. import { Texture } from "babylonjs/Materials/Textures/texture";
  67096. /**
  67097. * Class used to host texture specific utilities
  67098. */
  67099. export class TextureTools {
  67100. /**
  67101. * Uses the GPU to create a copy texture rescaled at a given size
  67102. * @param texture Texture to copy from
  67103. * @param width defines the desired width
  67104. * @param height defines the desired height
  67105. * @param useBilinearMode defines if bilinear mode has to be used
  67106. * @return the generated texture
  67107. */
  67108. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67109. }
  67110. }
  67111. declare module "babylonjs/Misc/videoRecorder" {
  67112. import { Nullable } from "babylonjs/types";
  67113. import { Engine } from "babylonjs/Engines/engine";
  67114. /**
  67115. * This represents the different options available for the video capture.
  67116. */
  67117. export interface VideoRecorderOptions {
  67118. /** Defines the mime type of the video. */
  67119. mimeType: string;
  67120. /** Defines the FPS the video should be recorded at. */
  67121. fps: number;
  67122. /** Defines the chunk size for the recording data. */
  67123. recordChunckSize: number;
  67124. /** The audio tracks to attach to the recording. */
  67125. audioTracks?: MediaStreamTrack[];
  67126. }
  67127. /**
  67128. * This can help with recording videos from BabylonJS.
  67129. * This is based on the available WebRTC functionalities of the browser.
  67130. *
  67131. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67132. */
  67133. export class VideoRecorder {
  67134. private static readonly _defaultOptions;
  67135. /**
  67136. * Returns whether or not the VideoRecorder is available in your browser.
  67137. * @param engine Defines the Babylon Engine.
  67138. * @returns true if supported otherwise false.
  67139. */
  67140. static IsSupported(engine: Engine): boolean;
  67141. private readonly _options;
  67142. private _canvas;
  67143. private _mediaRecorder;
  67144. private _recordedChunks;
  67145. private _fileName;
  67146. private _resolve;
  67147. private _reject;
  67148. /**
  67149. * True when a recording is already in progress.
  67150. */
  67151. readonly isRecording: boolean;
  67152. /**
  67153. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67154. * @param engine Defines the BabylonJS Engine you wish to record.
  67155. * @param options Defines options that can be used to customize the capture.
  67156. */
  67157. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67158. /**
  67159. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67160. */
  67161. stopRecording(): void;
  67162. /**
  67163. * Starts recording the canvas for a max duration specified in parameters.
  67164. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67165. * If null no automatic download will start and you can rely on the promise to get the data back.
  67166. * @param maxDuration Defines the maximum recording time in seconds.
  67167. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67168. * @return A promise callback at the end of the recording with the video data in Blob.
  67169. */
  67170. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67171. /**
  67172. * Releases internal resources used during the recording.
  67173. */
  67174. dispose(): void;
  67175. private _handleDataAvailable;
  67176. private _handleError;
  67177. private _handleStop;
  67178. }
  67179. }
  67180. declare module "babylonjs/Misc/screenshotTools" {
  67181. import { Camera } from "babylonjs/Cameras/camera";
  67182. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67183. import { Engine } from "babylonjs/Engines/engine";
  67184. /**
  67185. * Class containing a set of static utilities functions for screenshots
  67186. */
  67187. export class ScreenshotTools {
  67188. /**
  67189. * Captures a screenshot of the current rendering
  67190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67191. * @param engine defines the rendering engine
  67192. * @param camera defines the source camera
  67193. * @param size This parameter can be set to a single number or to an object with the
  67194. * following (optional) properties: precision, width, height. If a single number is passed,
  67195. * it will be used for both width and height. If an object is passed, the screenshot size
  67196. * will be derived from the parameters. The precision property is a multiplier allowing
  67197. * rendering at a higher or lower resolution
  67198. * @param successCallback defines the callback receives a single parameter which contains the
  67199. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67200. * src parameter of an <img> to display it
  67201. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67202. * Check your browser for supported MIME types
  67203. */
  67204. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67205. /**
  67206. * Captures a screenshot of the current rendering
  67207. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67208. * @param engine defines the rendering engine
  67209. * @param camera defines the source camera
  67210. * @param size This parameter can be set to a single number or to an object with the
  67211. * following (optional) properties: precision, width, height. If a single number is passed,
  67212. * it will be used for both width and height. If an object is passed, the screenshot size
  67213. * will be derived from the parameters. The precision property is a multiplier allowing
  67214. * rendering at a higher or lower resolution
  67215. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67216. * Check your browser for supported MIME types
  67217. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67218. * to the src parameter of an <img> to display it
  67219. */
  67220. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67221. /**
  67222. * Generates an image screenshot from the specified camera.
  67223. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67224. * @param engine The engine to use for rendering
  67225. * @param camera The camera to use for rendering
  67226. * @param size This parameter can be set to a single number or to an object with the
  67227. * following (optional) properties: precision, width, height. If a single number is passed,
  67228. * it will be used for both width and height. If an object is passed, the screenshot size
  67229. * will be derived from the parameters. The precision property is a multiplier allowing
  67230. * rendering at a higher or lower resolution
  67231. * @param successCallback The callback receives a single parameter which contains the
  67232. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67233. * src parameter of an <img> to display it
  67234. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67235. * Check your browser for supported MIME types
  67236. * @param samples Texture samples (default: 1)
  67237. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67238. * @param fileName A name for for the downloaded file.
  67239. */
  67240. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67241. /**
  67242. * Generates an image screenshot from the specified camera.
  67243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67244. * @param engine The engine to use for rendering
  67245. * @param camera The camera to use for rendering
  67246. * @param size This parameter can be set to a single number or to an object with the
  67247. * following (optional) properties: precision, width, height. If a single number is passed,
  67248. * it will be used for both width and height. If an object is passed, the screenshot size
  67249. * will be derived from the parameters. The precision property is a multiplier allowing
  67250. * rendering at a higher or lower resolution
  67251. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67252. * Check your browser for supported MIME types
  67253. * @param samples Texture samples (default: 1)
  67254. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67255. * @param fileName A name for for the downloaded file.
  67256. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67257. * to the src parameter of an <img> to display it
  67258. */
  67259. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67260. /**
  67261. * Gets height and width for screenshot size
  67262. * @private
  67263. */
  67264. private static _getScreenshotSize;
  67265. }
  67266. }
  67267. declare module "babylonjs/Misc/index" {
  67268. export * from "babylonjs/Misc/andOrNotEvaluator";
  67269. export * from "babylonjs/Misc/assetsManager";
  67270. export * from "babylonjs/Misc/dds";
  67271. export * from "babylonjs/Misc/decorators";
  67272. export * from "babylonjs/Misc/deferred";
  67273. export * from "babylonjs/Misc/environmentTextureTools";
  67274. export * from "babylonjs/Misc/meshExploder";
  67275. export * from "babylonjs/Misc/filesInput";
  67276. export * from "babylonjs/Misc/HighDynamicRange/index";
  67277. export * from "babylonjs/Misc/khronosTextureContainer";
  67278. export * from "babylonjs/Misc/observable";
  67279. export * from "babylonjs/Misc/performanceMonitor";
  67280. export * from "babylonjs/Misc/promise";
  67281. export * from "babylonjs/Misc/sceneOptimizer";
  67282. export * from "babylonjs/Misc/sceneSerializer";
  67283. export * from "babylonjs/Misc/smartArray";
  67284. export * from "babylonjs/Misc/stringDictionary";
  67285. export * from "babylonjs/Misc/tags";
  67286. export * from "babylonjs/Misc/textureTools";
  67287. export * from "babylonjs/Misc/tga";
  67288. export * from "babylonjs/Misc/tools";
  67289. export * from "babylonjs/Misc/videoRecorder";
  67290. export * from "babylonjs/Misc/virtualJoystick";
  67291. export * from "babylonjs/Misc/workerPool";
  67292. export * from "babylonjs/Misc/logger";
  67293. export * from "babylonjs/Misc/typeStore";
  67294. export * from "babylonjs/Misc/filesInputStore";
  67295. export * from "babylonjs/Misc/deepCopier";
  67296. export * from "babylonjs/Misc/pivotTools";
  67297. export * from "babylonjs/Misc/precisionDate";
  67298. export * from "babylonjs/Misc/screenshotTools";
  67299. export * from "babylonjs/Misc/typeStore";
  67300. export * from "babylonjs/Misc/webRequest";
  67301. export * from "babylonjs/Misc/iInspectable";
  67302. export * from "babylonjs/Misc/brdfTextureTools";
  67303. export * from "babylonjs/Misc/rgbdTextureTools";
  67304. export * from "babylonjs/Misc/gradients";
  67305. export * from "babylonjs/Misc/perfCounter";
  67306. export * from "babylonjs/Misc/fileRequest";
  67307. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67308. export * from "babylonjs/Misc/retryStrategy";
  67309. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67310. export * from "babylonjs/Misc/canvasGenerator";
  67311. export * from "babylonjs/Misc/fileTools";
  67312. export * from "babylonjs/Misc/stringTools";
  67313. }
  67314. declare module "babylonjs/index" {
  67315. export * from "babylonjs/abstractScene";
  67316. export * from "babylonjs/Actions/index";
  67317. export * from "babylonjs/Animations/index";
  67318. export * from "babylonjs/assetContainer";
  67319. export * from "babylonjs/Audio/index";
  67320. export * from "babylonjs/Behaviors/index";
  67321. export * from "babylonjs/Bones/index";
  67322. export * from "babylonjs/Cameras/index";
  67323. export * from "babylonjs/Collisions/index";
  67324. export * from "babylonjs/Culling/index";
  67325. export * from "babylonjs/Debug/index";
  67326. export * from "babylonjs/Engines/index";
  67327. export * from "babylonjs/Events/index";
  67328. export * from "babylonjs/Gamepads/index";
  67329. export * from "babylonjs/Gizmos/index";
  67330. export * from "babylonjs/Helpers/index";
  67331. export * from "babylonjs/Instrumentation/index";
  67332. export * from "babylonjs/Layers/index";
  67333. export * from "babylonjs/LensFlares/index";
  67334. export * from "babylonjs/Lights/index";
  67335. export * from "babylonjs/Loading/index";
  67336. export * from "babylonjs/Materials/index";
  67337. export * from "babylonjs/Maths/index";
  67338. export * from "babylonjs/Meshes/index";
  67339. export * from "babylonjs/Morph/index";
  67340. export * from "babylonjs/Navigation/index";
  67341. export * from "babylonjs/node";
  67342. export * from "babylonjs/Offline/index";
  67343. export * from "babylonjs/Particles/index";
  67344. export * from "babylonjs/Physics/index";
  67345. export * from "babylonjs/PostProcesses/index";
  67346. export * from "babylonjs/Probes/index";
  67347. export * from "babylonjs/Rendering/index";
  67348. export * from "babylonjs/scene";
  67349. export * from "babylonjs/sceneComponent";
  67350. export * from "babylonjs/Sprites/index";
  67351. export * from "babylonjs/States/index";
  67352. export * from "babylonjs/Misc/index";
  67353. export * from "babylonjs/types";
  67354. }
  67355. declare module "babylonjs/Animations/pathCursor" {
  67356. import { Vector3 } from "babylonjs/Maths/math.vector";
  67357. import { Path2 } from "babylonjs/Maths/math.path";
  67358. /**
  67359. * A cursor which tracks a point on a path
  67360. */
  67361. export class PathCursor {
  67362. private path;
  67363. /**
  67364. * Stores path cursor callbacks for when an onchange event is triggered
  67365. */
  67366. private _onchange;
  67367. /**
  67368. * The value of the path cursor
  67369. */
  67370. value: number;
  67371. /**
  67372. * The animation array of the path cursor
  67373. */
  67374. animations: Animation[];
  67375. /**
  67376. * Initializes the path cursor
  67377. * @param path The path to track
  67378. */
  67379. constructor(path: Path2);
  67380. /**
  67381. * Gets the cursor point on the path
  67382. * @returns A point on the path cursor at the cursor location
  67383. */
  67384. getPoint(): Vector3;
  67385. /**
  67386. * Moves the cursor ahead by the step amount
  67387. * @param step The amount to move the cursor forward
  67388. * @returns This path cursor
  67389. */
  67390. moveAhead(step?: number): PathCursor;
  67391. /**
  67392. * Moves the cursor behind by the step amount
  67393. * @param step The amount to move the cursor back
  67394. * @returns This path cursor
  67395. */
  67396. moveBack(step?: number): PathCursor;
  67397. /**
  67398. * Moves the cursor by the step amount
  67399. * If the step amount is greater than one, an exception is thrown
  67400. * @param step The amount to move the cursor
  67401. * @returns This path cursor
  67402. */
  67403. move(step: number): PathCursor;
  67404. /**
  67405. * Ensures that the value is limited between zero and one
  67406. * @returns This path cursor
  67407. */
  67408. private ensureLimits;
  67409. /**
  67410. * Runs onchange callbacks on change (used by the animation engine)
  67411. * @returns This path cursor
  67412. */
  67413. private raiseOnChange;
  67414. /**
  67415. * Executes a function on change
  67416. * @param f A path cursor onchange callback
  67417. * @returns This path cursor
  67418. */
  67419. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67420. }
  67421. }
  67422. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67423. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67424. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67425. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67426. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67427. }
  67428. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67429. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67430. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67431. }
  67432. declare module "babylonjs/Engines/Processors/index" {
  67433. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67434. export * from "babylonjs/Engines/Processors/Expressions/index";
  67435. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67436. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67437. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67438. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67439. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67440. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67441. }
  67442. declare module "babylonjs/Legacy/legacy" {
  67443. import * as Babylon from "babylonjs/index";
  67444. export * from "babylonjs/index";
  67445. }
  67446. declare module "babylonjs/Shaders/blur.fragment" {
  67447. /** @hidden */
  67448. export var blurPixelShader: {
  67449. name: string;
  67450. shader: string;
  67451. };
  67452. }
  67453. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67454. /** @hidden */
  67455. export var pointCloudVertexDeclaration: {
  67456. name: string;
  67457. shader: string;
  67458. };
  67459. }
  67460. declare module "babylonjs" {
  67461. export * from "babylonjs/Legacy/legacy";
  67462. }
  67463. declare module BABYLON {
  67464. /** Alias type for value that can be null */
  67465. export type Nullable<T> = T | null;
  67466. /**
  67467. * Alias type for number that are floats
  67468. * @ignorenaming
  67469. */
  67470. export type float = number;
  67471. /**
  67472. * Alias type for number that are doubles.
  67473. * @ignorenaming
  67474. */
  67475. export type double = number;
  67476. /**
  67477. * Alias type for number that are integer
  67478. * @ignorenaming
  67479. */
  67480. export type int = number;
  67481. /** Alias type for number array or Float32Array */
  67482. export type FloatArray = number[] | Float32Array;
  67483. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67484. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67485. /**
  67486. * Alias for types that can be used by a Buffer or VertexBuffer.
  67487. */
  67488. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67489. /**
  67490. * Alias type for primitive types
  67491. * @ignorenaming
  67492. */
  67493. type Primitive = undefined | null | boolean | string | number | Function;
  67494. /**
  67495. * Type modifier to make all the properties of an object Readonly
  67496. */
  67497. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67498. /**
  67499. * Type modifier to make all the properties of an object Readonly recursively
  67500. */
  67501. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67502. /**
  67503. * Type modifier to make object properties readonly.
  67504. */
  67505. export type DeepImmutableObject<T> = {
  67506. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67507. };
  67508. /** @hidden */
  67509. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67510. }
  67511. }
  67512. declare module BABYLON {
  67513. /**
  67514. * A class serves as a medium between the observable and its observers
  67515. */
  67516. export class EventState {
  67517. /**
  67518. * Create a new EventState
  67519. * @param mask defines the mask associated with this state
  67520. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67521. * @param target defines the original target of the state
  67522. * @param currentTarget defines the current target of the state
  67523. */
  67524. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67525. /**
  67526. * Initialize the current event state
  67527. * @param mask defines the mask associated with this state
  67528. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67529. * @param target defines the original target of the state
  67530. * @param currentTarget defines the current target of the state
  67531. * @returns the current event state
  67532. */
  67533. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67534. /**
  67535. * An Observer can set this property to true to prevent subsequent observers of being notified
  67536. */
  67537. skipNextObservers: boolean;
  67538. /**
  67539. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67540. */
  67541. mask: number;
  67542. /**
  67543. * The object that originally notified the event
  67544. */
  67545. target?: any;
  67546. /**
  67547. * The current object in the bubbling phase
  67548. */
  67549. currentTarget?: any;
  67550. /**
  67551. * This will be populated with the return value of the last function that was executed.
  67552. * If it is the first function in the callback chain it will be the event data.
  67553. */
  67554. lastReturnValue?: any;
  67555. }
  67556. /**
  67557. * Represent an Observer registered to a given Observable object.
  67558. */
  67559. export class Observer<T> {
  67560. /**
  67561. * Defines the callback to call when the observer is notified
  67562. */
  67563. callback: (eventData: T, eventState: EventState) => void;
  67564. /**
  67565. * Defines the mask of the observer (used to filter notifications)
  67566. */
  67567. mask: number;
  67568. /**
  67569. * Defines the current scope used to restore the JS context
  67570. */
  67571. scope: any;
  67572. /** @hidden */
  67573. _willBeUnregistered: boolean;
  67574. /**
  67575. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67576. */
  67577. unregisterOnNextCall: boolean;
  67578. /**
  67579. * Creates a new observer
  67580. * @param callback defines the callback to call when the observer is notified
  67581. * @param mask defines the mask of the observer (used to filter notifications)
  67582. * @param scope defines the current scope used to restore the JS context
  67583. */
  67584. constructor(
  67585. /**
  67586. * Defines the callback to call when the observer is notified
  67587. */
  67588. callback: (eventData: T, eventState: EventState) => void,
  67589. /**
  67590. * Defines the mask of the observer (used to filter notifications)
  67591. */
  67592. mask: number,
  67593. /**
  67594. * Defines the current scope used to restore the JS context
  67595. */
  67596. scope?: any);
  67597. }
  67598. /**
  67599. * Represent a list of observers registered to multiple Observables object.
  67600. */
  67601. export class MultiObserver<T> {
  67602. private _observers;
  67603. private _observables;
  67604. /**
  67605. * Release associated resources
  67606. */
  67607. dispose(): void;
  67608. /**
  67609. * Raise a callback when one of the observable will notify
  67610. * @param observables defines a list of observables to watch
  67611. * @param callback defines the callback to call on notification
  67612. * @param mask defines the mask used to filter notifications
  67613. * @param scope defines the current scope used to restore the JS context
  67614. * @returns the new MultiObserver
  67615. */
  67616. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67617. }
  67618. /**
  67619. * The Observable class is a simple implementation of the Observable pattern.
  67620. *
  67621. * 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.
  67622. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67623. * 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).
  67624. * 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.
  67625. */
  67626. export class Observable<T> {
  67627. private _observers;
  67628. private _eventState;
  67629. private _onObserverAdded;
  67630. /**
  67631. * Gets the list of observers
  67632. */
  67633. readonly observers: Array<Observer<T>>;
  67634. /**
  67635. * Creates a new observable
  67636. * @param onObserverAdded defines a callback to call when a new observer is added
  67637. */
  67638. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67639. /**
  67640. * Create a new Observer with the specified callback
  67641. * @param callback the callback that will be executed for that Observer
  67642. * @param mask the mask used to filter observers
  67643. * @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.
  67644. * @param scope optional scope for the callback to be called from
  67645. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67646. * @returns the new observer created for the callback
  67647. */
  67648. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67649. /**
  67650. * Create a new Observer with the specified callback and unregisters after the next notification
  67651. * @param callback the callback that will be executed for that Observer
  67652. * @returns the new observer created for the callback
  67653. */
  67654. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67655. /**
  67656. * Remove an Observer from the Observable object
  67657. * @param observer the instance of the Observer to remove
  67658. * @returns false if it doesn't belong to this Observable
  67659. */
  67660. remove(observer: Nullable<Observer<T>>): boolean;
  67661. /**
  67662. * Remove a callback from the Observable object
  67663. * @param callback the callback to remove
  67664. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67665. * @returns false if it doesn't belong to this Observable
  67666. */
  67667. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67668. private _deferUnregister;
  67669. private _remove;
  67670. /**
  67671. * Moves the observable to the top of the observer list making it get called first when notified
  67672. * @param observer the observer to move
  67673. */
  67674. makeObserverTopPriority(observer: Observer<T>): void;
  67675. /**
  67676. * Moves the observable to the bottom of the observer list making it get called last when notified
  67677. * @param observer the observer to move
  67678. */
  67679. makeObserverBottomPriority(observer: Observer<T>): void;
  67680. /**
  67681. * Notify all Observers by calling their respective callback with the given data
  67682. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67683. * @param eventData defines the data to send to all observers
  67684. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67685. * @param target defines the original target of the state
  67686. * @param currentTarget defines the current target of the state
  67687. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67688. */
  67689. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67690. /**
  67691. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67692. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67693. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67694. * and it is crucial that all callbacks will be executed.
  67695. * The order of the callbacks is kept, callbacks are not executed parallel.
  67696. *
  67697. * @param eventData The data to be sent to each callback
  67698. * @param mask is used to filter observers defaults to -1
  67699. * @param target defines the callback target (see EventState)
  67700. * @param currentTarget defines he current object in the bubbling phase
  67701. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67702. */
  67703. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67704. /**
  67705. * Notify a specific observer
  67706. * @param observer defines the observer to notify
  67707. * @param eventData defines the data to be sent to each callback
  67708. * @param mask is used to filter observers defaults to -1
  67709. */
  67710. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67711. /**
  67712. * Gets a boolean indicating if the observable has at least one observer
  67713. * @returns true is the Observable has at least one Observer registered
  67714. */
  67715. hasObservers(): boolean;
  67716. /**
  67717. * Clear the list of observers
  67718. */
  67719. clear(): void;
  67720. /**
  67721. * Clone the current observable
  67722. * @returns a new observable
  67723. */
  67724. clone(): Observable<T>;
  67725. /**
  67726. * Does this observable handles observer registered with a given mask
  67727. * @param mask defines the mask to be tested
  67728. * @return whether or not one observer registered with the given mask is handeled
  67729. **/
  67730. hasSpecificMask(mask?: number): boolean;
  67731. }
  67732. }
  67733. declare module BABYLON {
  67734. /**
  67735. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67736. * Babylon.js
  67737. */
  67738. export class DomManagement {
  67739. /**
  67740. * Checks if the window object exists
  67741. * @returns true if the window object exists
  67742. */
  67743. static IsWindowObjectExist(): boolean;
  67744. /**
  67745. * Checks if the navigator object exists
  67746. * @returns true if the navigator object exists
  67747. */
  67748. static IsNavigatorAvailable(): boolean;
  67749. /**
  67750. * Extracts text content from a DOM element hierarchy
  67751. * @param element defines the root element
  67752. * @returns a string
  67753. */
  67754. static GetDOMTextContent(element: HTMLElement): string;
  67755. }
  67756. }
  67757. declare module BABYLON {
  67758. /**
  67759. * Logger used througouht the application to allow configuration of
  67760. * the log level required for the messages.
  67761. */
  67762. export class Logger {
  67763. /**
  67764. * No log
  67765. */
  67766. static readonly NoneLogLevel: number;
  67767. /**
  67768. * Only message logs
  67769. */
  67770. static readonly MessageLogLevel: number;
  67771. /**
  67772. * Only warning logs
  67773. */
  67774. static readonly WarningLogLevel: number;
  67775. /**
  67776. * Only error logs
  67777. */
  67778. static readonly ErrorLogLevel: number;
  67779. /**
  67780. * All logs
  67781. */
  67782. static readonly AllLogLevel: number;
  67783. private static _LogCache;
  67784. /**
  67785. * Gets a value indicating the number of loading errors
  67786. * @ignorenaming
  67787. */
  67788. static errorsCount: number;
  67789. /**
  67790. * Callback called when a new log is added
  67791. */
  67792. static OnNewCacheEntry: (entry: string) => void;
  67793. private static _AddLogEntry;
  67794. private static _FormatMessage;
  67795. private static _LogDisabled;
  67796. private static _LogEnabled;
  67797. private static _WarnDisabled;
  67798. private static _WarnEnabled;
  67799. private static _ErrorDisabled;
  67800. private static _ErrorEnabled;
  67801. /**
  67802. * Log a message to the console
  67803. */
  67804. static Log: (message: string) => void;
  67805. /**
  67806. * Write a warning message to the console
  67807. */
  67808. static Warn: (message: string) => void;
  67809. /**
  67810. * Write an error message to the console
  67811. */
  67812. static Error: (message: string) => void;
  67813. /**
  67814. * Gets current log cache (list of logs)
  67815. */
  67816. static readonly LogCache: string;
  67817. /**
  67818. * Clears the log cache
  67819. */
  67820. static ClearLogCache(): void;
  67821. /**
  67822. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67823. */
  67824. static LogLevels: number;
  67825. }
  67826. }
  67827. declare module BABYLON {
  67828. /** @hidden */
  67829. export class _TypeStore {
  67830. /** @hidden */
  67831. static RegisteredTypes: {
  67832. [key: string]: Object;
  67833. };
  67834. /** @hidden */
  67835. static GetClass(fqdn: string): any;
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /**
  67840. * Class containing a set of static utilities functions for deep copy.
  67841. */
  67842. export class DeepCopier {
  67843. /**
  67844. * Tries to copy an object by duplicating every property
  67845. * @param source defines the source object
  67846. * @param destination defines the target object
  67847. * @param doNotCopyList defines a list of properties to avoid
  67848. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67849. */
  67850. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67851. }
  67852. }
  67853. declare module BABYLON {
  67854. /**
  67855. * Class containing a set of static utilities functions for precision date
  67856. */
  67857. export class PrecisionDate {
  67858. /**
  67859. * Gets either window.performance.now() if supported or Date.now() else
  67860. */
  67861. static readonly Now: number;
  67862. }
  67863. }
  67864. declare module BABYLON {
  67865. /** @hidden */
  67866. export class _DevTools {
  67867. static WarnImport(name: string): string;
  67868. }
  67869. }
  67870. declare module BABYLON {
  67871. /**
  67872. * Interface used to define the mechanism to get data from the network
  67873. */
  67874. export interface IWebRequest {
  67875. /**
  67876. * Returns client's response url
  67877. */
  67878. responseURL: string;
  67879. /**
  67880. * Returns client's status
  67881. */
  67882. status: number;
  67883. /**
  67884. * Returns client's status as a text
  67885. */
  67886. statusText: string;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. /**
  67891. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67892. */
  67893. export class WebRequest implements IWebRequest {
  67894. private _xhr;
  67895. /**
  67896. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67897. * i.e. when loading files, where the server/service expects an Authorization header
  67898. */
  67899. static CustomRequestHeaders: {
  67900. [key: string]: string;
  67901. };
  67902. /**
  67903. * Add callback functions in this array to update all the requests before they get sent to the network
  67904. */
  67905. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67906. private _injectCustomRequestHeaders;
  67907. /**
  67908. * Gets or sets a function to be called when loading progress changes
  67909. */
  67910. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67911. /**
  67912. * Returns client's state
  67913. */
  67914. readonly readyState: number;
  67915. /**
  67916. * Returns client's status
  67917. */
  67918. readonly status: number;
  67919. /**
  67920. * Returns client's status as a text
  67921. */
  67922. readonly statusText: string;
  67923. /**
  67924. * Returns client's response
  67925. */
  67926. readonly response: any;
  67927. /**
  67928. * Returns client's response url
  67929. */
  67930. readonly responseURL: string;
  67931. /**
  67932. * Returns client's response as text
  67933. */
  67934. readonly responseText: string;
  67935. /**
  67936. * Gets or sets the expected response type
  67937. */
  67938. responseType: XMLHttpRequestResponseType;
  67939. /** @hidden */
  67940. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67941. /** @hidden */
  67942. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67943. /**
  67944. * Cancels any network activity
  67945. */
  67946. abort(): void;
  67947. /**
  67948. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67949. * @param body defines an optional request body
  67950. */
  67951. send(body?: Document | BodyInit | null): void;
  67952. /**
  67953. * Sets the request method, request URL
  67954. * @param method defines the method to use (GET, POST, etc..)
  67955. * @param url defines the url to connect with
  67956. */
  67957. open(method: string, url: string): void;
  67958. /**
  67959. * Sets the value of a request header.
  67960. * @param name The name of the header whose value is to be set
  67961. * @param value The value to set as the body of the header
  67962. */
  67963. setRequestHeader(name: string, value: string): void;
  67964. /**
  67965. * Get the string containing the text of a particular header's value.
  67966. * @param name The name of the header
  67967. * @returns The string containing the text of the given header name
  67968. */
  67969. getResponseHeader(name: string): Nullable<string>;
  67970. }
  67971. }
  67972. declare module BABYLON {
  67973. /**
  67974. * File request interface
  67975. */
  67976. export interface IFileRequest {
  67977. /**
  67978. * Raised when the request is complete (success or error).
  67979. */
  67980. onCompleteObservable: Observable<IFileRequest>;
  67981. /**
  67982. * Aborts the request for a file.
  67983. */
  67984. abort: () => void;
  67985. }
  67986. }
  67987. declare module BABYLON {
  67988. /**
  67989. * Define options used to create a render target texture
  67990. */
  67991. export class RenderTargetCreationOptions {
  67992. /**
  67993. * Specifies is mipmaps must be generated
  67994. */
  67995. generateMipMaps?: boolean;
  67996. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67997. generateDepthBuffer?: boolean;
  67998. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67999. generateStencilBuffer?: boolean;
  68000. /** Defines texture type (int by default) */
  68001. type?: number;
  68002. /** Defines sampling mode (trilinear by default) */
  68003. samplingMode?: number;
  68004. /** Defines format (RGBA by default) */
  68005. format?: number;
  68006. }
  68007. }
  68008. declare module BABYLON {
  68009. /**
  68010. * @hidden
  68011. **/
  68012. export class _TimeToken {
  68013. _startTimeQuery: Nullable<WebGLQuery>;
  68014. _endTimeQuery: Nullable<WebGLQuery>;
  68015. _timeElapsedQuery: Nullable<WebGLQuery>;
  68016. _timeElapsedQueryEnded: boolean;
  68017. }
  68018. }
  68019. declare module BABYLON {
  68020. /** Defines the cross module used constants to avoid circular dependncies */
  68021. export class Constants {
  68022. /** Defines that alpha blending is disabled */
  68023. static readonly ALPHA_DISABLE: number;
  68024. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68025. static readonly ALPHA_ADD: number;
  68026. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68027. static readonly ALPHA_COMBINE: number;
  68028. /** Defines that alpha blending to DEST - SRC * DEST */
  68029. static readonly ALPHA_SUBTRACT: number;
  68030. /** Defines that alpha blending to SRC * DEST */
  68031. static readonly ALPHA_MULTIPLY: number;
  68032. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68033. static readonly ALPHA_MAXIMIZED: number;
  68034. /** Defines that alpha blending to SRC + DEST */
  68035. static readonly ALPHA_ONEONE: number;
  68036. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68037. static readonly ALPHA_PREMULTIPLIED: number;
  68038. /**
  68039. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68040. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68041. */
  68042. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68043. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68044. static readonly ALPHA_INTERPOLATE: number;
  68045. /**
  68046. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68047. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68048. */
  68049. static readonly ALPHA_SCREENMODE: number;
  68050. /**
  68051. * Defines that alpha blending to SRC + DST
  68052. * Alpha will be set to SRC ALPHA + DST ALPHA
  68053. */
  68054. static readonly ALPHA_ONEONE_ONEONE: number;
  68055. /**
  68056. * Defines that alpha blending to SRC * DST ALPHA + DST
  68057. * Alpha will be set to 0
  68058. */
  68059. static readonly ALPHA_ALPHATOCOLOR: number;
  68060. /**
  68061. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68062. */
  68063. static readonly ALPHA_REVERSEONEMINUS: number;
  68064. /**
  68065. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68066. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68067. */
  68068. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68069. /**
  68070. * Defines that alpha blending to SRC + DST
  68071. * Alpha will be set to SRC ALPHA
  68072. */
  68073. static readonly ALPHA_ONEONE_ONEZERO: number;
  68074. /** Defines that alpha blending equation a SUM */
  68075. static readonly ALPHA_EQUATION_ADD: number;
  68076. /** Defines that alpha blending equation a SUBSTRACTION */
  68077. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68078. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68079. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68080. /** Defines that alpha blending equation a MAX operation */
  68081. static readonly ALPHA_EQUATION_MAX: number;
  68082. /** Defines that alpha blending equation a MIN operation */
  68083. static readonly ALPHA_EQUATION_MIN: number;
  68084. /**
  68085. * Defines that alpha blending equation a DARKEN operation:
  68086. * It takes the min of the src and sums the alpha channels.
  68087. */
  68088. static readonly ALPHA_EQUATION_DARKEN: number;
  68089. /** Defines that the ressource is not delayed*/
  68090. static readonly DELAYLOADSTATE_NONE: number;
  68091. /** Defines that the ressource was successfully delay loaded */
  68092. static readonly DELAYLOADSTATE_LOADED: number;
  68093. /** Defines that the ressource is currently delay loading */
  68094. static readonly DELAYLOADSTATE_LOADING: number;
  68095. /** Defines that the ressource is delayed and has not started loading */
  68096. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68098. static readonly NEVER: number;
  68099. /** 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 */
  68100. static readonly ALWAYS: number;
  68101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68102. static readonly LESS: number;
  68103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68104. static readonly EQUAL: number;
  68105. /** 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 */
  68106. static readonly LEQUAL: number;
  68107. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68108. static readonly GREATER: number;
  68109. /** 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 */
  68110. static readonly GEQUAL: number;
  68111. /** 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 */
  68112. static readonly NOTEQUAL: number;
  68113. /** Passed to stencilOperation to specify that stencil value must be kept */
  68114. static readonly KEEP: number;
  68115. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68116. static readonly REPLACE: number;
  68117. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68118. static readonly INCR: number;
  68119. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68120. static readonly DECR: number;
  68121. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68122. static readonly INVERT: number;
  68123. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68124. static readonly INCR_WRAP: number;
  68125. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68126. static readonly DECR_WRAP: number;
  68127. /** Texture is not repeating outside of 0..1 UVs */
  68128. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68129. /** Texture is repeating outside of 0..1 UVs */
  68130. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68131. /** Texture is repeating and mirrored */
  68132. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68133. /** ALPHA */
  68134. static readonly TEXTUREFORMAT_ALPHA: number;
  68135. /** LUMINANCE */
  68136. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68137. /** LUMINANCE_ALPHA */
  68138. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68139. /** RGB */
  68140. static readonly TEXTUREFORMAT_RGB: number;
  68141. /** RGBA */
  68142. static readonly TEXTUREFORMAT_RGBA: number;
  68143. /** RED */
  68144. static readonly TEXTUREFORMAT_RED: number;
  68145. /** RED (2nd reference) */
  68146. static readonly TEXTUREFORMAT_R: number;
  68147. /** RG */
  68148. static readonly TEXTUREFORMAT_RG: number;
  68149. /** RED_INTEGER */
  68150. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68151. /** RED_INTEGER (2nd reference) */
  68152. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68153. /** RG_INTEGER */
  68154. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68155. /** RGB_INTEGER */
  68156. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68157. /** RGBA_INTEGER */
  68158. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68159. /** UNSIGNED_BYTE */
  68160. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68161. /** UNSIGNED_BYTE (2nd reference) */
  68162. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68163. /** FLOAT */
  68164. static readonly TEXTURETYPE_FLOAT: number;
  68165. /** HALF_FLOAT */
  68166. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68167. /** BYTE */
  68168. static readonly TEXTURETYPE_BYTE: number;
  68169. /** SHORT */
  68170. static readonly TEXTURETYPE_SHORT: number;
  68171. /** UNSIGNED_SHORT */
  68172. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68173. /** INT */
  68174. static readonly TEXTURETYPE_INT: number;
  68175. /** UNSIGNED_INT */
  68176. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68177. /** UNSIGNED_SHORT_4_4_4_4 */
  68178. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68179. /** UNSIGNED_SHORT_5_5_5_1 */
  68180. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68181. /** UNSIGNED_SHORT_5_6_5 */
  68182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68183. /** UNSIGNED_INT_2_10_10_10_REV */
  68184. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68185. /** UNSIGNED_INT_24_8 */
  68186. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68187. /** UNSIGNED_INT_10F_11F_11F_REV */
  68188. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68189. /** UNSIGNED_INT_5_9_9_9_REV */
  68190. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68191. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68192. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68193. /** nearest is mag = nearest and min = nearest and mip = linear */
  68194. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68196. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68197. /** Trilinear is mag = linear and min = linear and mip = linear */
  68198. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68199. /** nearest is mag = nearest and min = nearest and mip = linear */
  68200. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68201. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68202. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68203. /** Trilinear is mag = linear and min = linear and mip = linear */
  68204. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68205. /** mag = nearest and min = nearest and mip = nearest */
  68206. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68207. /** mag = nearest and min = linear and mip = nearest */
  68208. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68209. /** mag = nearest and min = linear and mip = linear */
  68210. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68211. /** mag = nearest and min = linear and mip = none */
  68212. static readonly TEXTURE_NEAREST_LINEAR: number;
  68213. /** mag = nearest and min = nearest and mip = none */
  68214. static readonly TEXTURE_NEAREST_NEAREST: number;
  68215. /** mag = linear and min = nearest and mip = nearest */
  68216. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68217. /** mag = linear and min = nearest and mip = linear */
  68218. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68219. /** mag = linear and min = linear and mip = none */
  68220. static readonly TEXTURE_LINEAR_LINEAR: number;
  68221. /** mag = linear and min = nearest and mip = none */
  68222. static readonly TEXTURE_LINEAR_NEAREST: number;
  68223. /** Explicit coordinates mode */
  68224. static readonly TEXTURE_EXPLICIT_MODE: number;
  68225. /** Spherical coordinates mode */
  68226. static readonly TEXTURE_SPHERICAL_MODE: number;
  68227. /** Planar coordinates mode */
  68228. static readonly TEXTURE_PLANAR_MODE: number;
  68229. /** Cubic coordinates mode */
  68230. static readonly TEXTURE_CUBIC_MODE: number;
  68231. /** Projection coordinates mode */
  68232. static readonly TEXTURE_PROJECTION_MODE: number;
  68233. /** Skybox coordinates mode */
  68234. static readonly TEXTURE_SKYBOX_MODE: number;
  68235. /** Inverse Cubic coordinates mode */
  68236. static readonly TEXTURE_INVCUBIC_MODE: number;
  68237. /** Equirectangular coordinates mode */
  68238. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68239. /** Equirectangular Fixed coordinates mode */
  68240. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68241. /** Equirectangular Fixed Mirrored coordinates mode */
  68242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68243. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68244. static readonly SCALEMODE_FLOOR: number;
  68245. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68246. static readonly SCALEMODE_NEAREST: number;
  68247. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68248. static readonly SCALEMODE_CEILING: number;
  68249. /**
  68250. * The dirty texture flag value
  68251. */
  68252. static readonly MATERIAL_TextureDirtyFlag: number;
  68253. /**
  68254. * The dirty light flag value
  68255. */
  68256. static readonly MATERIAL_LightDirtyFlag: number;
  68257. /**
  68258. * The dirty fresnel flag value
  68259. */
  68260. static readonly MATERIAL_FresnelDirtyFlag: number;
  68261. /**
  68262. * The dirty attribute flag value
  68263. */
  68264. static readonly MATERIAL_AttributesDirtyFlag: number;
  68265. /**
  68266. * The dirty misc flag value
  68267. */
  68268. static readonly MATERIAL_MiscDirtyFlag: number;
  68269. /**
  68270. * The all dirty flag value
  68271. */
  68272. static readonly MATERIAL_AllDirtyFlag: number;
  68273. /**
  68274. * Returns the triangle fill mode
  68275. */
  68276. static readonly MATERIAL_TriangleFillMode: number;
  68277. /**
  68278. * Returns the wireframe mode
  68279. */
  68280. static readonly MATERIAL_WireFrameFillMode: number;
  68281. /**
  68282. * Returns the point fill mode
  68283. */
  68284. static readonly MATERIAL_PointFillMode: number;
  68285. /**
  68286. * Returns the point list draw mode
  68287. */
  68288. static readonly MATERIAL_PointListDrawMode: number;
  68289. /**
  68290. * Returns the line list draw mode
  68291. */
  68292. static readonly MATERIAL_LineListDrawMode: number;
  68293. /**
  68294. * Returns the line loop draw mode
  68295. */
  68296. static readonly MATERIAL_LineLoopDrawMode: number;
  68297. /**
  68298. * Returns the line strip draw mode
  68299. */
  68300. static readonly MATERIAL_LineStripDrawMode: number;
  68301. /**
  68302. * Returns the triangle strip draw mode
  68303. */
  68304. static readonly MATERIAL_TriangleStripDrawMode: number;
  68305. /**
  68306. * Returns the triangle fan draw mode
  68307. */
  68308. static readonly MATERIAL_TriangleFanDrawMode: number;
  68309. /**
  68310. * Stores the clock-wise side orientation
  68311. */
  68312. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68313. /**
  68314. * Stores the counter clock-wise side orientation
  68315. */
  68316. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68317. /**
  68318. * Nothing
  68319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68320. */
  68321. static readonly ACTION_NothingTrigger: number;
  68322. /**
  68323. * On pick
  68324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68325. */
  68326. static readonly ACTION_OnPickTrigger: number;
  68327. /**
  68328. * On left pick
  68329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68330. */
  68331. static readonly ACTION_OnLeftPickTrigger: number;
  68332. /**
  68333. * On right pick
  68334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68335. */
  68336. static readonly ACTION_OnRightPickTrigger: number;
  68337. /**
  68338. * On center pick
  68339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68340. */
  68341. static readonly ACTION_OnCenterPickTrigger: number;
  68342. /**
  68343. * On pick down
  68344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68345. */
  68346. static readonly ACTION_OnPickDownTrigger: number;
  68347. /**
  68348. * On double pick
  68349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68350. */
  68351. static readonly ACTION_OnDoublePickTrigger: number;
  68352. /**
  68353. * On pick up
  68354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68355. */
  68356. static readonly ACTION_OnPickUpTrigger: number;
  68357. /**
  68358. * On pick out.
  68359. * This trigger will only be raised if you also declared a OnPickDown
  68360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68361. */
  68362. static readonly ACTION_OnPickOutTrigger: number;
  68363. /**
  68364. * On long press
  68365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68366. */
  68367. static readonly ACTION_OnLongPressTrigger: number;
  68368. /**
  68369. * On pointer over
  68370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68371. */
  68372. static readonly ACTION_OnPointerOverTrigger: number;
  68373. /**
  68374. * On pointer out
  68375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68376. */
  68377. static readonly ACTION_OnPointerOutTrigger: number;
  68378. /**
  68379. * On every frame
  68380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68381. */
  68382. static readonly ACTION_OnEveryFrameTrigger: number;
  68383. /**
  68384. * On intersection enter
  68385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68386. */
  68387. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68388. /**
  68389. * On intersection exit
  68390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68391. */
  68392. static readonly ACTION_OnIntersectionExitTrigger: number;
  68393. /**
  68394. * On key down
  68395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68396. */
  68397. static readonly ACTION_OnKeyDownTrigger: number;
  68398. /**
  68399. * On key up
  68400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68401. */
  68402. static readonly ACTION_OnKeyUpTrigger: number;
  68403. /**
  68404. * Billboard mode will only apply to Y axis
  68405. */
  68406. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68407. /**
  68408. * Billboard mode will apply to all axes
  68409. */
  68410. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68411. /**
  68412. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68413. */
  68414. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68415. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68416. * Test order :
  68417. * Is the bounding sphere outside the frustum ?
  68418. * If not, are the bounding box vertices outside the frustum ?
  68419. * It not, then the cullable object is in the frustum.
  68420. */
  68421. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68422. /** Culling strategy : Bounding Sphere Only.
  68423. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68424. * It's also less accurate than the standard because some not visible objects can still be selected.
  68425. * Test : is the bounding sphere outside the frustum ?
  68426. * If not, then the cullable object is in the frustum.
  68427. */
  68428. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68429. /** Culling strategy : Optimistic Inclusion.
  68430. * This in an inclusion test first, then the standard exclusion test.
  68431. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68432. * 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.
  68433. * Anyway, it's as accurate as the standard strategy.
  68434. * Test :
  68435. * Is the cullable object bounding sphere center in the frustum ?
  68436. * If not, apply the default culling strategy.
  68437. */
  68438. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68439. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68440. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68441. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68442. * 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.
  68443. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68444. * Test :
  68445. * Is the cullable object bounding sphere center in the frustum ?
  68446. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68447. */
  68448. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68449. /**
  68450. * No logging while loading
  68451. */
  68452. static readonly SCENELOADER_NO_LOGGING: number;
  68453. /**
  68454. * Minimal logging while loading
  68455. */
  68456. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68457. /**
  68458. * Summary logging while loading
  68459. */
  68460. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68461. /**
  68462. * Detailled logging while loading
  68463. */
  68464. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68465. }
  68466. }
  68467. declare module BABYLON {
  68468. /**
  68469. * This represents the required contract to create a new type of texture loader.
  68470. */
  68471. export interface IInternalTextureLoader {
  68472. /**
  68473. * Defines wether the loader supports cascade loading the different faces.
  68474. */
  68475. supportCascades: boolean;
  68476. /**
  68477. * This returns if the loader support the current file information.
  68478. * @param extension defines the file extension of the file being loaded
  68479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68480. * @param fallback defines the fallback internal texture if any
  68481. * @param isBase64 defines whether the texture is encoded as a base64
  68482. * @param isBuffer defines whether the texture data are stored as a buffer
  68483. * @returns true if the loader can load the specified file
  68484. */
  68485. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68486. /**
  68487. * Transform the url before loading if required.
  68488. * @param rootUrl the url of the texture
  68489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68490. * @returns the transformed texture
  68491. */
  68492. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68493. /**
  68494. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68495. * @param rootUrl the url of the texture
  68496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68497. * @returns the fallback texture
  68498. */
  68499. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68500. /**
  68501. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68502. * @param data contains the texture data
  68503. * @param texture defines the BabylonJS internal texture
  68504. * @param createPolynomials will be true if polynomials have been requested
  68505. * @param onLoad defines the callback to trigger once the texture is ready
  68506. * @param onError defines the callback to trigger in case of error
  68507. */
  68508. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68509. /**
  68510. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68511. * @param data contains the texture data
  68512. * @param texture defines the BabylonJS internal texture
  68513. * @param callback defines the method to call once ready to upload
  68514. */
  68515. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68516. }
  68517. }
  68518. declare module BABYLON {
  68519. /**
  68520. * Class used to store and describe the pipeline context associated with an effect
  68521. */
  68522. export interface IPipelineContext {
  68523. /**
  68524. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68525. */
  68526. isAsync: boolean;
  68527. /**
  68528. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68529. */
  68530. isReady: boolean;
  68531. /** @hidden */
  68532. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68533. }
  68534. }
  68535. declare module BABYLON {
  68536. /**
  68537. * Class used to store gfx data (like WebGLBuffer)
  68538. */
  68539. export class DataBuffer {
  68540. /**
  68541. * Gets or sets the number of objects referencing this buffer
  68542. */
  68543. references: number;
  68544. /** Gets or sets the size of the underlying buffer */
  68545. capacity: number;
  68546. /**
  68547. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68548. */
  68549. is32Bits: boolean;
  68550. /**
  68551. * Gets the underlying buffer
  68552. */
  68553. readonly underlyingResource: any;
  68554. }
  68555. }
  68556. declare module BABYLON {
  68557. /** @hidden */
  68558. export interface IShaderProcessor {
  68559. attributeProcessor?: (attribute: string) => string;
  68560. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68561. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68562. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68563. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68564. lineProcessor?: (line: string, isFragment: boolean) => string;
  68565. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68566. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68567. }
  68568. }
  68569. declare module BABYLON {
  68570. /** @hidden */
  68571. export interface ProcessingOptions {
  68572. defines: string[];
  68573. indexParameters: any;
  68574. isFragment: boolean;
  68575. shouldUseHighPrecisionShader: boolean;
  68576. supportsUniformBuffers: boolean;
  68577. shadersRepository: string;
  68578. includesShadersStore: {
  68579. [key: string]: string;
  68580. };
  68581. processor?: IShaderProcessor;
  68582. version: string;
  68583. platformName: string;
  68584. lookForClosingBracketForUniformBuffer?: boolean;
  68585. }
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * Helper to manipulate strings
  68590. */
  68591. export class StringTools {
  68592. /**
  68593. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68594. * @param str Source string
  68595. * @param suffix Suffix to search for in the source string
  68596. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68597. */
  68598. static EndsWith(str: string, suffix: string): boolean;
  68599. /**
  68600. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68601. * @param str Source string
  68602. * @param suffix Suffix to search for in the source string
  68603. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68604. */
  68605. static StartsWith(str: string, suffix: string): boolean;
  68606. /**
  68607. * Decodes a buffer into a string
  68608. * @param buffer The buffer to decode
  68609. * @returns The decoded string
  68610. */
  68611. static Decode(buffer: Uint8Array | Uint16Array): string;
  68612. /**
  68613. * Encode a buffer to a base64 string
  68614. * @param buffer defines the buffer to encode
  68615. * @returns the encoded string
  68616. */
  68617. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68618. }
  68619. }
  68620. declare module BABYLON {
  68621. /** @hidden */
  68622. export class ShaderCodeNode {
  68623. line: string;
  68624. children: ShaderCodeNode[];
  68625. additionalDefineKey?: string;
  68626. additionalDefineValue?: string;
  68627. isValid(preprocessors: {
  68628. [key: string]: string;
  68629. }): boolean;
  68630. process(preprocessors: {
  68631. [key: string]: string;
  68632. }, options: ProcessingOptions): string;
  68633. }
  68634. }
  68635. declare module BABYLON {
  68636. /** @hidden */
  68637. export class ShaderCodeCursor {
  68638. private _lines;
  68639. lineIndex: number;
  68640. readonly currentLine: string;
  68641. readonly canRead: boolean;
  68642. lines: string[];
  68643. }
  68644. }
  68645. declare module BABYLON {
  68646. /** @hidden */
  68647. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68648. process(preprocessors: {
  68649. [key: string]: string;
  68650. }, options: ProcessingOptions): string;
  68651. }
  68652. }
  68653. declare module BABYLON {
  68654. /** @hidden */
  68655. export class ShaderDefineExpression {
  68656. isTrue(preprocessors: {
  68657. [key: string]: string;
  68658. }): boolean;
  68659. }
  68660. }
  68661. declare module BABYLON {
  68662. /** @hidden */
  68663. export class ShaderCodeTestNode extends ShaderCodeNode {
  68664. testExpression: ShaderDefineExpression;
  68665. isValid(preprocessors: {
  68666. [key: string]: string;
  68667. }): boolean;
  68668. }
  68669. }
  68670. declare module BABYLON {
  68671. /** @hidden */
  68672. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68673. define: string;
  68674. not: boolean;
  68675. constructor(define: string, not?: boolean);
  68676. isTrue(preprocessors: {
  68677. [key: string]: string;
  68678. }): boolean;
  68679. }
  68680. }
  68681. declare module BABYLON {
  68682. /** @hidden */
  68683. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68684. leftOperand: ShaderDefineExpression;
  68685. rightOperand: ShaderDefineExpression;
  68686. isTrue(preprocessors: {
  68687. [key: string]: string;
  68688. }): boolean;
  68689. }
  68690. }
  68691. declare module BABYLON {
  68692. /** @hidden */
  68693. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68694. leftOperand: ShaderDefineExpression;
  68695. rightOperand: ShaderDefineExpression;
  68696. isTrue(preprocessors: {
  68697. [key: string]: string;
  68698. }): boolean;
  68699. }
  68700. }
  68701. declare module BABYLON {
  68702. /** @hidden */
  68703. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68704. define: string;
  68705. operand: string;
  68706. testValue: string;
  68707. constructor(define: string, operand: string, testValue: string);
  68708. isTrue(preprocessors: {
  68709. [key: string]: string;
  68710. }): boolean;
  68711. }
  68712. }
  68713. declare module BABYLON {
  68714. /**
  68715. * Class used to enable access to offline support
  68716. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68717. */
  68718. export interface IOfflineProvider {
  68719. /**
  68720. * Gets a boolean indicating if scene must be saved in the database
  68721. */
  68722. enableSceneOffline: boolean;
  68723. /**
  68724. * Gets a boolean indicating if textures must be saved in the database
  68725. */
  68726. enableTexturesOffline: boolean;
  68727. /**
  68728. * Open the offline support and make it available
  68729. * @param successCallback defines the callback to call on success
  68730. * @param errorCallback defines the callback to call on error
  68731. */
  68732. open(successCallback: () => void, errorCallback: () => void): void;
  68733. /**
  68734. * Loads an image from the offline support
  68735. * @param url defines the url to load from
  68736. * @param image defines the target DOM image
  68737. */
  68738. loadImage(url: string, image: HTMLImageElement): void;
  68739. /**
  68740. * Loads a file from offline support
  68741. * @param url defines the URL to load from
  68742. * @param sceneLoaded defines a callback to call on success
  68743. * @param progressCallBack defines a callback to call when progress changed
  68744. * @param errorCallback defines a callback to call on error
  68745. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68746. */
  68747. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68748. }
  68749. }
  68750. declare module BABYLON {
  68751. /**
  68752. * Class used to help managing file picking and drag'n'drop
  68753. * File Storage
  68754. */
  68755. export class FilesInputStore {
  68756. /**
  68757. * List of files ready to be loaded
  68758. */
  68759. static FilesToLoad: {
  68760. [key: string]: File;
  68761. };
  68762. }
  68763. }
  68764. declare module BABYLON {
  68765. /**
  68766. * Class used to define a retry strategy when error happens while loading assets
  68767. */
  68768. export class RetryStrategy {
  68769. /**
  68770. * Function used to defines an exponential back off strategy
  68771. * @param maxRetries defines the maximum number of retries (3 by default)
  68772. * @param baseInterval defines the interval between retries
  68773. * @returns the strategy function to use
  68774. */
  68775. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68776. }
  68777. }
  68778. declare module BABYLON {
  68779. /**
  68780. * @ignore
  68781. * Application error to support additional information when loading a file
  68782. */
  68783. export abstract class BaseError extends Error {
  68784. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  68785. }
  68786. }
  68787. declare module BABYLON {
  68788. /** @ignore */
  68789. export class LoadFileError extends BaseError {
  68790. request?: WebRequest;
  68791. file?: File;
  68792. /**
  68793. * Creates a new LoadFileError
  68794. * @param message defines the message of the error
  68795. * @param request defines the optional web request
  68796. * @param file defines the optional file
  68797. */
  68798. constructor(message: string, object?: WebRequest | File);
  68799. }
  68800. /** @ignore */
  68801. export class RequestFileError extends BaseError {
  68802. request: WebRequest;
  68803. /**
  68804. * Creates a new LoadFileError
  68805. * @param message defines the message of the error
  68806. * @param request defines the optional web request
  68807. */
  68808. constructor(message: string, request: WebRequest);
  68809. }
  68810. /** @ignore */
  68811. export class ReadFileError extends BaseError {
  68812. file: File;
  68813. /**
  68814. * Creates a new ReadFileError
  68815. * @param message defines the message of the error
  68816. * @param file defines the optional file
  68817. */
  68818. constructor(message: string, file: File);
  68819. }
  68820. /**
  68821. * @hidden
  68822. */
  68823. export class FileTools {
  68824. /**
  68825. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68826. */
  68827. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68828. /**
  68829. * Gets or sets the base URL to use to load assets
  68830. */
  68831. static BaseUrl: string;
  68832. /**
  68833. * Default behaviour for cors in the application.
  68834. * It can be a string if the expected behavior is identical in the entire app.
  68835. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68836. */
  68837. static CorsBehavior: string | ((url: string | string[]) => string);
  68838. /**
  68839. * Gets or sets a function used to pre-process url before using them to load assets
  68840. */
  68841. static PreprocessUrl: (url: string) => string;
  68842. /**
  68843. * Removes unwanted characters from an url
  68844. * @param url defines the url to clean
  68845. * @returns the cleaned url
  68846. */
  68847. private static _CleanUrl;
  68848. /**
  68849. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68850. * @param url define the url we are trying
  68851. * @param element define the dom element where to configure the cors policy
  68852. */
  68853. static SetCorsBehavior(url: string | string[], element: {
  68854. crossOrigin: string | null;
  68855. }): void;
  68856. /**
  68857. * Loads an image as an HTMLImageElement.
  68858. * @param input url string, ArrayBuffer, or Blob to load
  68859. * @param onLoad callback called when the image successfully loads
  68860. * @param onError callback called when the image fails to load
  68861. * @param offlineProvider offline provider for caching
  68862. * @param mimeType optional mime type
  68863. * @returns the HTMLImageElement of the loaded image
  68864. */
  68865. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  68866. /**
  68867. * Reads a file from a File object
  68868. * @param file defines the file to load
  68869. * @param onSuccess defines the callback to call when data is loaded
  68870. * @param onProgress defines the callback to call during loading process
  68871. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68872. * @param onError defines the callback to call when an error occurs
  68873. * @returns a file request object
  68874. */
  68875. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  68876. /**
  68877. * Loads a file from a url
  68878. * @param url url to load
  68879. * @param onSuccess callback called when the file successfully loads
  68880. * @param onProgress callback called while file is loading (if the server supports this mode)
  68881. * @param offlineProvider defines the offline provider for caching
  68882. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68883. * @param onError callback called when the file fails to load
  68884. * @returns a file request object
  68885. */
  68886. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  68887. /**
  68888. * Loads a file
  68889. * @param url url to load
  68890. * @param onSuccess callback called when the file successfully loads
  68891. * @param onProgress callback called while file is loading (if the server supports this mode)
  68892. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68893. * @param onError callback called when the file fails to load
  68894. * @param onOpened callback called when the web request is opened
  68895. * @returns a file request object
  68896. */
  68897. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  68898. /**
  68899. * Checks if the loaded document was accessed via `file:`-Protocol.
  68900. * @returns boolean
  68901. */
  68902. static IsFileURL(): boolean;
  68903. }
  68904. }
  68905. declare module BABYLON {
  68906. /** @hidden */
  68907. export class ShaderProcessor {
  68908. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68909. private static _ProcessPrecision;
  68910. private static _ExtractOperation;
  68911. private static _BuildSubExpression;
  68912. private static _BuildExpression;
  68913. private static _MoveCursorWithinIf;
  68914. private static _MoveCursor;
  68915. private static _EvaluatePreProcessors;
  68916. private static _PreparePreProcessors;
  68917. private static _ProcessShaderConversion;
  68918. private static _ProcessIncludes;
  68919. }
  68920. }
  68921. declare module BABYLON {
  68922. /**
  68923. * @hidden
  68924. */
  68925. export interface IColor4Like {
  68926. r: float;
  68927. g: float;
  68928. b: float;
  68929. a: float;
  68930. }
  68931. /**
  68932. * @hidden
  68933. */
  68934. export interface IColor3Like {
  68935. r: float;
  68936. g: float;
  68937. b: float;
  68938. }
  68939. /**
  68940. * @hidden
  68941. */
  68942. export interface IVector4Like {
  68943. x: float;
  68944. y: float;
  68945. z: float;
  68946. w: float;
  68947. }
  68948. /**
  68949. * @hidden
  68950. */
  68951. export interface IVector3Like {
  68952. x: float;
  68953. y: float;
  68954. z: float;
  68955. }
  68956. /**
  68957. * @hidden
  68958. */
  68959. export interface IVector2Like {
  68960. x: float;
  68961. y: float;
  68962. }
  68963. /**
  68964. * @hidden
  68965. */
  68966. export interface IMatrixLike {
  68967. toArray(): DeepImmutable<Float32Array>;
  68968. updateFlag: int;
  68969. }
  68970. /**
  68971. * @hidden
  68972. */
  68973. export interface IViewportLike {
  68974. x: float;
  68975. y: float;
  68976. width: float;
  68977. height: float;
  68978. }
  68979. /**
  68980. * @hidden
  68981. */
  68982. export interface IPlaneLike {
  68983. normal: IVector3Like;
  68984. d: float;
  68985. normalize(): void;
  68986. }
  68987. }
  68988. declare module BABYLON {
  68989. /**
  68990. * Interface used to define common properties for effect fallbacks
  68991. */
  68992. export interface IEffectFallbacks {
  68993. /**
  68994. * Removes the defines that should be removed when falling back.
  68995. * @param currentDefines defines the current define statements for the shader.
  68996. * @param effect defines the current effect we try to compile
  68997. * @returns The resulting defines with defines of the current rank removed.
  68998. */
  68999. reduce(currentDefines: string, effect: Effect): string;
  69000. /**
  69001. * Removes the fallback from the bound mesh.
  69002. */
  69003. unBindMesh(): void;
  69004. /**
  69005. * Checks to see if more fallbacks are still availible.
  69006. */
  69007. hasMoreFallbacks: boolean;
  69008. }
  69009. }
  69010. declare module BABYLON {
  69011. /**
  69012. * Class used to evalaute queries containing `and` and `or` operators
  69013. */
  69014. export class AndOrNotEvaluator {
  69015. /**
  69016. * Evaluate a query
  69017. * @param query defines the query to evaluate
  69018. * @param evaluateCallback defines the callback used to filter result
  69019. * @returns true if the query matches
  69020. */
  69021. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69022. private static _HandleParenthesisContent;
  69023. private static _SimplifyNegation;
  69024. }
  69025. }
  69026. declare module BABYLON {
  69027. /**
  69028. * Class used to store custom tags
  69029. */
  69030. export class Tags {
  69031. /**
  69032. * Adds support for tags on the given object
  69033. * @param obj defines the object to use
  69034. */
  69035. static EnableFor(obj: any): void;
  69036. /**
  69037. * Removes tags support
  69038. * @param obj defines the object to use
  69039. */
  69040. static DisableFor(obj: any): void;
  69041. /**
  69042. * Gets a boolean indicating if the given object has tags
  69043. * @param obj defines the object to use
  69044. * @returns a boolean
  69045. */
  69046. static HasTags(obj: any): boolean;
  69047. /**
  69048. * Gets the tags available on a given object
  69049. * @param obj defines the object to use
  69050. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69051. * @returns the tags
  69052. */
  69053. static GetTags(obj: any, asString?: boolean): any;
  69054. /**
  69055. * Adds tags to an object
  69056. * @param obj defines the object to use
  69057. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69058. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69059. */
  69060. static AddTagsTo(obj: any, tagsString: string): void;
  69061. /**
  69062. * @hidden
  69063. */
  69064. static _AddTagTo(obj: any, tag: string): void;
  69065. /**
  69066. * Removes specific tags from a specific object
  69067. * @param obj defines the object to use
  69068. * @param tagsString defines the tags to remove
  69069. */
  69070. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69071. /**
  69072. * @hidden
  69073. */
  69074. static _RemoveTagFrom(obj: any, tag: string): void;
  69075. /**
  69076. * Defines if tags hosted on an object match a given query
  69077. * @param obj defines the object to use
  69078. * @param tagsQuery defines the tag query
  69079. * @returns a boolean
  69080. */
  69081. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69082. }
  69083. }
  69084. declare module BABYLON {
  69085. /**
  69086. * Scalar computation library
  69087. */
  69088. export class Scalar {
  69089. /**
  69090. * Two pi constants convenient for computation.
  69091. */
  69092. static TwoPi: number;
  69093. /**
  69094. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69095. * @param a number
  69096. * @param b number
  69097. * @param epsilon (default = 1.401298E-45)
  69098. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69099. */
  69100. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69101. /**
  69102. * Returns a string : the upper case translation of the number i to hexadecimal.
  69103. * @param i number
  69104. * @returns the upper case translation of the number i to hexadecimal.
  69105. */
  69106. static ToHex(i: number): string;
  69107. /**
  69108. * Returns -1 if value is negative and +1 is value is positive.
  69109. * @param value the value
  69110. * @returns the value itself if it's equal to zero.
  69111. */
  69112. static Sign(value: number): number;
  69113. /**
  69114. * Returns the value itself if it's between min and max.
  69115. * Returns min if the value is lower than min.
  69116. * Returns max if the value is greater than max.
  69117. * @param value the value to clmap
  69118. * @param min the min value to clamp to (default: 0)
  69119. * @param max the max value to clamp to (default: 1)
  69120. * @returns the clamped value
  69121. */
  69122. static Clamp(value: number, min?: number, max?: number): number;
  69123. /**
  69124. * the log2 of value.
  69125. * @param value the value to compute log2 of
  69126. * @returns the log2 of value.
  69127. */
  69128. static Log2(value: number): number;
  69129. /**
  69130. * Loops the value, so that it is never larger than length and never smaller than 0.
  69131. *
  69132. * This is similar to the modulo operator but it works with floating point numbers.
  69133. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69134. * With t = 5 and length = 2.5, the result would be 0.0.
  69135. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69136. * @param value the value
  69137. * @param length the length
  69138. * @returns the looped value
  69139. */
  69140. static Repeat(value: number, length: number): number;
  69141. /**
  69142. * Normalize the value between 0.0 and 1.0 using min and max values
  69143. * @param value value to normalize
  69144. * @param min max to normalize between
  69145. * @param max min to normalize between
  69146. * @returns the normalized value
  69147. */
  69148. static Normalize(value: number, min: number, max: number): number;
  69149. /**
  69150. * Denormalize the value from 0.0 and 1.0 using min and max values
  69151. * @param normalized value to denormalize
  69152. * @param min max to denormalize between
  69153. * @param max min to denormalize between
  69154. * @returns the denormalized value
  69155. */
  69156. static Denormalize(normalized: number, min: number, max: number): number;
  69157. /**
  69158. * Calculates the shortest difference between two given angles given in degrees.
  69159. * @param current current angle in degrees
  69160. * @param target target angle in degrees
  69161. * @returns the delta
  69162. */
  69163. static DeltaAngle(current: number, target: number): number;
  69164. /**
  69165. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69166. * @param tx value
  69167. * @param length length
  69168. * @returns The returned value will move back and forth between 0 and length
  69169. */
  69170. static PingPong(tx: number, length: number): number;
  69171. /**
  69172. * Interpolates between min and max with smoothing at the limits.
  69173. *
  69174. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69175. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69176. * @param from from
  69177. * @param to to
  69178. * @param tx value
  69179. * @returns the smooth stepped value
  69180. */
  69181. static SmoothStep(from: number, to: number, tx: number): number;
  69182. /**
  69183. * Moves a value current towards target.
  69184. *
  69185. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69186. * Negative values of maxDelta pushes the value away from target.
  69187. * @param current current value
  69188. * @param target target value
  69189. * @param maxDelta max distance to move
  69190. * @returns resulting value
  69191. */
  69192. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69193. /**
  69194. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69195. *
  69196. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69197. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69198. * @param current current value
  69199. * @param target target value
  69200. * @param maxDelta max distance to move
  69201. * @returns resulting angle
  69202. */
  69203. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69204. /**
  69205. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69206. * @param start start value
  69207. * @param end target value
  69208. * @param amount amount to lerp between
  69209. * @returns the lerped value
  69210. */
  69211. static Lerp(start: number, end: number, amount: number): number;
  69212. /**
  69213. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69214. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69215. * @param start start value
  69216. * @param end target value
  69217. * @param amount amount to lerp between
  69218. * @returns the lerped value
  69219. */
  69220. static LerpAngle(start: number, end: number, amount: number): number;
  69221. /**
  69222. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69223. * @param a start value
  69224. * @param b target value
  69225. * @param value value between a and b
  69226. * @returns the inverseLerp value
  69227. */
  69228. static InverseLerp(a: number, b: number, value: number): number;
  69229. /**
  69230. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69231. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69232. * @param value1 spline value
  69233. * @param tangent1 spline value
  69234. * @param value2 spline value
  69235. * @param tangent2 spline value
  69236. * @param amount input value
  69237. * @returns hermite result
  69238. */
  69239. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69240. /**
  69241. * Returns a random float number between and min and max values
  69242. * @param min min value of random
  69243. * @param max max value of random
  69244. * @returns random value
  69245. */
  69246. static RandomRange(min: number, max: number): number;
  69247. /**
  69248. * This function returns percentage of a number in a given range.
  69249. *
  69250. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69251. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69252. * @param number to convert to percentage
  69253. * @param min min range
  69254. * @param max max range
  69255. * @returns the percentage
  69256. */
  69257. static RangeToPercent(number: number, min: number, max: number): number;
  69258. /**
  69259. * This function returns number that corresponds to the percentage in a given range.
  69260. *
  69261. * PercentToRange(0.34,0,100) will return 34.
  69262. * @param percent to convert to number
  69263. * @param min min range
  69264. * @param max max range
  69265. * @returns the number
  69266. */
  69267. static PercentToRange(percent: number, min: number, max: number): number;
  69268. /**
  69269. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69270. * @param angle The angle to normalize in radian.
  69271. * @return The converted angle.
  69272. */
  69273. static NormalizeRadians(angle: number): number;
  69274. }
  69275. }
  69276. declare module BABYLON {
  69277. /**
  69278. * Constant used to convert a value to gamma space
  69279. * @ignorenaming
  69280. */
  69281. export const ToGammaSpace: number;
  69282. /**
  69283. * Constant used to convert a value to linear space
  69284. * @ignorenaming
  69285. */
  69286. export const ToLinearSpace = 2.2;
  69287. /**
  69288. * Constant used to define the minimal number value in Babylon.js
  69289. * @ignorenaming
  69290. */
  69291. let Epsilon: number;
  69292. }
  69293. declare module BABYLON {
  69294. /**
  69295. * Class used to represent a viewport on screen
  69296. */
  69297. export class Viewport {
  69298. /** viewport left coordinate */
  69299. x: number;
  69300. /** viewport top coordinate */
  69301. y: number;
  69302. /**viewport width */
  69303. width: number;
  69304. /** viewport height */
  69305. height: number;
  69306. /**
  69307. * Creates a Viewport object located at (x, y) and sized (width, height)
  69308. * @param x defines viewport left coordinate
  69309. * @param y defines viewport top coordinate
  69310. * @param width defines the viewport width
  69311. * @param height defines the viewport height
  69312. */
  69313. constructor(
  69314. /** viewport left coordinate */
  69315. x: number,
  69316. /** viewport top coordinate */
  69317. y: number,
  69318. /**viewport width */
  69319. width: number,
  69320. /** viewport height */
  69321. height: number);
  69322. /**
  69323. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69324. * @param renderWidth defines the rendering width
  69325. * @param renderHeight defines the rendering height
  69326. * @returns a new Viewport
  69327. */
  69328. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69329. /**
  69330. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69331. * @param renderWidth defines the rendering width
  69332. * @param renderHeight defines the rendering height
  69333. * @param ref defines the target viewport
  69334. * @returns the current viewport
  69335. */
  69336. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69337. /**
  69338. * Returns a new Viewport copied from the current one
  69339. * @returns a new Viewport
  69340. */
  69341. clone(): Viewport;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /**
  69346. * Class containing a set of static utilities functions for arrays.
  69347. */
  69348. export class ArrayTools {
  69349. /**
  69350. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69351. * @param size the number of element to construct and put in the array
  69352. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69353. * @returns a new array filled with new objects
  69354. */
  69355. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69356. }
  69357. }
  69358. declare module BABYLON {
  69359. /**
  69360. * Class representing a vector containing 2 coordinates
  69361. */
  69362. export class Vector2 {
  69363. /** defines the first coordinate */
  69364. x: number;
  69365. /** defines the second coordinate */
  69366. y: number;
  69367. /**
  69368. * Creates a new Vector2 from the given x and y coordinates
  69369. * @param x defines the first coordinate
  69370. * @param y defines the second coordinate
  69371. */
  69372. constructor(
  69373. /** defines the first coordinate */
  69374. x?: number,
  69375. /** defines the second coordinate */
  69376. y?: number);
  69377. /**
  69378. * Gets a string with the Vector2 coordinates
  69379. * @returns a string with the Vector2 coordinates
  69380. */
  69381. toString(): string;
  69382. /**
  69383. * Gets class name
  69384. * @returns the string "Vector2"
  69385. */
  69386. getClassName(): string;
  69387. /**
  69388. * Gets current vector hash code
  69389. * @returns the Vector2 hash code as a number
  69390. */
  69391. getHashCode(): number;
  69392. /**
  69393. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69394. * @param array defines the source array
  69395. * @param index defines the offset in source array
  69396. * @returns the current Vector2
  69397. */
  69398. toArray(array: FloatArray, index?: number): Vector2;
  69399. /**
  69400. * Copy the current vector to an array
  69401. * @returns a new array with 2 elements: the Vector2 coordinates.
  69402. */
  69403. asArray(): number[];
  69404. /**
  69405. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69406. * @param source defines the source Vector2
  69407. * @returns the current updated Vector2
  69408. */
  69409. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69410. /**
  69411. * Sets the Vector2 coordinates with the given floats
  69412. * @param x defines the first coordinate
  69413. * @param y defines the second coordinate
  69414. * @returns the current updated Vector2
  69415. */
  69416. copyFromFloats(x: number, y: number): Vector2;
  69417. /**
  69418. * Sets the Vector2 coordinates with the given floats
  69419. * @param x defines the first coordinate
  69420. * @param y defines the second coordinate
  69421. * @returns the current updated Vector2
  69422. */
  69423. set(x: number, y: number): Vector2;
  69424. /**
  69425. * Add another vector with the current one
  69426. * @param otherVector defines the other vector
  69427. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69428. */
  69429. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69430. /**
  69431. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69432. * @param otherVector defines the other vector
  69433. * @param result defines the target vector
  69434. * @returns the unmodified current Vector2
  69435. */
  69436. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69437. /**
  69438. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69439. * @param otherVector defines the other vector
  69440. * @returns the current updated Vector2
  69441. */
  69442. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69443. /**
  69444. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69445. * @param otherVector defines the other vector
  69446. * @returns a new Vector2
  69447. */
  69448. addVector3(otherVector: Vector3): Vector2;
  69449. /**
  69450. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69451. * @param otherVector defines the other vector
  69452. * @returns a new Vector2
  69453. */
  69454. subtract(otherVector: Vector2): Vector2;
  69455. /**
  69456. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69457. * @param otherVector defines the other vector
  69458. * @param result defines the target vector
  69459. * @returns the unmodified current Vector2
  69460. */
  69461. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69462. /**
  69463. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69464. * @param otherVector defines the other vector
  69465. * @returns the current updated Vector2
  69466. */
  69467. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69468. /**
  69469. * Multiplies in place the current Vector2 coordinates by the given ones
  69470. * @param otherVector defines the other vector
  69471. * @returns the current updated Vector2
  69472. */
  69473. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69474. /**
  69475. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69476. * @param otherVector defines the other vector
  69477. * @returns a new Vector2
  69478. */
  69479. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69480. /**
  69481. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69482. * @param otherVector defines the other vector
  69483. * @param result defines the target vector
  69484. * @returns the unmodified current Vector2
  69485. */
  69486. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69487. /**
  69488. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69489. * @param x defines the first coordinate
  69490. * @param y defines the second coordinate
  69491. * @returns a new Vector2
  69492. */
  69493. multiplyByFloats(x: number, y: number): Vector2;
  69494. /**
  69495. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69496. * @param otherVector defines the other vector
  69497. * @returns a new Vector2
  69498. */
  69499. divide(otherVector: Vector2): Vector2;
  69500. /**
  69501. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69502. * @param otherVector defines the other vector
  69503. * @param result defines the target vector
  69504. * @returns the unmodified current Vector2
  69505. */
  69506. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69507. /**
  69508. * Divides the current Vector2 coordinates by the given ones
  69509. * @param otherVector defines the other vector
  69510. * @returns the current updated Vector2
  69511. */
  69512. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69513. /**
  69514. * Gets a new Vector2 with current Vector2 negated coordinates
  69515. * @returns a new Vector2
  69516. */
  69517. negate(): Vector2;
  69518. /**
  69519. * Multiply the Vector2 coordinates by scale
  69520. * @param scale defines the scaling factor
  69521. * @returns the current updated Vector2
  69522. */
  69523. scaleInPlace(scale: number): Vector2;
  69524. /**
  69525. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69526. * @param scale defines the scaling factor
  69527. * @returns a new Vector2
  69528. */
  69529. scale(scale: number): Vector2;
  69530. /**
  69531. * Scale the current Vector2 values by a factor to a given Vector2
  69532. * @param scale defines the scale factor
  69533. * @param result defines the Vector2 object where to store the result
  69534. * @returns the unmodified current Vector2
  69535. */
  69536. scaleToRef(scale: number, result: Vector2): Vector2;
  69537. /**
  69538. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69539. * @param scale defines the scale factor
  69540. * @param result defines the Vector2 object where to store the result
  69541. * @returns the unmodified current Vector2
  69542. */
  69543. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69544. /**
  69545. * Gets a boolean if two vectors are equals
  69546. * @param otherVector defines the other vector
  69547. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69548. */
  69549. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69550. /**
  69551. * Gets a boolean if two vectors are equals (using an epsilon value)
  69552. * @param otherVector defines the other vector
  69553. * @param epsilon defines the minimal distance to consider equality
  69554. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69555. */
  69556. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69557. /**
  69558. * Gets a new Vector2 from current Vector2 floored values
  69559. * @returns a new Vector2
  69560. */
  69561. floor(): Vector2;
  69562. /**
  69563. * Gets a new Vector2 from current Vector2 floored values
  69564. * @returns a new Vector2
  69565. */
  69566. fract(): Vector2;
  69567. /**
  69568. * Gets the length of the vector
  69569. * @returns the vector length (float)
  69570. */
  69571. length(): number;
  69572. /**
  69573. * Gets the vector squared length
  69574. * @returns the vector squared length (float)
  69575. */
  69576. lengthSquared(): number;
  69577. /**
  69578. * Normalize the vector
  69579. * @returns the current updated Vector2
  69580. */
  69581. normalize(): Vector2;
  69582. /**
  69583. * Gets a new Vector2 copied from the Vector2
  69584. * @returns a new Vector2
  69585. */
  69586. clone(): Vector2;
  69587. /**
  69588. * Gets a new Vector2(0, 0)
  69589. * @returns a new Vector2
  69590. */
  69591. static Zero(): Vector2;
  69592. /**
  69593. * Gets a new Vector2(1, 1)
  69594. * @returns a new Vector2
  69595. */
  69596. static One(): Vector2;
  69597. /**
  69598. * Gets a new Vector2 set from the given index element of the given array
  69599. * @param array defines the data source
  69600. * @param offset defines the offset in the data source
  69601. * @returns a new Vector2
  69602. */
  69603. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69604. /**
  69605. * Sets "result" from the given index element of the given array
  69606. * @param array defines the data source
  69607. * @param offset defines the offset in the data source
  69608. * @param result defines the target vector
  69609. */
  69610. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69611. /**
  69612. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69613. * @param value1 defines 1st point of control
  69614. * @param value2 defines 2nd point of control
  69615. * @param value3 defines 3rd point of control
  69616. * @param value4 defines 4th point of control
  69617. * @param amount defines the interpolation factor
  69618. * @returns a new Vector2
  69619. */
  69620. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69621. /**
  69622. * 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".
  69623. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69624. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69625. * @param value defines the value to clamp
  69626. * @param min defines the lower limit
  69627. * @param max defines the upper limit
  69628. * @returns a new Vector2
  69629. */
  69630. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69631. /**
  69632. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69633. * @param value1 defines the 1st control point
  69634. * @param tangent1 defines the outgoing tangent
  69635. * @param value2 defines the 2nd control point
  69636. * @param tangent2 defines the incoming tangent
  69637. * @param amount defines the interpolation factor
  69638. * @returns a new Vector2
  69639. */
  69640. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69641. /**
  69642. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69643. * @param start defines the start vector
  69644. * @param end defines the end vector
  69645. * @param amount defines the interpolation factor
  69646. * @returns a new Vector2
  69647. */
  69648. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69649. /**
  69650. * Gets the dot product of the vector "left" and the vector "right"
  69651. * @param left defines first vector
  69652. * @param right defines second vector
  69653. * @returns the dot product (float)
  69654. */
  69655. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69656. /**
  69657. * Returns a new Vector2 equal to the normalized given vector
  69658. * @param vector defines the vector to normalize
  69659. * @returns a new Vector2
  69660. */
  69661. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69662. /**
  69663. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69664. * @param left defines 1st vector
  69665. * @param right defines 2nd vector
  69666. * @returns a new Vector2
  69667. */
  69668. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69669. /**
  69670. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69671. * @param left defines 1st vector
  69672. * @param right defines 2nd vector
  69673. * @returns a new Vector2
  69674. */
  69675. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69676. /**
  69677. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69678. * @param vector defines the vector to transform
  69679. * @param transformation defines the matrix to apply
  69680. * @returns a new Vector2
  69681. */
  69682. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69683. /**
  69684. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69685. * @param vector defines the vector to transform
  69686. * @param transformation defines the matrix to apply
  69687. * @param result defines the target vector
  69688. */
  69689. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69690. /**
  69691. * Determines if a given vector is included in a triangle
  69692. * @param p defines the vector to test
  69693. * @param p0 defines 1st triangle point
  69694. * @param p1 defines 2nd triangle point
  69695. * @param p2 defines 3rd triangle point
  69696. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69697. */
  69698. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69699. /**
  69700. * Gets the distance between the vectors "value1" and "value2"
  69701. * @param value1 defines first vector
  69702. * @param value2 defines second vector
  69703. * @returns the distance between vectors
  69704. */
  69705. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69706. /**
  69707. * Returns the squared distance between the vectors "value1" and "value2"
  69708. * @param value1 defines first vector
  69709. * @param value2 defines second vector
  69710. * @returns the squared distance between vectors
  69711. */
  69712. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69713. /**
  69714. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69715. * @param value1 defines first vector
  69716. * @param value2 defines second vector
  69717. * @returns a new Vector2
  69718. */
  69719. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69720. /**
  69721. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69722. * @param p defines the middle point
  69723. * @param segA defines one point of the segment
  69724. * @param segB defines the other point of the segment
  69725. * @returns the shortest distance
  69726. */
  69727. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69728. }
  69729. /**
  69730. * Classed used to store (x,y,z) vector representation
  69731. * A Vector3 is the main object used in 3D geometry
  69732. * It can represent etiher the coordinates of a point the space, either a direction
  69733. * Reminder: js uses a left handed forward facing system
  69734. */
  69735. export class Vector3 {
  69736. /**
  69737. * Defines the first coordinates (on X axis)
  69738. */
  69739. x: number;
  69740. /**
  69741. * Defines the second coordinates (on Y axis)
  69742. */
  69743. y: number;
  69744. /**
  69745. * Defines the third coordinates (on Z axis)
  69746. */
  69747. z: number;
  69748. private static _UpReadOnly;
  69749. private static _ZeroReadOnly;
  69750. /**
  69751. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69752. * @param x defines the first coordinates (on X axis)
  69753. * @param y defines the second coordinates (on Y axis)
  69754. * @param z defines the third coordinates (on Z axis)
  69755. */
  69756. constructor(
  69757. /**
  69758. * Defines the first coordinates (on X axis)
  69759. */
  69760. x?: number,
  69761. /**
  69762. * Defines the second coordinates (on Y axis)
  69763. */
  69764. y?: number,
  69765. /**
  69766. * Defines the third coordinates (on Z axis)
  69767. */
  69768. z?: number);
  69769. /**
  69770. * Creates a string representation of the Vector3
  69771. * @returns a string with the Vector3 coordinates.
  69772. */
  69773. toString(): string;
  69774. /**
  69775. * Gets the class name
  69776. * @returns the string "Vector3"
  69777. */
  69778. getClassName(): string;
  69779. /**
  69780. * Creates the Vector3 hash code
  69781. * @returns a number which tends to be unique between Vector3 instances
  69782. */
  69783. getHashCode(): number;
  69784. /**
  69785. * Creates an array containing three elements : the coordinates of the Vector3
  69786. * @returns a new array of numbers
  69787. */
  69788. asArray(): number[];
  69789. /**
  69790. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69791. * @param array defines the destination array
  69792. * @param index defines the offset in the destination array
  69793. * @returns the current Vector3
  69794. */
  69795. toArray(array: FloatArray, index?: number): Vector3;
  69796. /**
  69797. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69798. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69799. */
  69800. toQuaternion(): Quaternion;
  69801. /**
  69802. * Adds the given vector to the current Vector3
  69803. * @param otherVector defines the second operand
  69804. * @returns the current updated Vector3
  69805. */
  69806. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69807. /**
  69808. * Adds the given coordinates to the current Vector3
  69809. * @param x defines the x coordinate of the operand
  69810. * @param y defines the y coordinate of the operand
  69811. * @param z defines the z coordinate of the operand
  69812. * @returns the current updated Vector3
  69813. */
  69814. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69815. /**
  69816. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69817. * @param otherVector defines the second operand
  69818. * @returns the resulting Vector3
  69819. */
  69820. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69821. /**
  69822. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69823. * @param otherVector defines the second operand
  69824. * @param result defines the Vector3 object where to store the result
  69825. * @returns the current Vector3
  69826. */
  69827. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69828. /**
  69829. * Subtract the given vector from the current Vector3
  69830. * @param otherVector defines the second operand
  69831. * @returns the current updated Vector3
  69832. */
  69833. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69834. /**
  69835. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69836. * @param otherVector defines the second operand
  69837. * @returns the resulting Vector3
  69838. */
  69839. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69840. /**
  69841. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69842. * @param otherVector defines the second operand
  69843. * @param result defines the Vector3 object where to store the result
  69844. * @returns the current Vector3
  69845. */
  69846. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69847. /**
  69848. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69849. * @param x defines the x coordinate of the operand
  69850. * @param y defines the y coordinate of the operand
  69851. * @param z defines the z coordinate of the operand
  69852. * @returns the resulting Vector3
  69853. */
  69854. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69855. /**
  69856. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69857. * @param x defines the x coordinate of the operand
  69858. * @param y defines the y coordinate of the operand
  69859. * @param z defines the z coordinate of the operand
  69860. * @param result defines the Vector3 object where to store the result
  69861. * @returns the current Vector3
  69862. */
  69863. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69864. /**
  69865. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69866. * @returns a new Vector3
  69867. */
  69868. negate(): Vector3;
  69869. /**
  69870. * Multiplies the Vector3 coordinates by the float "scale"
  69871. * @param scale defines the multiplier factor
  69872. * @returns the current updated Vector3
  69873. */
  69874. scaleInPlace(scale: number): Vector3;
  69875. /**
  69876. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69877. * @param scale defines the multiplier factor
  69878. * @returns a new Vector3
  69879. */
  69880. scale(scale: number): Vector3;
  69881. /**
  69882. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69883. * @param scale defines the multiplier factor
  69884. * @param result defines the Vector3 object where to store the result
  69885. * @returns the current Vector3
  69886. */
  69887. scaleToRef(scale: number, result: Vector3): Vector3;
  69888. /**
  69889. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69890. * @param scale defines the scale factor
  69891. * @param result defines the Vector3 object where to store the result
  69892. * @returns the unmodified current Vector3
  69893. */
  69894. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69895. /**
  69896. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69897. * @param otherVector defines the second operand
  69898. * @returns true if both vectors are equals
  69899. */
  69900. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69901. /**
  69902. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69903. * @param otherVector defines the second operand
  69904. * @param epsilon defines the minimal distance to define values as equals
  69905. * @returns true if both vectors are distant less than epsilon
  69906. */
  69907. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69908. /**
  69909. * Returns true if the current Vector3 coordinates equals the given floats
  69910. * @param x defines the x coordinate of the operand
  69911. * @param y defines the y coordinate of the operand
  69912. * @param z defines the z coordinate of the operand
  69913. * @returns true if both vectors are equals
  69914. */
  69915. equalsToFloats(x: number, y: number, z: number): boolean;
  69916. /**
  69917. * Multiplies the current Vector3 coordinates by the given ones
  69918. * @param otherVector defines the second operand
  69919. * @returns the current updated Vector3
  69920. */
  69921. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69922. /**
  69923. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69924. * @param otherVector defines the second operand
  69925. * @returns the new Vector3
  69926. */
  69927. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69928. /**
  69929. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69930. * @param otherVector defines the second operand
  69931. * @param result defines the Vector3 object where to store the result
  69932. * @returns the current Vector3
  69933. */
  69934. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69935. /**
  69936. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69937. * @param x defines the x coordinate of the operand
  69938. * @param y defines the y coordinate of the operand
  69939. * @param z defines the z coordinate of the operand
  69940. * @returns the new Vector3
  69941. */
  69942. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69943. /**
  69944. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69945. * @param otherVector defines the second operand
  69946. * @returns the new Vector3
  69947. */
  69948. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69949. /**
  69950. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69951. * @param otherVector defines the second operand
  69952. * @param result defines the Vector3 object where to store the result
  69953. * @returns the current Vector3
  69954. */
  69955. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69956. /**
  69957. * Divides the current Vector3 coordinates by the given ones.
  69958. * @param otherVector defines the second operand
  69959. * @returns the current updated Vector3
  69960. */
  69961. divideInPlace(otherVector: Vector3): Vector3;
  69962. /**
  69963. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69964. * @param other defines the second operand
  69965. * @returns the current updated Vector3
  69966. */
  69967. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69968. /**
  69969. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69970. * @param other defines the second operand
  69971. * @returns the current updated Vector3
  69972. */
  69973. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69974. /**
  69975. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69976. * @param x defines the x coordinate of the operand
  69977. * @param y defines the y coordinate of the operand
  69978. * @param z defines the z coordinate of the operand
  69979. * @returns the current updated Vector3
  69980. */
  69981. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69982. /**
  69983. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69984. * @param x defines the x coordinate of the operand
  69985. * @param y defines the y coordinate of the operand
  69986. * @param z defines the z coordinate of the operand
  69987. * @returns the current updated Vector3
  69988. */
  69989. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69990. /**
  69991. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69992. * Check if is non uniform within a certain amount of decimal places to account for this
  69993. * @param epsilon the amount the values can differ
  69994. * @returns if the the vector is non uniform to a certain number of decimal places
  69995. */
  69996. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69997. /**
  69998. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69999. */
  70000. readonly isNonUniform: boolean;
  70001. /**
  70002. * Gets a new Vector3 from current Vector3 floored values
  70003. * @returns a new Vector3
  70004. */
  70005. floor(): Vector3;
  70006. /**
  70007. * Gets a new Vector3 from current Vector3 floored values
  70008. * @returns a new Vector3
  70009. */
  70010. fract(): Vector3;
  70011. /**
  70012. * Gets the length of the Vector3
  70013. * @returns the length of the Vector3
  70014. */
  70015. length(): number;
  70016. /**
  70017. * Gets the squared length of the Vector3
  70018. * @returns squared length of the Vector3
  70019. */
  70020. lengthSquared(): number;
  70021. /**
  70022. * Normalize the current Vector3.
  70023. * Please note that this is an in place operation.
  70024. * @returns the current updated Vector3
  70025. */
  70026. normalize(): Vector3;
  70027. /**
  70028. * Reorders the x y z properties of the vector in place
  70029. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70030. * @returns the current updated vector
  70031. */
  70032. reorderInPlace(order: string): this;
  70033. /**
  70034. * Rotates the vector around 0,0,0 by a quaternion
  70035. * @param quaternion the rotation quaternion
  70036. * @param result vector to store the result
  70037. * @returns the resulting vector
  70038. */
  70039. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70040. /**
  70041. * Rotates a vector around a given point
  70042. * @param quaternion the rotation quaternion
  70043. * @param point the point to rotate around
  70044. * @param result vector to store the result
  70045. * @returns the resulting vector
  70046. */
  70047. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70048. /**
  70049. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70050. * The cross product is then orthogonal to both current and "other"
  70051. * @param other defines the right operand
  70052. * @returns the cross product
  70053. */
  70054. cross(other: Vector3): Vector3;
  70055. /**
  70056. * Normalize the current Vector3 with the given input length.
  70057. * Please note that this is an in place operation.
  70058. * @param len the length of the vector
  70059. * @returns the current updated Vector3
  70060. */
  70061. normalizeFromLength(len: number): Vector3;
  70062. /**
  70063. * Normalize the current Vector3 to a new vector
  70064. * @returns the new Vector3
  70065. */
  70066. normalizeToNew(): Vector3;
  70067. /**
  70068. * Normalize the current Vector3 to the reference
  70069. * @param reference define the Vector3 to update
  70070. * @returns the updated Vector3
  70071. */
  70072. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70073. /**
  70074. * Creates a new Vector3 copied from the current Vector3
  70075. * @returns the new Vector3
  70076. */
  70077. clone(): Vector3;
  70078. /**
  70079. * Copies the given vector coordinates to the current Vector3 ones
  70080. * @param source defines the source Vector3
  70081. * @returns the current updated Vector3
  70082. */
  70083. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70084. /**
  70085. * Copies the given floats to the current Vector3 coordinates
  70086. * @param x defines the x coordinate of the operand
  70087. * @param y defines the y coordinate of the operand
  70088. * @param z defines the z coordinate of the operand
  70089. * @returns the current updated Vector3
  70090. */
  70091. copyFromFloats(x: number, y: number, z: number): Vector3;
  70092. /**
  70093. * Copies the given floats to the current Vector3 coordinates
  70094. * @param x defines the x coordinate of the operand
  70095. * @param y defines the y coordinate of the operand
  70096. * @param z defines the z coordinate of the operand
  70097. * @returns the current updated Vector3
  70098. */
  70099. set(x: number, y: number, z: number): Vector3;
  70100. /**
  70101. * Copies the given float to the current Vector3 coordinates
  70102. * @param v defines the x, y and z coordinates of the operand
  70103. * @returns the current updated Vector3
  70104. */
  70105. setAll(v: number): Vector3;
  70106. /**
  70107. * Get the clip factor between two vectors
  70108. * @param vector0 defines the first operand
  70109. * @param vector1 defines the second operand
  70110. * @param axis defines the axis to use
  70111. * @param size defines the size along the axis
  70112. * @returns the clip factor
  70113. */
  70114. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70115. /**
  70116. * Get angle between two vectors
  70117. * @param vector0 angle between vector0 and vector1
  70118. * @param vector1 angle between vector0 and vector1
  70119. * @param normal direction of the normal
  70120. * @return the angle between vector0 and vector1
  70121. */
  70122. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70123. /**
  70124. * Returns a new Vector3 set from the index "offset" of the given array
  70125. * @param array defines the source array
  70126. * @param offset defines the offset in the source array
  70127. * @returns the new Vector3
  70128. */
  70129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70130. /**
  70131. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70132. * This function is deprecated. Use FromArray instead
  70133. * @param array defines the source array
  70134. * @param offset defines the offset in the source array
  70135. * @returns the new Vector3
  70136. */
  70137. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70138. /**
  70139. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70140. * @param array defines the source array
  70141. * @param offset defines the offset in the source array
  70142. * @param result defines the Vector3 where to store the result
  70143. */
  70144. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70145. /**
  70146. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70147. * This function is deprecated. Use FromArrayToRef instead.
  70148. * @param array defines the source array
  70149. * @param offset defines the offset in the source array
  70150. * @param result defines the Vector3 where to store the result
  70151. */
  70152. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70153. /**
  70154. * Sets the given vector "result" with the given floats.
  70155. * @param x defines the x coordinate of the source
  70156. * @param y defines the y coordinate of the source
  70157. * @param z defines the z coordinate of the source
  70158. * @param result defines the Vector3 where to store the result
  70159. */
  70160. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70161. /**
  70162. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70163. * @returns a new empty Vector3
  70164. */
  70165. static Zero(): Vector3;
  70166. /**
  70167. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70168. * @returns a new unit Vector3
  70169. */
  70170. static One(): Vector3;
  70171. /**
  70172. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70173. * @returns a new up Vector3
  70174. */
  70175. static Up(): Vector3;
  70176. /**
  70177. * Gets a up Vector3 that must not be updated
  70178. */
  70179. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70180. /**
  70181. * Gets a zero Vector3 that must not be updated
  70182. */
  70183. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70184. /**
  70185. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70186. * @returns a new down Vector3
  70187. */
  70188. static Down(): Vector3;
  70189. /**
  70190. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70191. * @returns a new forward Vector3
  70192. */
  70193. static Forward(): Vector3;
  70194. /**
  70195. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70196. * @returns a new forward Vector3
  70197. */
  70198. static Backward(): Vector3;
  70199. /**
  70200. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70201. * @returns a new right Vector3
  70202. */
  70203. static Right(): Vector3;
  70204. /**
  70205. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70206. * @returns a new left Vector3
  70207. */
  70208. static Left(): Vector3;
  70209. /**
  70210. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70211. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70212. * @param vector defines the Vector3 to transform
  70213. * @param transformation defines the transformation matrix
  70214. * @returns the transformed Vector3
  70215. */
  70216. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70217. /**
  70218. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70219. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70220. * @param vector defines the Vector3 to transform
  70221. * @param transformation defines the transformation matrix
  70222. * @param result defines the Vector3 where to store the result
  70223. */
  70224. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70225. /**
  70226. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70227. * This method computes tranformed coordinates only, not transformed direction vectors
  70228. * @param x define the x coordinate of the source vector
  70229. * @param y define the y coordinate of the source vector
  70230. * @param z define the z coordinate of the source vector
  70231. * @param transformation defines the transformation matrix
  70232. * @param result defines the Vector3 where to store the result
  70233. */
  70234. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70235. /**
  70236. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70237. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70238. * @param vector defines the Vector3 to transform
  70239. * @param transformation defines the transformation matrix
  70240. * @returns the new Vector3
  70241. */
  70242. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70243. /**
  70244. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70245. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70246. * @param vector defines the Vector3 to transform
  70247. * @param transformation defines the transformation matrix
  70248. * @param result defines the Vector3 where to store the result
  70249. */
  70250. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70251. /**
  70252. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70253. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70254. * @param x define the x coordinate of the source vector
  70255. * @param y define the y coordinate of the source vector
  70256. * @param z define the z coordinate of the source vector
  70257. * @param transformation defines the transformation matrix
  70258. * @param result defines the Vector3 where to store the result
  70259. */
  70260. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70261. /**
  70262. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70263. * @param value1 defines the first control point
  70264. * @param value2 defines the second control point
  70265. * @param value3 defines the third control point
  70266. * @param value4 defines the fourth control point
  70267. * @param amount defines the amount on the spline to use
  70268. * @returns the new Vector3
  70269. */
  70270. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70271. /**
  70272. * 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"
  70273. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70274. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70275. * @param value defines the current value
  70276. * @param min defines the lower range value
  70277. * @param max defines the upper range value
  70278. * @returns the new Vector3
  70279. */
  70280. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70281. /**
  70282. * 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"
  70283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70285. * @param value defines the current value
  70286. * @param min defines the lower range value
  70287. * @param max defines the upper range value
  70288. * @param result defines the Vector3 where to store the result
  70289. */
  70290. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70291. /**
  70292. * Checks if a given vector is inside a specific range
  70293. * @param v defines the vector to test
  70294. * @param min defines the minimum range
  70295. * @param max defines the maximum range
  70296. */
  70297. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70298. /**
  70299. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70300. * @param value1 defines the first control point
  70301. * @param tangent1 defines the first tangent vector
  70302. * @param value2 defines the second control point
  70303. * @param tangent2 defines the second tangent vector
  70304. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70305. * @returns the new Vector3
  70306. */
  70307. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70308. /**
  70309. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70310. * @param start defines the start value
  70311. * @param end defines the end value
  70312. * @param amount max defines amount between both (between 0 and 1)
  70313. * @returns the new Vector3
  70314. */
  70315. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70316. /**
  70317. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70318. * @param start defines the start value
  70319. * @param end defines the end value
  70320. * @param amount max defines amount between both (between 0 and 1)
  70321. * @param result defines the Vector3 where to store the result
  70322. */
  70323. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70324. /**
  70325. * Returns the dot product (float) between the vectors "left" and "right"
  70326. * @param left defines the left operand
  70327. * @param right defines the right operand
  70328. * @returns the dot product
  70329. */
  70330. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70331. /**
  70332. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70333. * The cross product is then orthogonal to both "left" and "right"
  70334. * @param left defines the left operand
  70335. * @param right defines the right operand
  70336. * @returns the cross product
  70337. */
  70338. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70339. /**
  70340. * Sets the given vector "result" with the cross product of "left" and "right"
  70341. * The cross product is then orthogonal to both "left" and "right"
  70342. * @param left defines the left operand
  70343. * @param right defines the right operand
  70344. * @param result defines the Vector3 where to store the result
  70345. */
  70346. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70347. /**
  70348. * Returns a new Vector3 as the normalization of the given vector
  70349. * @param vector defines the Vector3 to normalize
  70350. * @returns the new Vector3
  70351. */
  70352. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70353. /**
  70354. * Sets the given vector "result" with the normalization of the given first vector
  70355. * @param vector defines the Vector3 to normalize
  70356. * @param result defines the Vector3 where to store the result
  70357. */
  70358. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70359. /**
  70360. * Project a Vector3 onto screen space
  70361. * @param vector defines the Vector3 to project
  70362. * @param world defines the world matrix to use
  70363. * @param transform defines the transform (view x projection) matrix to use
  70364. * @param viewport defines the screen viewport to use
  70365. * @returns the new Vector3
  70366. */
  70367. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70368. /** @hidden */
  70369. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70370. /**
  70371. * Unproject from screen space to object space
  70372. * @param source defines the screen space Vector3 to use
  70373. * @param viewportWidth defines the current width of the viewport
  70374. * @param viewportHeight defines the current height of the viewport
  70375. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70376. * @param transform defines the transform (view x projection) matrix to use
  70377. * @returns the new Vector3
  70378. */
  70379. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70380. /**
  70381. * Unproject from screen space to object space
  70382. * @param source defines the screen space Vector3 to use
  70383. * @param viewportWidth defines the current width of the viewport
  70384. * @param viewportHeight defines the current height of the viewport
  70385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70386. * @param view defines the view matrix to use
  70387. * @param projection defines the projection matrix to use
  70388. * @returns the new Vector3
  70389. */
  70390. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70391. /**
  70392. * Unproject from screen space to object space
  70393. * @param source defines the screen space Vector3 to use
  70394. * @param viewportWidth defines the current width of the viewport
  70395. * @param viewportHeight defines the current height of the viewport
  70396. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70397. * @param view defines the view matrix to use
  70398. * @param projection defines the projection matrix to use
  70399. * @param result defines the Vector3 where to store the result
  70400. */
  70401. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70402. /**
  70403. * Unproject from screen space to object space
  70404. * @param sourceX defines the screen space x coordinate to use
  70405. * @param sourceY defines the screen space y coordinate to use
  70406. * @param sourceZ defines the screen space z coordinate to use
  70407. * @param viewportWidth defines the current width of the viewport
  70408. * @param viewportHeight defines the current height of the viewport
  70409. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70410. * @param view defines the view matrix to use
  70411. * @param projection defines the projection matrix to use
  70412. * @param result defines the Vector3 where to store the result
  70413. */
  70414. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70415. /**
  70416. * Gets the minimal coordinate values between two Vector3
  70417. * @param left defines the first operand
  70418. * @param right defines the second operand
  70419. * @returns the new Vector3
  70420. */
  70421. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70422. /**
  70423. * Gets the maximal coordinate values between two Vector3
  70424. * @param left defines the first operand
  70425. * @param right defines the second operand
  70426. * @returns the new Vector3
  70427. */
  70428. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70429. /**
  70430. * Returns the distance between the vectors "value1" and "value2"
  70431. * @param value1 defines the first operand
  70432. * @param value2 defines the second operand
  70433. * @returns the distance
  70434. */
  70435. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70436. /**
  70437. * Returns the squared distance between the vectors "value1" and "value2"
  70438. * @param value1 defines the first operand
  70439. * @param value2 defines the second operand
  70440. * @returns the squared distance
  70441. */
  70442. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70443. /**
  70444. * Returns a new Vector3 located at the center between "value1" and "value2"
  70445. * @param value1 defines the first operand
  70446. * @param value2 defines the second operand
  70447. * @returns the new Vector3
  70448. */
  70449. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70450. /**
  70451. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70452. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70453. * to something in order to rotate it from its local system to the given target system
  70454. * Note: axis1, axis2 and axis3 are normalized during this operation
  70455. * @param axis1 defines the first axis
  70456. * @param axis2 defines the second axis
  70457. * @param axis3 defines the third axis
  70458. * @returns a new Vector3
  70459. */
  70460. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70461. /**
  70462. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70463. * @param axis1 defines the first axis
  70464. * @param axis2 defines the second axis
  70465. * @param axis3 defines the third axis
  70466. * @param ref defines the Vector3 where to store the result
  70467. */
  70468. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70469. }
  70470. /**
  70471. * Vector4 class created for EulerAngle class conversion to Quaternion
  70472. */
  70473. export class Vector4 {
  70474. /** x value of the vector */
  70475. x: number;
  70476. /** y value of the vector */
  70477. y: number;
  70478. /** z value of the vector */
  70479. z: number;
  70480. /** w value of the vector */
  70481. w: number;
  70482. /**
  70483. * Creates a Vector4 object from the given floats.
  70484. * @param x x value of the vector
  70485. * @param y y value of the vector
  70486. * @param z z value of the vector
  70487. * @param w w value of the vector
  70488. */
  70489. constructor(
  70490. /** x value of the vector */
  70491. x: number,
  70492. /** y value of the vector */
  70493. y: number,
  70494. /** z value of the vector */
  70495. z: number,
  70496. /** w value of the vector */
  70497. w: number);
  70498. /**
  70499. * Returns the string with the Vector4 coordinates.
  70500. * @returns a string containing all the vector values
  70501. */
  70502. toString(): string;
  70503. /**
  70504. * Returns the string "Vector4".
  70505. * @returns "Vector4"
  70506. */
  70507. getClassName(): string;
  70508. /**
  70509. * Returns the Vector4 hash code.
  70510. * @returns a unique hash code
  70511. */
  70512. getHashCode(): number;
  70513. /**
  70514. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70515. * @returns the resulting array
  70516. */
  70517. asArray(): number[];
  70518. /**
  70519. * Populates the given array from the given index with the Vector4 coordinates.
  70520. * @param array array to populate
  70521. * @param index index of the array to start at (default: 0)
  70522. * @returns the Vector4.
  70523. */
  70524. toArray(array: FloatArray, index?: number): Vector4;
  70525. /**
  70526. * Adds the given vector to the current Vector4.
  70527. * @param otherVector the vector to add
  70528. * @returns the updated Vector4.
  70529. */
  70530. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70531. /**
  70532. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70533. * @param otherVector the vector to add
  70534. * @returns the resulting vector
  70535. */
  70536. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70537. /**
  70538. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70539. * @param otherVector the vector to add
  70540. * @param result the vector to store the result
  70541. * @returns the current Vector4.
  70542. */
  70543. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70544. /**
  70545. * Subtract in place the given vector from the current Vector4.
  70546. * @param otherVector the vector to subtract
  70547. * @returns the updated Vector4.
  70548. */
  70549. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70550. /**
  70551. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70552. * @param otherVector the vector to add
  70553. * @returns the new vector with the result
  70554. */
  70555. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70556. /**
  70557. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70558. * @param otherVector the vector to subtract
  70559. * @param result the vector to store the result
  70560. * @returns the current Vector4.
  70561. */
  70562. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70563. /**
  70564. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70565. */
  70566. /**
  70567. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70568. * @param x value to subtract
  70569. * @param y value to subtract
  70570. * @param z value to subtract
  70571. * @param w value to subtract
  70572. * @returns new vector containing the result
  70573. */
  70574. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70575. /**
  70576. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70577. * @param x value to subtract
  70578. * @param y value to subtract
  70579. * @param z value to subtract
  70580. * @param w value to subtract
  70581. * @param result the vector to store the result in
  70582. * @returns the current Vector4.
  70583. */
  70584. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70585. /**
  70586. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70587. * @returns a new vector with the negated values
  70588. */
  70589. negate(): Vector4;
  70590. /**
  70591. * Multiplies the current Vector4 coordinates by scale (float).
  70592. * @param scale the number to scale with
  70593. * @returns the updated Vector4.
  70594. */
  70595. scaleInPlace(scale: number): Vector4;
  70596. /**
  70597. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70598. * @param scale the number to scale with
  70599. * @returns a new vector with the result
  70600. */
  70601. scale(scale: number): Vector4;
  70602. /**
  70603. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70604. * @param scale the number to scale with
  70605. * @param result a vector to store the result in
  70606. * @returns the current Vector4.
  70607. */
  70608. scaleToRef(scale: number, result: Vector4): Vector4;
  70609. /**
  70610. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70611. * @param scale defines the scale factor
  70612. * @param result defines the Vector4 object where to store the result
  70613. * @returns the unmodified current Vector4
  70614. */
  70615. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70616. /**
  70617. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70618. * @param otherVector the vector to compare against
  70619. * @returns true if they are equal
  70620. */
  70621. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70622. /**
  70623. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70624. * @param otherVector vector to compare against
  70625. * @param epsilon (Default: very small number)
  70626. * @returns true if they are equal
  70627. */
  70628. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70629. /**
  70630. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70631. * @param x x value to compare against
  70632. * @param y y value to compare against
  70633. * @param z z value to compare against
  70634. * @param w w value to compare against
  70635. * @returns true if equal
  70636. */
  70637. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70638. /**
  70639. * Multiplies in place the current Vector4 by the given one.
  70640. * @param otherVector vector to multiple with
  70641. * @returns the updated Vector4.
  70642. */
  70643. multiplyInPlace(otherVector: Vector4): Vector4;
  70644. /**
  70645. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70646. * @param otherVector vector to multiple with
  70647. * @returns resulting new vector
  70648. */
  70649. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70650. /**
  70651. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70652. * @param otherVector vector to multiple with
  70653. * @param result vector to store the result
  70654. * @returns the current Vector4.
  70655. */
  70656. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70657. /**
  70658. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70659. * @param x x value multiply with
  70660. * @param y y value multiply with
  70661. * @param z z value multiply with
  70662. * @param w w value multiply with
  70663. * @returns resulting new vector
  70664. */
  70665. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70666. /**
  70667. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70668. * @param otherVector vector to devide with
  70669. * @returns resulting new vector
  70670. */
  70671. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70672. /**
  70673. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70674. * @param otherVector vector to devide with
  70675. * @param result vector to store the result
  70676. * @returns the current Vector4.
  70677. */
  70678. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70679. /**
  70680. * Divides the current Vector3 coordinates by the given ones.
  70681. * @param otherVector vector to devide with
  70682. * @returns the updated Vector3.
  70683. */
  70684. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70685. /**
  70686. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70687. * @param other defines the second operand
  70688. * @returns the current updated Vector4
  70689. */
  70690. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70691. /**
  70692. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70693. * @param other defines the second operand
  70694. * @returns the current updated Vector4
  70695. */
  70696. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70697. /**
  70698. * Gets a new Vector4 from current Vector4 floored values
  70699. * @returns a new Vector4
  70700. */
  70701. floor(): Vector4;
  70702. /**
  70703. * Gets a new Vector4 from current Vector3 floored values
  70704. * @returns a new Vector4
  70705. */
  70706. fract(): Vector4;
  70707. /**
  70708. * Returns the Vector4 length (float).
  70709. * @returns the length
  70710. */
  70711. length(): number;
  70712. /**
  70713. * Returns the Vector4 squared length (float).
  70714. * @returns the length squared
  70715. */
  70716. lengthSquared(): number;
  70717. /**
  70718. * Normalizes in place the Vector4.
  70719. * @returns the updated Vector4.
  70720. */
  70721. normalize(): Vector4;
  70722. /**
  70723. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70724. * @returns this converted to a new vector3
  70725. */
  70726. toVector3(): Vector3;
  70727. /**
  70728. * Returns a new Vector4 copied from the current one.
  70729. * @returns the new cloned vector
  70730. */
  70731. clone(): Vector4;
  70732. /**
  70733. * Updates the current Vector4 with the given one coordinates.
  70734. * @param source the source vector to copy from
  70735. * @returns the updated Vector4.
  70736. */
  70737. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70738. /**
  70739. * Updates the current Vector4 coordinates with the given floats.
  70740. * @param x float to copy from
  70741. * @param y float to copy from
  70742. * @param z float to copy from
  70743. * @param w float to copy from
  70744. * @returns the updated Vector4.
  70745. */
  70746. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70747. /**
  70748. * Updates the current Vector4 coordinates with the given floats.
  70749. * @param x float to set from
  70750. * @param y float to set from
  70751. * @param z float to set from
  70752. * @param w float to set from
  70753. * @returns the updated Vector4.
  70754. */
  70755. set(x: number, y: number, z: number, w: number): Vector4;
  70756. /**
  70757. * Copies the given float to the current Vector3 coordinates
  70758. * @param v defines the x, y, z and w coordinates of the operand
  70759. * @returns the current updated Vector3
  70760. */
  70761. setAll(v: number): Vector4;
  70762. /**
  70763. * Returns a new Vector4 set from the starting index of the given array.
  70764. * @param array the array to pull values from
  70765. * @param offset the offset into the array to start at
  70766. * @returns the new vector
  70767. */
  70768. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70769. /**
  70770. * Updates the given vector "result" from the starting index of the given array.
  70771. * @param array the array to pull values from
  70772. * @param offset the offset into the array to start at
  70773. * @param result the vector to store the result in
  70774. */
  70775. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70776. /**
  70777. * Updates the given vector "result" from the starting index of the given Float32Array.
  70778. * @param array the array to pull values from
  70779. * @param offset the offset into the array to start at
  70780. * @param result the vector to store the result in
  70781. */
  70782. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70783. /**
  70784. * Updates the given vector "result" coordinates from the given floats.
  70785. * @param x float to set from
  70786. * @param y float to set from
  70787. * @param z float to set from
  70788. * @param w float to set from
  70789. * @param result the vector to the floats in
  70790. */
  70791. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70792. /**
  70793. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70794. * @returns the new vector
  70795. */
  70796. static Zero(): Vector4;
  70797. /**
  70798. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70799. * @returns the new vector
  70800. */
  70801. static One(): Vector4;
  70802. /**
  70803. * Returns a new normalized Vector4 from the given one.
  70804. * @param vector the vector to normalize
  70805. * @returns the vector
  70806. */
  70807. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70808. /**
  70809. * Updates the given vector "result" from the normalization of the given one.
  70810. * @param vector the vector to normalize
  70811. * @param result the vector to store the result in
  70812. */
  70813. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70814. /**
  70815. * Returns a vector with the minimum values from the left and right vectors
  70816. * @param left left vector to minimize
  70817. * @param right right vector to minimize
  70818. * @returns a new vector with the minimum of the left and right vector values
  70819. */
  70820. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70821. /**
  70822. * Returns a vector with the maximum values from the left and right vectors
  70823. * @param left left vector to maximize
  70824. * @param right right vector to maximize
  70825. * @returns a new vector with the maximum of the left and right vector values
  70826. */
  70827. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70828. /**
  70829. * Returns the distance (float) between the vectors "value1" and "value2".
  70830. * @param value1 value to calulate the distance between
  70831. * @param value2 value to calulate the distance between
  70832. * @return the distance between the two vectors
  70833. */
  70834. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70835. /**
  70836. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70837. * @param value1 value to calulate the distance between
  70838. * @param value2 value to calulate the distance between
  70839. * @return the distance between the two vectors squared
  70840. */
  70841. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70842. /**
  70843. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70844. * @param value1 value to calulate the center between
  70845. * @param value2 value to calulate the center between
  70846. * @return the center between the two vectors
  70847. */
  70848. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70849. /**
  70850. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70851. * This methods computes transformed normalized direction vectors only.
  70852. * @param vector the vector to transform
  70853. * @param transformation the transformation matrix to apply
  70854. * @returns the new vector
  70855. */
  70856. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70857. /**
  70858. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70859. * This methods computes transformed normalized direction vectors only.
  70860. * @param vector the vector to transform
  70861. * @param transformation the transformation matrix to apply
  70862. * @param result the vector to store the result in
  70863. */
  70864. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70865. /**
  70866. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70867. * This methods computes transformed normalized direction vectors only.
  70868. * @param x value to transform
  70869. * @param y value to transform
  70870. * @param z value to transform
  70871. * @param w value to transform
  70872. * @param transformation the transformation matrix to apply
  70873. * @param result the vector to store the results in
  70874. */
  70875. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70876. /**
  70877. * Creates a new Vector4 from a Vector3
  70878. * @param source defines the source data
  70879. * @param w defines the 4th component (default is 0)
  70880. * @returns a new Vector4
  70881. */
  70882. static FromVector3(source: Vector3, w?: number): Vector4;
  70883. }
  70884. /**
  70885. * Class used to store quaternion data
  70886. * @see https://en.wikipedia.org/wiki/Quaternion
  70887. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70888. */
  70889. export class Quaternion {
  70890. /** defines the first component (0 by default) */
  70891. x: number;
  70892. /** defines the second component (0 by default) */
  70893. y: number;
  70894. /** defines the third component (0 by default) */
  70895. z: number;
  70896. /** defines the fourth component (1.0 by default) */
  70897. w: number;
  70898. /**
  70899. * Creates a new Quaternion from the given floats
  70900. * @param x defines the first component (0 by default)
  70901. * @param y defines the second component (0 by default)
  70902. * @param z defines the third component (0 by default)
  70903. * @param w defines the fourth component (1.0 by default)
  70904. */
  70905. constructor(
  70906. /** defines the first component (0 by default) */
  70907. x?: number,
  70908. /** defines the second component (0 by default) */
  70909. y?: number,
  70910. /** defines the third component (0 by default) */
  70911. z?: number,
  70912. /** defines the fourth component (1.0 by default) */
  70913. w?: number);
  70914. /**
  70915. * Gets a string representation for the current quaternion
  70916. * @returns a string with the Quaternion coordinates
  70917. */
  70918. toString(): string;
  70919. /**
  70920. * Gets the class name of the quaternion
  70921. * @returns the string "Quaternion"
  70922. */
  70923. getClassName(): string;
  70924. /**
  70925. * Gets a hash code for this quaternion
  70926. * @returns the quaternion hash code
  70927. */
  70928. getHashCode(): number;
  70929. /**
  70930. * Copy the quaternion to an array
  70931. * @returns a new array populated with 4 elements from the quaternion coordinates
  70932. */
  70933. asArray(): number[];
  70934. /**
  70935. * Check if two quaternions are equals
  70936. * @param otherQuaternion defines the second operand
  70937. * @return true if the current quaternion and the given one coordinates are strictly equals
  70938. */
  70939. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70940. /**
  70941. * Clone the current quaternion
  70942. * @returns a new quaternion copied from the current one
  70943. */
  70944. clone(): Quaternion;
  70945. /**
  70946. * Copy a quaternion to the current one
  70947. * @param other defines the other quaternion
  70948. * @returns the updated current quaternion
  70949. */
  70950. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70951. /**
  70952. * Updates the current quaternion with the given float coordinates
  70953. * @param x defines the x coordinate
  70954. * @param y defines the y coordinate
  70955. * @param z defines the z coordinate
  70956. * @param w defines the w coordinate
  70957. * @returns the updated current quaternion
  70958. */
  70959. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70960. /**
  70961. * Updates the current quaternion from the given float coordinates
  70962. * @param x defines the x coordinate
  70963. * @param y defines the y coordinate
  70964. * @param z defines the z coordinate
  70965. * @param w defines the w coordinate
  70966. * @returns the updated current quaternion
  70967. */
  70968. set(x: number, y: number, z: number, w: number): Quaternion;
  70969. /**
  70970. * Adds two quaternions
  70971. * @param other defines the second operand
  70972. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70973. */
  70974. add(other: DeepImmutable<Quaternion>): Quaternion;
  70975. /**
  70976. * Add a quaternion to the current one
  70977. * @param other defines the quaternion to add
  70978. * @returns the current quaternion
  70979. */
  70980. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70981. /**
  70982. * Subtract two quaternions
  70983. * @param other defines the second operand
  70984. * @returns a new quaternion as the subtraction result of the given one from the current one
  70985. */
  70986. subtract(other: Quaternion): Quaternion;
  70987. /**
  70988. * Multiplies the current quaternion by a scale factor
  70989. * @param value defines the scale factor
  70990. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70991. */
  70992. scale(value: number): Quaternion;
  70993. /**
  70994. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70995. * @param scale defines the scale factor
  70996. * @param result defines the Quaternion object where to store the result
  70997. * @returns the unmodified current quaternion
  70998. */
  70999. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71000. /**
  71001. * Multiplies in place the current quaternion by a scale factor
  71002. * @param value defines the scale factor
  71003. * @returns the current modified quaternion
  71004. */
  71005. scaleInPlace(value: number): Quaternion;
  71006. /**
  71007. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71008. * @param scale defines the scale factor
  71009. * @param result defines the Quaternion object where to store the result
  71010. * @returns the unmodified current quaternion
  71011. */
  71012. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71013. /**
  71014. * Multiplies two quaternions
  71015. * @param q1 defines the second operand
  71016. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71017. */
  71018. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71019. /**
  71020. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71021. * @param q1 defines the second operand
  71022. * @param result defines the target quaternion
  71023. * @returns the current quaternion
  71024. */
  71025. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71026. /**
  71027. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71028. * @param q1 defines the second operand
  71029. * @returns the currentupdated quaternion
  71030. */
  71031. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71032. /**
  71033. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71034. * @param ref defines the target quaternion
  71035. * @returns the current quaternion
  71036. */
  71037. conjugateToRef(ref: Quaternion): Quaternion;
  71038. /**
  71039. * Conjugates in place (1-q) the current quaternion
  71040. * @returns the current updated quaternion
  71041. */
  71042. conjugateInPlace(): Quaternion;
  71043. /**
  71044. * Conjugates in place (1-q) the current quaternion
  71045. * @returns a new quaternion
  71046. */
  71047. conjugate(): Quaternion;
  71048. /**
  71049. * Gets length of current quaternion
  71050. * @returns the quaternion length (float)
  71051. */
  71052. length(): number;
  71053. /**
  71054. * Normalize in place the current quaternion
  71055. * @returns the current updated quaternion
  71056. */
  71057. normalize(): Quaternion;
  71058. /**
  71059. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71060. * @param order is a reserved parameter and is ignore for now
  71061. * @returns a new Vector3 containing the Euler angles
  71062. */
  71063. toEulerAngles(order?: string): Vector3;
  71064. /**
  71065. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71066. * @param result defines the vector which will be filled with the Euler angles
  71067. * @param order is a reserved parameter and is ignore for now
  71068. * @returns the current unchanged quaternion
  71069. */
  71070. toEulerAnglesToRef(result: Vector3): Quaternion;
  71071. /**
  71072. * Updates the given rotation matrix with the current quaternion values
  71073. * @param result defines the target matrix
  71074. * @returns the current unchanged quaternion
  71075. */
  71076. toRotationMatrix(result: Matrix): Quaternion;
  71077. /**
  71078. * Updates the current quaternion from the given rotation matrix values
  71079. * @param matrix defines the source matrix
  71080. * @returns the current updated quaternion
  71081. */
  71082. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71083. /**
  71084. * Creates a new quaternion from a rotation matrix
  71085. * @param matrix defines the source matrix
  71086. * @returns a new quaternion created from the given rotation matrix values
  71087. */
  71088. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71089. /**
  71090. * Updates the given quaternion with the given rotation matrix values
  71091. * @param matrix defines the source matrix
  71092. * @param result defines the target quaternion
  71093. */
  71094. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71095. /**
  71096. * Returns the dot product (float) between the quaternions "left" and "right"
  71097. * @param left defines the left operand
  71098. * @param right defines the right operand
  71099. * @returns the dot product
  71100. */
  71101. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71102. /**
  71103. * Checks if the two quaternions are close to each other
  71104. * @param quat0 defines the first quaternion to check
  71105. * @param quat1 defines the second quaternion to check
  71106. * @returns true if the two quaternions are close to each other
  71107. */
  71108. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71109. /**
  71110. * Creates an empty quaternion
  71111. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71112. */
  71113. static Zero(): Quaternion;
  71114. /**
  71115. * Inverse a given quaternion
  71116. * @param q defines the source quaternion
  71117. * @returns a new quaternion as the inverted current quaternion
  71118. */
  71119. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71120. /**
  71121. * Inverse a given quaternion
  71122. * @param q defines the source quaternion
  71123. * @param result the quaternion the result will be stored in
  71124. * @returns the result quaternion
  71125. */
  71126. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71127. /**
  71128. * Creates an identity quaternion
  71129. * @returns the identity quaternion
  71130. */
  71131. static Identity(): Quaternion;
  71132. /**
  71133. * Gets a boolean indicating if the given quaternion is identity
  71134. * @param quaternion defines the quaternion to check
  71135. * @returns true if the quaternion is identity
  71136. */
  71137. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71138. /**
  71139. * Creates a quaternion from a rotation around an axis
  71140. * @param axis defines the axis to use
  71141. * @param angle defines the angle to use
  71142. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71143. */
  71144. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71145. /**
  71146. * Creates a rotation around an axis and stores it into the given quaternion
  71147. * @param axis defines the axis to use
  71148. * @param angle defines the angle to use
  71149. * @param result defines the target quaternion
  71150. * @returns the target quaternion
  71151. */
  71152. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71153. /**
  71154. * Creates a new quaternion from data stored into an array
  71155. * @param array defines the data source
  71156. * @param offset defines the offset in the source array where the data starts
  71157. * @returns a new quaternion
  71158. */
  71159. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71160. /**
  71161. * Create a quaternion from Euler rotation angles
  71162. * @param x Pitch
  71163. * @param y Yaw
  71164. * @param z Roll
  71165. * @returns the new Quaternion
  71166. */
  71167. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71168. /**
  71169. * Updates a quaternion from Euler rotation angles
  71170. * @param x Pitch
  71171. * @param y Yaw
  71172. * @param z Roll
  71173. * @param result the quaternion to store the result
  71174. * @returns the updated quaternion
  71175. */
  71176. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71177. /**
  71178. * Create a quaternion from Euler rotation vector
  71179. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71180. * @returns the new Quaternion
  71181. */
  71182. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71183. /**
  71184. * Updates a quaternion from Euler rotation vector
  71185. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71186. * @param result the quaternion to store the result
  71187. * @returns the updated quaternion
  71188. */
  71189. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71190. /**
  71191. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71192. * @param yaw defines the rotation around Y axis
  71193. * @param pitch defines the rotation around X axis
  71194. * @param roll defines the rotation around Z axis
  71195. * @returns the new quaternion
  71196. */
  71197. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71198. /**
  71199. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71200. * @param yaw defines the rotation around Y axis
  71201. * @param pitch defines the rotation around X axis
  71202. * @param roll defines the rotation around Z axis
  71203. * @param result defines the target quaternion
  71204. */
  71205. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71206. /**
  71207. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71208. * @param alpha defines the rotation around first axis
  71209. * @param beta defines the rotation around second axis
  71210. * @param gamma defines the rotation around third axis
  71211. * @returns the new quaternion
  71212. */
  71213. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71214. /**
  71215. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71216. * @param alpha defines the rotation around first axis
  71217. * @param beta defines the rotation around second axis
  71218. * @param gamma defines the rotation around third axis
  71219. * @param result defines the target quaternion
  71220. */
  71221. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71222. /**
  71223. * 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)
  71224. * @param axis1 defines the first axis
  71225. * @param axis2 defines the second axis
  71226. * @param axis3 defines the third axis
  71227. * @returns the new quaternion
  71228. */
  71229. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71230. /**
  71231. * 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
  71232. * @param axis1 defines the first axis
  71233. * @param axis2 defines the second axis
  71234. * @param axis3 defines the third axis
  71235. * @param ref defines the target quaternion
  71236. */
  71237. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71238. /**
  71239. * Interpolates between two quaternions
  71240. * @param left defines first quaternion
  71241. * @param right defines second quaternion
  71242. * @param amount defines the gradient to use
  71243. * @returns the new interpolated quaternion
  71244. */
  71245. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71246. /**
  71247. * Interpolates between two quaternions and stores it into a target quaternion
  71248. * @param left defines first quaternion
  71249. * @param right defines second quaternion
  71250. * @param amount defines the gradient to use
  71251. * @param result defines the target quaternion
  71252. */
  71253. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71254. /**
  71255. * Interpolate between two quaternions using Hermite interpolation
  71256. * @param value1 defines first quaternion
  71257. * @param tangent1 defines the incoming tangent
  71258. * @param value2 defines second quaternion
  71259. * @param tangent2 defines the outgoing tangent
  71260. * @param amount defines the target quaternion
  71261. * @returns the new interpolated quaternion
  71262. */
  71263. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71264. }
  71265. /**
  71266. * Class used to store matrix data (4x4)
  71267. */
  71268. export class Matrix {
  71269. private static _updateFlagSeed;
  71270. private static _identityReadOnly;
  71271. private _isIdentity;
  71272. private _isIdentityDirty;
  71273. private _isIdentity3x2;
  71274. private _isIdentity3x2Dirty;
  71275. /**
  71276. * Gets the update flag of the matrix which is an unique number for the matrix.
  71277. * It will be incremented every time the matrix data change.
  71278. * You can use it to speed the comparison between two versions of the same matrix.
  71279. */
  71280. updateFlag: number;
  71281. private readonly _m;
  71282. /**
  71283. * Gets the internal data of the matrix
  71284. */
  71285. readonly m: DeepImmutable<Float32Array>;
  71286. /** @hidden */
  71287. _markAsUpdated(): void;
  71288. /** @hidden */
  71289. private _updateIdentityStatus;
  71290. /**
  71291. * Creates an empty matrix (filled with zeros)
  71292. */
  71293. constructor();
  71294. /**
  71295. * Check if the current matrix is identity
  71296. * @returns true is the matrix is the identity matrix
  71297. */
  71298. isIdentity(): boolean;
  71299. /**
  71300. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71301. * @returns true is the matrix is the identity matrix
  71302. */
  71303. isIdentityAs3x2(): boolean;
  71304. /**
  71305. * Gets the determinant of the matrix
  71306. * @returns the matrix determinant
  71307. */
  71308. determinant(): number;
  71309. /**
  71310. * Returns the matrix as a Float32Array
  71311. * @returns the matrix underlying array
  71312. */
  71313. toArray(): DeepImmutable<Float32Array>;
  71314. /**
  71315. * Returns the matrix as a Float32Array
  71316. * @returns the matrix underlying array.
  71317. */
  71318. asArray(): DeepImmutable<Float32Array>;
  71319. /**
  71320. * Inverts the current matrix in place
  71321. * @returns the current inverted matrix
  71322. */
  71323. invert(): Matrix;
  71324. /**
  71325. * Sets all the matrix elements to zero
  71326. * @returns the current matrix
  71327. */
  71328. reset(): Matrix;
  71329. /**
  71330. * Adds the current matrix with a second one
  71331. * @param other defines the matrix to add
  71332. * @returns a new matrix as the addition of the current matrix and the given one
  71333. */
  71334. add(other: DeepImmutable<Matrix>): Matrix;
  71335. /**
  71336. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71337. * @param other defines the matrix to add
  71338. * @param result defines the target matrix
  71339. * @returns the current matrix
  71340. */
  71341. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71342. /**
  71343. * Adds in place the given matrix to the current matrix
  71344. * @param other defines the second operand
  71345. * @returns the current updated matrix
  71346. */
  71347. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71348. /**
  71349. * Sets the given matrix to the current inverted Matrix
  71350. * @param other defines the target matrix
  71351. * @returns the unmodified current matrix
  71352. */
  71353. invertToRef(other: Matrix): Matrix;
  71354. /**
  71355. * add a value at the specified position in the current Matrix
  71356. * @param index the index of the value within the matrix. between 0 and 15.
  71357. * @param value the value to be added
  71358. * @returns the current updated matrix
  71359. */
  71360. addAtIndex(index: number, value: number): Matrix;
  71361. /**
  71362. * mutiply the specified position in the current Matrix by a value
  71363. * @param index the index of the value within the matrix. between 0 and 15.
  71364. * @param value the value to be added
  71365. * @returns the current updated matrix
  71366. */
  71367. multiplyAtIndex(index: number, value: number): Matrix;
  71368. /**
  71369. * Inserts the translation vector (using 3 floats) in the current matrix
  71370. * @param x defines the 1st component of the translation
  71371. * @param y defines the 2nd component of the translation
  71372. * @param z defines the 3rd component of the translation
  71373. * @returns the current updated matrix
  71374. */
  71375. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71376. /**
  71377. * Adds the translation vector (using 3 floats) in the current matrix
  71378. * @param x defines the 1st component of the translation
  71379. * @param y defines the 2nd component of the translation
  71380. * @param z defines the 3rd component of the translation
  71381. * @returns the current updated matrix
  71382. */
  71383. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71384. /**
  71385. * Inserts the translation vector in the current matrix
  71386. * @param vector3 defines the translation to insert
  71387. * @returns the current updated matrix
  71388. */
  71389. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71390. /**
  71391. * Gets the translation value of the current matrix
  71392. * @returns a new Vector3 as the extracted translation from the matrix
  71393. */
  71394. getTranslation(): Vector3;
  71395. /**
  71396. * Fill a Vector3 with the extracted translation from the matrix
  71397. * @param result defines the Vector3 where to store the translation
  71398. * @returns the current matrix
  71399. */
  71400. getTranslationToRef(result: Vector3): Matrix;
  71401. /**
  71402. * Remove rotation and scaling part from the matrix
  71403. * @returns the updated matrix
  71404. */
  71405. removeRotationAndScaling(): Matrix;
  71406. /**
  71407. * Multiply two matrices
  71408. * @param other defines the second operand
  71409. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71410. */
  71411. multiply(other: DeepImmutable<Matrix>): Matrix;
  71412. /**
  71413. * Copy the current matrix from the given one
  71414. * @param other defines the source matrix
  71415. * @returns the current updated matrix
  71416. */
  71417. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71418. /**
  71419. * Populates the given array from the starting index with the current matrix values
  71420. * @param array defines the target array
  71421. * @param offset defines the offset in the target array where to start storing values
  71422. * @returns the current matrix
  71423. */
  71424. copyToArray(array: Float32Array, offset?: number): Matrix;
  71425. /**
  71426. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71427. * @param other defines the second operand
  71428. * @param result defines the matrix where to store the multiplication
  71429. * @returns the current matrix
  71430. */
  71431. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71432. /**
  71433. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71434. * @param other defines the second operand
  71435. * @param result defines the array where to store the multiplication
  71436. * @param offset defines the offset in the target array where to start storing values
  71437. * @returns the current matrix
  71438. */
  71439. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71440. /**
  71441. * Check equality between this matrix and a second one
  71442. * @param value defines the second matrix to compare
  71443. * @returns true is the current matrix and the given one values are strictly equal
  71444. */
  71445. equals(value: DeepImmutable<Matrix>): boolean;
  71446. /**
  71447. * Clone the current matrix
  71448. * @returns a new matrix from the current matrix
  71449. */
  71450. clone(): Matrix;
  71451. /**
  71452. * Returns the name of the current matrix class
  71453. * @returns the string "Matrix"
  71454. */
  71455. getClassName(): string;
  71456. /**
  71457. * Gets the hash code of the current matrix
  71458. * @returns the hash code
  71459. */
  71460. getHashCode(): number;
  71461. /**
  71462. * Decomposes the current Matrix into a translation, rotation and scaling components
  71463. * @param scale defines the scale vector3 given as a reference to update
  71464. * @param rotation defines the rotation quaternion given as a reference to update
  71465. * @param translation defines the translation vector3 given as a reference to update
  71466. * @returns true if operation was successful
  71467. */
  71468. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71469. /**
  71470. * Gets specific row of the matrix
  71471. * @param index defines the number of the row to get
  71472. * @returns the index-th row of the current matrix as a new Vector4
  71473. */
  71474. getRow(index: number): Nullable<Vector4>;
  71475. /**
  71476. * Sets the index-th row of the current matrix to the vector4 values
  71477. * @param index defines the number of the row to set
  71478. * @param row defines the target vector4
  71479. * @returns the updated current matrix
  71480. */
  71481. setRow(index: number, row: Vector4): Matrix;
  71482. /**
  71483. * Compute the transpose of the matrix
  71484. * @returns the new transposed matrix
  71485. */
  71486. transpose(): Matrix;
  71487. /**
  71488. * Compute the transpose of the matrix and store it in a given matrix
  71489. * @param result defines the target matrix
  71490. * @returns the current matrix
  71491. */
  71492. transposeToRef(result: Matrix): Matrix;
  71493. /**
  71494. * Sets the index-th row of the current matrix with the given 4 x float values
  71495. * @param index defines the row index
  71496. * @param x defines the x component to set
  71497. * @param y defines the y component to set
  71498. * @param z defines the z component to set
  71499. * @param w defines the w component to set
  71500. * @returns the updated current matrix
  71501. */
  71502. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71503. /**
  71504. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71505. * @param scale defines the scale factor
  71506. * @returns a new matrix
  71507. */
  71508. scale(scale: number): Matrix;
  71509. /**
  71510. * Scale the current matrix values by a factor to a given result matrix
  71511. * @param scale defines the scale factor
  71512. * @param result defines the matrix to store the result
  71513. * @returns the current matrix
  71514. */
  71515. scaleToRef(scale: number, result: Matrix): Matrix;
  71516. /**
  71517. * Scale the current matrix values by a factor and add the result to a given matrix
  71518. * @param scale defines the scale factor
  71519. * @param result defines the Matrix to store the result
  71520. * @returns the current matrix
  71521. */
  71522. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71523. /**
  71524. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71525. * @param ref matrix to store the result
  71526. */
  71527. toNormalMatrix(ref: Matrix): void;
  71528. /**
  71529. * Gets only rotation part of the current matrix
  71530. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71531. */
  71532. getRotationMatrix(): Matrix;
  71533. /**
  71534. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71535. * @param result defines the target matrix to store data to
  71536. * @returns the current matrix
  71537. */
  71538. getRotationMatrixToRef(result: Matrix): Matrix;
  71539. /**
  71540. * Toggles model matrix from being right handed to left handed in place and vice versa
  71541. */
  71542. toggleModelMatrixHandInPlace(): void;
  71543. /**
  71544. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71545. */
  71546. toggleProjectionMatrixHandInPlace(): void;
  71547. /**
  71548. * Creates a matrix from an array
  71549. * @param array defines the source array
  71550. * @param offset defines an offset in the source array
  71551. * @returns a new Matrix set from the starting index of the given array
  71552. */
  71553. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71554. /**
  71555. * Copy the content of an array into a given matrix
  71556. * @param array defines the source array
  71557. * @param offset defines an offset in the source array
  71558. * @param result defines the target matrix
  71559. */
  71560. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71561. /**
  71562. * Stores an array into a matrix after having multiplied each component by a given factor
  71563. * @param array defines the source array
  71564. * @param offset defines the offset in the source array
  71565. * @param scale defines the scaling factor
  71566. * @param result defines the target matrix
  71567. */
  71568. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71569. /**
  71570. * Gets an identity matrix that must not be updated
  71571. */
  71572. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71573. /**
  71574. * Stores a list of values (16) inside a given matrix
  71575. * @param initialM11 defines 1st value of 1st row
  71576. * @param initialM12 defines 2nd value of 1st row
  71577. * @param initialM13 defines 3rd value of 1st row
  71578. * @param initialM14 defines 4th value of 1st row
  71579. * @param initialM21 defines 1st value of 2nd row
  71580. * @param initialM22 defines 2nd value of 2nd row
  71581. * @param initialM23 defines 3rd value of 2nd row
  71582. * @param initialM24 defines 4th value of 2nd row
  71583. * @param initialM31 defines 1st value of 3rd row
  71584. * @param initialM32 defines 2nd value of 3rd row
  71585. * @param initialM33 defines 3rd value of 3rd row
  71586. * @param initialM34 defines 4th value of 3rd row
  71587. * @param initialM41 defines 1st value of 4th row
  71588. * @param initialM42 defines 2nd value of 4th row
  71589. * @param initialM43 defines 3rd value of 4th row
  71590. * @param initialM44 defines 4th value of 4th row
  71591. * @param result defines the target matrix
  71592. */
  71593. 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;
  71594. /**
  71595. * Creates new matrix from a list of values (16)
  71596. * @param initialM11 defines 1st value of 1st row
  71597. * @param initialM12 defines 2nd value of 1st row
  71598. * @param initialM13 defines 3rd value of 1st row
  71599. * @param initialM14 defines 4th value of 1st row
  71600. * @param initialM21 defines 1st value of 2nd row
  71601. * @param initialM22 defines 2nd value of 2nd row
  71602. * @param initialM23 defines 3rd value of 2nd row
  71603. * @param initialM24 defines 4th value of 2nd row
  71604. * @param initialM31 defines 1st value of 3rd row
  71605. * @param initialM32 defines 2nd value of 3rd row
  71606. * @param initialM33 defines 3rd value of 3rd row
  71607. * @param initialM34 defines 4th value of 3rd row
  71608. * @param initialM41 defines 1st value of 4th row
  71609. * @param initialM42 defines 2nd value of 4th row
  71610. * @param initialM43 defines 3rd value of 4th row
  71611. * @param initialM44 defines 4th value of 4th row
  71612. * @returns the new matrix
  71613. */
  71614. 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;
  71615. /**
  71616. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71617. * @param scale defines the scale vector3
  71618. * @param rotation defines the rotation quaternion
  71619. * @param translation defines the translation vector3
  71620. * @returns a new matrix
  71621. */
  71622. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71623. /**
  71624. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71625. * @param scale defines the scale vector3
  71626. * @param rotation defines the rotation quaternion
  71627. * @param translation defines the translation vector3
  71628. * @param result defines the target matrix
  71629. */
  71630. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71631. /**
  71632. * Creates a new identity matrix
  71633. * @returns a new identity matrix
  71634. */
  71635. static Identity(): Matrix;
  71636. /**
  71637. * Creates a new identity matrix and stores the result in a given matrix
  71638. * @param result defines the target matrix
  71639. */
  71640. static IdentityToRef(result: Matrix): void;
  71641. /**
  71642. * Creates a new zero matrix
  71643. * @returns a new zero matrix
  71644. */
  71645. static Zero(): Matrix;
  71646. /**
  71647. * Creates a new rotation matrix for "angle" radians around the X axis
  71648. * @param angle defines the angle (in radians) to use
  71649. * @return the new matrix
  71650. */
  71651. static RotationX(angle: number): Matrix;
  71652. /**
  71653. * Creates a new matrix as the invert of a given matrix
  71654. * @param source defines the source matrix
  71655. * @returns the new matrix
  71656. */
  71657. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71658. /**
  71659. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71660. * @param angle defines the angle (in radians) to use
  71661. * @param result defines the target matrix
  71662. */
  71663. static RotationXToRef(angle: number, result: Matrix): void;
  71664. /**
  71665. * Creates a new rotation matrix for "angle" radians around the Y axis
  71666. * @param angle defines the angle (in radians) to use
  71667. * @return the new matrix
  71668. */
  71669. static RotationY(angle: number): Matrix;
  71670. /**
  71671. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71672. * @param angle defines the angle (in radians) to use
  71673. * @param result defines the target matrix
  71674. */
  71675. static RotationYToRef(angle: number, result: Matrix): void;
  71676. /**
  71677. * Creates a new rotation matrix for "angle" radians around the Z axis
  71678. * @param angle defines the angle (in radians) to use
  71679. * @return the new matrix
  71680. */
  71681. static RotationZ(angle: number): Matrix;
  71682. /**
  71683. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71684. * @param angle defines the angle (in radians) to use
  71685. * @param result defines the target matrix
  71686. */
  71687. static RotationZToRef(angle: number, result: Matrix): void;
  71688. /**
  71689. * Creates a new rotation matrix for "angle" radians around the given axis
  71690. * @param axis defines the axis to use
  71691. * @param angle defines the angle (in radians) to use
  71692. * @return the new matrix
  71693. */
  71694. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71695. /**
  71696. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71697. * @param axis defines the axis to use
  71698. * @param angle defines the angle (in radians) to use
  71699. * @param result defines the target matrix
  71700. */
  71701. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71702. /**
  71703. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71704. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71705. * @param from defines the vector to align
  71706. * @param to defines the vector to align to
  71707. * @param result defines the target matrix
  71708. */
  71709. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71710. /**
  71711. * Creates a rotation matrix
  71712. * @param yaw defines the yaw angle in radians (Y axis)
  71713. * @param pitch defines the pitch angle in radians (X axis)
  71714. * @param roll defines the roll angle in radians (X axis)
  71715. * @returns the new rotation matrix
  71716. */
  71717. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71718. /**
  71719. * Creates a rotation matrix and stores it in a given matrix
  71720. * @param yaw defines the yaw angle in radians (Y axis)
  71721. * @param pitch defines the pitch angle in radians (X axis)
  71722. * @param roll defines the roll angle in radians (X axis)
  71723. * @param result defines the target matrix
  71724. */
  71725. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71726. /**
  71727. * Creates a scaling matrix
  71728. * @param x defines the scale factor on X axis
  71729. * @param y defines the scale factor on Y axis
  71730. * @param z defines the scale factor on Z axis
  71731. * @returns the new matrix
  71732. */
  71733. static Scaling(x: number, y: number, z: number): Matrix;
  71734. /**
  71735. * Creates a scaling matrix and stores it in a given matrix
  71736. * @param x defines the scale factor on X axis
  71737. * @param y defines the scale factor on Y axis
  71738. * @param z defines the scale factor on Z axis
  71739. * @param result defines the target matrix
  71740. */
  71741. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71742. /**
  71743. * Creates a translation matrix
  71744. * @param x defines the translation on X axis
  71745. * @param y defines the translation on Y axis
  71746. * @param z defines the translationon Z axis
  71747. * @returns the new matrix
  71748. */
  71749. static Translation(x: number, y: number, z: number): Matrix;
  71750. /**
  71751. * Creates a translation matrix and stores it in a given matrix
  71752. * @param x defines the translation on X axis
  71753. * @param y defines the translation on Y axis
  71754. * @param z defines the translationon Z axis
  71755. * @param result defines the target matrix
  71756. */
  71757. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71758. /**
  71759. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71760. * @param startValue defines the start value
  71761. * @param endValue defines the end value
  71762. * @param gradient defines the gradient factor
  71763. * @returns the new matrix
  71764. */
  71765. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71766. /**
  71767. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71768. * @param startValue defines the start value
  71769. * @param endValue defines the end value
  71770. * @param gradient defines the gradient factor
  71771. * @param result defines the Matrix object where to store data
  71772. */
  71773. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71774. /**
  71775. * Builds a new matrix whose values are computed by:
  71776. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71777. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71778. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71779. * @param startValue defines the first matrix
  71780. * @param endValue defines the second matrix
  71781. * @param gradient defines the gradient between the two matrices
  71782. * @returns the new matrix
  71783. */
  71784. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71785. /**
  71786. * Update a matrix to values which are computed by:
  71787. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71788. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71789. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71790. * @param startValue defines the first matrix
  71791. * @param endValue defines the second matrix
  71792. * @param gradient defines the gradient between the two matrices
  71793. * @param result defines the target matrix
  71794. */
  71795. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71796. /**
  71797. * 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"
  71798. * This function works in left handed mode
  71799. * @param eye defines the final position of the entity
  71800. * @param target defines where the entity should look at
  71801. * @param up defines the up vector for the entity
  71802. * @returns the new matrix
  71803. */
  71804. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71805. /**
  71806. * 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".
  71807. * This function works in left handed mode
  71808. * @param eye defines the final position of the entity
  71809. * @param target defines where the entity should look at
  71810. * @param up defines the up vector for the entity
  71811. * @param result defines the target matrix
  71812. */
  71813. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71814. /**
  71815. * 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"
  71816. * This function works in right handed mode
  71817. * @param eye defines the final position of the entity
  71818. * @param target defines where the entity should look at
  71819. * @param up defines the up vector for the entity
  71820. * @returns the new matrix
  71821. */
  71822. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71823. /**
  71824. * 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".
  71825. * This function works in right handed mode
  71826. * @param eye defines the final position of the entity
  71827. * @param target defines where the entity should look at
  71828. * @param up defines the up vector for the entity
  71829. * @param result defines the target matrix
  71830. */
  71831. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71832. /**
  71833. * Create a left-handed orthographic projection matrix
  71834. * @param width defines the viewport width
  71835. * @param height defines the viewport height
  71836. * @param znear defines the near clip plane
  71837. * @param zfar defines the far clip plane
  71838. * @returns a new matrix as a left-handed orthographic projection matrix
  71839. */
  71840. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71841. /**
  71842. * Store a left-handed orthographic projection to a given matrix
  71843. * @param width defines the viewport width
  71844. * @param height defines the viewport height
  71845. * @param znear defines the near clip plane
  71846. * @param zfar defines the far clip plane
  71847. * @param result defines the target matrix
  71848. */
  71849. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71850. /**
  71851. * Create a left-handed orthographic projection matrix
  71852. * @param left defines the viewport left coordinate
  71853. * @param right defines the viewport right coordinate
  71854. * @param bottom defines the viewport bottom coordinate
  71855. * @param top defines the viewport top coordinate
  71856. * @param znear defines the near clip plane
  71857. * @param zfar defines the far clip plane
  71858. * @returns a new matrix as a left-handed orthographic projection matrix
  71859. */
  71860. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71861. /**
  71862. * Stores a left-handed orthographic projection into a given matrix
  71863. * @param left defines the viewport left coordinate
  71864. * @param right defines the viewport right coordinate
  71865. * @param bottom defines the viewport bottom coordinate
  71866. * @param top defines the viewport top coordinate
  71867. * @param znear defines the near clip plane
  71868. * @param zfar defines the far clip plane
  71869. * @param result defines the target matrix
  71870. */
  71871. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71872. /**
  71873. * Creates a right-handed orthographic projection matrix
  71874. * @param left defines the viewport left coordinate
  71875. * @param right defines the viewport right coordinate
  71876. * @param bottom defines the viewport bottom coordinate
  71877. * @param top defines the viewport top coordinate
  71878. * @param znear defines the near clip plane
  71879. * @param zfar defines the far clip plane
  71880. * @returns a new matrix as a right-handed orthographic projection matrix
  71881. */
  71882. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71883. /**
  71884. * Stores a right-handed orthographic projection into a given matrix
  71885. * @param left defines the viewport left coordinate
  71886. * @param right defines the viewport right coordinate
  71887. * @param bottom defines the viewport bottom coordinate
  71888. * @param top defines the viewport top coordinate
  71889. * @param znear defines the near clip plane
  71890. * @param zfar defines the far clip plane
  71891. * @param result defines the target matrix
  71892. */
  71893. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71894. /**
  71895. * Creates a left-handed perspective projection matrix
  71896. * @param width defines the viewport width
  71897. * @param height defines the viewport height
  71898. * @param znear defines the near clip plane
  71899. * @param zfar defines the far clip plane
  71900. * @returns a new matrix as a left-handed perspective projection matrix
  71901. */
  71902. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71903. /**
  71904. * Creates a left-handed perspective projection matrix
  71905. * @param fov defines the horizontal field of view
  71906. * @param aspect defines the aspect ratio
  71907. * @param znear defines the near clip plane
  71908. * @param zfar defines the far clip plane
  71909. * @returns a new matrix as a left-handed perspective projection matrix
  71910. */
  71911. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71912. /**
  71913. * Stores a left-handed perspective projection into a given matrix
  71914. * @param fov defines the horizontal field of view
  71915. * @param aspect defines the aspect ratio
  71916. * @param znear defines the near clip plane
  71917. * @param zfar defines the far clip plane
  71918. * @param result defines the target matrix
  71919. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71920. */
  71921. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71922. /**
  71923. * Creates a right-handed perspective projection matrix
  71924. * @param fov defines the horizontal field of view
  71925. * @param aspect defines the aspect ratio
  71926. * @param znear defines the near clip plane
  71927. * @param zfar defines the far clip plane
  71928. * @returns a new matrix as a right-handed perspective projection matrix
  71929. */
  71930. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71931. /**
  71932. * Stores a right-handed perspective projection into a given matrix
  71933. * @param fov defines the horizontal field of view
  71934. * @param aspect defines the aspect ratio
  71935. * @param znear defines the near clip plane
  71936. * @param zfar defines the far clip plane
  71937. * @param result defines the target matrix
  71938. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71939. */
  71940. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71941. /**
  71942. * Stores a perspective projection for WebVR info a given matrix
  71943. * @param fov defines the field of view
  71944. * @param znear defines the near clip plane
  71945. * @param zfar defines the far clip plane
  71946. * @param result defines the target matrix
  71947. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71948. */
  71949. static PerspectiveFovWebVRToRef(fov: {
  71950. upDegrees: number;
  71951. downDegrees: number;
  71952. leftDegrees: number;
  71953. rightDegrees: number;
  71954. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71955. /**
  71956. * Computes a complete transformation matrix
  71957. * @param viewport defines the viewport to use
  71958. * @param world defines the world matrix
  71959. * @param view defines the view matrix
  71960. * @param projection defines the projection matrix
  71961. * @param zmin defines the near clip plane
  71962. * @param zmax defines the far clip plane
  71963. * @returns the transformation matrix
  71964. */
  71965. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71966. /**
  71967. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71968. * @param matrix defines the matrix to use
  71969. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71970. */
  71971. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71972. /**
  71973. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71974. * @param matrix defines the matrix to use
  71975. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71976. */
  71977. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71978. /**
  71979. * Compute the transpose of a given matrix
  71980. * @param matrix defines the matrix to transpose
  71981. * @returns the new matrix
  71982. */
  71983. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71984. /**
  71985. * Compute the transpose of a matrix and store it in a target matrix
  71986. * @param matrix defines the matrix to transpose
  71987. * @param result defines the target matrix
  71988. */
  71989. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71990. /**
  71991. * Computes a reflection matrix from a plane
  71992. * @param plane defines the reflection plane
  71993. * @returns a new matrix
  71994. */
  71995. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71996. /**
  71997. * Computes a reflection matrix from a plane
  71998. * @param plane defines the reflection plane
  71999. * @param result defines the target matrix
  72000. */
  72001. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72002. /**
  72003. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72004. * @param xaxis defines the value of the 1st axis
  72005. * @param yaxis defines the value of the 2nd axis
  72006. * @param zaxis defines the value of the 3rd axis
  72007. * @param result defines the target matrix
  72008. */
  72009. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72010. /**
  72011. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72012. * @param quat defines the quaternion to use
  72013. * @param result defines the target matrix
  72014. */
  72015. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72016. }
  72017. /**
  72018. * @hidden
  72019. */
  72020. export class TmpVectors {
  72021. static Vector2: Vector2[];
  72022. static Vector3: Vector3[];
  72023. static Vector4: Vector4[];
  72024. static Quaternion: Quaternion[];
  72025. static Matrix: Matrix[];
  72026. }
  72027. }
  72028. declare module BABYLON {
  72029. /**
  72030. * Defines potential orientation for back face culling
  72031. */
  72032. export enum Orientation {
  72033. /**
  72034. * Clockwise
  72035. */
  72036. CW = 0,
  72037. /** Counter clockwise */
  72038. CCW = 1
  72039. }
  72040. /** Class used to represent a Bezier curve */
  72041. export class BezierCurve {
  72042. /**
  72043. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72044. * @param t defines the time
  72045. * @param x1 defines the left coordinate on X axis
  72046. * @param y1 defines the left coordinate on Y axis
  72047. * @param x2 defines the right coordinate on X axis
  72048. * @param y2 defines the right coordinate on Y axis
  72049. * @returns the interpolated value
  72050. */
  72051. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72052. }
  72053. /**
  72054. * Defines angle representation
  72055. */
  72056. export class Angle {
  72057. private _radians;
  72058. /**
  72059. * Creates an Angle object of "radians" radians (float).
  72060. * @param radians the angle in radians
  72061. */
  72062. constructor(radians: number);
  72063. /**
  72064. * Get value in degrees
  72065. * @returns the Angle value in degrees (float)
  72066. */
  72067. degrees(): number;
  72068. /**
  72069. * Get value in radians
  72070. * @returns the Angle value in radians (float)
  72071. */
  72072. radians(): number;
  72073. /**
  72074. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72075. * @param a defines first vector
  72076. * @param b defines second vector
  72077. * @returns a new Angle
  72078. */
  72079. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72080. /**
  72081. * Gets a new Angle object from the given float in radians
  72082. * @param radians defines the angle value in radians
  72083. * @returns a new Angle
  72084. */
  72085. static FromRadians(radians: number): Angle;
  72086. /**
  72087. * Gets a new Angle object from the given float in degrees
  72088. * @param degrees defines the angle value in degrees
  72089. * @returns a new Angle
  72090. */
  72091. static FromDegrees(degrees: number): Angle;
  72092. }
  72093. /**
  72094. * This represents an arc in a 2d space.
  72095. */
  72096. export class Arc2 {
  72097. /** Defines the start point of the arc */
  72098. startPoint: Vector2;
  72099. /** Defines the mid point of the arc */
  72100. midPoint: Vector2;
  72101. /** Defines the end point of the arc */
  72102. endPoint: Vector2;
  72103. /**
  72104. * Defines the center point of the arc.
  72105. */
  72106. centerPoint: Vector2;
  72107. /**
  72108. * Defines the radius of the arc.
  72109. */
  72110. radius: number;
  72111. /**
  72112. * Defines the angle of the arc (from mid point to end point).
  72113. */
  72114. angle: Angle;
  72115. /**
  72116. * Defines the start angle of the arc (from start point to middle point).
  72117. */
  72118. startAngle: Angle;
  72119. /**
  72120. * Defines the orientation of the arc (clock wise/counter clock wise).
  72121. */
  72122. orientation: Orientation;
  72123. /**
  72124. * Creates an Arc object from the three given points : start, middle and end.
  72125. * @param startPoint Defines the start point of the arc
  72126. * @param midPoint Defines the midlle point of the arc
  72127. * @param endPoint Defines the end point of the arc
  72128. */
  72129. constructor(
  72130. /** Defines the start point of the arc */
  72131. startPoint: Vector2,
  72132. /** Defines the mid point of the arc */
  72133. midPoint: Vector2,
  72134. /** Defines the end point of the arc */
  72135. endPoint: Vector2);
  72136. }
  72137. /**
  72138. * Represents a 2D path made up of multiple 2D points
  72139. */
  72140. export class Path2 {
  72141. private _points;
  72142. private _length;
  72143. /**
  72144. * If the path start and end point are the same
  72145. */
  72146. closed: boolean;
  72147. /**
  72148. * Creates a Path2 object from the starting 2D coordinates x and y.
  72149. * @param x the starting points x value
  72150. * @param y the starting points y value
  72151. */
  72152. constructor(x: number, y: number);
  72153. /**
  72154. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72155. * @param x the added points x value
  72156. * @param y the added points y value
  72157. * @returns the updated Path2.
  72158. */
  72159. addLineTo(x: number, y: number): Path2;
  72160. /**
  72161. * 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.
  72162. * @param midX middle point x value
  72163. * @param midY middle point y value
  72164. * @param endX end point x value
  72165. * @param endY end point y value
  72166. * @param numberOfSegments (default: 36)
  72167. * @returns the updated Path2.
  72168. */
  72169. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72170. /**
  72171. * Closes the Path2.
  72172. * @returns the Path2.
  72173. */
  72174. close(): Path2;
  72175. /**
  72176. * Gets the sum of the distance between each sequential point in the path
  72177. * @returns the Path2 total length (float).
  72178. */
  72179. length(): number;
  72180. /**
  72181. * Gets the points which construct the path
  72182. * @returns the Path2 internal array of points.
  72183. */
  72184. getPoints(): Vector2[];
  72185. /**
  72186. * Retreives the point at the distance aways from the starting point
  72187. * @param normalizedLengthPosition the length along the path to retreive the point from
  72188. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72189. */
  72190. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72191. /**
  72192. * Creates a new path starting from an x and y position
  72193. * @param x starting x value
  72194. * @param y starting y value
  72195. * @returns a new Path2 starting at the coordinates (x, y).
  72196. */
  72197. static StartingAt(x: number, y: number): Path2;
  72198. }
  72199. /**
  72200. * Represents a 3D path made up of multiple 3D points
  72201. */
  72202. export class Path3D {
  72203. /**
  72204. * an array of Vector3, the curve axis of the Path3D
  72205. */
  72206. path: Vector3[];
  72207. private _curve;
  72208. private _distances;
  72209. private _tangents;
  72210. private _normals;
  72211. private _binormals;
  72212. private _raw;
  72213. /**
  72214. * new Path3D(path, normal, raw)
  72215. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72216. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72217. * @param path an array of Vector3, the curve axis of the Path3D
  72218. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72219. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72220. */
  72221. constructor(
  72222. /**
  72223. * an array of Vector3, the curve axis of the Path3D
  72224. */
  72225. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72226. /**
  72227. * Returns the Path3D array of successive Vector3 designing its curve.
  72228. * @returns the Path3D array of successive Vector3 designing its curve.
  72229. */
  72230. getCurve(): Vector3[];
  72231. /**
  72232. * Returns an array populated with tangent vectors on each Path3D curve point.
  72233. * @returns an array populated with tangent vectors on each Path3D curve point.
  72234. */
  72235. getTangents(): Vector3[];
  72236. /**
  72237. * Returns an array populated with normal vectors on each Path3D curve point.
  72238. * @returns an array populated with normal vectors on each Path3D curve point.
  72239. */
  72240. getNormals(): Vector3[];
  72241. /**
  72242. * Returns an array populated with binormal vectors on each Path3D curve point.
  72243. * @returns an array populated with binormal vectors on each Path3D curve point.
  72244. */
  72245. getBinormals(): Vector3[];
  72246. /**
  72247. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72248. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72249. */
  72250. getDistances(): number[];
  72251. /**
  72252. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72253. * @param path path which all values are copied into the curves points
  72254. * @param firstNormal which should be projected onto the curve
  72255. * @returns the same object updated.
  72256. */
  72257. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72258. private _compute;
  72259. private _getFirstNonNullVector;
  72260. private _getLastNonNullVector;
  72261. private _normalVector;
  72262. }
  72263. /**
  72264. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72265. * A Curve3 is designed from a series of successive Vector3.
  72266. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72267. */
  72268. export class Curve3 {
  72269. private _points;
  72270. private _length;
  72271. /**
  72272. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72273. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72274. * @param v1 (Vector3) the control point
  72275. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72276. * @param nbPoints (integer) the wanted number of points in the curve
  72277. * @returns the created Curve3
  72278. */
  72279. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72280. /**
  72281. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72282. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72283. * @param v1 (Vector3) the first control point
  72284. * @param v2 (Vector3) the second control point
  72285. * @param v3 (Vector3) the end point of the Cubic Bezier
  72286. * @param nbPoints (integer) the wanted number of points in the curve
  72287. * @returns the created Curve3
  72288. */
  72289. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72290. /**
  72291. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72292. * @param p1 (Vector3) the origin point of the Hermite Spline
  72293. * @param t1 (Vector3) the tangent vector at the origin point
  72294. * @param p2 (Vector3) the end point of the Hermite Spline
  72295. * @param t2 (Vector3) the tangent vector at the end point
  72296. * @param nbPoints (integer) the wanted number of points in the curve
  72297. * @returns the created Curve3
  72298. */
  72299. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72300. /**
  72301. * Returns a Curve3 object along a CatmullRom Spline curve :
  72302. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72303. * @param nbPoints (integer) the wanted number of points between each curve control points
  72304. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72305. * @returns the created Curve3
  72306. */
  72307. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72308. /**
  72309. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72310. * A Curve3 is designed from a series of successive Vector3.
  72311. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72312. * @param points points which make up the curve
  72313. */
  72314. constructor(points: Vector3[]);
  72315. /**
  72316. * @returns the Curve3 stored array of successive Vector3
  72317. */
  72318. getPoints(): Vector3[];
  72319. /**
  72320. * @returns the computed length (float) of the curve.
  72321. */
  72322. length(): number;
  72323. /**
  72324. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72325. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72326. * curveA and curveB keep unchanged.
  72327. * @param curve the curve to continue from this curve
  72328. * @returns the newly constructed curve
  72329. */
  72330. continue(curve: DeepImmutable<Curve3>): Curve3;
  72331. private _computeLength;
  72332. }
  72333. }
  72334. declare module BABYLON {
  72335. /**
  72336. * This represents the main contract an easing function should follow.
  72337. * Easing functions are used throughout the animation system.
  72338. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72339. */
  72340. export interface IEasingFunction {
  72341. /**
  72342. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72343. * of the easing function.
  72344. * The link below provides some of the most common examples of easing functions.
  72345. * @see https://easings.net/
  72346. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72347. * @returns the corresponding value on the curve defined by the easing function
  72348. */
  72349. ease(gradient: number): number;
  72350. }
  72351. /**
  72352. * Base class used for every default easing function.
  72353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72354. */
  72355. export class EasingFunction implements IEasingFunction {
  72356. /**
  72357. * Interpolation follows the mathematical formula associated with the easing function.
  72358. */
  72359. static readonly EASINGMODE_EASEIN: number;
  72360. /**
  72361. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72362. */
  72363. static readonly EASINGMODE_EASEOUT: number;
  72364. /**
  72365. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72366. */
  72367. static readonly EASINGMODE_EASEINOUT: number;
  72368. private _easingMode;
  72369. /**
  72370. * Sets the easing mode of the current function.
  72371. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72372. */
  72373. setEasingMode(easingMode: number): void;
  72374. /**
  72375. * Gets the current easing mode.
  72376. * @returns the easing mode
  72377. */
  72378. getEasingMode(): number;
  72379. /**
  72380. * @hidden
  72381. */
  72382. easeInCore(gradient: number): number;
  72383. /**
  72384. * Given an input gradient between 0 and 1, this returns the corresponding value
  72385. * of the easing function.
  72386. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72387. * @returns the corresponding value on the curve defined by the easing function
  72388. */
  72389. ease(gradient: number): number;
  72390. }
  72391. /**
  72392. * Easing function with a circle shape (see link below).
  72393. * @see https://easings.net/#easeInCirc
  72394. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72395. */
  72396. export class CircleEase extends EasingFunction implements IEasingFunction {
  72397. /** @hidden */
  72398. easeInCore(gradient: number): number;
  72399. }
  72400. /**
  72401. * Easing function with a ease back shape (see link below).
  72402. * @see https://easings.net/#easeInBack
  72403. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72404. */
  72405. export class BackEase extends EasingFunction implements IEasingFunction {
  72406. /** Defines the amplitude of the function */
  72407. amplitude: number;
  72408. /**
  72409. * Instantiates a back ease easing
  72410. * @see https://easings.net/#easeInBack
  72411. * @param amplitude Defines the amplitude of the function
  72412. */
  72413. constructor(
  72414. /** Defines the amplitude of the function */
  72415. amplitude?: number);
  72416. /** @hidden */
  72417. easeInCore(gradient: number): number;
  72418. }
  72419. /**
  72420. * Easing function with a bouncing shape (see link below).
  72421. * @see https://easings.net/#easeInBounce
  72422. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72423. */
  72424. export class BounceEase extends EasingFunction implements IEasingFunction {
  72425. /** Defines the number of bounces */
  72426. bounces: number;
  72427. /** Defines the amplitude of the bounce */
  72428. bounciness: number;
  72429. /**
  72430. * Instantiates a bounce easing
  72431. * @see https://easings.net/#easeInBounce
  72432. * @param bounces Defines the number of bounces
  72433. * @param bounciness Defines the amplitude of the bounce
  72434. */
  72435. constructor(
  72436. /** Defines the number of bounces */
  72437. bounces?: number,
  72438. /** Defines the amplitude of the bounce */
  72439. bounciness?: number);
  72440. /** @hidden */
  72441. easeInCore(gradient: number): number;
  72442. }
  72443. /**
  72444. * Easing function with a power of 3 shape (see link below).
  72445. * @see https://easings.net/#easeInCubic
  72446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72447. */
  72448. export class CubicEase extends EasingFunction implements IEasingFunction {
  72449. /** @hidden */
  72450. easeInCore(gradient: number): number;
  72451. }
  72452. /**
  72453. * Easing function with an elastic shape (see link below).
  72454. * @see https://easings.net/#easeInElastic
  72455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72456. */
  72457. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72458. /** Defines the number of oscillations*/
  72459. oscillations: number;
  72460. /** Defines the amplitude of the oscillations*/
  72461. springiness: number;
  72462. /**
  72463. * Instantiates an elastic easing function
  72464. * @see https://easings.net/#easeInElastic
  72465. * @param oscillations Defines the number of oscillations
  72466. * @param springiness Defines the amplitude of the oscillations
  72467. */
  72468. constructor(
  72469. /** Defines the number of oscillations*/
  72470. oscillations?: number,
  72471. /** Defines the amplitude of the oscillations*/
  72472. springiness?: number);
  72473. /** @hidden */
  72474. easeInCore(gradient: number): number;
  72475. }
  72476. /**
  72477. * Easing function with an exponential shape (see link below).
  72478. * @see https://easings.net/#easeInExpo
  72479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72480. */
  72481. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72482. /** Defines the exponent of the function */
  72483. exponent: number;
  72484. /**
  72485. * Instantiates an exponential easing function
  72486. * @see https://easings.net/#easeInExpo
  72487. * @param exponent Defines the exponent of the function
  72488. */
  72489. constructor(
  72490. /** Defines the exponent of the function */
  72491. exponent?: number);
  72492. /** @hidden */
  72493. easeInCore(gradient: number): number;
  72494. }
  72495. /**
  72496. * Easing function with a power shape (see link below).
  72497. * @see https://easings.net/#easeInQuad
  72498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72499. */
  72500. export class PowerEase extends EasingFunction implements IEasingFunction {
  72501. /** Defines the power of the function */
  72502. power: number;
  72503. /**
  72504. * Instantiates an power base easing function
  72505. * @see https://easings.net/#easeInQuad
  72506. * @param power Defines the power of the function
  72507. */
  72508. constructor(
  72509. /** Defines the power of the function */
  72510. power?: number);
  72511. /** @hidden */
  72512. easeInCore(gradient: number): number;
  72513. }
  72514. /**
  72515. * Easing function with a power of 2 shape (see link below).
  72516. * @see https://easings.net/#easeInQuad
  72517. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72518. */
  72519. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72520. /** @hidden */
  72521. easeInCore(gradient: number): number;
  72522. }
  72523. /**
  72524. * Easing function with a power of 4 shape (see link below).
  72525. * @see https://easings.net/#easeInQuart
  72526. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72527. */
  72528. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72529. /** @hidden */
  72530. easeInCore(gradient: number): number;
  72531. }
  72532. /**
  72533. * Easing function with a power of 5 shape (see link below).
  72534. * @see https://easings.net/#easeInQuint
  72535. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72536. */
  72537. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72538. /** @hidden */
  72539. easeInCore(gradient: number): number;
  72540. }
  72541. /**
  72542. * Easing function with a sin shape (see link below).
  72543. * @see https://easings.net/#easeInSine
  72544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72545. */
  72546. export class SineEase extends EasingFunction implements IEasingFunction {
  72547. /** @hidden */
  72548. easeInCore(gradient: number): number;
  72549. }
  72550. /**
  72551. * Easing function with a bezier shape (see link below).
  72552. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72553. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72554. */
  72555. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72556. /** Defines the x component of the start tangent in the bezier curve */
  72557. x1: number;
  72558. /** Defines the y component of the start tangent in the bezier curve */
  72559. y1: number;
  72560. /** Defines the x component of the end tangent in the bezier curve */
  72561. x2: number;
  72562. /** Defines the y component of the end tangent in the bezier curve */
  72563. y2: number;
  72564. /**
  72565. * Instantiates a bezier function
  72566. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72567. * @param x1 Defines the x component of the start tangent in the bezier curve
  72568. * @param y1 Defines the y component of the start tangent in the bezier curve
  72569. * @param x2 Defines the x component of the end tangent in the bezier curve
  72570. * @param y2 Defines the y component of the end tangent in the bezier curve
  72571. */
  72572. constructor(
  72573. /** Defines the x component of the start tangent in the bezier curve */
  72574. x1?: number,
  72575. /** Defines the y component of the start tangent in the bezier curve */
  72576. y1?: number,
  72577. /** Defines the x component of the end tangent in the bezier curve */
  72578. x2?: number,
  72579. /** Defines the y component of the end tangent in the bezier curve */
  72580. y2?: number);
  72581. /** @hidden */
  72582. easeInCore(gradient: number): number;
  72583. }
  72584. }
  72585. declare module BABYLON {
  72586. /**
  72587. * Class used to hold a RBG color
  72588. */
  72589. export class Color3 {
  72590. /**
  72591. * Defines the red component (between 0 and 1, default is 0)
  72592. */
  72593. r: number;
  72594. /**
  72595. * Defines the green component (between 0 and 1, default is 0)
  72596. */
  72597. g: number;
  72598. /**
  72599. * Defines the blue component (between 0 and 1, default is 0)
  72600. */
  72601. b: number;
  72602. /**
  72603. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72604. * @param r defines the red component (between 0 and 1, default is 0)
  72605. * @param g defines the green component (between 0 and 1, default is 0)
  72606. * @param b defines the blue component (between 0 and 1, default is 0)
  72607. */
  72608. constructor(
  72609. /**
  72610. * Defines the red component (between 0 and 1, default is 0)
  72611. */
  72612. r?: number,
  72613. /**
  72614. * Defines the green component (between 0 and 1, default is 0)
  72615. */
  72616. g?: number,
  72617. /**
  72618. * Defines the blue component (between 0 and 1, default is 0)
  72619. */
  72620. b?: number);
  72621. /**
  72622. * Creates a string with the Color3 current values
  72623. * @returns the string representation of the Color3 object
  72624. */
  72625. toString(): string;
  72626. /**
  72627. * Returns the string "Color3"
  72628. * @returns "Color3"
  72629. */
  72630. getClassName(): string;
  72631. /**
  72632. * Compute the Color3 hash code
  72633. * @returns an unique number that can be used to hash Color3 objects
  72634. */
  72635. getHashCode(): number;
  72636. /**
  72637. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72638. * @param array defines the array where to store the r,g,b components
  72639. * @param index defines an optional index in the target array to define where to start storing values
  72640. * @returns the current Color3 object
  72641. */
  72642. toArray(array: FloatArray, index?: number): Color3;
  72643. /**
  72644. * Returns a new Color4 object from the current Color3 and the given alpha
  72645. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72646. * @returns a new Color4 object
  72647. */
  72648. toColor4(alpha?: number): Color4;
  72649. /**
  72650. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72651. * @returns the new array
  72652. */
  72653. asArray(): number[];
  72654. /**
  72655. * Returns the luminance value
  72656. * @returns a float value
  72657. */
  72658. toLuminance(): number;
  72659. /**
  72660. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72661. * @param otherColor defines the second operand
  72662. * @returns the new Color3 object
  72663. */
  72664. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72665. /**
  72666. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72667. * @param otherColor defines the second operand
  72668. * @param result defines the Color3 object where to store the result
  72669. * @returns the current Color3
  72670. */
  72671. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72672. /**
  72673. * Determines equality between Color3 objects
  72674. * @param otherColor defines the second operand
  72675. * @returns true if the rgb values are equal to the given ones
  72676. */
  72677. equals(otherColor: DeepImmutable<Color3>): boolean;
  72678. /**
  72679. * Determines equality between the current Color3 object and a set of r,b,g values
  72680. * @param r defines the red component to check
  72681. * @param g defines the green component to check
  72682. * @param b defines the blue component to check
  72683. * @returns true if the rgb values are equal to the given ones
  72684. */
  72685. equalsFloats(r: number, g: number, b: number): boolean;
  72686. /**
  72687. * Multiplies in place each rgb value by scale
  72688. * @param scale defines the scaling factor
  72689. * @returns the updated Color3
  72690. */
  72691. scale(scale: number): Color3;
  72692. /**
  72693. * Multiplies the rgb values by scale and stores the result into "result"
  72694. * @param scale defines the scaling factor
  72695. * @param result defines the Color3 object where to store the result
  72696. * @returns the unmodified current Color3
  72697. */
  72698. scaleToRef(scale: number, result: Color3): Color3;
  72699. /**
  72700. * Scale the current Color3 values by a factor and add the result to a given Color3
  72701. * @param scale defines the scale factor
  72702. * @param result defines color to store the result into
  72703. * @returns the unmodified current Color3
  72704. */
  72705. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72706. /**
  72707. * Clamps the rgb values by the min and max values and stores the result into "result"
  72708. * @param min defines minimum clamping value (default is 0)
  72709. * @param max defines maximum clamping value (default is 1)
  72710. * @param result defines color to store the result into
  72711. * @returns the original Color3
  72712. */
  72713. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72714. /**
  72715. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72716. * @param otherColor defines the second operand
  72717. * @returns the new Color3
  72718. */
  72719. add(otherColor: DeepImmutable<Color3>): Color3;
  72720. /**
  72721. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72722. * @param otherColor defines the second operand
  72723. * @param result defines Color3 object to store the result into
  72724. * @returns the unmodified current Color3
  72725. */
  72726. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72727. /**
  72728. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72729. * @param otherColor defines the second operand
  72730. * @returns the new Color3
  72731. */
  72732. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72733. /**
  72734. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72735. * @param otherColor defines the second operand
  72736. * @param result defines Color3 object to store the result into
  72737. * @returns the unmodified current Color3
  72738. */
  72739. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72740. /**
  72741. * Copy the current object
  72742. * @returns a new Color3 copied the current one
  72743. */
  72744. clone(): Color3;
  72745. /**
  72746. * Copies the rgb values from the source in the current Color3
  72747. * @param source defines the source Color3 object
  72748. * @returns the updated Color3 object
  72749. */
  72750. copyFrom(source: DeepImmutable<Color3>): Color3;
  72751. /**
  72752. * Updates the Color3 rgb values from the given floats
  72753. * @param r defines the red component to read from
  72754. * @param g defines the green component to read from
  72755. * @param b defines the blue component to read from
  72756. * @returns the current Color3 object
  72757. */
  72758. copyFromFloats(r: number, g: number, b: number): Color3;
  72759. /**
  72760. * Updates the Color3 rgb values from the given floats
  72761. * @param r defines the red component to read from
  72762. * @param g defines the green component to read from
  72763. * @param b defines the blue component to read from
  72764. * @returns the current Color3 object
  72765. */
  72766. set(r: number, g: number, b: number): Color3;
  72767. /**
  72768. * Compute the Color3 hexadecimal code as a string
  72769. * @returns a string containing the hexadecimal representation of the Color3 object
  72770. */
  72771. toHexString(): string;
  72772. /**
  72773. * Computes a new Color3 converted from the current one to linear space
  72774. * @returns a new Color3 object
  72775. */
  72776. toLinearSpace(): Color3;
  72777. /**
  72778. * Converts current color in rgb space to HSV values
  72779. * @returns a new color3 representing the HSV values
  72780. */
  72781. toHSV(): Color3;
  72782. /**
  72783. * Converts current color in rgb space to HSV values
  72784. * @param result defines the Color3 where to store the HSV values
  72785. */
  72786. toHSVToRef(result: Color3): void;
  72787. /**
  72788. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72789. * @param convertedColor defines the Color3 object where to store the linear space version
  72790. * @returns the unmodified Color3
  72791. */
  72792. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72793. /**
  72794. * Computes a new Color3 converted from the current one to gamma space
  72795. * @returns a new Color3 object
  72796. */
  72797. toGammaSpace(): Color3;
  72798. /**
  72799. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72800. * @param convertedColor defines the Color3 object where to store the gamma space version
  72801. * @returns the unmodified Color3
  72802. */
  72803. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72804. private static _BlackReadOnly;
  72805. /**
  72806. * Convert Hue, saturation and value to a Color3 (RGB)
  72807. * @param hue defines the hue
  72808. * @param saturation defines the saturation
  72809. * @param value defines the value
  72810. * @param result defines the Color3 where to store the RGB values
  72811. */
  72812. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72813. /**
  72814. * Creates a new Color3 from the string containing valid hexadecimal values
  72815. * @param hex defines a string containing valid hexadecimal values
  72816. * @returns a new Color3 object
  72817. */
  72818. static FromHexString(hex: string): Color3;
  72819. /**
  72820. * Creates a new Color3 from the starting index of the given array
  72821. * @param array defines the source array
  72822. * @param offset defines an offset in the source array
  72823. * @returns a new Color3 object
  72824. */
  72825. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72826. /**
  72827. * Creates a new Color3 from integer values (< 256)
  72828. * @param r defines the red component to read from (value between 0 and 255)
  72829. * @param g defines the green component to read from (value between 0 and 255)
  72830. * @param b defines the blue component to read from (value between 0 and 255)
  72831. * @returns a new Color3 object
  72832. */
  72833. static FromInts(r: number, g: number, b: number): Color3;
  72834. /**
  72835. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72836. * @param start defines the start Color3 value
  72837. * @param end defines the end Color3 value
  72838. * @param amount defines the gradient value between start and end
  72839. * @returns a new Color3 object
  72840. */
  72841. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72842. /**
  72843. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72844. * @param left defines the start value
  72845. * @param right defines the end value
  72846. * @param amount defines the gradient factor
  72847. * @param result defines the Color3 object where to store the result
  72848. */
  72849. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72850. /**
  72851. * Returns a Color3 value containing a red color
  72852. * @returns a new Color3 object
  72853. */
  72854. static Red(): Color3;
  72855. /**
  72856. * Returns a Color3 value containing a green color
  72857. * @returns a new Color3 object
  72858. */
  72859. static Green(): Color3;
  72860. /**
  72861. * Returns a Color3 value containing a blue color
  72862. * @returns a new Color3 object
  72863. */
  72864. static Blue(): Color3;
  72865. /**
  72866. * Returns a Color3 value containing a black color
  72867. * @returns a new Color3 object
  72868. */
  72869. static Black(): Color3;
  72870. /**
  72871. * Gets a Color3 value containing a black color that must not be updated
  72872. */
  72873. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72874. /**
  72875. * Returns a Color3 value containing a white color
  72876. * @returns a new Color3 object
  72877. */
  72878. static White(): Color3;
  72879. /**
  72880. * Returns a Color3 value containing a purple color
  72881. * @returns a new Color3 object
  72882. */
  72883. static Purple(): Color3;
  72884. /**
  72885. * Returns a Color3 value containing a magenta color
  72886. * @returns a new Color3 object
  72887. */
  72888. static Magenta(): Color3;
  72889. /**
  72890. * Returns a Color3 value containing a yellow color
  72891. * @returns a new Color3 object
  72892. */
  72893. static Yellow(): Color3;
  72894. /**
  72895. * Returns a Color3 value containing a gray color
  72896. * @returns a new Color3 object
  72897. */
  72898. static Gray(): Color3;
  72899. /**
  72900. * Returns a Color3 value containing a teal color
  72901. * @returns a new Color3 object
  72902. */
  72903. static Teal(): Color3;
  72904. /**
  72905. * Returns a Color3 value containing a random color
  72906. * @returns a new Color3 object
  72907. */
  72908. static Random(): Color3;
  72909. }
  72910. /**
  72911. * Class used to hold a RBGA color
  72912. */
  72913. export class Color4 {
  72914. /**
  72915. * Defines the red component (between 0 and 1, default is 0)
  72916. */
  72917. r: number;
  72918. /**
  72919. * Defines the green component (between 0 and 1, default is 0)
  72920. */
  72921. g: number;
  72922. /**
  72923. * Defines the blue component (between 0 and 1, default is 0)
  72924. */
  72925. b: number;
  72926. /**
  72927. * Defines the alpha component (between 0 and 1, default is 1)
  72928. */
  72929. a: number;
  72930. /**
  72931. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72932. * @param r defines the red component (between 0 and 1, default is 0)
  72933. * @param g defines the green component (between 0 and 1, default is 0)
  72934. * @param b defines the blue component (between 0 and 1, default is 0)
  72935. * @param a defines the alpha component (between 0 and 1, default is 1)
  72936. */
  72937. constructor(
  72938. /**
  72939. * Defines the red component (between 0 and 1, default is 0)
  72940. */
  72941. r?: number,
  72942. /**
  72943. * Defines the green component (between 0 and 1, default is 0)
  72944. */
  72945. g?: number,
  72946. /**
  72947. * Defines the blue component (between 0 and 1, default is 0)
  72948. */
  72949. b?: number,
  72950. /**
  72951. * Defines the alpha component (between 0 and 1, default is 1)
  72952. */
  72953. a?: number);
  72954. /**
  72955. * Adds in place the given Color4 values to the current Color4 object
  72956. * @param right defines the second operand
  72957. * @returns the current updated Color4 object
  72958. */
  72959. addInPlace(right: DeepImmutable<Color4>): Color4;
  72960. /**
  72961. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72962. * @returns the new array
  72963. */
  72964. asArray(): number[];
  72965. /**
  72966. * Stores from the starting index in the given array the Color4 successive values
  72967. * @param array defines the array where to store the r,g,b components
  72968. * @param index defines an optional index in the target array to define where to start storing values
  72969. * @returns the current Color4 object
  72970. */
  72971. toArray(array: number[], index?: number): Color4;
  72972. /**
  72973. * Determines equality between Color4 objects
  72974. * @param otherColor defines the second operand
  72975. * @returns true if the rgba values are equal to the given ones
  72976. */
  72977. equals(otherColor: DeepImmutable<Color4>): boolean;
  72978. /**
  72979. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72980. * @param right defines the second operand
  72981. * @returns a new Color4 object
  72982. */
  72983. add(right: DeepImmutable<Color4>): Color4;
  72984. /**
  72985. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72986. * @param right defines the second operand
  72987. * @returns a new Color4 object
  72988. */
  72989. subtract(right: DeepImmutable<Color4>): Color4;
  72990. /**
  72991. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72992. * @param right defines the second operand
  72993. * @param result defines the Color4 object where to store the result
  72994. * @returns the current Color4 object
  72995. */
  72996. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72997. /**
  72998. * Creates a new Color4 with the current Color4 values multiplied by scale
  72999. * @param scale defines the scaling factor to apply
  73000. * @returns a new Color4 object
  73001. */
  73002. scale(scale: number): Color4;
  73003. /**
  73004. * Multiplies the current Color4 values by scale and stores the result in "result"
  73005. * @param scale defines the scaling factor to apply
  73006. * @param result defines the Color4 object where to store the result
  73007. * @returns the current unmodified Color4
  73008. */
  73009. scaleToRef(scale: number, result: Color4): Color4;
  73010. /**
  73011. * Scale the current Color4 values by a factor and add the result to a given Color4
  73012. * @param scale defines the scale factor
  73013. * @param result defines the Color4 object where to store the result
  73014. * @returns the unmodified current Color4
  73015. */
  73016. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73017. /**
  73018. * Clamps the rgb values by the min and max values and stores the result into "result"
  73019. * @param min defines minimum clamping value (default is 0)
  73020. * @param max defines maximum clamping value (default is 1)
  73021. * @param result defines color to store the result into.
  73022. * @returns the cuurent Color4
  73023. */
  73024. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73025. /**
  73026. * Multipy an Color4 value by another and return a new Color4 object
  73027. * @param color defines the Color4 value to multiply by
  73028. * @returns a new Color4 object
  73029. */
  73030. multiply(color: Color4): Color4;
  73031. /**
  73032. * Multipy a Color4 value by another and push the result in a reference value
  73033. * @param color defines the Color4 value to multiply by
  73034. * @param result defines the Color4 to fill the result in
  73035. * @returns the result Color4
  73036. */
  73037. multiplyToRef(color: Color4, result: Color4): Color4;
  73038. /**
  73039. * Creates a string with the Color4 current values
  73040. * @returns the string representation of the Color4 object
  73041. */
  73042. toString(): string;
  73043. /**
  73044. * Returns the string "Color4"
  73045. * @returns "Color4"
  73046. */
  73047. getClassName(): string;
  73048. /**
  73049. * Compute the Color4 hash code
  73050. * @returns an unique number that can be used to hash Color4 objects
  73051. */
  73052. getHashCode(): number;
  73053. /**
  73054. * Creates a new Color4 copied from the current one
  73055. * @returns a new Color4 object
  73056. */
  73057. clone(): Color4;
  73058. /**
  73059. * Copies the given Color4 values into the current one
  73060. * @param source defines the source Color4 object
  73061. * @returns the current updated Color4 object
  73062. */
  73063. copyFrom(source: Color4): Color4;
  73064. /**
  73065. * Copies the given float values into the current one
  73066. * @param r defines the red component to read from
  73067. * @param g defines the green component to read from
  73068. * @param b defines the blue component to read from
  73069. * @param a defines the alpha component to read from
  73070. * @returns the current updated Color4 object
  73071. */
  73072. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73073. /**
  73074. * Copies the given float values into the current one
  73075. * @param r defines the red component to read from
  73076. * @param g defines the green component to read from
  73077. * @param b defines the blue component to read from
  73078. * @param a defines the alpha component to read from
  73079. * @returns the current updated Color4 object
  73080. */
  73081. set(r: number, g: number, b: number, a: number): Color4;
  73082. /**
  73083. * Compute the Color4 hexadecimal code as a string
  73084. * @returns a string containing the hexadecimal representation of the Color4 object
  73085. */
  73086. toHexString(): string;
  73087. /**
  73088. * Computes a new Color4 converted from the current one to linear space
  73089. * @returns a new Color4 object
  73090. */
  73091. toLinearSpace(): Color4;
  73092. /**
  73093. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73094. * @param convertedColor defines the Color4 object where to store the linear space version
  73095. * @returns the unmodified Color4
  73096. */
  73097. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73098. /**
  73099. * Computes a new Color4 converted from the current one to gamma space
  73100. * @returns a new Color4 object
  73101. */
  73102. toGammaSpace(): Color4;
  73103. /**
  73104. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73105. * @param convertedColor defines the Color4 object where to store the gamma space version
  73106. * @returns the unmodified Color4
  73107. */
  73108. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73109. /**
  73110. * Creates a new Color4 from the string containing valid hexadecimal values
  73111. * @param hex defines a string containing valid hexadecimal values
  73112. * @returns a new Color4 object
  73113. */
  73114. static FromHexString(hex: string): Color4;
  73115. /**
  73116. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73117. * @param left defines the start value
  73118. * @param right defines the end value
  73119. * @param amount defines the gradient factor
  73120. * @returns a new Color4 object
  73121. */
  73122. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73123. /**
  73124. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73125. * @param left defines the start value
  73126. * @param right defines the end value
  73127. * @param amount defines the gradient factor
  73128. * @param result defines the Color4 object where to store data
  73129. */
  73130. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73131. /**
  73132. * Creates a new Color4 from a Color3 and an alpha value
  73133. * @param color3 defines the source Color3 to read from
  73134. * @param alpha defines the alpha component (1.0 by default)
  73135. * @returns a new Color4 object
  73136. */
  73137. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73138. /**
  73139. * Creates a new Color4 from the starting index element of the given array
  73140. * @param array defines the source array to read from
  73141. * @param offset defines the offset in the source array
  73142. * @returns a new Color4 object
  73143. */
  73144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73145. /**
  73146. * Creates a new Color3 from integer values (< 256)
  73147. * @param r defines the red component to read from (value between 0 and 255)
  73148. * @param g defines the green component to read from (value between 0 and 255)
  73149. * @param b defines the blue component to read from (value between 0 and 255)
  73150. * @param a defines the alpha component to read from (value between 0 and 255)
  73151. * @returns a new Color3 object
  73152. */
  73153. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73154. /**
  73155. * Check the content of a given array and convert it to an array containing RGBA data
  73156. * If the original array was already containing count * 4 values then it is returned directly
  73157. * @param colors defines the array to check
  73158. * @param count defines the number of RGBA data to expect
  73159. * @returns an array containing count * 4 values (RGBA)
  73160. */
  73161. static CheckColors4(colors: number[], count: number): number[];
  73162. }
  73163. /**
  73164. * @hidden
  73165. */
  73166. export class TmpColors {
  73167. static Color3: Color3[];
  73168. static Color4: Color4[];
  73169. }
  73170. }
  73171. declare module BABYLON {
  73172. /**
  73173. * Defines an interface which represents an animation key frame
  73174. */
  73175. export interface IAnimationKey {
  73176. /**
  73177. * Frame of the key frame
  73178. */
  73179. frame: number;
  73180. /**
  73181. * Value at the specifies key frame
  73182. */
  73183. value: any;
  73184. /**
  73185. * The input tangent for the cubic hermite spline
  73186. */
  73187. inTangent?: any;
  73188. /**
  73189. * The output tangent for the cubic hermite spline
  73190. */
  73191. outTangent?: any;
  73192. /**
  73193. * The animation interpolation type
  73194. */
  73195. interpolation?: AnimationKeyInterpolation;
  73196. }
  73197. /**
  73198. * Enum for the animation key frame interpolation type
  73199. */
  73200. export enum AnimationKeyInterpolation {
  73201. /**
  73202. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73203. */
  73204. STEP = 1
  73205. }
  73206. }
  73207. declare module BABYLON {
  73208. /**
  73209. * Represents the range of an animation
  73210. */
  73211. export class AnimationRange {
  73212. /**The name of the animation range**/
  73213. name: string;
  73214. /**The starting frame of the animation */
  73215. from: number;
  73216. /**The ending frame of the animation*/
  73217. to: number;
  73218. /**
  73219. * Initializes the range of an animation
  73220. * @param name The name of the animation range
  73221. * @param from The starting frame of the animation
  73222. * @param to The ending frame of the animation
  73223. */
  73224. constructor(
  73225. /**The name of the animation range**/
  73226. name: string,
  73227. /**The starting frame of the animation */
  73228. from: number,
  73229. /**The ending frame of the animation*/
  73230. to: number);
  73231. /**
  73232. * Makes a copy of the animation range
  73233. * @returns A copy of the animation range
  73234. */
  73235. clone(): AnimationRange;
  73236. }
  73237. }
  73238. declare module BABYLON {
  73239. /**
  73240. * Composed of a frame, and an action function
  73241. */
  73242. export class AnimationEvent {
  73243. /** The frame for which the event is triggered **/
  73244. frame: number;
  73245. /** The event to perform when triggered **/
  73246. action: (currentFrame: number) => void;
  73247. /** Specifies if the event should be triggered only once**/
  73248. onlyOnce?: boolean | undefined;
  73249. /**
  73250. * Specifies if the animation event is done
  73251. */
  73252. isDone: boolean;
  73253. /**
  73254. * Initializes the animation event
  73255. * @param frame The frame for which the event is triggered
  73256. * @param action The event to perform when triggered
  73257. * @param onlyOnce Specifies if the event should be triggered only once
  73258. */
  73259. constructor(
  73260. /** The frame for which the event is triggered **/
  73261. frame: number,
  73262. /** The event to perform when triggered **/
  73263. action: (currentFrame: number) => void,
  73264. /** Specifies if the event should be triggered only once**/
  73265. onlyOnce?: boolean | undefined);
  73266. /** @hidden */
  73267. _clone(): AnimationEvent;
  73268. }
  73269. }
  73270. declare module BABYLON {
  73271. /**
  73272. * Interface used to define a behavior
  73273. */
  73274. export interface Behavior<T> {
  73275. /** gets or sets behavior's name */
  73276. name: string;
  73277. /**
  73278. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73279. */
  73280. init(): void;
  73281. /**
  73282. * Called when the behavior is attached to a target
  73283. * @param target defines the target where the behavior is attached to
  73284. */
  73285. attach(target: T): void;
  73286. /**
  73287. * Called when the behavior is detached from its target
  73288. */
  73289. detach(): void;
  73290. }
  73291. /**
  73292. * Interface implemented by classes supporting behaviors
  73293. */
  73294. export interface IBehaviorAware<T> {
  73295. /**
  73296. * Attach a behavior
  73297. * @param behavior defines the behavior to attach
  73298. * @returns the current host
  73299. */
  73300. addBehavior(behavior: Behavior<T>): T;
  73301. /**
  73302. * Remove a behavior from the current object
  73303. * @param behavior defines the behavior to detach
  73304. * @returns the current host
  73305. */
  73306. removeBehavior(behavior: Behavior<T>): T;
  73307. /**
  73308. * Gets a behavior using its name to search
  73309. * @param name defines the name to search
  73310. * @returns the behavior or null if not found
  73311. */
  73312. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73313. }
  73314. }
  73315. declare module BABYLON {
  73316. /**
  73317. * Defines an array and its length.
  73318. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73319. */
  73320. export interface ISmartArrayLike<T> {
  73321. /**
  73322. * The data of the array.
  73323. */
  73324. data: Array<T>;
  73325. /**
  73326. * The active length of the array.
  73327. */
  73328. length: number;
  73329. }
  73330. /**
  73331. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73332. */
  73333. export class SmartArray<T> implements ISmartArrayLike<T> {
  73334. /**
  73335. * The full set of data from the array.
  73336. */
  73337. data: Array<T>;
  73338. /**
  73339. * The active length of the array.
  73340. */
  73341. length: number;
  73342. protected _id: number;
  73343. /**
  73344. * Instantiates a Smart Array.
  73345. * @param capacity defines the default capacity of the array.
  73346. */
  73347. constructor(capacity: number);
  73348. /**
  73349. * Pushes a value at the end of the active data.
  73350. * @param value defines the object to push in the array.
  73351. */
  73352. push(value: T): void;
  73353. /**
  73354. * Iterates over the active data and apply the lambda to them.
  73355. * @param func defines the action to apply on each value.
  73356. */
  73357. forEach(func: (content: T) => void): void;
  73358. /**
  73359. * Sorts the full sets of data.
  73360. * @param compareFn defines the comparison function to apply.
  73361. */
  73362. sort(compareFn: (a: T, b: T) => number): void;
  73363. /**
  73364. * Resets the active data to an empty array.
  73365. */
  73366. reset(): void;
  73367. /**
  73368. * Releases all the data from the array as well as the array.
  73369. */
  73370. dispose(): void;
  73371. /**
  73372. * Concats the active data with a given array.
  73373. * @param array defines the data to concatenate with.
  73374. */
  73375. concat(array: any): void;
  73376. /**
  73377. * Returns the position of a value in the active data.
  73378. * @param value defines the value to find the index for
  73379. * @returns the index if found in the active data otherwise -1
  73380. */
  73381. indexOf(value: T): number;
  73382. /**
  73383. * Returns whether an element is part of the active data.
  73384. * @param value defines the value to look for
  73385. * @returns true if found in the active data otherwise false
  73386. */
  73387. contains(value: T): boolean;
  73388. private static _GlobalId;
  73389. }
  73390. /**
  73391. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73392. * The data in this array can only be present once
  73393. */
  73394. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73395. private _duplicateId;
  73396. /**
  73397. * Pushes a value at the end of the active data.
  73398. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73399. * @param value defines the object to push in the array.
  73400. */
  73401. push(value: T): void;
  73402. /**
  73403. * Pushes a value at the end of the active data.
  73404. * If the data is already present, it won t be added again
  73405. * @param value defines the object to push in the array.
  73406. * @returns true if added false if it was already present
  73407. */
  73408. pushNoDuplicate(value: T): boolean;
  73409. /**
  73410. * Resets the active data to an empty array.
  73411. */
  73412. reset(): void;
  73413. /**
  73414. * Concats the active data with a given array.
  73415. * This ensures no dupplicate will be present in the result.
  73416. * @param array defines the data to concatenate with.
  73417. */
  73418. concatWithNoDuplicate(array: any): void;
  73419. }
  73420. }
  73421. declare module BABYLON {
  73422. /**
  73423. * @ignore
  73424. * This is a list of all the different input types that are available in the application.
  73425. * Fo instance: ArcRotateCameraGamepadInput...
  73426. */
  73427. export var CameraInputTypes: {};
  73428. /**
  73429. * This is the contract to implement in order to create a new input class.
  73430. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73431. */
  73432. export interface ICameraInput<TCamera extends Camera> {
  73433. /**
  73434. * Defines the camera the input is attached to.
  73435. */
  73436. camera: Nullable<TCamera>;
  73437. /**
  73438. * Gets the class name of the current intput.
  73439. * @returns the class name
  73440. */
  73441. getClassName(): string;
  73442. /**
  73443. * Get the friendly name associated with the input class.
  73444. * @returns the input friendly name
  73445. */
  73446. getSimpleName(): string;
  73447. /**
  73448. * Attach the input controls to a specific dom element to get the input from.
  73449. * @param element Defines the element the controls should be listened from
  73450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73451. */
  73452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73453. /**
  73454. * Detach the current controls from the specified dom element.
  73455. * @param element Defines the element to stop listening the inputs from
  73456. */
  73457. detachControl(element: Nullable<HTMLElement>): void;
  73458. /**
  73459. * Update the current camera state depending on the inputs that have been used this frame.
  73460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73461. */
  73462. checkInputs?: () => void;
  73463. }
  73464. /**
  73465. * Represents a map of input types to input instance or input index to input instance.
  73466. */
  73467. export interface CameraInputsMap<TCamera extends Camera> {
  73468. /**
  73469. * Accessor to the input by input type.
  73470. */
  73471. [name: string]: ICameraInput<TCamera>;
  73472. /**
  73473. * Accessor to the input by input index.
  73474. */
  73475. [idx: number]: ICameraInput<TCamera>;
  73476. }
  73477. /**
  73478. * This represents the input manager used within a camera.
  73479. * It helps dealing with all the different kind of input attached to a camera.
  73480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73481. */
  73482. export class CameraInputsManager<TCamera extends Camera> {
  73483. /**
  73484. * Defines the list of inputs attahed to the camera.
  73485. */
  73486. attached: CameraInputsMap<TCamera>;
  73487. /**
  73488. * Defines the dom element the camera is collecting inputs from.
  73489. * This is null if the controls have not been attached.
  73490. */
  73491. attachedElement: Nullable<HTMLElement>;
  73492. /**
  73493. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73494. */
  73495. noPreventDefault: boolean;
  73496. /**
  73497. * Defined the camera the input manager belongs to.
  73498. */
  73499. camera: TCamera;
  73500. /**
  73501. * Update the current camera state depending on the inputs that have been used this frame.
  73502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73503. */
  73504. checkInputs: () => void;
  73505. /**
  73506. * Instantiate a new Camera Input Manager.
  73507. * @param camera Defines the camera the input manager blongs to
  73508. */
  73509. constructor(camera: TCamera);
  73510. /**
  73511. * Add an input method to a camera
  73512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73513. * @param input camera input method
  73514. */
  73515. add(input: ICameraInput<TCamera>): void;
  73516. /**
  73517. * Remove a specific input method from a camera
  73518. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73519. * @param inputToRemove camera input method
  73520. */
  73521. remove(inputToRemove: ICameraInput<TCamera>): void;
  73522. /**
  73523. * Remove a specific input type from a camera
  73524. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73525. * @param inputType the type of the input to remove
  73526. */
  73527. removeByType(inputType: string): void;
  73528. private _addCheckInputs;
  73529. /**
  73530. * Attach the input controls to the currently attached dom element to listen the events from.
  73531. * @param input Defines the input to attach
  73532. */
  73533. attachInput(input: ICameraInput<TCamera>): void;
  73534. /**
  73535. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73536. * @param element Defines the dom element to collect the events from
  73537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73538. */
  73539. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73540. /**
  73541. * Detach the current manager inputs controls from a specific dom element.
  73542. * @param element Defines the dom element to collect the events from
  73543. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73544. */
  73545. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73546. /**
  73547. * Rebuild the dynamic inputCheck function from the current list of
  73548. * defined inputs in the manager.
  73549. */
  73550. rebuildInputCheck(): void;
  73551. /**
  73552. * Remove all attached input methods from a camera
  73553. */
  73554. clear(): void;
  73555. /**
  73556. * Serialize the current input manager attached to a camera.
  73557. * This ensures than once parsed,
  73558. * the input associated to the camera will be identical to the current ones
  73559. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73560. */
  73561. serialize(serializedCamera: any): void;
  73562. /**
  73563. * Parses an input manager serialized JSON to restore the previous list of inputs
  73564. * and states associated to a camera.
  73565. * @param parsedCamera Defines the JSON to parse
  73566. */
  73567. parse(parsedCamera: any): void;
  73568. }
  73569. }
  73570. declare module BABYLON {
  73571. /**
  73572. * Class used to store data that will be store in GPU memory
  73573. */
  73574. export class Buffer {
  73575. private _engine;
  73576. private _buffer;
  73577. /** @hidden */
  73578. _data: Nullable<DataArray>;
  73579. private _updatable;
  73580. private _instanced;
  73581. private _divisor;
  73582. /**
  73583. * Gets the byte stride.
  73584. */
  73585. readonly byteStride: number;
  73586. /**
  73587. * Constructor
  73588. * @param engine the engine
  73589. * @param data the data to use for this buffer
  73590. * @param updatable whether the data is updatable
  73591. * @param stride the stride (optional)
  73592. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73593. * @param instanced whether the buffer is instanced (optional)
  73594. * @param useBytes set to true if the stride in in bytes (optional)
  73595. * @param divisor sets an optional divisor for instances (1 by default)
  73596. */
  73597. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73598. /**
  73599. * Create a new VertexBuffer based on the current buffer
  73600. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73601. * @param offset defines offset in the buffer (0 by default)
  73602. * @param size defines the size in floats of attributes (position is 3 for instance)
  73603. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73604. * @param instanced defines if the vertex buffer contains indexed data
  73605. * @param useBytes defines if the offset and stride are in bytes *
  73606. * @param divisor sets an optional divisor for instances (1 by default)
  73607. * @returns the new vertex buffer
  73608. */
  73609. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73610. /**
  73611. * Gets a boolean indicating if the Buffer is updatable?
  73612. * @returns true if the buffer is updatable
  73613. */
  73614. isUpdatable(): boolean;
  73615. /**
  73616. * Gets current buffer's data
  73617. * @returns a DataArray or null
  73618. */
  73619. getData(): Nullable<DataArray>;
  73620. /**
  73621. * Gets underlying native buffer
  73622. * @returns underlying native buffer
  73623. */
  73624. getBuffer(): Nullable<DataBuffer>;
  73625. /**
  73626. * Gets the stride in float32 units (i.e. byte stride / 4).
  73627. * May not be an integer if the byte stride is not divisible by 4.
  73628. * DEPRECATED. Use byteStride instead.
  73629. * @returns the stride in float32 units
  73630. */
  73631. getStrideSize(): number;
  73632. /**
  73633. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73634. * @param data defines the data to store
  73635. */
  73636. create(data?: Nullable<DataArray>): void;
  73637. /** @hidden */
  73638. _rebuild(): void;
  73639. /**
  73640. * Update current buffer data
  73641. * @param data defines the data to store
  73642. */
  73643. update(data: DataArray): void;
  73644. /**
  73645. * Updates the data directly.
  73646. * @param data the new data
  73647. * @param offset the new offset
  73648. * @param vertexCount the vertex count (optional)
  73649. * @param useBytes set to true if the offset is in bytes
  73650. */
  73651. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73652. /**
  73653. * Release all resources
  73654. */
  73655. dispose(): void;
  73656. }
  73657. /**
  73658. * Specialized buffer used to store vertex data
  73659. */
  73660. export class VertexBuffer {
  73661. /** @hidden */
  73662. _buffer: Buffer;
  73663. private _kind;
  73664. private _size;
  73665. private _ownsBuffer;
  73666. private _instanced;
  73667. private _instanceDivisor;
  73668. /**
  73669. * The byte type.
  73670. */
  73671. static readonly BYTE: number;
  73672. /**
  73673. * The unsigned byte type.
  73674. */
  73675. static readonly UNSIGNED_BYTE: number;
  73676. /**
  73677. * The short type.
  73678. */
  73679. static readonly SHORT: number;
  73680. /**
  73681. * The unsigned short type.
  73682. */
  73683. static readonly UNSIGNED_SHORT: number;
  73684. /**
  73685. * The integer type.
  73686. */
  73687. static readonly INT: number;
  73688. /**
  73689. * The unsigned integer type.
  73690. */
  73691. static readonly UNSIGNED_INT: number;
  73692. /**
  73693. * The float type.
  73694. */
  73695. static readonly FLOAT: number;
  73696. /**
  73697. * Gets or sets the instance divisor when in instanced mode
  73698. */
  73699. instanceDivisor: number;
  73700. /**
  73701. * Gets the byte stride.
  73702. */
  73703. readonly byteStride: number;
  73704. /**
  73705. * Gets the byte offset.
  73706. */
  73707. readonly byteOffset: number;
  73708. /**
  73709. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73710. */
  73711. readonly normalized: boolean;
  73712. /**
  73713. * Gets the data type of each component in the array.
  73714. */
  73715. readonly type: number;
  73716. /**
  73717. * Constructor
  73718. * @param engine the engine
  73719. * @param data the data to use for this vertex buffer
  73720. * @param kind the vertex buffer kind
  73721. * @param updatable whether the data is updatable
  73722. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73723. * @param stride the stride (optional)
  73724. * @param instanced whether the buffer is instanced (optional)
  73725. * @param offset the offset of the data (optional)
  73726. * @param size the number of components (optional)
  73727. * @param type the type of the component (optional)
  73728. * @param normalized whether the data contains normalized data (optional)
  73729. * @param useBytes set to true if stride and offset are in bytes (optional)
  73730. * @param divisor defines the instance divisor to use (1 by default)
  73731. */
  73732. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  73733. /** @hidden */
  73734. _rebuild(): void;
  73735. /**
  73736. * Returns the kind of the VertexBuffer (string)
  73737. * @returns a string
  73738. */
  73739. getKind(): string;
  73740. /**
  73741. * Gets a boolean indicating if the VertexBuffer is updatable?
  73742. * @returns true if the buffer is updatable
  73743. */
  73744. isUpdatable(): boolean;
  73745. /**
  73746. * Gets current buffer's data
  73747. * @returns a DataArray or null
  73748. */
  73749. getData(): Nullable<DataArray>;
  73750. /**
  73751. * Gets underlying native buffer
  73752. * @returns underlying native buffer
  73753. */
  73754. getBuffer(): Nullable<DataBuffer>;
  73755. /**
  73756. * Gets the stride in float32 units (i.e. byte stride / 4).
  73757. * May not be an integer if the byte stride is not divisible by 4.
  73758. * DEPRECATED. Use byteStride instead.
  73759. * @returns the stride in float32 units
  73760. */
  73761. getStrideSize(): number;
  73762. /**
  73763. * Returns the offset as a multiple of the type byte length.
  73764. * DEPRECATED. Use byteOffset instead.
  73765. * @returns the offset in bytes
  73766. */
  73767. getOffset(): number;
  73768. /**
  73769. * Returns the number of components per vertex attribute (integer)
  73770. * @returns the size in float
  73771. */
  73772. getSize(): number;
  73773. /**
  73774. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73775. * @returns true if this buffer is instanced
  73776. */
  73777. getIsInstanced(): boolean;
  73778. /**
  73779. * Returns the instancing divisor, zero for non-instanced (integer).
  73780. * @returns a number
  73781. */
  73782. getInstanceDivisor(): number;
  73783. /**
  73784. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73785. * @param data defines the data to store
  73786. */
  73787. create(data?: DataArray): void;
  73788. /**
  73789. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73790. * This function will create a new buffer if the current one is not updatable
  73791. * @param data defines the data to store
  73792. */
  73793. update(data: DataArray): void;
  73794. /**
  73795. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73796. * Returns the directly updated WebGLBuffer.
  73797. * @param data the new data
  73798. * @param offset the new offset
  73799. * @param useBytes set to true if the offset is in bytes
  73800. */
  73801. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73802. /**
  73803. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73804. */
  73805. dispose(): void;
  73806. /**
  73807. * Enumerates each value of this vertex buffer as numbers.
  73808. * @param count the number of values to enumerate
  73809. * @param callback the callback function called for each value
  73810. */
  73811. forEach(count: number, callback: (value: number, index: number) => void): void;
  73812. /**
  73813. * Positions
  73814. */
  73815. static readonly PositionKind: string;
  73816. /**
  73817. * Normals
  73818. */
  73819. static readonly NormalKind: string;
  73820. /**
  73821. * Tangents
  73822. */
  73823. static readonly TangentKind: string;
  73824. /**
  73825. * Texture coordinates
  73826. */
  73827. static readonly UVKind: string;
  73828. /**
  73829. * Texture coordinates 2
  73830. */
  73831. static readonly UV2Kind: string;
  73832. /**
  73833. * Texture coordinates 3
  73834. */
  73835. static readonly UV3Kind: string;
  73836. /**
  73837. * Texture coordinates 4
  73838. */
  73839. static readonly UV4Kind: string;
  73840. /**
  73841. * Texture coordinates 5
  73842. */
  73843. static readonly UV5Kind: string;
  73844. /**
  73845. * Texture coordinates 6
  73846. */
  73847. static readonly UV6Kind: string;
  73848. /**
  73849. * Colors
  73850. */
  73851. static readonly ColorKind: string;
  73852. /**
  73853. * Matrix indices (for bones)
  73854. */
  73855. static readonly MatricesIndicesKind: string;
  73856. /**
  73857. * Matrix weights (for bones)
  73858. */
  73859. static readonly MatricesWeightsKind: string;
  73860. /**
  73861. * Additional matrix indices (for bones)
  73862. */
  73863. static readonly MatricesIndicesExtraKind: string;
  73864. /**
  73865. * Additional matrix weights (for bones)
  73866. */
  73867. static readonly MatricesWeightsExtraKind: string;
  73868. /**
  73869. * Deduces the stride given a kind.
  73870. * @param kind The kind string to deduce
  73871. * @returns The deduced stride
  73872. */
  73873. static DeduceStride(kind: string): number;
  73874. /**
  73875. * Gets the byte length of the given type.
  73876. * @param type the type
  73877. * @returns the number of bytes
  73878. */
  73879. static GetTypeByteLength(type: number): number;
  73880. /**
  73881. * Enumerates each value of the given parameters as numbers.
  73882. * @param data the data to enumerate
  73883. * @param byteOffset the byte offset of the data
  73884. * @param byteStride the byte stride of the data
  73885. * @param componentCount the number of components per element
  73886. * @param componentType the type of the component
  73887. * @param count the number of values to enumerate
  73888. * @param normalized whether the data is normalized
  73889. * @param callback the callback function called for each value
  73890. */
  73891. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73892. private static _GetFloatValue;
  73893. }
  73894. }
  73895. declare module BABYLON {
  73896. /**
  73897. * @hidden
  73898. */
  73899. export class IntersectionInfo {
  73900. bu: Nullable<number>;
  73901. bv: Nullable<number>;
  73902. distance: number;
  73903. faceId: number;
  73904. subMeshId: number;
  73905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73906. }
  73907. }
  73908. declare module BABYLON {
  73909. /**
  73910. * Represens a plane by the equation ax + by + cz + d = 0
  73911. */
  73912. export class Plane {
  73913. private static _TmpMatrix;
  73914. /**
  73915. * Normal of the plane (a,b,c)
  73916. */
  73917. normal: Vector3;
  73918. /**
  73919. * d component of the plane
  73920. */
  73921. d: number;
  73922. /**
  73923. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73924. * @param a a component of the plane
  73925. * @param b b component of the plane
  73926. * @param c c component of the plane
  73927. * @param d d component of the plane
  73928. */
  73929. constructor(a: number, b: number, c: number, d: number);
  73930. /**
  73931. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73932. */
  73933. asArray(): number[];
  73934. /**
  73935. * @returns a new plane copied from the current Plane.
  73936. */
  73937. clone(): Plane;
  73938. /**
  73939. * @returns the string "Plane".
  73940. */
  73941. getClassName(): string;
  73942. /**
  73943. * @returns the Plane hash code.
  73944. */
  73945. getHashCode(): number;
  73946. /**
  73947. * Normalize the current Plane in place.
  73948. * @returns the updated Plane.
  73949. */
  73950. normalize(): Plane;
  73951. /**
  73952. * Applies a transformation the plane and returns the result
  73953. * @param transformation the transformation matrix to be applied to the plane
  73954. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73955. */
  73956. transform(transformation: DeepImmutable<Matrix>): Plane;
  73957. /**
  73958. * Calcualtte the dot product between the point and the plane normal
  73959. * @param point point to calculate the dot product with
  73960. * @returns the dot product (float) of the point coordinates and the plane normal.
  73961. */
  73962. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73963. /**
  73964. * Updates the current Plane from the plane defined by the three given points.
  73965. * @param point1 one of the points used to contruct the plane
  73966. * @param point2 one of the points used to contruct the plane
  73967. * @param point3 one of the points used to contruct the plane
  73968. * @returns the updated Plane.
  73969. */
  73970. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73971. /**
  73972. * Checks if the plane is facing a given direction
  73973. * @param direction the direction to check if the plane is facing
  73974. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73975. * @returns True is the vector "direction" is the same side than the plane normal.
  73976. */
  73977. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73978. /**
  73979. * Calculates the distance to a point
  73980. * @param point point to calculate distance to
  73981. * @returns the signed distance (float) from the given point to the Plane.
  73982. */
  73983. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73984. /**
  73985. * Creates a plane from an array
  73986. * @param array the array to create a plane from
  73987. * @returns a new Plane from the given array.
  73988. */
  73989. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73990. /**
  73991. * Creates a plane from three points
  73992. * @param point1 point used to create the plane
  73993. * @param point2 point used to create the plane
  73994. * @param point3 point used to create the plane
  73995. * @returns a new Plane defined by the three given points.
  73996. */
  73997. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73998. /**
  73999. * Creates a plane from an origin point and a normal
  74000. * @param origin origin of the plane to be constructed
  74001. * @param normal normal of the plane to be constructed
  74002. * @returns a new Plane the normal vector to this plane at the given origin point.
  74003. * Note : the vector "normal" is updated because normalized.
  74004. */
  74005. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74006. /**
  74007. * Calculates the distance from a plane and a point
  74008. * @param origin origin of the plane to be constructed
  74009. * @param normal normal of the plane to be constructed
  74010. * @param point point to calculate distance to
  74011. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74012. */
  74013. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74014. }
  74015. }
  74016. declare module BABYLON {
  74017. /**
  74018. * Class used to store bounding sphere information
  74019. */
  74020. export class BoundingSphere {
  74021. /**
  74022. * Gets the center of the bounding sphere in local space
  74023. */
  74024. readonly center: Vector3;
  74025. /**
  74026. * Radius of the bounding sphere in local space
  74027. */
  74028. radius: number;
  74029. /**
  74030. * Gets the center of the bounding sphere in world space
  74031. */
  74032. readonly centerWorld: Vector3;
  74033. /**
  74034. * Radius of the bounding sphere in world space
  74035. */
  74036. radiusWorld: number;
  74037. /**
  74038. * Gets the minimum vector in local space
  74039. */
  74040. readonly minimum: Vector3;
  74041. /**
  74042. * Gets the maximum vector in local space
  74043. */
  74044. readonly maximum: Vector3;
  74045. private _worldMatrix;
  74046. private static readonly TmpVector3;
  74047. /**
  74048. * Creates a new bounding sphere
  74049. * @param min defines the minimum vector (in local space)
  74050. * @param max defines the maximum vector (in local space)
  74051. * @param worldMatrix defines the new world matrix
  74052. */
  74053. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74054. /**
  74055. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74056. * @param min defines the new minimum vector (in local space)
  74057. * @param max defines the new maximum vector (in local space)
  74058. * @param worldMatrix defines the new world matrix
  74059. */
  74060. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74061. /**
  74062. * Scale the current bounding sphere by applying a scale factor
  74063. * @param factor defines the scale factor to apply
  74064. * @returns the current bounding box
  74065. */
  74066. scale(factor: number): BoundingSphere;
  74067. /**
  74068. * Gets the world matrix of the bounding box
  74069. * @returns a matrix
  74070. */
  74071. getWorldMatrix(): DeepImmutable<Matrix>;
  74072. /** @hidden */
  74073. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74074. /**
  74075. * Tests if the bounding sphere is intersecting the frustum planes
  74076. * @param frustumPlanes defines the frustum planes to test
  74077. * @returns true if there is an intersection
  74078. */
  74079. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74080. /**
  74081. * Tests if the bounding sphere center is in between the frustum planes.
  74082. * Used for optimistic fast inclusion.
  74083. * @param frustumPlanes defines the frustum planes to test
  74084. * @returns true if the sphere center is in between the frustum planes
  74085. */
  74086. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74087. /**
  74088. * Tests if a point is inside the bounding sphere
  74089. * @param point defines the point to test
  74090. * @returns true if the point is inside the bounding sphere
  74091. */
  74092. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74093. /**
  74094. * Checks if two sphere intersct
  74095. * @param sphere0 sphere 0
  74096. * @param sphere1 sphere 1
  74097. * @returns true if the speres intersect
  74098. */
  74099. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74100. }
  74101. }
  74102. declare module BABYLON {
  74103. /**
  74104. * Class used to store bounding box information
  74105. */
  74106. export class BoundingBox implements ICullable {
  74107. /**
  74108. * Gets the 8 vectors representing the bounding box in local space
  74109. */
  74110. readonly vectors: Vector3[];
  74111. /**
  74112. * Gets the center of the bounding box in local space
  74113. */
  74114. readonly center: Vector3;
  74115. /**
  74116. * Gets the center of the bounding box in world space
  74117. */
  74118. readonly centerWorld: Vector3;
  74119. /**
  74120. * Gets the extend size in local space
  74121. */
  74122. readonly extendSize: Vector3;
  74123. /**
  74124. * Gets the extend size in world space
  74125. */
  74126. readonly extendSizeWorld: Vector3;
  74127. /**
  74128. * Gets the OBB (object bounding box) directions
  74129. */
  74130. readonly directions: Vector3[];
  74131. /**
  74132. * Gets the 8 vectors representing the bounding box in world space
  74133. */
  74134. readonly vectorsWorld: Vector3[];
  74135. /**
  74136. * Gets the minimum vector in world space
  74137. */
  74138. readonly minimumWorld: Vector3;
  74139. /**
  74140. * Gets the maximum vector in world space
  74141. */
  74142. readonly maximumWorld: Vector3;
  74143. /**
  74144. * Gets the minimum vector in local space
  74145. */
  74146. readonly minimum: Vector3;
  74147. /**
  74148. * Gets the maximum vector in local space
  74149. */
  74150. readonly maximum: Vector3;
  74151. private _worldMatrix;
  74152. private static readonly TmpVector3;
  74153. /**
  74154. * @hidden
  74155. */
  74156. _tag: number;
  74157. /**
  74158. * Creates a new bounding box
  74159. * @param min defines the minimum vector (in local space)
  74160. * @param max defines the maximum vector (in local space)
  74161. * @param worldMatrix defines the new world matrix
  74162. */
  74163. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74164. /**
  74165. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74166. * @param min defines the new minimum vector (in local space)
  74167. * @param max defines the new maximum vector (in local space)
  74168. * @param worldMatrix defines the new world matrix
  74169. */
  74170. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74171. /**
  74172. * Scale the current bounding box by applying a scale factor
  74173. * @param factor defines the scale factor to apply
  74174. * @returns the current bounding box
  74175. */
  74176. scale(factor: number): BoundingBox;
  74177. /**
  74178. * Gets the world matrix of the bounding box
  74179. * @returns a matrix
  74180. */
  74181. getWorldMatrix(): DeepImmutable<Matrix>;
  74182. /** @hidden */
  74183. _update(world: DeepImmutable<Matrix>): void;
  74184. /**
  74185. * Tests if the bounding box is intersecting the frustum planes
  74186. * @param frustumPlanes defines the frustum planes to test
  74187. * @returns true if there is an intersection
  74188. */
  74189. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74190. /**
  74191. * Tests if the bounding box is entirely inside the frustum planes
  74192. * @param frustumPlanes defines the frustum planes to test
  74193. * @returns true if there is an inclusion
  74194. */
  74195. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74196. /**
  74197. * Tests if a point is inside the bounding box
  74198. * @param point defines the point to test
  74199. * @returns true if the point is inside the bounding box
  74200. */
  74201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74202. /**
  74203. * Tests if the bounding box intersects with a bounding sphere
  74204. * @param sphere defines the sphere to test
  74205. * @returns true if there is an intersection
  74206. */
  74207. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74208. /**
  74209. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74210. * @param min defines the min vector to use
  74211. * @param max defines the max vector to use
  74212. * @returns true if there is an intersection
  74213. */
  74214. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74215. /**
  74216. * Tests if two bounding boxes are intersections
  74217. * @param box0 defines the first box to test
  74218. * @param box1 defines the second box to test
  74219. * @returns true if there is an intersection
  74220. */
  74221. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74222. /**
  74223. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74224. * @param minPoint defines the minimum vector of the bounding box
  74225. * @param maxPoint defines the maximum vector of the bounding box
  74226. * @param sphereCenter defines the sphere center
  74227. * @param sphereRadius defines the sphere radius
  74228. * @returns true if there is an intersection
  74229. */
  74230. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74231. /**
  74232. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74233. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74234. * @param frustumPlanes defines the frustum planes to test
  74235. * @return true if there is an inclusion
  74236. */
  74237. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74238. /**
  74239. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74240. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74241. * @param frustumPlanes defines the frustum planes to test
  74242. * @return true if there is an intersection
  74243. */
  74244. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74245. }
  74246. }
  74247. declare module BABYLON {
  74248. /** @hidden */
  74249. export class Collider {
  74250. /** Define if a collision was found */
  74251. collisionFound: boolean;
  74252. /**
  74253. * Define last intersection point in local space
  74254. */
  74255. intersectionPoint: Vector3;
  74256. /**
  74257. * Define last collided mesh
  74258. */
  74259. collidedMesh: Nullable<AbstractMesh>;
  74260. private _collisionPoint;
  74261. private _planeIntersectionPoint;
  74262. private _tempVector;
  74263. private _tempVector2;
  74264. private _tempVector3;
  74265. private _tempVector4;
  74266. private _edge;
  74267. private _baseToVertex;
  74268. private _destinationPoint;
  74269. private _slidePlaneNormal;
  74270. private _displacementVector;
  74271. /** @hidden */
  74272. _radius: Vector3;
  74273. /** @hidden */
  74274. _retry: number;
  74275. private _velocity;
  74276. private _basePoint;
  74277. private _epsilon;
  74278. /** @hidden */
  74279. _velocityWorldLength: number;
  74280. /** @hidden */
  74281. _basePointWorld: Vector3;
  74282. private _velocityWorld;
  74283. private _normalizedVelocity;
  74284. /** @hidden */
  74285. _initialVelocity: Vector3;
  74286. /** @hidden */
  74287. _initialPosition: Vector3;
  74288. private _nearestDistance;
  74289. private _collisionMask;
  74290. collisionMask: number;
  74291. /**
  74292. * Gets the plane normal used to compute the sliding response (in local space)
  74293. */
  74294. readonly slidePlaneNormal: Vector3;
  74295. /** @hidden */
  74296. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74297. /** @hidden */
  74298. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74299. /** @hidden */
  74300. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74301. /** @hidden */
  74302. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74303. /** @hidden */
  74304. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74305. /** @hidden */
  74306. _getResponse(pos: Vector3, vel: Vector3): void;
  74307. }
  74308. }
  74309. declare module BABYLON {
  74310. /**
  74311. * Interface for cullable objects
  74312. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74313. */
  74314. export interface ICullable {
  74315. /**
  74316. * Checks if the object or part of the object is in the frustum
  74317. * @param frustumPlanes Camera near/planes
  74318. * @returns true if the object is in frustum otherwise false
  74319. */
  74320. isInFrustum(frustumPlanes: Plane[]): boolean;
  74321. /**
  74322. * Checks if a cullable object (mesh...) is in the camera frustum
  74323. * Unlike isInFrustum this cheks the full bounding box
  74324. * @param frustumPlanes Camera near/planes
  74325. * @returns true if the object is in frustum otherwise false
  74326. */
  74327. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74328. }
  74329. /**
  74330. * Info for a bounding data of a mesh
  74331. */
  74332. export class BoundingInfo implements ICullable {
  74333. /**
  74334. * Bounding box for the mesh
  74335. */
  74336. readonly boundingBox: BoundingBox;
  74337. /**
  74338. * Bounding sphere for the mesh
  74339. */
  74340. readonly boundingSphere: BoundingSphere;
  74341. private _isLocked;
  74342. private static readonly TmpVector3;
  74343. /**
  74344. * Constructs bounding info
  74345. * @param minimum min vector of the bounding box/sphere
  74346. * @param maximum max vector of the bounding box/sphere
  74347. * @param worldMatrix defines the new world matrix
  74348. */
  74349. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74350. /**
  74351. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74352. * @param min defines the new minimum vector (in local space)
  74353. * @param max defines the new maximum vector (in local space)
  74354. * @param worldMatrix defines the new world matrix
  74355. */
  74356. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74357. /**
  74358. * min vector of the bounding box/sphere
  74359. */
  74360. readonly minimum: Vector3;
  74361. /**
  74362. * max vector of the bounding box/sphere
  74363. */
  74364. readonly maximum: Vector3;
  74365. /**
  74366. * If the info is locked and won't be updated to avoid perf overhead
  74367. */
  74368. isLocked: boolean;
  74369. /**
  74370. * Updates the bounding sphere and box
  74371. * @param world world matrix to be used to update
  74372. */
  74373. update(world: DeepImmutable<Matrix>): void;
  74374. /**
  74375. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74376. * @param center New center of the bounding info
  74377. * @param extend New extend of the bounding info
  74378. * @returns the current bounding info
  74379. */
  74380. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74381. /**
  74382. * Scale the current bounding info by applying a scale factor
  74383. * @param factor defines the scale factor to apply
  74384. * @returns the current bounding info
  74385. */
  74386. scale(factor: number): BoundingInfo;
  74387. /**
  74388. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74389. * @param frustumPlanes defines the frustum to test
  74390. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74391. * @returns true if the bounding info is in the frustum planes
  74392. */
  74393. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74394. /**
  74395. * Gets the world distance between the min and max points of the bounding box
  74396. */
  74397. readonly diagonalLength: number;
  74398. /**
  74399. * Checks if a cullable object (mesh...) is in the camera frustum
  74400. * Unlike isInFrustum this cheks the full bounding box
  74401. * @param frustumPlanes Camera near/planes
  74402. * @returns true if the object is in frustum otherwise false
  74403. */
  74404. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74405. /** @hidden */
  74406. _checkCollision(collider: Collider): boolean;
  74407. /**
  74408. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74409. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74410. * @param point the point to check intersection with
  74411. * @returns if the point intersects
  74412. */
  74413. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74414. /**
  74415. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74416. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74417. * @param boundingInfo the bounding info to check intersection with
  74418. * @param precise if the intersection should be done using OBB
  74419. * @returns if the bounding info intersects
  74420. */
  74421. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74422. }
  74423. }
  74424. declare module BABYLON {
  74425. /**
  74426. * Extracts minimum and maximum values from a list of indexed positions
  74427. * @param positions defines the positions to use
  74428. * @param indices defines the indices to the positions
  74429. * @param indexStart defines the start index
  74430. * @param indexCount defines the end index
  74431. * @param bias defines bias value to add to the result
  74432. * @return minimum and maximum values
  74433. */
  74434. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74435. minimum: Vector3;
  74436. maximum: Vector3;
  74437. };
  74438. /**
  74439. * Extracts minimum and maximum values from a list of positions
  74440. * @param positions defines the positions to use
  74441. * @param start defines the start index in the positions array
  74442. * @param count defines the number of positions to handle
  74443. * @param bias defines bias value to add to the result
  74444. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74445. * @return minimum and maximum values
  74446. */
  74447. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74448. minimum: Vector3;
  74449. maximum: Vector3;
  74450. };
  74451. }
  74452. declare module BABYLON {
  74453. /** @hidden */
  74454. export class WebGLDataBuffer extends DataBuffer {
  74455. private _buffer;
  74456. constructor(resource: WebGLBuffer);
  74457. readonly underlyingResource: any;
  74458. }
  74459. }
  74460. declare module BABYLON {
  74461. /** @hidden */
  74462. export class WebGLPipelineContext implements IPipelineContext {
  74463. engine: ThinEngine;
  74464. program: Nullable<WebGLProgram>;
  74465. context?: WebGLRenderingContext;
  74466. vertexShader?: WebGLShader;
  74467. fragmentShader?: WebGLShader;
  74468. isParallelCompiled: boolean;
  74469. onCompiled?: () => void;
  74470. transformFeedback?: WebGLTransformFeedback | null;
  74471. readonly isAsync: boolean;
  74472. readonly isReady: boolean;
  74473. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74474. }
  74475. }
  74476. declare module BABYLON {
  74477. interface ThinEngine {
  74478. /**
  74479. * Create an uniform buffer
  74480. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74481. * @param elements defines the content of the uniform buffer
  74482. * @returns the webGL uniform buffer
  74483. */
  74484. createUniformBuffer(elements: FloatArray): DataBuffer;
  74485. /**
  74486. * Create a dynamic uniform buffer
  74487. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74488. * @param elements defines the content of the uniform buffer
  74489. * @returns the webGL uniform buffer
  74490. */
  74491. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74492. /**
  74493. * Update an existing uniform buffer
  74494. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74495. * @param uniformBuffer defines the target uniform buffer
  74496. * @param elements defines the content to update
  74497. * @param offset defines the offset in the uniform buffer where update should start
  74498. * @param count defines the size of the data to update
  74499. */
  74500. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74501. /**
  74502. * Bind an uniform buffer to the current webGL context
  74503. * @param buffer defines the buffer to bind
  74504. */
  74505. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74506. /**
  74507. * Bind a buffer to the current webGL context at a given location
  74508. * @param buffer defines the buffer to bind
  74509. * @param location defines the index where to bind the buffer
  74510. */
  74511. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74512. /**
  74513. * Bind a specific block at a given index in a specific shader program
  74514. * @param pipelineContext defines the pipeline context to use
  74515. * @param blockName defines the block name
  74516. * @param index defines the index where to bind the block
  74517. */
  74518. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74519. }
  74520. }
  74521. declare module BABYLON {
  74522. /**
  74523. * Uniform buffer objects.
  74524. *
  74525. * Handles blocks of uniform on the GPU.
  74526. *
  74527. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74528. *
  74529. * For more information, please refer to :
  74530. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74531. */
  74532. export class UniformBuffer {
  74533. private _engine;
  74534. private _buffer;
  74535. private _data;
  74536. private _bufferData;
  74537. private _dynamic?;
  74538. private _uniformLocations;
  74539. private _uniformSizes;
  74540. private _uniformLocationPointer;
  74541. private _needSync;
  74542. private _noUBO;
  74543. private _currentEffect;
  74544. /** @hidden */
  74545. _alreadyBound: boolean;
  74546. private static _MAX_UNIFORM_SIZE;
  74547. private static _tempBuffer;
  74548. /**
  74549. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74550. * This is dynamic to allow compat with webgl 1 and 2.
  74551. * You will need to pass the name of the uniform as well as the value.
  74552. */
  74553. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74554. /**
  74555. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74556. * This is dynamic to allow compat with webgl 1 and 2.
  74557. * You will need to pass the name of the uniform as well as the value.
  74558. */
  74559. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74560. /**
  74561. * Lambda to Update a single float in a uniform buffer.
  74562. * This is dynamic to allow compat with webgl 1 and 2.
  74563. * You will need to pass the name of the uniform as well as the value.
  74564. */
  74565. updateFloat: (name: string, x: number) => void;
  74566. /**
  74567. * Lambda to Update a vec2 of float in a uniform buffer.
  74568. * This is dynamic to allow compat with webgl 1 and 2.
  74569. * You will need to pass the name of the uniform as well as the value.
  74570. */
  74571. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74572. /**
  74573. * Lambda to Update a vec3 of float in a uniform buffer.
  74574. * This is dynamic to allow compat with webgl 1 and 2.
  74575. * You will need to pass the name of the uniform as well as the value.
  74576. */
  74577. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74578. /**
  74579. * Lambda to Update a vec4 of float in a uniform buffer.
  74580. * This is dynamic to allow compat with webgl 1 and 2.
  74581. * You will need to pass the name of the uniform as well as the value.
  74582. */
  74583. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74584. /**
  74585. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74586. * This is dynamic to allow compat with webgl 1 and 2.
  74587. * You will need to pass the name of the uniform as well as the value.
  74588. */
  74589. updateMatrix: (name: string, mat: Matrix) => void;
  74590. /**
  74591. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74592. * This is dynamic to allow compat with webgl 1 and 2.
  74593. * You will need to pass the name of the uniform as well as the value.
  74594. */
  74595. updateVector3: (name: string, vector: Vector3) => void;
  74596. /**
  74597. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74598. * This is dynamic to allow compat with webgl 1 and 2.
  74599. * You will need to pass the name of the uniform as well as the value.
  74600. */
  74601. updateVector4: (name: string, vector: Vector4) => void;
  74602. /**
  74603. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74604. * This is dynamic to allow compat with webgl 1 and 2.
  74605. * You will need to pass the name of the uniform as well as the value.
  74606. */
  74607. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74608. /**
  74609. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74610. * This is dynamic to allow compat with webgl 1 and 2.
  74611. * You will need to pass the name of the uniform as well as the value.
  74612. */
  74613. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74614. /**
  74615. * Instantiates a new Uniform buffer objects.
  74616. *
  74617. * Handles blocks of uniform on the GPU.
  74618. *
  74619. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74620. *
  74621. * For more information, please refer to :
  74622. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74623. * @param engine Define the engine the buffer is associated with
  74624. * @param data Define the data contained in the buffer
  74625. * @param dynamic Define if the buffer is updatable
  74626. */
  74627. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74628. /**
  74629. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74630. * or just falling back on setUniformXXX calls.
  74631. */
  74632. readonly useUbo: boolean;
  74633. /**
  74634. * Indicates if the WebGL underlying uniform buffer is in sync
  74635. * with the javascript cache data.
  74636. */
  74637. readonly isSync: boolean;
  74638. /**
  74639. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74640. * Also, a dynamic UniformBuffer will disable cache verification and always
  74641. * update the underlying WebGL uniform buffer to the GPU.
  74642. * @returns if Dynamic, otherwise false
  74643. */
  74644. isDynamic(): boolean;
  74645. /**
  74646. * The data cache on JS side.
  74647. * @returns the underlying data as a float array
  74648. */
  74649. getData(): Float32Array;
  74650. /**
  74651. * The underlying WebGL Uniform buffer.
  74652. * @returns the webgl buffer
  74653. */
  74654. getBuffer(): Nullable<DataBuffer>;
  74655. /**
  74656. * std140 layout specifies how to align data within an UBO structure.
  74657. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74658. * for specs.
  74659. */
  74660. private _fillAlignment;
  74661. /**
  74662. * Adds an uniform in the buffer.
  74663. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74664. * for the layout to be correct !
  74665. * @param name Name of the uniform, as used in the uniform block in the shader.
  74666. * @param size Data size, or data directly.
  74667. */
  74668. addUniform(name: string, size: number | number[]): void;
  74669. /**
  74670. * Adds a Matrix 4x4 to the uniform buffer.
  74671. * @param name Name of the uniform, as used in the uniform block in the shader.
  74672. * @param mat A 4x4 matrix.
  74673. */
  74674. addMatrix(name: string, mat: Matrix): void;
  74675. /**
  74676. * Adds a vec2 to the uniform buffer.
  74677. * @param name Name of the uniform, as used in the uniform block in the shader.
  74678. * @param x Define the x component value of the vec2
  74679. * @param y Define the y component value of the vec2
  74680. */
  74681. addFloat2(name: string, x: number, y: number): void;
  74682. /**
  74683. * Adds a vec3 to the uniform buffer.
  74684. * @param name Name of the uniform, as used in the uniform block in the shader.
  74685. * @param x Define the x component value of the vec3
  74686. * @param y Define the y component value of the vec3
  74687. * @param z Define the z component value of the vec3
  74688. */
  74689. addFloat3(name: string, x: number, y: number, z: number): void;
  74690. /**
  74691. * Adds a vec3 to the uniform buffer.
  74692. * @param name Name of the uniform, as used in the uniform block in the shader.
  74693. * @param color Define the vec3 from a Color
  74694. */
  74695. addColor3(name: string, color: Color3): void;
  74696. /**
  74697. * Adds a vec4 to the uniform buffer.
  74698. * @param name Name of the uniform, as used in the uniform block in the shader.
  74699. * @param color Define the rgb components from a Color
  74700. * @param alpha Define the a component of the vec4
  74701. */
  74702. addColor4(name: string, color: Color3, alpha: number): void;
  74703. /**
  74704. * Adds a vec3 to the uniform buffer.
  74705. * @param name Name of the uniform, as used in the uniform block in the shader.
  74706. * @param vector Define the vec3 components from a Vector
  74707. */
  74708. addVector3(name: string, vector: Vector3): void;
  74709. /**
  74710. * Adds a Matrix 3x3 to the uniform buffer.
  74711. * @param name Name of the uniform, as used in the uniform block in the shader.
  74712. */
  74713. addMatrix3x3(name: string): void;
  74714. /**
  74715. * Adds a Matrix 2x2 to the uniform buffer.
  74716. * @param name Name of the uniform, as used in the uniform block in the shader.
  74717. */
  74718. addMatrix2x2(name: string): void;
  74719. /**
  74720. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74721. */
  74722. create(): void;
  74723. /** @hidden */
  74724. _rebuild(): void;
  74725. /**
  74726. * Updates the WebGL Uniform Buffer on the GPU.
  74727. * If the `dynamic` flag is set to true, no cache comparison is done.
  74728. * Otherwise, the buffer will be updated only if the cache differs.
  74729. */
  74730. update(): void;
  74731. /**
  74732. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74733. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74734. * @param data Define the flattened data
  74735. * @param size Define the size of the data.
  74736. */
  74737. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74738. private _valueCache;
  74739. private _cacheMatrix;
  74740. private _updateMatrix3x3ForUniform;
  74741. private _updateMatrix3x3ForEffect;
  74742. private _updateMatrix2x2ForEffect;
  74743. private _updateMatrix2x2ForUniform;
  74744. private _updateFloatForEffect;
  74745. private _updateFloatForUniform;
  74746. private _updateFloat2ForEffect;
  74747. private _updateFloat2ForUniform;
  74748. private _updateFloat3ForEffect;
  74749. private _updateFloat3ForUniform;
  74750. private _updateFloat4ForEffect;
  74751. private _updateFloat4ForUniform;
  74752. private _updateMatrixForEffect;
  74753. private _updateMatrixForUniform;
  74754. private _updateVector3ForEffect;
  74755. private _updateVector3ForUniform;
  74756. private _updateVector4ForEffect;
  74757. private _updateVector4ForUniform;
  74758. private _updateColor3ForEffect;
  74759. private _updateColor3ForUniform;
  74760. private _updateColor4ForEffect;
  74761. private _updateColor4ForUniform;
  74762. /**
  74763. * Sets a sampler uniform on the effect.
  74764. * @param name Define the name of the sampler.
  74765. * @param texture Define the texture to set in the sampler
  74766. */
  74767. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74768. /**
  74769. * Directly updates the value of the uniform in the cache AND on the GPU.
  74770. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74771. * @param data Define the flattened data
  74772. */
  74773. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74774. /**
  74775. * Binds this uniform buffer to an effect.
  74776. * @param effect Define the effect to bind the buffer to
  74777. * @param name Name of the uniform block in the shader.
  74778. */
  74779. bindToEffect(effect: Effect, name: string): void;
  74780. /**
  74781. * Disposes the uniform buffer.
  74782. */
  74783. dispose(): void;
  74784. }
  74785. }
  74786. declare module BABYLON {
  74787. /**
  74788. * Enum that determines the text-wrapping mode to use.
  74789. */
  74790. export enum InspectableType {
  74791. /**
  74792. * Checkbox for booleans
  74793. */
  74794. Checkbox = 0,
  74795. /**
  74796. * Sliders for numbers
  74797. */
  74798. Slider = 1,
  74799. /**
  74800. * Vector3
  74801. */
  74802. Vector3 = 2,
  74803. /**
  74804. * Quaternions
  74805. */
  74806. Quaternion = 3,
  74807. /**
  74808. * Color3
  74809. */
  74810. Color3 = 4,
  74811. /**
  74812. * String
  74813. */
  74814. String = 5
  74815. }
  74816. /**
  74817. * Interface used to define custom inspectable properties.
  74818. * This interface is used by the inspector to display custom property grids
  74819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74820. */
  74821. export interface IInspectable {
  74822. /**
  74823. * Gets the label to display
  74824. */
  74825. label: string;
  74826. /**
  74827. * Gets the name of the property to edit
  74828. */
  74829. propertyName: string;
  74830. /**
  74831. * Gets the type of the editor to use
  74832. */
  74833. type: InspectableType;
  74834. /**
  74835. * Gets the minimum value of the property when using in "slider" mode
  74836. */
  74837. min?: number;
  74838. /**
  74839. * Gets the maximum value of the property when using in "slider" mode
  74840. */
  74841. max?: number;
  74842. /**
  74843. * Gets the setp to use when using in "slider" mode
  74844. */
  74845. step?: number;
  74846. }
  74847. }
  74848. declare module BABYLON {
  74849. /**
  74850. * Class used to provide helper for timing
  74851. */
  74852. export class TimingTools {
  74853. /**
  74854. * Polyfill for setImmediate
  74855. * @param action defines the action to execute after the current execution block
  74856. */
  74857. static SetImmediate(action: () => void): void;
  74858. }
  74859. }
  74860. declare module BABYLON {
  74861. /**
  74862. * Class used to enable instatition of objects by class name
  74863. */
  74864. export class InstantiationTools {
  74865. /**
  74866. * Use this object to register external classes like custom textures or material
  74867. * to allow the laoders to instantiate them
  74868. */
  74869. static RegisteredExternalClasses: {
  74870. [key: string]: Object;
  74871. };
  74872. /**
  74873. * Tries to instantiate a new object from a given class name
  74874. * @param className defines the class name to instantiate
  74875. * @returns the new object or null if the system was not able to do the instantiation
  74876. */
  74877. static Instantiate(className: string): any;
  74878. }
  74879. }
  74880. declare module BABYLON {
  74881. /**
  74882. * Define options used to create a depth texture
  74883. */
  74884. export class DepthTextureCreationOptions {
  74885. /** Specifies whether or not a stencil should be allocated in the texture */
  74886. generateStencil?: boolean;
  74887. /** Specifies whether or not bilinear filtering is enable on the texture */
  74888. bilinearFiltering?: boolean;
  74889. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74890. comparisonFunction?: number;
  74891. /** Specifies if the created texture is a cube texture */
  74892. isCube?: boolean;
  74893. }
  74894. }
  74895. declare module BABYLON {
  74896. interface ThinEngine {
  74897. /**
  74898. * Creates a depth stencil cube texture.
  74899. * This is only available in WebGL 2.
  74900. * @param size The size of face edge in the cube texture.
  74901. * @param options The options defining the cube texture.
  74902. * @returns The cube texture
  74903. */
  74904. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74905. /**
  74906. * Creates a cube texture
  74907. * @param rootUrl defines the url where the files to load is located
  74908. * @param scene defines the current scene
  74909. * @param files defines the list of files to load (1 per face)
  74910. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74911. * @param onLoad defines an optional callback raised when the texture is loaded
  74912. * @param onError defines an optional callback raised if there is an issue to load the texture
  74913. * @param format defines the format of the data
  74914. * @param forcedExtension defines the extension to use to pick the right loader
  74915. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74916. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74917. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74918. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74919. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74920. * @returns the cube texture as an InternalTexture
  74921. */
  74922. 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;
  74923. /**
  74924. * Creates a cube texture
  74925. * @param rootUrl defines the url where the files to load is located
  74926. * @param scene defines the current scene
  74927. * @param files defines the list of files to load (1 per face)
  74928. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74929. * @param onLoad defines an optional callback raised when the texture is loaded
  74930. * @param onError defines an optional callback raised if there is an issue to load the texture
  74931. * @param format defines the format of the data
  74932. * @param forcedExtension defines the extension to use to pick the right loader
  74933. * @returns the cube texture as an InternalTexture
  74934. */
  74935. 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;
  74936. /**
  74937. * Creates a cube texture
  74938. * @param rootUrl defines the url where the files to load is located
  74939. * @param scene defines the current scene
  74940. * @param files defines the list of files to load (1 per face)
  74941. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74942. * @param onLoad defines an optional callback raised when the texture is loaded
  74943. * @param onError defines an optional callback raised if there is an issue to load the texture
  74944. * @param format defines the format of the data
  74945. * @param forcedExtension defines the extension to use to pick the right loader
  74946. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74949. * @returns the cube texture as an InternalTexture
  74950. */
  74951. 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;
  74952. /** @hidden */
  74953. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74954. /** @hidden */
  74955. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74956. /** @hidden */
  74957. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74958. /** @hidden */
  74959. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74960. /**
  74961. * @hidden
  74962. */
  74963. _setCubeMapTextureParams(loadMipmap: boolean): void;
  74964. }
  74965. }
  74966. declare module BABYLON {
  74967. /**
  74968. * Class for creating a cube texture
  74969. */
  74970. export class CubeTexture extends BaseTexture {
  74971. private _delayedOnLoad;
  74972. /**
  74973. * The url of the texture
  74974. */
  74975. url: string;
  74976. /**
  74977. * Gets or sets the center of the bounding box associated with the cube texture.
  74978. * It must define where the camera used to render the texture was set
  74979. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74980. */
  74981. boundingBoxPosition: Vector3;
  74982. private _boundingBoxSize;
  74983. /**
  74984. * Gets or sets the size of the bounding box associated with the cube texture
  74985. * When defined, the cubemap will switch to local mode
  74986. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74987. * @example https://www.babylonjs-playground.com/#RNASML
  74988. */
  74989. /**
  74990. * Returns the bounding box size
  74991. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74992. */
  74993. boundingBoxSize: Vector3;
  74994. protected _rotationY: number;
  74995. /**
  74996. * Sets texture matrix rotation angle around Y axis in radians.
  74997. */
  74998. /**
  74999. * Gets texture matrix rotation angle around Y axis radians.
  75000. */
  75001. rotationY: number;
  75002. /**
  75003. * Are mip maps generated for this texture or not.
  75004. */
  75005. readonly noMipmap: boolean;
  75006. private _noMipmap;
  75007. private _files;
  75008. protected _forcedExtension: Nullable<string>;
  75009. private _extensions;
  75010. private _textureMatrix;
  75011. private _format;
  75012. private _createPolynomials;
  75013. /** @hidden */
  75014. _prefiltered: boolean;
  75015. /**
  75016. * Creates a cube texture from an array of image urls
  75017. * @param files defines an array of image urls
  75018. * @param scene defines the hosting scene
  75019. * @param noMipmap specifies if mip maps are not used
  75020. * @returns a cube texture
  75021. */
  75022. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75023. /**
  75024. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75025. * @param url defines the url of the prefiltered texture
  75026. * @param scene defines the scene the texture is attached to
  75027. * @param forcedExtension defines the extension of the file if different from the url
  75028. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75029. * @return the prefiltered texture
  75030. */
  75031. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75032. /**
  75033. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75034. * as prefiltered data.
  75035. * @param rootUrl defines the url of the texture or the root name of the six images
  75036. * @param scene defines the scene the texture is attached to
  75037. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75038. * @param noMipmap defines if mipmaps should be created or not
  75039. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75040. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75041. * @param onError defines a callback triggered in case of error during load
  75042. * @param format defines the internal format to use for the texture once loaded
  75043. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75044. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75045. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75046. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75047. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75048. * @return the cube texture
  75049. */
  75050. 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);
  75051. /**
  75052. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75053. */
  75054. readonly isPrefiltered: boolean;
  75055. /**
  75056. * Get the current class name of the texture useful for serialization or dynamic coding.
  75057. * @returns "CubeTexture"
  75058. */
  75059. getClassName(): string;
  75060. /**
  75061. * Update the url (and optional buffer) of this texture if url was null during construction.
  75062. * @param url the url of the texture
  75063. * @param forcedExtension defines the extension to use
  75064. * @param onLoad callback called when the texture is loaded (defaults to null)
  75065. */
  75066. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75067. /**
  75068. * Delays loading of the cube texture
  75069. * @param forcedExtension defines the extension to use
  75070. */
  75071. delayLoad(forcedExtension?: string): void;
  75072. /**
  75073. * Returns the reflection texture matrix
  75074. * @returns the reflection texture matrix
  75075. */
  75076. getReflectionTextureMatrix(): Matrix;
  75077. /**
  75078. * Sets the reflection texture matrix
  75079. * @param value Reflection texture matrix
  75080. */
  75081. setReflectionTextureMatrix(value: Matrix): void;
  75082. /**
  75083. * Parses text to create a cube texture
  75084. * @param parsedTexture define the serialized text to read from
  75085. * @param scene defines the hosting scene
  75086. * @param rootUrl defines the root url of the cube texture
  75087. * @returns a cube texture
  75088. */
  75089. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75090. /**
  75091. * Makes a clone, or deep copy, of the cube texture
  75092. * @returns a new cube texture
  75093. */
  75094. clone(): CubeTexture;
  75095. }
  75096. }
  75097. declare module BABYLON {
  75098. /**
  75099. * Manages the defines for the Material
  75100. */
  75101. export class MaterialDefines {
  75102. /** @hidden */
  75103. protected _keys: string[];
  75104. private _isDirty;
  75105. /** @hidden */
  75106. _renderId: number;
  75107. /** @hidden */
  75108. _areLightsDirty: boolean;
  75109. /** @hidden */
  75110. _areLightsDisposed: boolean;
  75111. /** @hidden */
  75112. _areAttributesDirty: boolean;
  75113. /** @hidden */
  75114. _areTexturesDirty: boolean;
  75115. /** @hidden */
  75116. _areFresnelDirty: boolean;
  75117. /** @hidden */
  75118. _areMiscDirty: boolean;
  75119. /** @hidden */
  75120. _areImageProcessingDirty: boolean;
  75121. /** @hidden */
  75122. _normals: boolean;
  75123. /** @hidden */
  75124. _uvs: boolean;
  75125. /** @hidden */
  75126. _needNormals: boolean;
  75127. /** @hidden */
  75128. _needUVs: boolean;
  75129. [id: string]: any;
  75130. /**
  75131. * Specifies if the material needs to be re-calculated
  75132. */
  75133. readonly isDirty: boolean;
  75134. /**
  75135. * Marks the material to indicate that it has been re-calculated
  75136. */
  75137. markAsProcessed(): void;
  75138. /**
  75139. * Marks the material to indicate that it needs to be re-calculated
  75140. */
  75141. markAsUnprocessed(): void;
  75142. /**
  75143. * Marks the material to indicate all of its defines need to be re-calculated
  75144. */
  75145. markAllAsDirty(): void;
  75146. /**
  75147. * Marks the material to indicate that image processing needs to be re-calculated
  75148. */
  75149. markAsImageProcessingDirty(): void;
  75150. /**
  75151. * Marks the material to indicate the lights need to be re-calculated
  75152. * @param disposed Defines whether the light is dirty due to dispose or not
  75153. */
  75154. markAsLightDirty(disposed?: boolean): void;
  75155. /**
  75156. * Marks the attribute state as changed
  75157. */
  75158. markAsAttributesDirty(): void;
  75159. /**
  75160. * Marks the texture state as changed
  75161. */
  75162. markAsTexturesDirty(): void;
  75163. /**
  75164. * Marks the fresnel state as changed
  75165. */
  75166. markAsFresnelDirty(): void;
  75167. /**
  75168. * Marks the misc state as changed
  75169. */
  75170. markAsMiscDirty(): void;
  75171. /**
  75172. * Rebuilds the material defines
  75173. */
  75174. rebuild(): void;
  75175. /**
  75176. * Specifies if two material defines are equal
  75177. * @param other - A material define instance to compare to
  75178. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75179. */
  75180. isEqual(other: MaterialDefines): boolean;
  75181. /**
  75182. * Clones this instance's defines to another instance
  75183. * @param other - material defines to clone values to
  75184. */
  75185. cloneTo(other: MaterialDefines): void;
  75186. /**
  75187. * Resets the material define values
  75188. */
  75189. reset(): void;
  75190. /**
  75191. * Converts the material define values to a string
  75192. * @returns - String of material define information
  75193. */
  75194. toString(): string;
  75195. }
  75196. }
  75197. declare module BABYLON {
  75198. /**
  75199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75201. * 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;
  75202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75203. */
  75204. export class ColorCurves {
  75205. private _dirty;
  75206. private _tempColor;
  75207. private _globalCurve;
  75208. private _highlightsCurve;
  75209. private _midtonesCurve;
  75210. private _shadowsCurve;
  75211. private _positiveCurve;
  75212. private _negativeCurve;
  75213. private _globalHue;
  75214. private _globalDensity;
  75215. private _globalSaturation;
  75216. private _globalExposure;
  75217. /**
  75218. * Gets the global Hue value.
  75219. * 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).
  75220. */
  75221. /**
  75222. * Sets the global Hue value.
  75223. * 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).
  75224. */
  75225. globalHue: number;
  75226. /**
  75227. * Gets the global Density value.
  75228. * 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.
  75229. * Values less than zero provide a filter of opposite hue.
  75230. */
  75231. /**
  75232. * Sets the global Density value.
  75233. * 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.
  75234. * Values less than zero provide a filter of opposite hue.
  75235. */
  75236. globalDensity: number;
  75237. /**
  75238. * Gets the global Saturation value.
  75239. * 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.
  75240. */
  75241. /**
  75242. * Sets the global Saturation value.
  75243. * 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.
  75244. */
  75245. globalSaturation: number;
  75246. /**
  75247. * Gets the global Exposure value.
  75248. * 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.
  75249. */
  75250. /**
  75251. * Sets the global Exposure value.
  75252. * 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.
  75253. */
  75254. globalExposure: number;
  75255. private _highlightsHue;
  75256. private _highlightsDensity;
  75257. private _highlightsSaturation;
  75258. private _highlightsExposure;
  75259. /**
  75260. * Gets the highlights Hue value.
  75261. * 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).
  75262. */
  75263. /**
  75264. * Sets the highlights Hue value.
  75265. * 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).
  75266. */
  75267. highlightsHue: number;
  75268. /**
  75269. * Gets the highlights Density value.
  75270. * 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.
  75271. * Values less than zero provide a filter of opposite hue.
  75272. */
  75273. /**
  75274. * Sets the highlights Density value.
  75275. * 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.
  75276. * Values less than zero provide a filter of opposite hue.
  75277. */
  75278. highlightsDensity: number;
  75279. /**
  75280. * Gets the highlights Saturation value.
  75281. * 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.
  75282. */
  75283. /**
  75284. * Sets the highlights Saturation value.
  75285. * 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.
  75286. */
  75287. highlightsSaturation: number;
  75288. /**
  75289. * Gets the highlights Exposure value.
  75290. * 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.
  75291. */
  75292. /**
  75293. * Sets the highlights Exposure value.
  75294. * 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.
  75295. */
  75296. highlightsExposure: number;
  75297. private _midtonesHue;
  75298. private _midtonesDensity;
  75299. private _midtonesSaturation;
  75300. private _midtonesExposure;
  75301. /**
  75302. * Gets the midtones Hue value.
  75303. * 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).
  75304. */
  75305. /**
  75306. * Sets the midtones Hue value.
  75307. * 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).
  75308. */
  75309. midtonesHue: number;
  75310. /**
  75311. * Gets the midtones Density value.
  75312. * 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.
  75313. * Values less than zero provide a filter of opposite hue.
  75314. */
  75315. /**
  75316. * Sets the midtones Density value.
  75317. * 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.
  75318. * Values less than zero provide a filter of opposite hue.
  75319. */
  75320. midtonesDensity: number;
  75321. /**
  75322. * Gets the midtones Saturation value.
  75323. * 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.
  75324. */
  75325. /**
  75326. * Sets the midtones Saturation value.
  75327. * 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.
  75328. */
  75329. midtonesSaturation: number;
  75330. /**
  75331. * Gets the midtones Exposure value.
  75332. * 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.
  75333. */
  75334. /**
  75335. * Sets the midtones Exposure value.
  75336. * 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.
  75337. */
  75338. midtonesExposure: number;
  75339. private _shadowsHue;
  75340. private _shadowsDensity;
  75341. private _shadowsSaturation;
  75342. private _shadowsExposure;
  75343. /**
  75344. * Gets the shadows Hue value.
  75345. * 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).
  75346. */
  75347. /**
  75348. * Sets the shadows Hue value.
  75349. * 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).
  75350. */
  75351. shadowsHue: number;
  75352. /**
  75353. * Gets the shadows Density value.
  75354. * 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.
  75355. * Values less than zero provide a filter of opposite hue.
  75356. */
  75357. /**
  75358. * Sets the shadows Density value.
  75359. * 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.
  75360. * Values less than zero provide a filter of opposite hue.
  75361. */
  75362. shadowsDensity: number;
  75363. /**
  75364. * Gets the shadows Saturation value.
  75365. * 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.
  75366. */
  75367. /**
  75368. * Sets the shadows Saturation value.
  75369. * 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.
  75370. */
  75371. shadowsSaturation: number;
  75372. /**
  75373. * Gets the shadows Exposure value.
  75374. * 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.
  75375. */
  75376. /**
  75377. * Sets the shadows Exposure value.
  75378. * 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.
  75379. */
  75380. shadowsExposure: number;
  75381. /**
  75382. * Returns the class name
  75383. * @returns The class name
  75384. */
  75385. getClassName(): string;
  75386. /**
  75387. * Binds the color curves to the shader.
  75388. * @param colorCurves The color curve to bind
  75389. * @param effect The effect to bind to
  75390. * @param positiveUniform The positive uniform shader parameter
  75391. * @param neutralUniform The neutral uniform shader parameter
  75392. * @param negativeUniform The negative uniform shader parameter
  75393. */
  75394. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75395. /**
  75396. * Prepare the list of uniforms associated with the ColorCurves effects.
  75397. * @param uniformsList The list of uniforms used in the effect
  75398. */
  75399. static PrepareUniforms(uniformsList: string[]): void;
  75400. /**
  75401. * Returns color grading data based on a hue, density, saturation and exposure value.
  75402. * @param filterHue The hue of the color filter.
  75403. * @param filterDensity The density of the color filter.
  75404. * @param saturation The saturation.
  75405. * @param exposure The exposure.
  75406. * @param result The result data container.
  75407. */
  75408. private getColorGradingDataToRef;
  75409. /**
  75410. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75411. * @param value The input slider value in range [-100,100].
  75412. * @returns Adjusted value.
  75413. */
  75414. private static applyColorGradingSliderNonlinear;
  75415. /**
  75416. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75417. * @param hue The hue (H) input.
  75418. * @param saturation The saturation (S) input.
  75419. * @param brightness The brightness (B) input.
  75420. * @result An RGBA color represented as Vector4.
  75421. */
  75422. private static fromHSBToRef;
  75423. /**
  75424. * Returns a value clamped between min and max
  75425. * @param value The value to clamp
  75426. * @param min The minimum of value
  75427. * @param max The maximum of value
  75428. * @returns The clamped value.
  75429. */
  75430. private static clamp;
  75431. /**
  75432. * Clones the current color curve instance.
  75433. * @return The cloned curves
  75434. */
  75435. clone(): ColorCurves;
  75436. /**
  75437. * Serializes the current color curve instance to a json representation.
  75438. * @return a JSON representation
  75439. */
  75440. serialize(): any;
  75441. /**
  75442. * Parses the color curve from a json representation.
  75443. * @param source the JSON source to parse
  75444. * @return The parsed curves
  75445. */
  75446. static Parse(source: any): ColorCurves;
  75447. }
  75448. }
  75449. declare module BABYLON {
  75450. /**
  75451. * Interface to follow in your material defines to integrate easily the
  75452. * Image proccessing functions.
  75453. * @hidden
  75454. */
  75455. export interface IImageProcessingConfigurationDefines {
  75456. IMAGEPROCESSING: boolean;
  75457. VIGNETTE: boolean;
  75458. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75459. VIGNETTEBLENDMODEOPAQUE: boolean;
  75460. TONEMAPPING: boolean;
  75461. TONEMAPPING_ACES: boolean;
  75462. CONTRAST: boolean;
  75463. EXPOSURE: boolean;
  75464. COLORCURVES: boolean;
  75465. COLORGRADING: boolean;
  75466. COLORGRADING3D: boolean;
  75467. SAMPLER3DGREENDEPTH: boolean;
  75468. SAMPLER3DBGRMAP: boolean;
  75469. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75470. }
  75471. /**
  75472. * @hidden
  75473. */
  75474. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75475. IMAGEPROCESSING: boolean;
  75476. VIGNETTE: boolean;
  75477. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75478. VIGNETTEBLENDMODEOPAQUE: boolean;
  75479. TONEMAPPING: boolean;
  75480. TONEMAPPING_ACES: boolean;
  75481. CONTRAST: boolean;
  75482. COLORCURVES: boolean;
  75483. COLORGRADING: boolean;
  75484. COLORGRADING3D: boolean;
  75485. SAMPLER3DGREENDEPTH: boolean;
  75486. SAMPLER3DBGRMAP: boolean;
  75487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75488. EXPOSURE: boolean;
  75489. constructor();
  75490. }
  75491. /**
  75492. * This groups together the common properties used for image processing either in direct forward pass
  75493. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75494. * or not.
  75495. */
  75496. export class ImageProcessingConfiguration {
  75497. /**
  75498. * Default tone mapping applied in BabylonJS.
  75499. */
  75500. static readonly TONEMAPPING_STANDARD: number;
  75501. /**
  75502. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75503. * to other engines rendering to increase portability.
  75504. */
  75505. static readonly TONEMAPPING_ACES: number;
  75506. /**
  75507. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75508. */
  75509. colorCurves: Nullable<ColorCurves>;
  75510. private _colorCurvesEnabled;
  75511. /**
  75512. * Gets wether the color curves effect is enabled.
  75513. */
  75514. /**
  75515. * Sets wether the color curves effect is enabled.
  75516. */
  75517. colorCurvesEnabled: boolean;
  75518. private _colorGradingTexture;
  75519. /**
  75520. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75521. */
  75522. /**
  75523. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75524. */
  75525. colorGradingTexture: Nullable<BaseTexture>;
  75526. private _colorGradingEnabled;
  75527. /**
  75528. * Gets wether the color grading effect is enabled.
  75529. */
  75530. /**
  75531. * Sets wether the color grading effect is enabled.
  75532. */
  75533. colorGradingEnabled: boolean;
  75534. private _colorGradingWithGreenDepth;
  75535. /**
  75536. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75537. */
  75538. /**
  75539. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75540. */
  75541. colorGradingWithGreenDepth: boolean;
  75542. private _colorGradingBGR;
  75543. /**
  75544. * Gets wether the color grading texture contains BGR values.
  75545. */
  75546. /**
  75547. * Sets wether the color grading texture contains BGR values.
  75548. */
  75549. colorGradingBGR: boolean;
  75550. /** @hidden */
  75551. _exposure: number;
  75552. /**
  75553. * Gets the Exposure used in the effect.
  75554. */
  75555. /**
  75556. * Sets the Exposure used in the effect.
  75557. */
  75558. exposure: number;
  75559. private _toneMappingEnabled;
  75560. /**
  75561. * Gets wether the tone mapping effect is enabled.
  75562. */
  75563. /**
  75564. * Sets wether the tone mapping effect is enabled.
  75565. */
  75566. toneMappingEnabled: boolean;
  75567. private _toneMappingType;
  75568. /**
  75569. * Gets the type of tone mapping effect.
  75570. */
  75571. /**
  75572. * Sets the type of tone mapping effect used in BabylonJS.
  75573. */
  75574. toneMappingType: number;
  75575. protected _contrast: number;
  75576. /**
  75577. * Gets the contrast used in the effect.
  75578. */
  75579. /**
  75580. * Sets the contrast used in the effect.
  75581. */
  75582. contrast: number;
  75583. /**
  75584. * Vignette stretch size.
  75585. */
  75586. vignetteStretch: number;
  75587. /**
  75588. * Vignette centre X Offset.
  75589. */
  75590. vignetteCentreX: number;
  75591. /**
  75592. * Vignette centre Y Offset.
  75593. */
  75594. vignetteCentreY: number;
  75595. /**
  75596. * Vignette weight or intensity of the vignette effect.
  75597. */
  75598. vignetteWeight: number;
  75599. /**
  75600. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75601. * if vignetteEnabled is set to true.
  75602. */
  75603. vignetteColor: Color4;
  75604. /**
  75605. * Camera field of view used by the Vignette effect.
  75606. */
  75607. vignetteCameraFov: number;
  75608. private _vignetteBlendMode;
  75609. /**
  75610. * Gets the vignette blend mode allowing different kind of effect.
  75611. */
  75612. /**
  75613. * Sets the vignette blend mode allowing different kind of effect.
  75614. */
  75615. vignetteBlendMode: number;
  75616. private _vignetteEnabled;
  75617. /**
  75618. * Gets wether the vignette effect is enabled.
  75619. */
  75620. /**
  75621. * Sets wether the vignette effect is enabled.
  75622. */
  75623. vignetteEnabled: boolean;
  75624. private _applyByPostProcess;
  75625. /**
  75626. * Gets wether the image processing is applied through a post process or not.
  75627. */
  75628. /**
  75629. * Sets wether the image processing is applied through a post process or not.
  75630. */
  75631. applyByPostProcess: boolean;
  75632. private _isEnabled;
  75633. /**
  75634. * Gets wether the image processing is enabled or not.
  75635. */
  75636. /**
  75637. * Sets wether the image processing is enabled or not.
  75638. */
  75639. isEnabled: boolean;
  75640. /**
  75641. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75642. */
  75643. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75644. /**
  75645. * Method called each time the image processing information changes requires to recompile the effect.
  75646. */
  75647. protected _updateParameters(): void;
  75648. /**
  75649. * Gets the current class name.
  75650. * @return "ImageProcessingConfiguration"
  75651. */
  75652. getClassName(): string;
  75653. /**
  75654. * Prepare the list of uniforms associated with the Image Processing effects.
  75655. * @param uniforms The list of uniforms used in the effect
  75656. * @param defines the list of defines currently in use
  75657. */
  75658. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75659. /**
  75660. * Prepare the list of samplers associated with the Image Processing effects.
  75661. * @param samplersList The list of uniforms used in the effect
  75662. * @param defines the list of defines currently in use
  75663. */
  75664. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75665. /**
  75666. * Prepare the list of defines associated to the shader.
  75667. * @param defines the list of defines to complete
  75668. * @param forPostProcess Define if we are currently in post process mode or not
  75669. */
  75670. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75671. /**
  75672. * Returns true if all the image processing information are ready.
  75673. * @returns True if ready, otherwise, false
  75674. */
  75675. isReady(): boolean;
  75676. /**
  75677. * Binds the image processing to the shader.
  75678. * @param effect The effect to bind to
  75679. * @param aspectRatio Define the current aspect ratio of the effect
  75680. */
  75681. bind(effect: Effect, aspectRatio?: number): void;
  75682. /**
  75683. * Clones the current image processing instance.
  75684. * @return The cloned image processing
  75685. */
  75686. clone(): ImageProcessingConfiguration;
  75687. /**
  75688. * Serializes the current image processing instance to a json representation.
  75689. * @return a JSON representation
  75690. */
  75691. serialize(): any;
  75692. /**
  75693. * Parses the image processing from a json representation.
  75694. * @param source the JSON source to parse
  75695. * @return The parsed image processing
  75696. */
  75697. static Parse(source: any): ImageProcessingConfiguration;
  75698. private static _VIGNETTEMODE_MULTIPLY;
  75699. private static _VIGNETTEMODE_OPAQUE;
  75700. /**
  75701. * Used to apply the vignette as a mix with the pixel color.
  75702. */
  75703. static readonly VIGNETTEMODE_MULTIPLY: number;
  75704. /**
  75705. * Used to apply the vignette as a replacement of the pixel color.
  75706. */
  75707. static readonly VIGNETTEMODE_OPAQUE: number;
  75708. }
  75709. }
  75710. declare module BABYLON {
  75711. /** @hidden */
  75712. export var postprocessVertexShader: {
  75713. name: string;
  75714. shader: string;
  75715. };
  75716. }
  75717. declare module BABYLON {
  75718. interface ThinEngine {
  75719. /**
  75720. * Creates a new render target texture
  75721. * @param size defines the size of the texture
  75722. * @param options defines the options used to create the texture
  75723. * @returns a new render target texture stored in an InternalTexture
  75724. */
  75725. createRenderTargetTexture(size: number | {
  75726. width: number;
  75727. height: number;
  75728. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75729. /**
  75730. * Creates a depth stencil texture.
  75731. * This is only available in WebGL 2 or with the depth texture extension available.
  75732. * @param size The size of face edge in the texture.
  75733. * @param options The options defining the texture.
  75734. * @returns The texture
  75735. */
  75736. createDepthStencilTexture(size: number | {
  75737. width: number;
  75738. height: number;
  75739. }, options: DepthTextureCreationOptions): InternalTexture;
  75740. /** @hidden */
  75741. _createDepthStencilTexture(size: number | {
  75742. width: number;
  75743. height: number;
  75744. }, options: DepthTextureCreationOptions): InternalTexture;
  75745. }
  75746. }
  75747. declare module BABYLON {
  75748. /** Defines supported spaces */
  75749. export enum Space {
  75750. /** Local (object) space */
  75751. LOCAL = 0,
  75752. /** World space */
  75753. WORLD = 1,
  75754. /** Bone space */
  75755. BONE = 2
  75756. }
  75757. /** Defines the 3 main axes */
  75758. export class Axis {
  75759. /** X axis */
  75760. static X: Vector3;
  75761. /** Y axis */
  75762. static Y: Vector3;
  75763. /** Z axis */
  75764. static Z: Vector3;
  75765. }
  75766. }
  75767. declare module BABYLON {
  75768. /**
  75769. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75770. * This is the base of the follow, arc rotate cameras and Free camera
  75771. * @see http://doc.babylonjs.com/features/cameras
  75772. */
  75773. export class TargetCamera extends Camera {
  75774. private static _RigCamTransformMatrix;
  75775. private static _TargetTransformMatrix;
  75776. private static _TargetFocalPoint;
  75777. /**
  75778. * Define the current direction the camera is moving to
  75779. */
  75780. cameraDirection: Vector3;
  75781. /**
  75782. * Define the current rotation the camera is rotating to
  75783. */
  75784. cameraRotation: Vector2;
  75785. /**
  75786. * When set, the up vector of the camera will be updated by the rotation of the camera
  75787. */
  75788. updateUpVectorFromRotation: boolean;
  75789. private _tmpQuaternion;
  75790. /**
  75791. * Define the current rotation of the camera
  75792. */
  75793. rotation: Vector3;
  75794. /**
  75795. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75796. */
  75797. rotationQuaternion: Quaternion;
  75798. /**
  75799. * Define the current speed of the camera
  75800. */
  75801. speed: number;
  75802. /**
  75803. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75804. * around all axis.
  75805. */
  75806. noRotationConstraint: boolean;
  75807. /**
  75808. * Define the current target of the camera as an object or a position.
  75809. */
  75810. lockedTarget: any;
  75811. /** @hidden */
  75812. _currentTarget: Vector3;
  75813. /** @hidden */
  75814. _initialFocalDistance: number;
  75815. /** @hidden */
  75816. _viewMatrix: Matrix;
  75817. /** @hidden */
  75818. _camMatrix: Matrix;
  75819. /** @hidden */
  75820. _cameraTransformMatrix: Matrix;
  75821. /** @hidden */
  75822. _cameraRotationMatrix: Matrix;
  75823. /** @hidden */
  75824. _referencePoint: Vector3;
  75825. /** @hidden */
  75826. _transformedReferencePoint: Vector3;
  75827. protected _globalCurrentTarget: Vector3;
  75828. protected _globalCurrentUpVector: Vector3;
  75829. /** @hidden */
  75830. _reset: () => void;
  75831. private _defaultUp;
  75832. /**
  75833. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75834. * This is the base of the follow, arc rotate cameras and Free camera
  75835. * @see http://doc.babylonjs.com/features/cameras
  75836. * @param name Defines the name of the camera in the scene
  75837. * @param position Defines the start position of the camera in the scene
  75838. * @param scene Defines the scene the camera belongs to
  75839. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75840. */
  75841. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75842. /**
  75843. * Gets the position in front of the camera at a given distance.
  75844. * @param distance The distance from the camera we want the position to be
  75845. * @returns the position
  75846. */
  75847. getFrontPosition(distance: number): Vector3;
  75848. /** @hidden */
  75849. _getLockedTargetPosition(): Nullable<Vector3>;
  75850. private _storedPosition;
  75851. private _storedRotation;
  75852. private _storedRotationQuaternion;
  75853. /**
  75854. * Store current camera state of the camera (fov, position, rotation, etc..)
  75855. * @returns the camera
  75856. */
  75857. storeState(): Camera;
  75858. /**
  75859. * Restored camera state. You must call storeState() first
  75860. * @returns whether it was successful or not
  75861. * @hidden
  75862. */
  75863. _restoreStateValues(): boolean;
  75864. /** @hidden */
  75865. _initCache(): void;
  75866. /** @hidden */
  75867. _updateCache(ignoreParentClass?: boolean): void;
  75868. /** @hidden */
  75869. _isSynchronizedViewMatrix(): boolean;
  75870. /** @hidden */
  75871. _computeLocalCameraSpeed(): number;
  75872. /**
  75873. * Defines the target the camera should look at.
  75874. * @param target Defines the new target as a Vector or a mesh
  75875. */
  75876. setTarget(target: Vector3): void;
  75877. /**
  75878. * Return the current target position of the camera. This value is expressed in local space.
  75879. * @returns the target position
  75880. */
  75881. getTarget(): Vector3;
  75882. /** @hidden */
  75883. _decideIfNeedsToMove(): boolean;
  75884. /** @hidden */
  75885. _updatePosition(): void;
  75886. /** @hidden */
  75887. _checkInputs(): void;
  75888. protected _updateCameraRotationMatrix(): void;
  75889. /**
  75890. * 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)
  75891. * @returns the current camera
  75892. */
  75893. private _rotateUpVectorWithCameraRotationMatrix;
  75894. private _cachedRotationZ;
  75895. private _cachedQuaternionRotationZ;
  75896. /** @hidden */
  75897. _getViewMatrix(): Matrix;
  75898. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75899. /**
  75900. * @hidden
  75901. */
  75902. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75903. /**
  75904. * @hidden
  75905. */
  75906. _updateRigCameras(): void;
  75907. private _getRigCamPositionAndTarget;
  75908. /**
  75909. * Gets the current object class name.
  75910. * @return the class name
  75911. */
  75912. getClassName(): string;
  75913. }
  75914. }
  75915. declare module BABYLON {
  75916. /**
  75917. * Gather the list of keyboard event types as constants.
  75918. */
  75919. export class KeyboardEventTypes {
  75920. /**
  75921. * The keydown event is fired when a key becomes active (pressed).
  75922. */
  75923. static readonly KEYDOWN: number;
  75924. /**
  75925. * The keyup event is fired when a key has been released.
  75926. */
  75927. static readonly KEYUP: number;
  75928. }
  75929. /**
  75930. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75931. */
  75932. export class KeyboardInfo {
  75933. /**
  75934. * Defines the type of event (KeyboardEventTypes)
  75935. */
  75936. type: number;
  75937. /**
  75938. * Defines the related dom event
  75939. */
  75940. event: KeyboardEvent;
  75941. /**
  75942. * Instantiates a new keyboard info.
  75943. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75944. * @param type Defines the type of event (KeyboardEventTypes)
  75945. * @param event Defines the related dom event
  75946. */
  75947. constructor(
  75948. /**
  75949. * Defines the type of event (KeyboardEventTypes)
  75950. */
  75951. type: number,
  75952. /**
  75953. * Defines the related dom event
  75954. */
  75955. event: KeyboardEvent);
  75956. }
  75957. /**
  75958. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75959. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75960. */
  75961. export class KeyboardInfoPre extends KeyboardInfo {
  75962. /**
  75963. * Defines the type of event (KeyboardEventTypes)
  75964. */
  75965. type: number;
  75966. /**
  75967. * Defines the related dom event
  75968. */
  75969. event: KeyboardEvent;
  75970. /**
  75971. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75972. */
  75973. skipOnPointerObservable: boolean;
  75974. /**
  75975. * Instantiates a new keyboard pre info.
  75976. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75977. * @param type Defines the type of event (KeyboardEventTypes)
  75978. * @param event Defines the related dom event
  75979. */
  75980. constructor(
  75981. /**
  75982. * Defines the type of event (KeyboardEventTypes)
  75983. */
  75984. type: number,
  75985. /**
  75986. * Defines the related dom event
  75987. */
  75988. event: KeyboardEvent);
  75989. }
  75990. }
  75991. declare module BABYLON {
  75992. /**
  75993. * Manage the keyboard inputs to control the movement of a free camera.
  75994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75995. */
  75996. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75997. /**
  75998. * Defines the camera the input is attached to.
  75999. */
  76000. camera: FreeCamera;
  76001. /**
  76002. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76003. */
  76004. keysUp: number[];
  76005. /**
  76006. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76007. */
  76008. keysDown: number[];
  76009. /**
  76010. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76011. */
  76012. keysLeft: number[];
  76013. /**
  76014. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76015. */
  76016. keysRight: number[];
  76017. private _keys;
  76018. private _onCanvasBlurObserver;
  76019. private _onKeyboardObserver;
  76020. private _engine;
  76021. private _scene;
  76022. /**
  76023. * Attach the input controls to a specific dom element to get the input from.
  76024. * @param element Defines the element the controls should be listened from
  76025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76026. */
  76027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76028. /**
  76029. * Detach the current controls from the specified dom element.
  76030. * @param element Defines the element to stop listening the inputs from
  76031. */
  76032. detachControl(element: Nullable<HTMLElement>): void;
  76033. /**
  76034. * Update the current camera state depending on the inputs that have been used this frame.
  76035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76036. */
  76037. checkInputs(): void;
  76038. /**
  76039. * Gets the class name of the current intput.
  76040. * @returns the class name
  76041. */
  76042. getClassName(): string;
  76043. /** @hidden */
  76044. _onLostFocus(): void;
  76045. /**
  76046. * Get the friendly name associated with the input class.
  76047. * @returns the input friendly name
  76048. */
  76049. getSimpleName(): string;
  76050. }
  76051. }
  76052. declare module BABYLON {
  76053. /**
  76054. * Interface describing all the common properties and methods a shadow light needs to implement.
  76055. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76056. * as well as binding the different shadow properties to the effects.
  76057. */
  76058. export interface IShadowLight extends Light {
  76059. /**
  76060. * The light id in the scene (used in scene.findLighById for instance)
  76061. */
  76062. id: string;
  76063. /**
  76064. * The position the shdow will be casted from.
  76065. */
  76066. position: Vector3;
  76067. /**
  76068. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76069. */
  76070. direction: Vector3;
  76071. /**
  76072. * The transformed position. Position of the light in world space taking parenting in account.
  76073. */
  76074. transformedPosition: Vector3;
  76075. /**
  76076. * The transformed direction. Direction of the light in world space taking parenting in account.
  76077. */
  76078. transformedDirection: Vector3;
  76079. /**
  76080. * The friendly name of the light in the scene.
  76081. */
  76082. name: string;
  76083. /**
  76084. * Defines the shadow projection clipping minimum z value.
  76085. */
  76086. shadowMinZ: number;
  76087. /**
  76088. * Defines the shadow projection clipping maximum z value.
  76089. */
  76090. shadowMaxZ: number;
  76091. /**
  76092. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76093. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76094. */
  76095. computeTransformedInformation(): boolean;
  76096. /**
  76097. * Gets the scene the light belongs to.
  76098. * @returns The scene
  76099. */
  76100. getScene(): Scene;
  76101. /**
  76102. * Callback defining a custom Projection Matrix Builder.
  76103. * This can be used to override the default projection matrix computation.
  76104. */
  76105. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76106. /**
  76107. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76108. * @param matrix The materix to updated with the projection information
  76109. * @param viewMatrix The transform matrix of the light
  76110. * @param renderList The list of mesh to render in the map
  76111. * @returns The current light
  76112. */
  76113. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76114. /**
  76115. * Gets the current depth scale used in ESM.
  76116. * @returns The scale
  76117. */
  76118. getDepthScale(): number;
  76119. /**
  76120. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76121. * @returns true if a cube texture needs to be use
  76122. */
  76123. needCube(): boolean;
  76124. /**
  76125. * Detects if the projection matrix requires to be recomputed this frame.
  76126. * @returns true if it requires to be recomputed otherwise, false.
  76127. */
  76128. needProjectionMatrixCompute(): boolean;
  76129. /**
  76130. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76131. */
  76132. forceProjectionMatrixCompute(): void;
  76133. /**
  76134. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76135. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76136. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76137. */
  76138. getShadowDirection(faceIndex?: number): Vector3;
  76139. /**
  76140. * Gets the minZ used for shadow according to both the scene and the light.
  76141. * @param activeCamera The camera we are returning the min for
  76142. * @returns the depth min z
  76143. */
  76144. getDepthMinZ(activeCamera: Camera): number;
  76145. /**
  76146. * Gets the maxZ used for shadow according to both the scene and the light.
  76147. * @param activeCamera The camera we are returning the max for
  76148. * @returns the depth max z
  76149. */
  76150. getDepthMaxZ(activeCamera: Camera): number;
  76151. }
  76152. /**
  76153. * Base implementation IShadowLight
  76154. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76155. */
  76156. export abstract class ShadowLight extends Light implements IShadowLight {
  76157. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76158. protected _position: Vector3;
  76159. protected _setPosition(value: Vector3): void;
  76160. /**
  76161. * Sets the position the shadow will be casted from. Also use as the light position for both
  76162. * point and spot lights.
  76163. */
  76164. /**
  76165. * Sets the position the shadow will be casted from. Also use as the light position for both
  76166. * point and spot lights.
  76167. */
  76168. position: Vector3;
  76169. protected _direction: Vector3;
  76170. protected _setDirection(value: Vector3): void;
  76171. /**
  76172. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76173. * Also use as the light direction on spot and directional lights.
  76174. */
  76175. /**
  76176. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76177. * Also use as the light direction on spot and directional lights.
  76178. */
  76179. direction: Vector3;
  76180. private _shadowMinZ;
  76181. /**
  76182. * Gets the shadow projection clipping minimum z value.
  76183. */
  76184. /**
  76185. * Sets the shadow projection clipping minimum z value.
  76186. */
  76187. shadowMinZ: number;
  76188. private _shadowMaxZ;
  76189. /**
  76190. * Sets the shadow projection clipping maximum z value.
  76191. */
  76192. /**
  76193. * Gets the shadow projection clipping maximum z value.
  76194. */
  76195. shadowMaxZ: number;
  76196. /**
  76197. * Callback defining a custom Projection Matrix Builder.
  76198. * This can be used to override the default projection matrix computation.
  76199. */
  76200. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76201. /**
  76202. * The transformed position. Position of the light in world space taking parenting in account.
  76203. */
  76204. transformedPosition: Vector3;
  76205. /**
  76206. * The transformed direction. Direction of the light in world space taking parenting in account.
  76207. */
  76208. transformedDirection: Vector3;
  76209. private _needProjectionMatrixCompute;
  76210. /**
  76211. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76212. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76213. */
  76214. computeTransformedInformation(): boolean;
  76215. /**
  76216. * Return the depth scale used for the shadow map.
  76217. * @returns the depth scale.
  76218. */
  76219. getDepthScale(): number;
  76220. /**
  76221. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76222. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76223. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76224. */
  76225. getShadowDirection(faceIndex?: number): Vector3;
  76226. /**
  76227. * Returns the ShadowLight absolute position in the World.
  76228. * @returns the position vector in world space
  76229. */
  76230. getAbsolutePosition(): Vector3;
  76231. /**
  76232. * Sets the ShadowLight direction toward the passed target.
  76233. * @param target The point to target in local space
  76234. * @returns the updated ShadowLight direction
  76235. */
  76236. setDirectionToTarget(target: Vector3): Vector3;
  76237. /**
  76238. * Returns the light rotation in euler definition.
  76239. * @returns the x y z rotation in local space.
  76240. */
  76241. getRotation(): Vector3;
  76242. /**
  76243. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76244. * @returns true if a cube texture needs to be use
  76245. */
  76246. needCube(): boolean;
  76247. /**
  76248. * Detects if the projection matrix requires to be recomputed this frame.
  76249. * @returns true if it requires to be recomputed otherwise, false.
  76250. */
  76251. needProjectionMatrixCompute(): boolean;
  76252. /**
  76253. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76254. */
  76255. forceProjectionMatrixCompute(): void;
  76256. /** @hidden */
  76257. _initCache(): void;
  76258. /** @hidden */
  76259. _isSynchronized(): boolean;
  76260. /**
  76261. * Computes the world matrix of the node
  76262. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76263. * @returns the world matrix
  76264. */
  76265. computeWorldMatrix(force?: boolean): Matrix;
  76266. /**
  76267. * Gets the minZ used for shadow according to both the scene and the light.
  76268. * @param activeCamera The camera we are returning the min for
  76269. * @returns the depth min z
  76270. */
  76271. getDepthMinZ(activeCamera: Camera): number;
  76272. /**
  76273. * Gets the maxZ used for shadow according to both the scene and the light.
  76274. * @param activeCamera The camera we are returning the max for
  76275. * @returns the depth max z
  76276. */
  76277. getDepthMaxZ(activeCamera: Camera): number;
  76278. /**
  76279. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76280. * @param matrix The materix to updated with the projection information
  76281. * @param viewMatrix The transform matrix of the light
  76282. * @param renderList The list of mesh to render in the map
  76283. * @returns The current light
  76284. */
  76285. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76286. }
  76287. }
  76288. declare module BABYLON {
  76289. /**
  76290. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76291. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76292. */
  76293. export class EffectFallbacks implements IEffectFallbacks {
  76294. private _defines;
  76295. private _currentRank;
  76296. private _maxRank;
  76297. private _mesh;
  76298. /**
  76299. * Removes the fallback from the bound mesh.
  76300. */
  76301. unBindMesh(): void;
  76302. /**
  76303. * Adds a fallback on the specified property.
  76304. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76305. * @param define The name of the define in the shader
  76306. */
  76307. addFallback(rank: number, define: string): void;
  76308. /**
  76309. * Sets the mesh to use CPU skinning when needing to fallback.
  76310. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76311. * @param mesh The mesh to use the fallbacks.
  76312. */
  76313. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76314. /**
  76315. * Checks to see if more fallbacks are still availible.
  76316. */
  76317. readonly hasMoreFallbacks: boolean;
  76318. /**
  76319. * Removes the defines that should be removed when falling back.
  76320. * @param currentDefines defines the current define statements for the shader.
  76321. * @param effect defines the current effect we try to compile
  76322. * @returns The resulting defines with defines of the current rank removed.
  76323. */
  76324. reduce(currentDefines: string, effect: Effect): string;
  76325. }
  76326. }
  76327. declare module BABYLON {
  76328. /**
  76329. * "Static Class" containing the most commonly used helper while dealing with material for
  76330. * rendering purpose.
  76331. *
  76332. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76333. *
  76334. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76335. */
  76336. export class MaterialHelper {
  76337. /**
  76338. * Bind the current view position to an effect.
  76339. * @param effect The effect to be bound
  76340. * @param scene The scene the eyes position is used from
  76341. */
  76342. static BindEyePosition(effect: Effect, scene: Scene): void;
  76343. /**
  76344. * Helps preparing the defines values about the UVs in used in the effect.
  76345. * UVs are shared as much as we can accross channels in the shaders.
  76346. * @param texture The texture we are preparing the UVs for
  76347. * @param defines The defines to update
  76348. * @param key The channel key "diffuse", "specular"... used in the shader
  76349. */
  76350. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76351. /**
  76352. * Binds a texture matrix value to its corrsponding uniform
  76353. * @param texture The texture to bind the matrix for
  76354. * @param uniformBuffer The uniform buffer receivin the data
  76355. * @param key The channel key "diffuse", "specular"... used in the shader
  76356. */
  76357. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76358. /**
  76359. * Gets the current status of the fog (should it be enabled?)
  76360. * @param mesh defines the mesh to evaluate for fog support
  76361. * @param scene defines the hosting scene
  76362. * @returns true if fog must be enabled
  76363. */
  76364. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76365. /**
  76366. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76367. * @param mesh defines the current mesh
  76368. * @param scene defines the current scene
  76369. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76370. * @param pointsCloud defines if point cloud rendering has to be turned on
  76371. * @param fogEnabled defines if fog has to be turned on
  76372. * @param alphaTest defines if alpha testing has to be turned on
  76373. * @param defines defines the current list of defines
  76374. */
  76375. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76376. /**
  76377. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76378. * @param scene defines the current scene
  76379. * @param engine defines the current engine
  76380. * @param defines specifies the list of active defines
  76381. * @param useInstances defines if instances have to be turned on
  76382. * @param useClipPlane defines if clip plane have to be turned on
  76383. */
  76384. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76385. /**
  76386. * Prepares the defines for bones
  76387. * @param mesh The mesh containing the geometry data we will draw
  76388. * @param defines The defines to update
  76389. */
  76390. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76391. /**
  76392. * Prepares the defines for morph targets
  76393. * @param mesh The mesh containing the geometry data we will draw
  76394. * @param defines The defines to update
  76395. */
  76396. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76397. /**
  76398. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76399. * @param mesh The mesh containing the geometry data we will draw
  76400. * @param defines The defines to update
  76401. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76402. * @param useBones Precise whether bones should be used or not (override mesh info)
  76403. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76404. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76405. * @returns false if defines are considered not dirty and have not been checked
  76406. */
  76407. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76408. /**
  76409. * Prepares the defines related to multiview
  76410. * @param scene The scene we are intending to draw
  76411. * @param defines The defines to update
  76412. */
  76413. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76414. /**
  76415. * Prepares the defines related to the light information passed in parameter
  76416. * @param scene The scene we are intending to draw
  76417. * @param mesh The mesh the effect is compiling for
  76418. * @param light The light the effect is compiling for
  76419. * @param lightIndex The index of the light
  76420. * @param defines The defines to update
  76421. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76422. * @param state Defines the current state regarding what is needed (normals, etc...)
  76423. */
  76424. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76425. needNormals: boolean;
  76426. needRebuild: boolean;
  76427. shadowEnabled: boolean;
  76428. specularEnabled: boolean;
  76429. lightmapMode: boolean;
  76430. }): void;
  76431. /**
  76432. * Prepares the defines related to the light information passed in parameter
  76433. * @param scene The scene we are intending to draw
  76434. * @param mesh The mesh the effect is compiling for
  76435. * @param defines The defines to update
  76436. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76437. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76438. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76439. * @returns true if normals will be required for the rest of the effect
  76440. */
  76441. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76442. /**
  76443. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76444. * @param lightIndex defines the light index
  76445. * @param uniformsList The uniform list
  76446. * @param samplersList The sampler list
  76447. * @param projectedLightTexture defines if projected texture must be used
  76448. * @param uniformBuffersList defines an optional list of uniform buffers
  76449. */
  76450. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76451. /**
  76452. * Prepares the uniforms and samplers list to be used in the effect
  76453. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76454. * @param samplersList The sampler list
  76455. * @param defines The defines helping in the list generation
  76456. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76457. */
  76458. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76459. /**
  76460. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76461. * @param defines The defines to update while falling back
  76462. * @param fallbacks The authorized effect fallbacks
  76463. * @param maxSimultaneousLights The maximum number of lights allowed
  76464. * @param rank the current rank of the Effect
  76465. * @returns The newly affected rank
  76466. */
  76467. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76468. private static _TmpMorphInfluencers;
  76469. /**
  76470. * Prepares the list of attributes required for morph targets according to the effect defines.
  76471. * @param attribs The current list of supported attribs
  76472. * @param mesh The mesh to prepare the morph targets attributes for
  76473. * @param influencers The number of influencers
  76474. */
  76475. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76476. /**
  76477. * Prepares the list of attributes required for morph targets according to the effect defines.
  76478. * @param attribs The current list of supported attribs
  76479. * @param mesh The mesh to prepare the morph targets attributes for
  76480. * @param defines The current Defines of the effect
  76481. */
  76482. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76483. /**
  76484. * Prepares the list of attributes required for bones according to the effect defines.
  76485. * @param attribs The current list of supported attribs
  76486. * @param mesh The mesh to prepare the bones attributes for
  76487. * @param defines The current Defines of the effect
  76488. * @param fallbacks The current efffect fallback strategy
  76489. */
  76490. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76491. /**
  76492. * Check and prepare the list of attributes required for instances according to the effect defines.
  76493. * @param attribs The current list of supported attribs
  76494. * @param defines The current MaterialDefines of the effect
  76495. */
  76496. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76497. /**
  76498. * Add the list of attributes required for instances to the attribs array.
  76499. * @param attribs The current list of supported attribs
  76500. */
  76501. static PushAttributesForInstances(attribs: string[]): void;
  76502. /**
  76503. * Binds the light information to the effect.
  76504. * @param light The light containing the generator
  76505. * @param effect The effect we are binding the data to
  76506. * @param lightIndex The light index in the effect used to render
  76507. */
  76508. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76509. /**
  76510. * Binds the lights information from the scene to the effect for the given mesh.
  76511. * @param light Light to bind
  76512. * @param lightIndex Light index
  76513. * @param scene The scene where the light belongs to
  76514. * @param effect The effect we are binding the data to
  76515. * @param useSpecular Defines if specular is supported
  76516. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76517. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76518. */
  76519. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76520. /**
  76521. * Binds the lights information from the scene to the effect for the given mesh.
  76522. * @param scene The scene the lights belongs to
  76523. * @param mesh The mesh we are binding the information to render
  76524. * @param effect The effect we are binding the data to
  76525. * @param defines The generated defines for the effect
  76526. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76527. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76528. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76529. */
  76530. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76531. private static _tempFogColor;
  76532. /**
  76533. * Binds the fog information from the scene to the effect for the given mesh.
  76534. * @param scene The scene the lights belongs to
  76535. * @param mesh The mesh we are binding the information to render
  76536. * @param effect The effect we are binding the data to
  76537. * @param linearSpace Defines if the fog effect is applied in linear space
  76538. */
  76539. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76540. /**
  76541. * Binds the bones information from the mesh to the effect.
  76542. * @param mesh The mesh we are binding the information to render
  76543. * @param effect The effect we are binding the data to
  76544. */
  76545. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76546. /**
  76547. * Binds the morph targets information from the mesh to the effect.
  76548. * @param abstractMesh The mesh we are binding the information to render
  76549. * @param effect The effect we are binding the data to
  76550. */
  76551. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76552. /**
  76553. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76554. * @param defines The generated defines used in the effect
  76555. * @param effect The effect we are binding the data to
  76556. * @param scene The scene we are willing to render with logarithmic scale for
  76557. */
  76558. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76559. /**
  76560. * Binds the clip plane information from the scene to the effect.
  76561. * @param scene The scene the clip plane information are extracted from
  76562. * @param effect The effect we are binding the data to
  76563. */
  76564. static BindClipPlane(effect: Effect, scene: Scene): void;
  76565. }
  76566. }
  76567. declare module BABYLON {
  76568. /** @hidden */
  76569. export var packingFunctions: {
  76570. name: string;
  76571. shader: string;
  76572. };
  76573. }
  76574. declare module BABYLON {
  76575. /** @hidden */
  76576. export var shadowMapPixelShader: {
  76577. name: string;
  76578. shader: string;
  76579. };
  76580. }
  76581. declare module BABYLON {
  76582. /** @hidden */
  76583. export var bonesDeclaration: {
  76584. name: string;
  76585. shader: string;
  76586. };
  76587. }
  76588. declare module BABYLON {
  76589. /** @hidden */
  76590. export var morphTargetsVertexGlobalDeclaration: {
  76591. name: string;
  76592. shader: string;
  76593. };
  76594. }
  76595. declare module BABYLON {
  76596. /** @hidden */
  76597. export var morphTargetsVertexDeclaration: {
  76598. name: string;
  76599. shader: string;
  76600. };
  76601. }
  76602. declare module BABYLON {
  76603. /** @hidden */
  76604. export var instancesDeclaration: {
  76605. name: string;
  76606. shader: string;
  76607. };
  76608. }
  76609. declare module BABYLON {
  76610. /** @hidden */
  76611. export var helperFunctions: {
  76612. name: string;
  76613. shader: string;
  76614. };
  76615. }
  76616. declare module BABYLON {
  76617. /** @hidden */
  76618. export var morphTargetsVertex: {
  76619. name: string;
  76620. shader: string;
  76621. };
  76622. }
  76623. declare module BABYLON {
  76624. /** @hidden */
  76625. export var instancesVertex: {
  76626. name: string;
  76627. shader: string;
  76628. };
  76629. }
  76630. declare module BABYLON {
  76631. /** @hidden */
  76632. export var bonesVertex: {
  76633. name: string;
  76634. shader: string;
  76635. };
  76636. }
  76637. declare module BABYLON {
  76638. /** @hidden */
  76639. export var shadowMapVertexShader: {
  76640. name: string;
  76641. shader: string;
  76642. };
  76643. }
  76644. declare module BABYLON {
  76645. /** @hidden */
  76646. export var depthBoxBlurPixelShader: {
  76647. name: string;
  76648. shader: string;
  76649. };
  76650. }
  76651. declare module BABYLON {
  76652. /**
  76653. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76654. */
  76655. export interface ICustomShaderOptions {
  76656. /**
  76657. * Gets or sets the custom shader name to use
  76658. */
  76659. shaderName: string;
  76660. /**
  76661. * The list of attribute names used in the shader
  76662. */
  76663. attributes?: string[];
  76664. /**
  76665. * The list of unifrom names used in the shader
  76666. */
  76667. uniforms?: string[];
  76668. /**
  76669. * The list of sampler names used in the shader
  76670. */
  76671. samplers?: string[];
  76672. /**
  76673. * The list of defines used in the shader
  76674. */
  76675. defines?: string[];
  76676. }
  76677. /**
  76678. * Interface to implement to create a shadow generator compatible with BJS.
  76679. */
  76680. export interface IShadowGenerator {
  76681. /**
  76682. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76683. * @returns The render target texture if present otherwise, null
  76684. */
  76685. getShadowMap(): Nullable<RenderTargetTexture>;
  76686. /**
  76687. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76688. * @returns The render target texture if the shadow map is present otherwise, null
  76689. */
  76690. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76691. /**
  76692. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76693. * @param subMesh The submesh we want to render in the shadow map
  76694. * @param useInstances Defines wether will draw in the map using instances
  76695. * @returns true if ready otherwise, false
  76696. */
  76697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76698. /**
  76699. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76700. * @param defines Defines of the material we want to update
  76701. * @param lightIndex Index of the light in the enabled light list of the material
  76702. */
  76703. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76704. /**
  76705. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76706. * defined in the generator but impacting the effect).
  76707. * It implies the unifroms available on the materials are the standard BJS ones.
  76708. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76709. * @param effect The effect we are binfing the information for
  76710. */
  76711. bindShadowLight(lightIndex: string, effect: Effect): void;
  76712. /**
  76713. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76714. * (eq to shadow prjection matrix * light transform matrix)
  76715. * @returns The transform matrix used to create the shadow map
  76716. */
  76717. getTransformMatrix(): Matrix;
  76718. /**
  76719. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76720. * Cube and 2D textures for instance.
  76721. */
  76722. recreateShadowMap(): void;
  76723. /**
  76724. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76725. * @param onCompiled Callback triggered at the and of the effects compilation
  76726. * @param options Sets of optional options forcing the compilation with different modes
  76727. */
  76728. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76729. useInstances: boolean;
  76730. }>): void;
  76731. /**
  76732. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76733. * @param options Sets of optional options forcing the compilation with different modes
  76734. * @returns A promise that resolves when the compilation completes
  76735. */
  76736. forceCompilationAsync(options?: Partial<{
  76737. useInstances: boolean;
  76738. }>): Promise<void>;
  76739. /**
  76740. * Serializes the shadow generator setup to a json object.
  76741. * @returns The serialized JSON object
  76742. */
  76743. serialize(): any;
  76744. /**
  76745. * Disposes the Shadow map and related Textures and effects.
  76746. */
  76747. dispose(): void;
  76748. }
  76749. /**
  76750. * Default implementation IShadowGenerator.
  76751. * This is the main object responsible of generating shadows in the framework.
  76752. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76753. */
  76754. export class ShadowGenerator implements IShadowGenerator {
  76755. /**
  76756. * Shadow generator mode None: no filtering applied.
  76757. */
  76758. static readonly FILTER_NONE: number;
  76759. /**
  76760. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76761. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76762. */
  76763. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76764. /**
  76765. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76766. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76767. */
  76768. static readonly FILTER_POISSONSAMPLING: number;
  76769. /**
  76770. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76771. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76772. */
  76773. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76774. /**
  76775. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76776. * edge artifacts on steep falloff.
  76777. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76778. */
  76779. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76780. /**
  76781. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76782. * edge artifacts on steep falloff.
  76783. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76784. */
  76785. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76786. /**
  76787. * Shadow generator mode PCF: Percentage Closer Filtering
  76788. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76789. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76790. */
  76791. static readonly FILTER_PCF: number;
  76792. /**
  76793. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76794. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76795. * Contact Hardening
  76796. */
  76797. static readonly FILTER_PCSS: number;
  76798. /**
  76799. * Reserved for PCF and PCSS
  76800. * Highest Quality.
  76801. *
  76802. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76803. *
  76804. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76805. */
  76806. static readonly QUALITY_HIGH: number;
  76807. /**
  76808. * Reserved for PCF and PCSS
  76809. * Good tradeoff for quality/perf cross devices
  76810. *
  76811. * Execute PCF on a 3*3 kernel.
  76812. *
  76813. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76814. */
  76815. static readonly QUALITY_MEDIUM: number;
  76816. /**
  76817. * Reserved for PCF and PCSS
  76818. * The lowest quality but the fastest.
  76819. *
  76820. * Execute PCF on a 1*1 kernel.
  76821. *
  76822. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76823. */
  76824. static readonly QUALITY_LOW: number;
  76825. /** Gets or sets the custom shader name to use */
  76826. customShaderOptions: ICustomShaderOptions;
  76827. /**
  76828. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76829. */
  76830. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76831. /**
  76832. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76833. */
  76834. onAfterShadowMapRenderObservable: Observable<Effect>;
  76835. /**
  76836. * Observable triggered before a mesh is rendered in the shadow map.
  76837. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76838. */
  76839. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76840. /**
  76841. * Observable triggered after a mesh is rendered in the shadow map.
  76842. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76843. */
  76844. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76845. private _bias;
  76846. /**
  76847. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76848. */
  76849. /**
  76850. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76851. */
  76852. bias: number;
  76853. private _normalBias;
  76854. /**
  76855. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76856. */
  76857. /**
  76858. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76859. */
  76860. normalBias: number;
  76861. private _blurBoxOffset;
  76862. /**
  76863. * Gets the blur box offset: offset applied during the blur pass.
  76864. * Only useful if useKernelBlur = false
  76865. */
  76866. /**
  76867. * Sets the blur box offset: offset applied during the blur pass.
  76868. * Only useful if useKernelBlur = false
  76869. */
  76870. blurBoxOffset: number;
  76871. private _blurScale;
  76872. /**
  76873. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76874. * 2 means half of the size.
  76875. */
  76876. /**
  76877. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76878. * 2 means half of the size.
  76879. */
  76880. blurScale: number;
  76881. private _blurKernel;
  76882. /**
  76883. * Gets the blur kernel: kernel size of the blur pass.
  76884. * Only useful if useKernelBlur = true
  76885. */
  76886. /**
  76887. * Sets the blur kernel: kernel size of the blur pass.
  76888. * Only useful if useKernelBlur = true
  76889. */
  76890. blurKernel: number;
  76891. private _useKernelBlur;
  76892. /**
  76893. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76894. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76895. */
  76896. /**
  76897. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76898. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76899. */
  76900. useKernelBlur: boolean;
  76901. private _depthScale;
  76902. /**
  76903. * Gets the depth scale used in ESM mode.
  76904. */
  76905. /**
  76906. * Sets the depth scale used in ESM mode.
  76907. * This can override the scale stored on the light.
  76908. */
  76909. depthScale: number;
  76910. private _filter;
  76911. /**
  76912. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76913. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76914. */
  76915. /**
  76916. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76917. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76918. */
  76919. filter: number;
  76920. /**
  76921. * Gets if the current filter is set to Poisson Sampling.
  76922. */
  76923. /**
  76924. * Sets the current filter to Poisson Sampling.
  76925. */
  76926. usePoissonSampling: boolean;
  76927. /**
  76928. * Gets if the current filter is set to ESM.
  76929. */
  76930. /**
  76931. * Sets the current filter is to ESM.
  76932. */
  76933. useExponentialShadowMap: boolean;
  76934. /**
  76935. * Gets if the current filter is set to filtered ESM.
  76936. */
  76937. /**
  76938. * Gets if the current filter is set to filtered ESM.
  76939. */
  76940. useBlurExponentialShadowMap: boolean;
  76941. /**
  76942. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76943. * exponential to prevent steep falloff artifacts).
  76944. */
  76945. /**
  76946. * Sets the current filter to "close ESM" (using the inverse of the
  76947. * exponential to prevent steep falloff artifacts).
  76948. */
  76949. useCloseExponentialShadowMap: boolean;
  76950. /**
  76951. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76952. * exponential to prevent steep falloff artifacts).
  76953. */
  76954. /**
  76955. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76956. * exponential to prevent steep falloff artifacts).
  76957. */
  76958. useBlurCloseExponentialShadowMap: boolean;
  76959. /**
  76960. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76961. */
  76962. /**
  76963. * Sets the current filter to "PCF" (percentage closer filtering).
  76964. */
  76965. usePercentageCloserFiltering: boolean;
  76966. private _filteringQuality;
  76967. /**
  76968. * Gets the PCF or PCSS Quality.
  76969. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76970. */
  76971. /**
  76972. * Sets the PCF or PCSS Quality.
  76973. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76974. */
  76975. filteringQuality: number;
  76976. /**
  76977. * Gets if the current filter is set to "PCSS" (contact hardening).
  76978. */
  76979. /**
  76980. * Sets the current filter to "PCSS" (contact hardening).
  76981. */
  76982. useContactHardeningShadow: boolean;
  76983. private _contactHardeningLightSizeUVRatio;
  76984. /**
  76985. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76986. * Using a ratio helps keeping shape stability independently of the map size.
  76987. *
  76988. * It does not account for the light projection as it was having too much
  76989. * instability during the light setup or during light position changes.
  76990. *
  76991. * Only valid if useContactHardeningShadow is true.
  76992. */
  76993. /**
  76994. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76995. * Using a ratio helps keeping shape stability independently of the map size.
  76996. *
  76997. * It does not account for the light projection as it was having too much
  76998. * instability during the light setup or during light position changes.
  76999. *
  77000. * Only valid if useContactHardeningShadow is true.
  77001. */
  77002. contactHardeningLightSizeUVRatio: number;
  77003. private _darkness;
  77004. /** Gets or sets the actual darkness of a shadow */
  77005. darkness: number;
  77006. /**
  77007. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77008. * 0 means strongest and 1 would means no shadow.
  77009. * @returns the darkness.
  77010. */
  77011. getDarkness(): number;
  77012. /**
  77013. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77014. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77015. * @returns the shadow generator allowing fluent coding.
  77016. */
  77017. setDarkness(darkness: number): ShadowGenerator;
  77018. private _transparencyShadow;
  77019. /** Gets or sets the ability to have transparent shadow */
  77020. transparencyShadow: boolean;
  77021. /**
  77022. * Sets the ability to have transparent shadow (boolean).
  77023. * @param transparent True if transparent else False
  77024. * @returns the shadow generator allowing fluent coding
  77025. */
  77026. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77027. private _shadowMap;
  77028. private _shadowMap2;
  77029. /**
  77030. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77031. * @returns The render target texture if present otherwise, null
  77032. */
  77033. getShadowMap(): Nullable<RenderTargetTexture>;
  77034. /**
  77035. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77036. * @returns The render target texture if the shadow map is present otherwise, null
  77037. */
  77038. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77039. /**
  77040. * Gets the class name of that object
  77041. * @returns "ShadowGenerator"
  77042. */
  77043. getClassName(): string;
  77044. /**
  77045. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77046. * @param mesh Mesh to add
  77047. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77048. * @returns the Shadow Generator itself
  77049. */
  77050. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77051. /**
  77052. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77053. * @param mesh Mesh to remove
  77054. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77055. * @returns the Shadow Generator itself
  77056. */
  77057. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77058. /**
  77059. * Controls the extent to which the shadows fade out at the edge of the frustum
  77060. * Used only by directionals and spots
  77061. */
  77062. frustumEdgeFalloff: number;
  77063. private _light;
  77064. /**
  77065. * Returns the associated light object.
  77066. * @returns the light generating the shadow
  77067. */
  77068. getLight(): IShadowLight;
  77069. /**
  77070. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77071. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77072. * It might on the other hand introduce peter panning.
  77073. */
  77074. forceBackFacesOnly: boolean;
  77075. private _scene;
  77076. private _lightDirection;
  77077. private _effect;
  77078. private _viewMatrix;
  77079. private _projectionMatrix;
  77080. private _transformMatrix;
  77081. private _cachedPosition;
  77082. private _cachedDirection;
  77083. private _cachedDefines;
  77084. private _currentRenderID;
  77085. private _boxBlurPostprocess;
  77086. private _kernelBlurXPostprocess;
  77087. private _kernelBlurYPostprocess;
  77088. private _blurPostProcesses;
  77089. private _mapSize;
  77090. private _currentFaceIndex;
  77091. private _currentFaceIndexCache;
  77092. private _textureType;
  77093. private _defaultTextureMatrix;
  77094. private _storedUniqueId;
  77095. /** @hidden */
  77096. static _SceneComponentInitialization: (scene: Scene) => void;
  77097. /**
  77098. * Creates a ShadowGenerator object.
  77099. * A ShadowGenerator is the required tool to use the shadows.
  77100. * Each light casting shadows needs to use its own ShadowGenerator.
  77101. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77102. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77103. * @param light The light object generating the shadows.
  77104. * @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.
  77105. */
  77106. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77107. private _initializeGenerator;
  77108. private _initializeShadowMap;
  77109. private _initializeBlurRTTAndPostProcesses;
  77110. private _renderForShadowMap;
  77111. private _renderSubMeshForShadowMap;
  77112. private _applyFilterValues;
  77113. /**
  77114. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77115. * @param onCompiled Callback triggered at the and of the effects compilation
  77116. * @param options Sets of optional options forcing the compilation with different modes
  77117. */
  77118. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77119. useInstances: boolean;
  77120. }>): void;
  77121. /**
  77122. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77123. * @param options Sets of optional options forcing the compilation with different modes
  77124. * @returns A promise that resolves when the compilation completes
  77125. */
  77126. forceCompilationAsync(options?: Partial<{
  77127. useInstances: boolean;
  77128. }>): Promise<void>;
  77129. /**
  77130. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77131. * @param subMesh The submesh we want to render in the shadow map
  77132. * @param useInstances Defines wether will draw in the map using instances
  77133. * @returns true if ready otherwise, false
  77134. */
  77135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77136. /**
  77137. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77138. * @param defines Defines of the material we want to update
  77139. * @param lightIndex Index of the light in the enabled light list of the material
  77140. */
  77141. prepareDefines(defines: any, lightIndex: number): void;
  77142. /**
  77143. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77144. * defined in the generator but impacting the effect).
  77145. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77146. * @param effect The effect we are binfing the information for
  77147. */
  77148. bindShadowLight(lightIndex: string, effect: Effect): void;
  77149. /**
  77150. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77151. * (eq to shadow prjection matrix * light transform matrix)
  77152. * @returns The transform matrix used to create the shadow map
  77153. */
  77154. getTransformMatrix(): Matrix;
  77155. /**
  77156. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77157. * Cube and 2D textures for instance.
  77158. */
  77159. recreateShadowMap(): void;
  77160. private _disposeBlurPostProcesses;
  77161. private _disposeRTTandPostProcesses;
  77162. /**
  77163. * Disposes the ShadowGenerator.
  77164. * Returns nothing.
  77165. */
  77166. dispose(): void;
  77167. /**
  77168. * Serializes the shadow generator setup to a json object.
  77169. * @returns The serialized JSON object
  77170. */
  77171. serialize(): any;
  77172. /**
  77173. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77174. * @param parsedShadowGenerator The JSON object to parse
  77175. * @param scene The scene to create the shadow map for
  77176. * @returns The parsed shadow generator
  77177. */
  77178. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77179. }
  77180. }
  77181. declare module BABYLON {
  77182. /**
  77183. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77184. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77185. * 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.
  77186. */
  77187. export abstract class Light extends Node {
  77188. /**
  77189. * Falloff Default: light is falling off following the material specification:
  77190. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77191. */
  77192. static readonly FALLOFF_DEFAULT: number;
  77193. /**
  77194. * Falloff Physical: light is falling off following the inverse squared distance law.
  77195. */
  77196. static readonly FALLOFF_PHYSICAL: number;
  77197. /**
  77198. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77199. * to enhance interoperability with other engines.
  77200. */
  77201. static readonly FALLOFF_GLTF: number;
  77202. /**
  77203. * Falloff Standard: light is falling off like in the standard material
  77204. * to enhance interoperability with other materials.
  77205. */
  77206. static readonly FALLOFF_STANDARD: number;
  77207. /**
  77208. * If every light affecting the material is in this lightmapMode,
  77209. * material.lightmapTexture adds or multiplies
  77210. * (depends on material.useLightmapAsShadowmap)
  77211. * after every other light calculations.
  77212. */
  77213. static readonly LIGHTMAP_DEFAULT: number;
  77214. /**
  77215. * material.lightmapTexture as only diffuse lighting from this light
  77216. * adds only specular lighting from this light
  77217. * adds dynamic shadows
  77218. */
  77219. static readonly LIGHTMAP_SPECULAR: number;
  77220. /**
  77221. * material.lightmapTexture as only lighting
  77222. * no light calculation from this light
  77223. * only adds dynamic shadows from this light
  77224. */
  77225. static readonly LIGHTMAP_SHADOWSONLY: number;
  77226. /**
  77227. * Each light type uses the default quantity according to its type:
  77228. * point/spot lights use luminous intensity
  77229. * directional lights use illuminance
  77230. */
  77231. static readonly INTENSITYMODE_AUTOMATIC: number;
  77232. /**
  77233. * lumen (lm)
  77234. */
  77235. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77236. /**
  77237. * candela (lm/sr)
  77238. */
  77239. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77240. /**
  77241. * lux (lm/m^2)
  77242. */
  77243. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77244. /**
  77245. * nit (cd/m^2)
  77246. */
  77247. static readonly INTENSITYMODE_LUMINANCE: number;
  77248. /**
  77249. * Light type const id of the point light.
  77250. */
  77251. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77252. /**
  77253. * Light type const id of the directional light.
  77254. */
  77255. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77256. /**
  77257. * Light type const id of the spot light.
  77258. */
  77259. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77260. /**
  77261. * Light type const id of the hemispheric light.
  77262. */
  77263. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77264. /**
  77265. * Diffuse gives the basic color to an object.
  77266. */
  77267. diffuse: Color3;
  77268. /**
  77269. * Specular produces a highlight color on an object.
  77270. * Note: This is note affecting PBR materials.
  77271. */
  77272. specular: Color3;
  77273. /**
  77274. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77275. * falling off base on range or angle.
  77276. * This can be set to any values in Light.FALLOFF_x.
  77277. *
  77278. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77279. * other types of materials.
  77280. */
  77281. falloffType: number;
  77282. /**
  77283. * Strength of the light.
  77284. * Note: By default it is define in the framework own unit.
  77285. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77286. */
  77287. intensity: number;
  77288. private _range;
  77289. protected _inverseSquaredRange: number;
  77290. /**
  77291. * Defines how far from the source the light is impacting in scene units.
  77292. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77293. */
  77294. /**
  77295. * Defines how far from the source the light is impacting in scene units.
  77296. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77297. */
  77298. range: number;
  77299. /**
  77300. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77301. * of light.
  77302. */
  77303. private _photometricScale;
  77304. private _intensityMode;
  77305. /**
  77306. * Gets the photometric scale used to interpret the intensity.
  77307. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77308. */
  77309. /**
  77310. * Sets the photometric scale used to interpret the intensity.
  77311. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77312. */
  77313. intensityMode: number;
  77314. private _radius;
  77315. /**
  77316. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77317. */
  77318. /**
  77319. * sets the light radius used by PBR Materials to simulate soft area lights.
  77320. */
  77321. radius: number;
  77322. private _renderPriority;
  77323. /**
  77324. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77325. * exceeding the number allowed of the materials.
  77326. */
  77327. renderPriority: number;
  77328. private _shadowEnabled;
  77329. /**
  77330. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77331. * the current shadow generator.
  77332. */
  77333. /**
  77334. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77335. * the current shadow generator.
  77336. */
  77337. shadowEnabled: boolean;
  77338. private _includedOnlyMeshes;
  77339. /**
  77340. * Gets the only meshes impacted by this light.
  77341. */
  77342. /**
  77343. * Sets the only meshes impacted by this light.
  77344. */
  77345. includedOnlyMeshes: AbstractMesh[];
  77346. private _excludedMeshes;
  77347. /**
  77348. * Gets the meshes not impacted by this light.
  77349. */
  77350. /**
  77351. * Sets the meshes not impacted by this light.
  77352. */
  77353. excludedMeshes: AbstractMesh[];
  77354. private _excludeWithLayerMask;
  77355. /**
  77356. * Gets the layer id use to find what meshes are not impacted by the light.
  77357. * Inactive if 0
  77358. */
  77359. /**
  77360. * Sets the layer id use to find what meshes are not impacted by the light.
  77361. * Inactive if 0
  77362. */
  77363. excludeWithLayerMask: number;
  77364. private _includeOnlyWithLayerMask;
  77365. /**
  77366. * Gets the layer id use to find what meshes are impacted by the light.
  77367. * Inactive if 0
  77368. */
  77369. /**
  77370. * Sets the layer id use to find what meshes are impacted by the light.
  77371. * Inactive if 0
  77372. */
  77373. includeOnlyWithLayerMask: number;
  77374. private _lightmapMode;
  77375. /**
  77376. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77377. */
  77378. /**
  77379. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77380. */
  77381. lightmapMode: number;
  77382. /**
  77383. * Shadow generator associted to the light.
  77384. * @hidden Internal use only.
  77385. */
  77386. _shadowGenerator: Nullable<IShadowGenerator>;
  77387. /**
  77388. * @hidden Internal use only.
  77389. */
  77390. _excludedMeshesIds: string[];
  77391. /**
  77392. * @hidden Internal use only.
  77393. */
  77394. _includedOnlyMeshesIds: string[];
  77395. /**
  77396. * The current light unifom buffer.
  77397. * @hidden Internal use only.
  77398. */
  77399. _uniformBuffer: UniformBuffer;
  77400. /** @hidden */
  77401. _renderId: number;
  77402. /**
  77403. * Creates a Light object in the scene.
  77404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77405. * @param name The firendly name of the light
  77406. * @param scene The scene the light belongs too
  77407. */
  77408. constructor(name: string, scene: Scene);
  77409. protected abstract _buildUniformLayout(): void;
  77410. /**
  77411. * Sets the passed Effect "effect" with the Light information.
  77412. * @param effect The effect to update
  77413. * @param lightIndex The index of the light in the effect to update
  77414. * @returns The light
  77415. */
  77416. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77417. /**
  77418. * Sets the passed Effect "effect" with the Light information.
  77419. * @param effect The effect to update
  77420. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77421. * @returns The light
  77422. */
  77423. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77424. /**
  77425. * Returns the string "Light".
  77426. * @returns the class name
  77427. */
  77428. getClassName(): string;
  77429. /** @hidden */
  77430. readonly _isLight: boolean;
  77431. /**
  77432. * Converts the light information to a readable string for debug purpose.
  77433. * @param fullDetails Supports for multiple levels of logging within scene loading
  77434. * @returns the human readable light info
  77435. */
  77436. toString(fullDetails?: boolean): string;
  77437. /** @hidden */
  77438. protected _syncParentEnabledState(): void;
  77439. /**
  77440. * Set the enabled state of this node.
  77441. * @param value - the new enabled state
  77442. */
  77443. setEnabled(value: boolean): void;
  77444. /**
  77445. * Returns the Light associated shadow generator if any.
  77446. * @return the associated shadow generator.
  77447. */
  77448. getShadowGenerator(): Nullable<IShadowGenerator>;
  77449. /**
  77450. * Returns a Vector3, the absolute light position in the World.
  77451. * @returns the world space position of the light
  77452. */
  77453. getAbsolutePosition(): Vector3;
  77454. /**
  77455. * Specifies if the light will affect the passed mesh.
  77456. * @param mesh The mesh to test against the light
  77457. * @return true the mesh is affected otherwise, false.
  77458. */
  77459. canAffectMesh(mesh: AbstractMesh): boolean;
  77460. /**
  77461. * Sort function to order lights for rendering.
  77462. * @param a First Light object to compare to second.
  77463. * @param b Second Light object to compare first.
  77464. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77465. */
  77466. static CompareLightsPriority(a: Light, b: Light): number;
  77467. /**
  77468. * Releases resources associated with this node.
  77469. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77470. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77471. */
  77472. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77473. /**
  77474. * Returns the light type ID (integer).
  77475. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77476. */
  77477. getTypeID(): number;
  77478. /**
  77479. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77480. * @returns the scaled intensity in intensity mode unit
  77481. */
  77482. getScaledIntensity(): number;
  77483. /**
  77484. * Returns a new Light object, named "name", from the current one.
  77485. * @param name The name of the cloned light
  77486. * @returns the new created light
  77487. */
  77488. clone(name: string): Nullable<Light>;
  77489. /**
  77490. * Serializes the current light into a Serialization object.
  77491. * @returns the serialized object.
  77492. */
  77493. serialize(): any;
  77494. /**
  77495. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77496. * This new light is named "name" and added to the passed scene.
  77497. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77498. * @param name The friendly name of the light
  77499. * @param scene The scene the new light will belong to
  77500. * @returns the constructor function
  77501. */
  77502. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77503. /**
  77504. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77505. * @param parsedLight The JSON representation of the light
  77506. * @param scene The scene to create the parsed light in
  77507. * @returns the created light after parsing
  77508. */
  77509. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77510. private _hookArrayForExcluded;
  77511. private _hookArrayForIncludedOnly;
  77512. private _resyncMeshes;
  77513. /**
  77514. * Forces the meshes to update their light related information in their rendering used effects
  77515. * @hidden Internal Use Only
  77516. */
  77517. _markMeshesAsLightDirty(): void;
  77518. /**
  77519. * Recomputes the cached photometric scale if needed.
  77520. */
  77521. private _computePhotometricScale;
  77522. /**
  77523. * Returns the Photometric Scale according to the light type and intensity mode.
  77524. */
  77525. private _getPhotometricScale;
  77526. /**
  77527. * Reorder the light in the scene according to their defined priority.
  77528. * @hidden Internal Use Only
  77529. */
  77530. _reorderLightsInScene(): void;
  77531. /**
  77532. * Prepares the list of defines specific to the light type.
  77533. * @param defines the list of defines
  77534. * @param lightIndex defines the index of the light for the effect
  77535. */
  77536. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77537. }
  77538. }
  77539. declare module BABYLON {
  77540. /**
  77541. * Interface used to define Action
  77542. */
  77543. export interface IAction {
  77544. /**
  77545. * Trigger for the action
  77546. */
  77547. trigger: number;
  77548. /** Options of the trigger */
  77549. triggerOptions: any;
  77550. /**
  77551. * Gets the trigger parameters
  77552. * @returns the trigger parameters
  77553. */
  77554. getTriggerParameter(): any;
  77555. /**
  77556. * Internal only - executes current action event
  77557. * @hidden
  77558. */
  77559. _executeCurrent(evt?: ActionEvent): void;
  77560. /**
  77561. * Serialize placeholder for child classes
  77562. * @param parent of child
  77563. * @returns the serialized object
  77564. */
  77565. serialize(parent: any): any;
  77566. /**
  77567. * Internal only
  77568. * @hidden
  77569. */
  77570. _prepare(): void;
  77571. /**
  77572. * Internal only - manager for action
  77573. * @hidden
  77574. */
  77575. _actionManager: AbstractActionManager;
  77576. /**
  77577. * Adds action to chain of actions, may be a DoNothingAction
  77578. * @param action defines the next action to execute
  77579. * @returns The action passed in
  77580. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77581. */
  77582. then(action: IAction): IAction;
  77583. }
  77584. /**
  77585. * The action to be carried out following a trigger
  77586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77587. */
  77588. export class Action implements IAction {
  77589. /** the trigger, with or without parameters, for the action */
  77590. triggerOptions: any;
  77591. /**
  77592. * Trigger for the action
  77593. */
  77594. trigger: number;
  77595. /**
  77596. * Internal only - manager for action
  77597. * @hidden
  77598. */
  77599. _actionManager: ActionManager;
  77600. private _nextActiveAction;
  77601. private _child;
  77602. private _condition?;
  77603. private _triggerParameter;
  77604. /**
  77605. * An event triggered prior to action being executed.
  77606. */
  77607. onBeforeExecuteObservable: Observable<Action>;
  77608. /**
  77609. * Creates a new Action
  77610. * @param triggerOptions the trigger, with or without parameters, for the action
  77611. * @param condition an optional determinant of action
  77612. */
  77613. constructor(
  77614. /** the trigger, with or without parameters, for the action */
  77615. triggerOptions: any, condition?: Condition);
  77616. /**
  77617. * Internal only
  77618. * @hidden
  77619. */
  77620. _prepare(): void;
  77621. /**
  77622. * Gets the trigger parameters
  77623. * @returns the trigger parameters
  77624. */
  77625. getTriggerParameter(): any;
  77626. /**
  77627. * Internal only - executes current action event
  77628. * @hidden
  77629. */
  77630. _executeCurrent(evt?: ActionEvent): void;
  77631. /**
  77632. * Execute placeholder for child classes
  77633. * @param evt optional action event
  77634. */
  77635. execute(evt?: ActionEvent): void;
  77636. /**
  77637. * Skips to next active action
  77638. */
  77639. skipToNextActiveAction(): void;
  77640. /**
  77641. * Adds action to chain of actions, may be a DoNothingAction
  77642. * @param action defines the next action to execute
  77643. * @returns The action passed in
  77644. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77645. */
  77646. then(action: Action): Action;
  77647. /**
  77648. * Internal only
  77649. * @hidden
  77650. */
  77651. _getProperty(propertyPath: string): string;
  77652. /**
  77653. * Internal only
  77654. * @hidden
  77655. */
  77656. _getEffectiveTarget(target: any, propertyPath: string): any;
  77657. /**
  77658. * Serialize placeholder for child classes
  77659. * @param parent of child
  77660. * @returns the serialized object
  77661. */
  77662. serialize(parent: any): any;
  77663. /**
  77664. * Internal only called by serialize
  77665. * @hidden
  77666. */
  77667. protected _serialize(serializedAction: any, parent?: any): any;
  77668. /**
  77669. * Internal only
  77670. * @hidden
  77671. */
  77672. static _SerializeValueAsString: (value: any) => string;
  77673. /**
  77674. * Internal only
  77675. * @hidden
  77676. */
  77677. static _GetTargetProperty: (target: Node | Scene) => {
  77678. name: string;
  77679. targetType: string;
  77680. value: string;
  77681. };
  77682. }
  77683. }
  77684. declare module BABYLON {
  77685. /**
  77686. * A Condition applied to an Action
  77687. */
  77688. export class Condition {
  77689. /**
  77690. * Internal only - manager for action
  77691. * @hidden
  77692. */
  77693. _actionManager: ActionManager;
  77694. /**
  77695. * Internal only
  77696. * @hidden
  77697. */
  77698. _evaluationId: number;
  77699. /**
  77700. * Internal only
  77701. * @hidden
  77702. */
  77703. _currentResult: boolean;
  77704. /**
  77705. * Creates a new Condition
  77706. * @param actionManager the manager of the action the condition is applied to
  77707. */
  77708. constructor(actionManager: ActionManager);
  77709. /**
  77710. * Check if the current condition is valid
  77711. * @returns a boolean
  77712. */
  77713. isValid(): boolean;
  77714. /**
  77715. * Internal only
  77716. * @hidden
  77717. */
  77718. _getProperty(propertyPath: string): string;
  77719. /**
  77720. * Internal only
  77721. * @hidden
  77722. */
  77723. _getEffectiveTarget(target: any, propertyPath: string): any;
  77724. /**
  77725. * Serialize placeholder for child classes
  77726. * @returns the serialized object
  77727. */
  77728. serialize(): any;
  77729. /**
  77730. * Internal only
  77731. * @hidden
  77732. */
  77733. protected _serialize(serializedCondition: any): any;
  77734. }
  77735. /**
  77736. * Defines specific conditional operators as extensions of Condition
  77737. */
  77738. export class ValueCondition extends Condition {
  77739. /** path to specify the property of the target the conditional operator uses */
  77740. propertyPath: string;
  77741. /** the value compared by the conditional operator against the current value of the property */
  77742. value: any;
  77743. /** the conditional operator, default ValueCondition.IsEqual */
  77744. operator: number;
  77745. /**
  77746. * Internal only
  77747. * @hidden
  77748. */
  77749. private static _IsEqual;
  77750. /**
  77751. * Internal only
  77752. * @hidden
  77753. */
  77754. private static _IsDifferent;
  77755. /**
  77756. * Internal only
  77757. * @hidden
  77758. */
  77759. private static _IsGreater;
  77760. /**
  77761. * Internal only
  77762. * @hidden
  77763. */
  77764. private static _IsLesser;
  77765. /**
  77766. * returns the number for IsEqual
  77767. */
  77768. static readonly IsEqual: number;
  77769. /**
  77770. * Returns the number for IsDifferent
  77771. */
  77772. static readonly IsDifferent: number;
  77773. /**
  77774. * Returns the number for IsGreater
  77775. */
  77776. static readonly IsGreater: number;
  77777. /**
  77778. * Returns the number for IsLesser
  77779. */
  77780. static readonly IsLesser: number;
  77781. /**
  77782. * Internal only The action manager for the condition
  77783. * @hidden
  77784. */
  77785. _actionManager: ActionManager;
  77786. /**
  77787. * Internal only
  77788. * @hidden
  77789. */
  77790. private _target;
  77791. /**
  77792. * Internal only
  77793. * @hidden
  77794. */
  77795. private _effectiveTarget;
  77796. /**
  77797. * Internal only
  77798. * @hidden
  77799. */
  77800. private _property;
  77801. /**
  77802. * Creates a new ValueCondition
  77803. * @param actionManager manager for the action the condition applies to
  77804. * @param target for the action
  77805. * @param propertyPath path to specify the property of the target the conditional operator uses
  77806. * @param value the value compared by the conditional operator against the current value of the property
  77807. * @param operator the conditional operator, default ValueCondition.IsEqual
  77808. */
  77809. constructor(actionManager: ActionManager, target: any,
  77810. /** path to specify the property of the target the conditional operator uses */
  77811. propertyPath: string,
  77812. /** the value compared by the conditional operator against the current value of the property */
  77813. value: any,
  77814. /** the conditional operator, default ValueCondition.IsEqual */
  77815. operator?: number);
  77816. /**
  77817. * Compares the given value with the property value for the specified conditional operator
  77818. * @returns the result of the comparison
  77819. */
  77820. isValid(): boolean;
  77821. /**
  77822. * Serialize the ValueCondition into a JSON compatible object
  77823. * @returns serialization object
  77824. */
  77825. serialize(): any;
  77826. /**
  77827. * Gets the name of the conditional operator for the ValueCondition
  77828. * @param operator the conditional operator
  77829. * @returns the name
  77830. */
  77831. static GetOperatorName(operator: number): string;
  77832. }
  77833. /**
  77834. * Defines a predicate condition as an extension of Condition
  77835. */
  77836. export class PredicateCondition extends Condition {
  77837. /** defines the predicate function used to validate the condition */
  77838. predicate: () => boolean;
  77839. /**
  77840. * Internal only - manager for action
  77841. * @hidden
  77842. */
  77843. _actionManager: ActionManager;
  77844. /**
  77845. * Creates a new PredicateCondition
  77846. * @param actionManager manager for the action the condition applies to
  77847. * @param predicate defines the predicate function used to validate the condition
  77848. */
  77849. constructor(actionManager: ActionManager,
  77850. /** defines the predicate function used to validate the condition */
  77851. predicate: () => boolean);
  77852. /**
  77853. * @returns the validity of the predicate condition
  77854. */
  77855. isValid(): boolean;
  77856. }
  77857. /**
  77858. * Defines a state condition as an extension of Condition
  77859. */
  77860. export class StateCondition extends Condition {
  77861. /** Value to compare with target state */
  77862. value: string;
  77863. /**
  77864. * Internal only - manager for action
  77865. * @hidden
  77866. */
  77867. _actionManager: ActionManager;
  77868. /**
  77869. * Internal only
  77870. * @hidden
  77871. */
  77872. private _target;
  77873. /**
  77874. * Creates a new StateCondition
  77875. * @param actionManager manager for the action the condition applies to
  77876. * @param target of the condition
  77877. * @param value to compare with target state
  77878. */
  77879. constructor(actionManager: ActionManager, target: any,
  77880. /** Value to compare with target state */
  77881. value: string);
  77882. /**
  77883. * Gets a boolean indicating if the current condition is met
  77884. * @returns the validity of the state
  77885. */
  77886. isValid(): boolean;
  77887. /**
  77888. * Serialize the StateCondition into a JSON compatible object
  77889. * @returns serialization object
  77890. */
  77891. serialize(): any;
  77892. }
  77893. }
  77894. declare module BABYLON {
  77895. /**
  77896. * This defines an action responsible to toggle a boolean once triggered.
  77897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77898. */
  77899. export class SwitchBooleanAction extends Action {
  77900. /**
  77901. * The path to the boolean property in the target object
  77902. */
  77903. propertyPath: string;
  77904. private _target;
  77905. private _effectiveTarget;
  77906. private _property;
  77907. /**
  77908. * Instantiate the action
  77909. * @param triggerOptions defines the trigger options
  77910. * @param target defines the object containing the boolean
  77911. * @param propertyPath defines the path to the boolean property in the target object
  77912. * @param condition defines the trigger related conditions
  77913. */
  77914. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77915. /** @hidden */
  77916. _prepare(): void;
  77917. /**
  77918. * Execute the action toggle the boolean value.
  77919. */
  77920. execute(): void;
  77921. /**
  77922. * Serializes the actions and its related information.
  77923. * @param parent defines the object to serialize in
  77924. * @returns the serialized object
  77925. */
  77926. serialize(parent: any): any;
  77927. }
  77928. /**
  77929. * This defines an action responsible to set a the state field of the target
  77930. * to a desired value once triggered.
  77931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77932. */
  77933. export class SetStateAction extends Action {
  77934. /**
  77935. * The value to store in the state field.
  77936. */
  77937. value: string;
  77938. private _target;
  77939. /**
  77940. * Instantiate the action
  77941. * @param triggerOptions defines the trigger options
  77942. * @param target defines the object containing the state property
  77943. * @param value defines the value to store in the state field
  77944. * @param condition defines the trigger related conditions
  77945. */
  77946. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77947. /**
  77948. * Execute the action and store the value on the target state property.
  77949. */
  77950. execute(): void;
  77951. /**
  77952. * Serializes the actions and its related information.
  77953. * @param parent defines the object to serialize in
  77954. * @returns the serialized object
  77955. */
  77956. serialize(parent: any): any;
  77957. }
  77958. /**
  77959. * This defines an action responsible to set a property of the target
  77960. * to a desired value once triggered.
  77961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77962. */
  77963. export class SetValueAction extends Action {
  77964. /**
  77965. * The path of the property to set in the target.
  77966. */
  77967. propertyPath: string;
  77968. /**
  77969. * The value to set in the property
  77970. */
  77971. value: any;
  77972. private _target;
  77973. private _effectiveTarget;
  77974. private _property;
  77975. /**
  77976. * Instantiate the action
  77977. * @param triggerOptions defines the trigger options
  77978. * @param target defines the object containing the property
  77979. * @param propertyPath defines the path of the property to set in the target
  77980. * @param value defines the value to set in the property
  77981. * @param condition defines the trigger related conditions
  77982. */
  77983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77984. /** @hidden */
  77985. _prepare(): void;
  77986. /**
  77987. * Execute the action and set the targetted property to the desired value.
  77988. */
  77989. execute(): void;
  77990. /**
  77991. * Serializes the actions and its related information.
  77992. * @param parent defines the object to serialize in
  77993. * @returns the serialized object
  77994. */
  77995. serialize(parent: any): any;
  77996. }
  77997. /**
  77998. * This defines an action responsible to increment the target value
  77999. * to a desired value once triggered.
  78000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78001. */
  78002. export class IncrementValueAction extends Action {
  78003. /**
  78004. * The path of the property to increment in the target.
  78005. */
  78006. propertyPath: string;
  78007. /**
  78008. * The value we should increment the property by.
  78009. */
  78010. value: any;
  78011. private _target;
  78012. private _effectiveTarget;
  78013. private _property;
  78014. /**
  78015. * Instantiate the action
  78016. * @param triggerOptions defines the trigger options
  78017. * @param target defines the object containing the property
  78018. * @param propertyPath defines the path of the property to increment in the target
  78019. * @param value defines the value value we should increment the property by
  78020. * @param condition defines the trigger related conditions
  78021. */
  78022. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78023. /** @hidden */
  78024. _prepare(): void;
  78025. /**
  78026. * Execute the action and increment the target of the value amount.
  78027. */
  78028. execute(): void;
  78029. /**
  78030. * Serializes the actions and its related information.
  78031. * @param parent defines the object to serialize in
  78032. * @returns the serialized object
  78033. */
  78034. serialize(parent: any): any;
  78035. }
  78036. /**
  78037. * This defines an action responsible to start an animation once triggered.
  78038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78039. */
  78040. export class PlayAnimationAction extends Action {
  78041. /**
  78042. * Where the animation should start (animation frame)
  78043. */
  78044. from: number;
  78045. /**
  78046. * Where the animation should stop (animation frame)
  78047. */
  78048. to: number;
  78049. /**
  78050. * Define if the animation should loop or stop after the first play.
  78051. */
  78052. loop?: boolean;
  78053. private _target;
  78054. /**
  78055. * Instantiate the action
  78056. * @param triggerOptions defines the trigger options
  78057. * @param target defines the target animation or animation name
  78058. * @param from defines from where the animation should start (animation frame)
  78059. * @param end defines where the animation should stop (animation frame)
  78060. * @param loop defines if the animation should loop or stop after the first play
  78061. * @param condition defines the trigger related conditions
  78062. */
  78063. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78064. /** @hidden */
  78065. _prepare(): void;
  78066. /**
  78067. * Execute the action and play the animation.
  78068. */
  78069. execute(): void;
  78070. /**
  78071. * Serializes the actions and its related information.
  78072. * @param parent defines the object to serialize in
  78073. * @returns the serialized object
  78074. */
  78075. serialize(parent: any): any;
  78076. }
  78077. /**
  78078. * This defines an action responsible to stop an animation once triggered.
  78079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78080. */
  78081. export class StopAnimationAction extends Action {
  78082. private _target;
  78083. /**
  78084. * Instantiate the action
  78085. * @param triggerOptions defines the trigger options
  78086. * @param target defines the target animation or animation name
  78087. * @param condition defines the trigger related conditions
  78088. */
  78089. constructor(triggerOptions: any, target: any, condition?: Condition);
  78090. /** @hidden */
  78091. _prepare(): void;
  78092. /**
  78093. * Execute the action and stop the animation.
  78094. */
  78095. execute(): void;
  78096. /**
  78097. * Serializes the actions and its related information.
  78098. * @param parent defines the object to serialize in
  78099. * @returns the serialized object
  78100. */
  78101. serialize(parent: any): any;
  78102. }
  78103. /**
  78104. * This defines an action responsible that does nothing once triggered.
  78105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78106. */
  78107. export class DoNothingAction extends Action {
  78108. /**
  78109. * Instantiate the action
  78110. * @param triggerOptions defines the trigger options
  78111. * @param condition defines the trigger related conditions
  78112. */
  78113. constructor(triggerOptions?: any, condition?: Condition);
  78114. /**
  78115. * Execute the action and do nothing.
  78116. */
  78117. execute(): void;
  78118. /**
  78119. * Serializes the actions and its related information.
  78120. * @param parent defines the object to serialize in
  78121. * @returns the serialized object
  78122. */
  78123. serialize(parent: any): any;
  78124. }
  78125. /**
  78126. * This defines an action responsible to trigger several actions once triggered.
  78127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78128. */
  78129. export class CombineAction extends Action {
  78130. /**
  78131. * The list of aggregated animations to run.
  78132. */
  78133. children: Action[];
  78134. /**
  78135. * Instantiate the action
  78136. * @param triggerOptions defines the trigger options
  78137. * @param children defines the list of aggregated animations to run
  78138. * @param condition defines the trigger related conditions
  78139. */
  78140. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78141. /** @hidden */
  78142. _prepare(): void;
  78143. /**
  78144. * Execute the action and executes all the aggregated actions.
  78145. */
  78146. execute(evt: ActionEvent): void;
  78147. /**
  78148. * Serializes the actions and its related information.
  78149. * @param parent defines the object to serialize in
  78150. * @returns the serialized object
  78151. */
  78152. serialize(parent: any): any;
  78153. }
  78154. /**
  78155. * This defines an action responsible to run code (external event) once triggered.
  78156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78157. */
  78158. export class ExecuteCodeAction extends Action {
  78159. /**
  78160. * The callback function to run.
  78161. */
  78162. func: (evt: ActionEvent) => void;
  78163. /**
  78164. * Instantiate the action
  78165. * @param triggerOptions defines the trigger options
  78166. * @param func defines the callback function to run
  78167. * @param condition defines the trigger related conditions
  78168. */
  78169. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78170. /**
  78171. * Execute the action and run the attached code.
  78172. */
  78173. execute(evt: ActionEvent): void;
  78174. }
  78175. /**
  78176. * This defines an action responsible to set the parent property of the target once triggered.
  78177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78178. */
  78179. export class SetParentAction extends Action {
  78180. private _parent;
  78181. private _target;
  78182. /**
  78183. * Instantiate the action
  78184. * @param triggerOptions defines the trigger options
  78185. * @param target defines the target containing the parent property
  78186. * @param parent defines from where the animation should start (animation frame)
  78187. * @param condition defines the trigger related conditions
  78188. */
  78189. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78190. /** @hidden */
  78191. _prepare(): void;
  78192. /**
  78193. * Execute the action and set the parent property.
  78194. */
  78195. execute(): void;
  78196. /**
  78197. * Serializes the actions and its related information.
  78198. * @param parent defines the object to serialize in
  78199. * @returns the serialized object
  78200. */
  78201. serialize(parent: any): any;
  78202. }
  78203. }
  78204. declare module BABYLON {
  78205. /**
  78206. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78207. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78209. */
  78210. export class ActionManager extends AbstractActionManager {
  78211. /**
  78212. * Nothing
  78213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78214. */
  78215. static readonly NothingTrigger: number;
  78216. /**
  78217. * On pick
  78218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78219. */
  78220. static readonly OnPickTrigger: number;
  78221. /**
  78222. * On left pick
  78223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78224. */
  78225. static readonly OnLeftPickTrigger: number;
  78226. /**
  78227. * On right pick
  78228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78229. */
  78230. static readonly OnRightPickTrigger: number;
  78231. /**
  78232. * On center pick
  78233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78234. */
  78235. static readonly OnCenterPickTrigger: number;
  78236. /**
  78237. * On pick down
  78238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78239. */
  78240. static readonly OnPickDownTrigger: number;
  78241. /**
  78242. * On double pick
  78243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78244. */
  78245. static readonly OnDoublePickTrigger: number;
  78246. /**
  78247. * On pick up
  78248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78249. */
  78250. static readonly OnPickUpTrigger: number;
  78251. /**
  78252. * On pick out.
  78253. * This trigger will only be raised if you also declared a OnPickDown
  78254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78255. */
  78256. static readonly OnPickOutTrigger: number;
  78257. /**
  78258. * On long press
  78259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78260. */
  78261. static readonly OnLongPressTrigger: number;
  78262. /**
  78263. * On pointer over
  78264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78265. */
  78266. static readonly OnPointerOverTrigger: number;
  78267. /**
  78268. * On pointer out
  78269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78270. */
  78271. static readonly OnPointerOutTrigger: number;
  78272. /**
  78273. * On every frame
  78274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78275. */
  78276. static readonly OnEveryFrameTrigger: number;
  78277. /**
  78278. * On intersection enter
  78279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78280. */
  78281. static readonly OnIntersectionEnterTrigger: number;
  78282. /**
  78283. * On intersection exit
  78284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78285. */
  78286. static readonly OnIntersectionExitTrigger: number;
  78287. /**
  78288. * On key down
  78289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78290. */
  78291. static readonly OnKeyDownTrigger: number;
  78292. /**
  78293. * On key up
  78294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78295. */
  78296. static readonly OnKeyUpTrigger: number;
  78297. private _scene;
  78298. /**
  78299. * Creates a new action manager
  78300. * @param scene defines the hosting scene
  78301. */
  78302. constructor(scene: Scene);
  78303. /**
  78304. * Releases all associated resources
  78305. */
  78306. dispose(): void;
  78307. /**
  78308. * Gets hosting scene
  78309. * @returns the hosting scene
  78310. */
  78311. getScene(): Scene;
  78312. /**
  78313. * Does this action manager handles actions of any of the given triggers
  78314. * @param triggers defines the triggers to be tested
  78315. * @return a boolean indicating whether one (or more) of the triggers is handled
  78316. */
  78317. hasSpecificTriggers(triggers: number[]): boolean;
  78318. /**
  78319. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78320. * speed.
  78321. * @param triggerA defines the trigger to be tested
  78322. * @param triggerB defines the trigger to be tested
  78323. * @return a boolean indicating whether one (or more) of the triggers is handled
  78324. */
  78325. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78326. /**
  78327. * Does this action manager handles actions of a given trigger
  78328. * @param trigger defines the trigger to be tested
  78329. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78330. * @return whether the trigger is handled
  78331. */
  78332. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78333. /**
  78334. * Does this action manager has pointer triggers
  78335. */
  78336. readonly hasPointerTriggers: boolean;
  78337. /**
  78338. * Does this action manager has pick triggers
  78339. */
  78340. readonly hasPickTriggers: boolean;
  78341. /**
  78342. * Registers an action to this action manager
  78343. * @param action defines the action to be registered
  78344. * @return the action amended (prepared) after registration
  78345. */
  78346. registerAction(action: IAction): Nullable<IAction>;
  78347. /**
  78348. * Unregisters an action to this action manager
  78349. * @param action defines the action to be unregistered
  78350. * @return a boolean indicating whether the action has been unregistered
  78351. */
  78352. unregisterAction(action: IAction): Boolean;
  78353. /**
  78354. * Process a specific trigger
  78355. * @param trigger defines the trigger to process
  78356. * @param evt defines the event details to be processed
  78357. */
  78358. processTrigger(trigger: number, evt?: IActionEvent): void;
  78359. /** @hidden */
  78360. _getEffectiveTarget(target: any, propertyPath: string): any;
  78361. /** @hidden */
  78362. _getProperty(propertyPath: string): string;
  78363. /**
  78364. * Serialize this manager to a JSON object
  78365. * @param name defines the property name to store this manager
  78366. * @returns a JSON representation of this manager
  78367. */
  78368. serialize(name: string): any;
  78369. /**
  78370. * Creates a new ActionManager from a JSON data
  78371. * @param parsedActions defines the JSON data to read from
  78372. * @param object defines the hosting mesh
  78373. * @param scene defines the hosting scene
  78374. */
  78375. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78376. /**
  78377. * Get a trigger name by index
  78378. * @param trigger defines the trigger index
  78379. * @returns a trigger name
  78380. */
  78381. static GetTriggerName(trigger: number): string;
  78382. }
  78383. }
  78384. declare module BABYLON {
  78385. /**
  78386. * Class representing a ray with position and direction
  78387. */
  78388. export class Ray {
  78389. /** origin point */
  78390. origin: Vector3;
  78391. /** direction */
  78392. direction: Vector3;
  78393. /** length of the ray */
  78394. length: number;
  78395. private static readonly TmpVector3;
  78396. private _tmpRay;
  78397. /**
  78398. * Creates a new ray
  78399. * @param origin origin point
  78400. * @param direction direction
  78401. * @param length length of the ray
  78402. */
  78403. constructor(
  78404. /** origin point */
  78405. origin: Vector3,
  78406. /** direction */
  78407. direction: Vector3,
  78408. /** length of the ray */
  78409. length?: number);
  78410. /**
  78411. * Checks if the ray intersects a box
  78412. * @param minimum bound of the box
  78413. * @param maximum bound of the box
  78414. * @param intersectionTreshold extra extend to be added to the box in all direction
  78415. * @returns if the box was hit
  78416. */
  78417. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78418. /**
  78419. * Checks if the ray intersects a box
  78420. * @param box the bounding box to check
  78421. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78422. * @returns if the box was hit
  78423. */
  78424. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78425. /**
  78426. * If the ray hits a sphere
  78427. * @param sphere the bounding sphere to check
  78428. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78429. * @returns true if it hits the sphere
  78430. */
  78431. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78432. /**
  78433. * If the ray hits a triange
  78434. * @param vertex0 triangle vertex
  78435. * @param vertex1 triangle vertex
  78436. * @param vertex2 triangle vertex
  78437. * @returns intersection information if hit
  78438. */
  78439. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78440. /**
  78441. * Checks if ray intersects a plane
  78442. * @param plane the plane to check
  78443. * @returns the distance away it was hit
  78444. */
  78445. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78446. /**
  78447. * Calculate the intercept of a ray on a given axis
  78448. * @param axis to check 'x' | 'y' | 'z'
  78449. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78450. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78451. */
  78452. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78453. /**
  78454. * Checks if ray intersects a mesh
  78455. * @param mesh the mesh to check
  78456. * @param fastCheck if only the bounding box should checked
  78457. * @returns picking info of the intersecton
  78458. */
  78459. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78460. /**
  78461. * Checks if ray intersects a mesh
  78462. * @param meshes the meshes to check
  78463. * @param fastCheck if only the bounding box should checked
  78464. * @param results array to store result in
  78465. * @returns Array of picking infos
  78466. */
  78467. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78468. private _comparePickingInfo;
  78469. private static smallnum;
  78470. private static rayl;
  78471. /**
  78472. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78473. * @param sega the first point of the segment to test the intersection against
  78474. * @param segb the second point of the segment to test the intersection against
  78475. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78476. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78477. */
  78478. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78479. /**
  78480. * Update the ray from viewport position
  78481. * @param x position
  78482. * @param y y position
  78483. * @param viewportWidth viewport width
  78484. * @param viewportHeight viewport height
  78485. * @param world world matrix
  78486. * @param view view matrix
  78487. * @param projection projection matrix
  78488. * @returns this ray updated
  78489. */
  78490. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78491. /**
  78492. * Creates a ray with origin and direction of 0,0,0
  78493. * @returns the new ray
  78494. */
  78495. static Zero(): Ray;
  78496. /**
  78497. * Creates a new ray from screen space and viewport
  78498. * @param x position
  78499. * @param y y position
  78500. * @param viewportWidth viewport width
  78501. * @param viewportHeight viewport height
  78502. * @param world world matrix
  78503. * @param view view matrix
  78504. * @param projection projection matrix
  78505. * @returns new ray
  78506. */
  78507. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78508. /**
  78509. * 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
  78510. * transformed to the given world matrix.
  78511. * @param origin The origin point
  78512. * @param end The end point
  78513. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78514. * @returns the new ray
  78515. */
  78516. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78517. /**
  78518. * Transforms a ray by a matrix
  78519. * @param ray ray to transform
  78520. * @param matrix matrix to apply
  78521. * @returns the resulting new ray
  78522. */
  78523. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78524. /**
  78525. * Transforms a ray by a matrix
  78526. * @param ray ray to transform
  78527. * @param matrix matrix to apply
  78528. * @param result ray to store result in
  78529. */
  78530. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78531. /**
  78532. * Unproject a ray from screen space to object space
  78533. * @param sourceX defines the screen space x coordinate to use
  78534. * @param sourceY defines the screen space y coordinate to use
  78535. * @param viewportWidth defines the current width of the viewport
  78536. * @param viewportHeight defines the current height of the viewport
  78537. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78538. * @param view defines the view matrix to use
  78539. * @param projection defines the projection matrix to use
  78540. */
  78541. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78542. }
  78543. /**
  78544. * Type used to define predicate used to select faces when a mesh intersection is detected
  78545. */
  78546. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78547. interface Scene {
  78548. /** @hidden */
  78549. _tempPickingRay: Nullable<Ray>;
  78550. /** @hidden */
  78551. _cachedRayForTransform: Ray;
  78552. /** @hidden */
  78553. _pickWithRayInverseMatrix: Matrix;
  78554. /** @hidden */
  78555. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78556. /** @hidden */
  78557. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78558. }
  78559. }
  78560. declare module BABYLON {
  78561. /**
  78562. * Groups all the scene component constants in one place to ease maintenance.
  78563. * @hidden
  78564. */
  78565. export class SceneComponentConstants {
  78566. static readonly NAME_EFFECTLAYER: string;
  78567. static readonly NAME_LAYER: string;
  78568. static readonly NAME_LENSFLARESYSTEM: string;
  78569. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78570. static readonly NAME_PARTICLESYSTEM: string;
  78571. static readonly NAME_GAMEPAD: string;
  78572. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78573. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78574. static readonly NAME_DEPTHRENDERER: string;
  78575. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78576. static readonly NAME_SPRITE: string;
  78577. static readonly NAME_OUTLINERENDERER: string;
  78578. static readonly NAME_PROCEDURALTEXTURE: string;
  78579. static readonly NAME_SHADOWGENERATOR: string;
  78580. static readonly NAME_OCTREE: string;
  78581. static readonly NAME_PHYSICSENGINE: string;
  78582. static readonly NAME_AUDIO: string;
  78583. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78584. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78585. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78586. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78587. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78588. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78589. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78590. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78591. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78592. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78593. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78594. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78595. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78596. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78597. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78598. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78599. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78600. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78601. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78602. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78603. static readonly STEP_AFTERRENDER_AUDIO: number;
  78604. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78605. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78606. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78607. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78608. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78609. static readonly STEP_POINTERMOVE_SPRITE: number;
  78610. static readonly STEP_POINTERDOWN_SPRITE: number;
  78611. static readonly STEP_POINTERUP_SPRITE: number;
  78612. }
  78613. /**
  78614. * This represents a scene component.
  78615. *
  78616. * This is used to decouple the dependency the scene is having on the different workloads like
  78617. * layers, post processes...
  78618. */
  78619. export interface ISceneComponent {
  78620. /**
  78621. * The name of the component. Each component must have a unique name.
  78622. */
  78623. name: string;
  78624. /**
  78625. * The scene the component belongs to.
  78626. */
  78627. scene: Scene;
  78628. /**
  78629. * Register the component to one instance of a scene.
  78630. */
  78631. register(): void;
  78632. /**
  78633. * Rebuilds the elements related to this component in case of
  78634. * context lost for instance.
  78635. */
  78636. rebuild(): void;
  78637. /**
  78638. * Disposes the component and the associated ressources.
  78639. */
  78640. dispose(): void;
  78641. }
  78642. /**
  78643. * This represents a SERIALIZABLE scene component.
  78644. *
  78645. * This extends Scene Component to add Serialization methods on top.
  78646. */
  78647. export interface ISceneSerializableComponent extends ISceneComponent {
  78648. /**
  78649. * Adds all the elements from the container to the scene
  78650. * @param container the container holding the elements
  78651. */
  78652. addFromContainer(container: AbstractScene): void;
  78653. /**
  78654. * Removes all the elements in the container from the scene
  78655. * @param container contains the elements to remove
  78656. * @param dispose if the removed element should be disposed (default: false)
  78657. */
  78658. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78659. /**
  78660. * Serializes the component data to the specified json object
  78661. * @param serializationObject The object to serialize to
  78662. */
  78663. serialize(serializationObject: any): void;
  78664. }
  78665. /**
  78666. * Strong typing of a Mesh related stage step action
  78667. */
  78668. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78669. /**
  78670. * Strong typing of a Evaluate Sub Mesh related stage step action
  78671. */
  78672. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78673. /**
  78674. * Strong typing of a Active Mesh related stage step action
  78675. */
  78676. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78677. /**
  78678. * Strong typing of a Camera related stage step action
  78679. */
  78680. export type CameraStageAction = (camera: Camera) => void;
  78681. /**
  78682. * Strong typing of a Camera Frame buffer related stage step action
  78683. */
  78684. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78685. /**
  78686. * Strong typing of a Render Target related stage step action
  78687. */
  78688. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78689. /**
  78690. * Strong typing of a RenderingGroup related stage step action
  78691. */
  78692. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78693. /**
  78694. * Strong typing of a Mesh Render related stage step action
  78695. */
  78696. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78697. /**
  78698. * Strong typing of a simple stage step action
  78699. */
  78700. export type SimpleStageAction = () => void;
  78701. /**
  78702. * Strong typing of a render target action.
  78703. */
  78704. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78705. /**
  78706. * Strong typing of a pointer move action.
  78707. */
  78708. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78709. /**
  78710. * Strong typing of a pointer up/down action.
  78711. */
  78712. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78713. /**
  78714. * Representation of a stage in the scene (Basically a list of ordered steps)
  78715. * @hidden
  78716. */
  78717. export class Stage<T extends Function> extends Array<{
  78718. index: number;
  78719. component: ISceneComponent;
  78720. action: T;
  78721. }> {
  78722. /**
  78723. * Hide ctor from the rest of the world.
  78724. * @param items The items to add.
  78725. */
  78726. private constructor();
  78727. /**
  78728. * Creates a new Stage.
  78729. * @returns A new instance of a Stage
  78730. */
  78731. static Create<T extends Function>(): Stage<T>;
  78732. /**
  78733. * Registers a step in an ordered way in the targeted stage.
  78734. * @param index Defines the position to register the step in
  78735. * @param component Defines the component attached to the step
  78736. * @param action Defines the action to launch during the step
  78737. */
  78738. registerStep(index: number, component: ISceneComponent, action: T): void;
  78739. /**
  78740. * Clears all the steps from the stage.
  78741. */
  78742. clear(): void;
  78743. }
  78744. }
  78745. declare module BABYLON {
  78746. interface Scene {
  78747. /** @hidden */
  78748. _pointerOverSprite: Nullable<Sprite>;
  78749. /** @hidden */
  78750. _pickedDownSprite: Nullable<Sprite>;
  78751. /** @hidden */
  78752. _tempSpritePickingRay: Nullable<Ray>;
  78753. /**
  78754. * All of the sprite managers added to this scene
  78755. * @see http://doc.babylonjs.com/babylon101/sprites
  78756. */
  78757. spriteManagers: Array<ISpriteManager>;
  78758. /**
  78759. * An event triggered when sprites rendering is about to start
  78760. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78761. */
  78762. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78763. /**
  78764. * An event triggered when sprites rendering is done
  78765. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78766. */
  78767. onAfterSpritesRenderingObservable: Observable<Scene>;
  78768. /** @hidden */
  78769. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78770. /** Launch a ray to try to pick a sprite in the scene
  78771. * @param x position on screen
  78772. * @param y position on screen
  78773. * @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
  78774. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78775. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78776. * @returns a PickingInfo
  78777. */
  78778. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78779. /** Use the given ray to pick a sprite in the scene
  78780. * @param ray The ray (in world space) to use to pick meshes
  78781. * @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
  78782. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78783. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78784. * @returns a PickingInfo
  78785. */
  78786. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78787. /** @hidden */
  78788. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78789. /** Launch a ray to try to pick sprites in the scene
  78790. * @param x position on screen
  78791. * @param y position on screen
  78792. * @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
  78793. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78794. * @returns a PickingInfo array
  78795. */
  78796. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78797. /** Use the given ray to pick sprites in the scene
  78798. * @param ray The ray (in world space) to use to pick meshes
  78799. * @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
  78800. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78801. * @returns a PickingInfo array
  78802. */
  78803. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78804. /**
  78805. * Force the sprite under the pointer
  78806. * @param sprite defines the sprite to use
  78807. */
  78808. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78809. /**
  78810. * Gets the sprite under the pointer
  78811. * @returns a Sprite or null if no sprite is under the pointer
  78812. */
  78813. getPointerOverSprite(): Nullable<Sprite>;
  78814. }
  78815. /**
  78816. * Defines the sprite scene component responsible to manage sprites
  78817. * in a given scene.
  78818. */
  78819. export class SpriteSceneComponent implements ISceneComponent {
  78820. /**
  78821. * The component name helpfull to identify the component in the list of scene components.
  78822. */
  78823. readonly name: string;
  78824. /**
  78825. * The scene the component belongs to.
  78826. */
  78827. scene: Scene;
  78828. /** @hidden */
  78829. private _spritePredicate;
  78830. /**
  78831. * Creates a new instance of the component for the given scene
  78832. * @param scene Defines the scene to register the component in
  78833. */
  78834. constructor(scene: Scene);
  78835. /**
  78836. * Registers the component in a given scene
  78837. */
  78838. register(): void;
  78839. /**
  78840. * Rebuilds the elements related to this component in case of
  78841. * context lost for instance.
  78842. */
  78843. rebuild(): void;
  78844. /**
  78845. * Disposes the component and the associated ressources.
  78846. */
  78847. dispose(): void;
  78848. private _pickSpriteButKeepRay;
  78849. private _pointerMove;
  78850. private _pointerDown;
  78851. private _pointerUp;
  78852. }
  78853. }
  78854. declare module BABYLON {
  78855. /** @hidden */
  78856. export var fogFragmentDeclaration: {
  78857. name: string;
  78858. shader: string;
  78859. };
  78860. }
  78861. declare module BABYLON {
  78862. /** @hidden */
  78863. export var fogFragment: {
  78864. name: string;
  78865. shader: string;
  78866. };
  78867. }
  78868. declare module BABYLON {
  78869. /** @hidden */
  78870. export var spritesPixelShader: {
  78871. name: string;
  78872. shader: string;
  78873. };
  78874. }
  78875. declare module BABYLON {
  78876. /** @hidden */
  78877. export var fogVertexDeclaration: {
  78878. name: string;
  78879. shader: string;
  78880. };
  78881. }
  78882. declare module BABYLON {
  78883. /** @hidden */
  78884. export var spritesVertexShader: {
  78885. name: string;
  78886. shader: string;
  78887. };
  78888. }
  78889. declare module BABYLON {
  78890. /**
  78891. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78892. */
  78893. export interface ISpriteManager extends IDisposable {
  78894. /**
  78895. * Restricts the camera to viewing objects with the same layerMask.
  78896. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78897. */
  78898. layerMask: number;
  78899. /**
  78900. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78901. */
  78902. isPickable: boolean;
  78903. /**
  78904. * Specifies the rendering group id for this mesh (0 by default)
  78905. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78906. */
  78907. renderingGroupId: number;
  78908. /**
  78909. * Defines the list of sprites managed by the manager.
  78910. */
  78911. sprites: Array<Sprite>;
  78912. /**
  78913. * Tests the intersection of a sprite with a specific ray.
  78914. * @param ray The ray we are sending to test the collision
  78915. * @param camera The camera space we are sending rays in
  78916. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78917. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78918. * @returns picking info or null.
  78919. */
  78920. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78921. /**
  78922. * Intersects the sprites with a ray
  78923. * @param ray defines the ray to intersect with
  78924. * @param camera defines the current active camera
  78925. * @param predicate defines a predicate used to select candidate sprites
  78926. * @returns null if no hit or a PickingInfo array
  78927. */
  78928. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78929. /**
  78930. * Renders the list of sprites on screen.
  78931. */
  78932. render(): void;
  78933. }
  78934. /**
  78935. * Class used to manage multiple sprites on the same spritesheet
  78936. * @see http://doc.babylonjs.com/babylon101/sprites
  78937. */
  78938. export class SpriteManager implements ISpriteManager {
  78939. /** defines the manager's name */
  78940. name: string;
  78941. /** Gets the list of sprites */
  78942. sprites: Sprite[];
  78943. /** Gets or sets the rendering group id (0 by default) */
  78944. renderingGroupId: number;
  78945. /** Gets or sets camera layer mask */
  78946. layerMask: number;
  78947. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78948. fogEnabled: boolean;
  78949. /** Gets or sets a boolean indicating if the sprites are pickable */
  78950. isPickable: boolean;
  78951. /** Defines the default width of a cell in the spritesheet */
  78952. cellWidth: number;
  78953. /** Defines the default height of a cell in the spritesheet */
  78954. cellHeight: number;
  78955. /** Associative array from JSON sprite data file */
  78956. private _cellData;
  78957. /** Array of sprite names from JSON sprite data file */
  78958. private _spriteMap;
  78959. /** True when packed cell data from JSON file is ready*/
  78960. private _packedAndReady;
  78961. /**
  78962. * An event triggered when the manager is disposed.
  78963. */
  78964. onDisposeObservable: Observable<SpriteManager>;
  78965. private _onDisposeObserver;
  78966. /**
  78967. * Callback called when the manager is disposed
  78968. */
  78969. onDispose: () => void;
  78970. private _capacity;
  78971. private _fromPacked;
  78972. private _spriteTexture;
  78973. private _epsilon;
  78974. private _scene;
  78975. private _vertexData;
  78976. private _buffer;
  78977. private _vertexBuffers;
  78978. private _indexBuffer;
  78979. private _effectBase;
  78980. private _effectFog;
  78981. /**
  78982. * Gets or sets the spritesheet texture
  78983. */
  78984. texture: Texture;
  78985. /**
  78986. * Creates a new sprite manager
  78987. * @param name defines the manager's name
  78988. * @param imgUrl defines the sprite sheet url
  78989. * @param capacity defines the maximum allowed number of sprites
  78990. * @param cellSize defines the size of a sprite cell
  78991. * @param scene defines the hosting scene
  78992. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78993. * @param samplingMode defines the smapling mode to use with spritesheet
  78994. * @param fromPacked set to false; do not alter
  78995. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78996. */
  78997. constructor(
  78998. /** defines the manager's name */
  78999. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79000. private _makePacked;
  79001. private _appendSpriteVertex;
  79002. /**
  79003. * Intersects the sprites with a ray
  79004. * @param ray defines the ray to intersect with
  79005. * @param camera defines the current active camera
  79006. * @param predicate defines a predicate used to select candidate sprites
  79007. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79008. * @returns null if no hit or a PickingInfo
  79009. */
  79010. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79011. /**
  79012. * Intersects the sprites with a ray
  79013. * @param ray defines the ray to intersect with
  79014. * @param camera defines the current active camera
  79015. * @param predicate defines a predicate used to select candidate sprites
  79016. * @returns null if no hit or a PickingInfo array
  79017. */
  79018. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79019. /**
  79020. * Render all child sprites
  79021. */
  79022. render(): void;
  79023. /**
  79024. * Release associated resources
  79025. */
  79026. dispose(): void;
  79027. }
  79028. }
  79029. declare module BABYLON {
  79030. /**
  79031. * Class used to represent a sprite
  79032. * @see http://doc.babylonjs.com/babylon101/sprites
  79033. */
  79034. export class Sprite {
  79035. /** defines the name */
  79036. name: string;
  79037. /** Gets or sets the current world position */
  79038. position: Vector3;
  79039. /** Gets or sets the main color */
  79040. color: Color4;
  79041. /** Gets or sets the width */
  79042. width: number;
  79043. /** Gets or sets the height */
  79044. height: number;
  79045. /** Gets or sets rotation angle */
  79046. angle: number;
  79047. /** Gets or sets the cell index in the sprite sheet */
  79048. cellIndex: number;
  79049. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79050. cellRef: string;
  79051. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79052. invertU: number;
  79053. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79054. invertV: number;
  79055. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79056. disposeWhenFinishedAnimating: boolean;
  79057. /** Gets the list of attached animations */
  79058. animations: Animation[];
  79059. /** Gets or sets a boolean indicating if the sprite can be picked */
  79060. isPickable: boolean;
  79061. /**
  79062. * Gets or sets the associated action manager
  79063. */
  79064. actionManager: Nullable<ActionManager>;
  79065. private _animationStarted;
  79066. private _loopAnimation;
  79067. private _fromIndex;
  79068. private _toIndex;
  79069. private _delay;
  79070. private _direction;
  79071. private _manager;
  79072. private _time;
  79073. private _onAnimationEnd;
  79074. /**
  79075. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79076. */
  79077. isVisible: boolean;
  79078. /**
  79079. * Gets or sets the sprite size
  79080. */
  79081. size: number;
  79082. /**
  79083. * Creates a new Sprite
  79084. * @param name defines the name
  79085. * @param manager defines the manager
  79086. */
  79087. constructor(
  79088. /** defines the name */
  79089. name: string, manager: ISpriteManager);
  79090. /**
  79091. * Starts an animation
  79092. * @param from defines the initial key
  79093. * @param to defines the end key
  79094. * @param loop defines if the animation must loop
  79095. * @param delay defines the start delay (in ms)
  79096. * @param onAnimationEnd defines a callback to call when animation ends
  79097. */
  79098. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79099. /** Stops current animation (if any) */
  79100. stopAnimation(): void;
  79101. /** @hidden */
  79102. _animate(deltaTime: number): void;
  79103. /** Release associated resources */
  79104. dispose(): void;
  79105. }
  79106. }
  79107. declare module BABYLON {
  79108. /**
  79109. * Information about the result of picking within a scene
  79110. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79111. */
  79112. export class PickingInfo {
  79113. /** @hidden */
  79114. _pickingUnavailable: boolean;
  79115. /**
  79116. * If the pick collided with an object
  79117. */
  79118. hit: boolean;
  79119. /**
  79120. * Distance away where the pick collided
  79121. */
  79122. distance: number;
  79123. /**
  79124. * The location of pick collision
  79125. */
  79126. pickedPoint: Nullable<Vector3>;
  79127. /**
  79128. * The mesh corresponding the the pick collision
  79129. */
  79130. pickedMesh: Nullable<AbstractMesh>;
  79131. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79132. bu: number;
  79133. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79134. bv: number;
  79135. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79136. faceId: number;
  79137. /** Id of the the submesh that was picked */
  79138. subMeshId: number;
  79139. /** If a sprite was picked, this will be the sprite the pick collided with */
  79140. pickedSprite: Nullable<Sprite>;
  79141. /**
  79142. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79143. */
  79144. originMesh: Nullable<AbstractMesh>;
  79145. /**
  79146. * The ray that was used to perform the picking.
  79147. */
  79148. ray: Nullable<Ray>;
  79149. /**
  79150. * Gets the normal correspodning to the face the pick collided with
  79151. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79152. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79153. * @returns The normal correspodning to the face the pick collided with
  79154. */
  79155. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79156. /**
  79157. * Gets the texture coordinates of where the pick occured
  79158. * @returns the vector containing the coordnates of the texture
  79159. */
  79160. getTextureCoordinates(): Nullable<Vector2>;
  79161. }
  79162. }
  79163. declare module BABYLON {
  79164. /**
  79165. * Gather the list of pointer event types as constants.
  79166. */
  79167. export class PointerEventTypes {
  79168. /**
  79169. * 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.
  79170. */
  79171. static readonly POINTERDOWN: number;
  79172. /**
  79173. * The pointerup event is fired when a pointer is no longer active.
  79174. */
  79175. static readonly POINTERUP: number;
  79176. /**
  79177. * The pointermove event is fired when a pointer changes coordinates.
  79178. */
  79179. static readonly POINTERMOVE: number;
  79180. /**
  79181. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79182. */
  79183. static readonly POINTERWHEEL: number;
  79184. /**
  79185. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79186. */
  79187. static readonly POINTERPICK: number;
  79188. /**
  79189. * The pointertap event is fired when a the object has been touched and released without drag.
  79190. */
  79191. static readonly POINTERTAP: number;
  79192. /**
  79193. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79194. */
  79195. static readonly POINTERDOUBLETAP: number;
  79196. }
  79197. /**
  79198. * Base class of pointer info types.
  79199. */
  79200. export class PointerInfoBase {
  79201. /**
  79202. * Defines the type of event (PointerEventTypes)
  79203. */
  79204. type: number;
  79205. /**
  79206. * Defines the related dom event
  79207. */
  79208. event: PointerEvent | MouseWheelEvent;
  79209. /**
  79210. * Instantiates the base class of pointers info.
  79211. * @param type Defines the type of event (PointerEventTypes)
  79212. * @param event Defines the related dom event
  79213. */
  79214. constructor(
  79215. /**
  79216. * Defines the type of event (PointerEventTypes)
  79217. */
  79218. type: number,
  79219. /**
  79220. * Defines the related dom event
  79221. */
  79222. event: PointerEvent | MouseWheelEvent);
  79223. }
  79224. /**
  79225. * This class is used to store pointer related info for the onPrePointerObservable event.
  79226. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79227. */
  79228. export class PointerInfoPre extends PointerInfoBase {
  79229. /**
  79230. * Ray from a pointer if availible (eg. 6dof controller)
  79231. */
  79232. ray: Nullable<Ray>;
  79233. /**
  79234. * Defines the local position of the pointer on the canvas.
  79235. */
  79236. localPosition: Vector2;
  79237. /**
  79238. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79239. */
  79240. skipOnPointerObservable: boolean;
  79241. /**
  79242. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79243. * @param type Defines the type of event (PointerEventTypes)
  79244. * @param event Defines the related dom event
  79245. * @param localX Defines the local x coordinates of the pointer when the event occured
  79246. * @param localY Defines the local y coordinates of the pointer when the event occured
  79247. */
  79248. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79249. }
  79250. /**
  79251. * This type contains all the data related to a pointer event in Babylon.js.
  79252. * 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.
  79253. */
  79254. export class PointerInfo extends PointerInfoBase {
  79255. /**
  79256. * Defines the picking info associated to the info (if any)\
  79257. */
  79258. pickInfo: Nullable<PickingInfo>;
  79259. /**
  79260. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79261. * @param type Defines the type of event (PointerEventTypes)
  79262. * @param event Defines the related dom event
  79263. * @param pickInfo Defines the picking info associated to the info (if any)\
  79264. */
  79265. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79266. /**
  79267. * Defines the picking info associated to the info (if any)\
  79268. */
  79269. pickInfo: Nullable<PickingInfo>);
  79270. }
  79271. /**
  79272. * Data relating to a touch event on the screen.
  79273. */
  79274. export interface PointerTouch {
  79275. /**
  79276. * X coordinate of touch.
  79277. */
  79278. x: number;
  79279. /**
  79280. * Y coordinate of touch.
  79281. */
  79282. y: number;
  79283. /**
  79284. * Id of touch. Unique for each finger.
  79285. */
  79286. pointerId: number;
  79287. /**
  79288. * Event type passed from DOM.
  79289. */
  79290. type: any;
  79291. }
  79292. }
  79293. declare module BABYLON {
  79294. /**
  79295. * Manage the mouse inputs to control the movement of a free camera.
  79296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79297. */
  79298. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79299. /**
  79300. * Define if touch is enabled in the mouse input
  79301. */
  79302. touchEnabled: boolean;
  79303. /**
  79304. * Defines the camera the input is attached to.
  79305. */
  79306. camera: FreeCamera;
  79307. /**
  79308. * Defines the buttons associated with the input to handle camera move.
  79309. */
  79310. buttons: number[];
  79311. /**
  79312. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79313. */
  79314. angularSensibility: number;
  79315. private _pointerInput;
  79316. private _onMouseMove;
  79317. private _observer;
  79318. private previousPosition;
  79319. /**
  79320. * Observable for when a pointer move event occurs containing the move offset
  79321. */
  79322. onPointerMovedObservable: Observable<{
  79323. offsetX: number;
  79324. offsetY: number;
  79325. }>;
  79326. /**
  79327. * @hidden
  79328. * If the camera should be rotated automatically based on pointer movement
  79329. */
  79330. _allowCameraRotation: boolean;
  79331. /**
  79332. * Manage the mouse inputs to control the movement of a free camera.
  79333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79334. * @param touchEnabled Defines if touch is enabled or not
  79335. */
  79336. constructor(
  79337. /**
  79338. * Define if touch is enabled in the mouse input
  79339. */
  79340. touchEnabled?: boolean);
  79341. /**
  79342. * Attach the input controls to a specific dom element to get the input from.
  79343. * @param element Defines the element the controls should be listened from
  79344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79345. */
  79346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79347. /**
  79348. * Called on JS contextmenu event.
  79349. * Override this method to provide functionality.
  79350. */
  79351. protected onContextMenu(evt: PointerEvent): void;
  79352. /**
  79353. * Detach the current controls from the specified dom element.
  79354. * @param element Defines the element to stop listening the inputs from
  79355. */
  79356. detachControl(element: Nullable<HTMLElement>): void;
  79357. /**
  79358. * Gets the class name of the current intput.
  79359. * @returns the class name
  79360. */
  79361. getClassName(): string;
  79362. /**
  79363. * Get the friendly name associated with the input class.
  79364. * @returns the input friendly name
  79365. */
  79366. getSimpleName(): string;
  79367. }
  79368. }
  79369. declare module BABYLON {
  79370. /**
  79371. * Manage the touch inputs to control the movement of a free camera.
  79372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79373. */
  79374. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79375. /**
  79376. * Defines the camera the input is attached to.
  79377. */
  79378. camera: FreeCamera;
  79379. /**
  79380. * Defines the touch sensibility for rotation.
  79381. * The higher the faster.
  79382. */
  79383. touchAngularSensibility: number;
  79384. /**
  79385. * Defines the touch sensibility for move.
  79386. * The higher the faster.
  79387. */
  79388. touchMoveSensibility: number;
  79389. private _offsetX;
  79390. private _offsetY;
  79391. private _pointerPressed;
  79392. private _pointerInput;
  79393. private _observer;
  79394. private _onLostFocus;
  79395. /**
  79396. * Attach the input controls to a specific dom element to get the input from.
  79397. * @param element Defines the element the controls should be listened from
  79398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79399. */
  79400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79401. /**
  79402. * Detach the current controls from the specified dom element.
  79403. * @param element Defines the element to stop listening the inputs from
  79404. */
  79405. detachControl(element: Nullable<HTMLElement>): void;
  79406. /**
  79407. * Update the current camera state depending on the inputs that have been used this frame.
  79408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79409. */
  79410. checkInputs(): void;
  79411. /**
  79412. * Gets the class name of the current intput.
  79413. * @returns the class name
  79414. */
  79415. getClassName(): string;
  79416. /**
  79417. * Get the friendly name associated with the input class.
  79418. * @returns the input friendly name
  79419. */
  79420. getSimpleName(): string;
  79421. }
  79422. }
  79423. declare module BABYLON {
  79424. /**
  79425. * Default Inputs manager for the FreeCamera.
  79426. * It groups all the default supported inputs for ease of use.
  79427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79428. */
  79429. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79430. /**
  79431. * @hidden
  79432. */
  79433. _mouseInput: Nullable<FreeCameraMouseInput>;
  79434. /**
  79435. * Instantiates a new FreeCameraInputsManager.
  79436. * @param camera Defines the camera the inputs belong to
  79437. */
  79438. constructor(camera: FreeCamera);
  79439. /**
  79440. * Add keyboard input support to the input manager.
  79441. * @returns the current input manager
  79442. */
  79443. addKeyboard(): FreeCameraInputsManager;
  79444. /**
  79445. * Add mouse input support to the input manager.
  79446. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79447. * @returns the current input manager
  79448. */
  79449. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79450. /**
  79451. * Removes the mouse input support from the manager
  79452. * @returns the current input manager
  79453. */
  79454. removeMouse(): FreeCameraInputsManager;
  79455. /**
  79456. * Add touch input support to the input manager.
  79457. * @returns the current input manager
  79458. */
  79459. addTouch(): FreeCameraInputsManager;
  79460. /**
  79461. * Remove all attached input methods from a camera
  79462. */
  79463. clear(): void;
  79464. }
  79465. }
  79466. declare module BABYLON {
  79467. /**
  79468. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79469. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79471. */
  79472. export class FreeCamera extends TargetCamera {
  79473. /**
  79474. * Define the collision ellipsoid of the camera.
  79475. * This is helpful to simulate a camera body like the player body around the camera
  79476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79477. */
  79478. ellipsoid: Vector3;
  79479. /**
  79480. * Define an offset for the position of the ellipsoid around the camera.
  79481. * This can be helpful to determine the center of the body near the gravity center of the body
  79482. * instead of its head.
  79483. */
  79484. ellipsoidOffset: Vector3;
  79485. /**
  79486. * Enable or disable collisions of the camera with the rest of the scene objects.
  79487. */
  79488. checkCollisions: boolean;
  79489. /**
  79490. * Enable or disable gravity on the camera.
  79491. */
  79492. applyGravity: boolean;
  79493. /**
  79494. * Define the input manager associated to the camera.
  79495. */
  79496. inputs: FreeCameraInputsManager;
  79497. /**
  79498. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79499. * Higher values reduce sensitivity.
  79500. */
  79501. /**
  79502. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79503. * Higher values reduce sensitivity.
  79504. */
  79505. angularSensibility: number;
  79506. /**
  79507. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79508. */
  79509. keysUp: number[];
  79510. /**
  79511. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79512. */
  79513. keysDown: number[];
  79514. /**
  79515. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79516. */
  79517. keysLeft: number[];
  79518. /**
  79519. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79520. */
  79521. keysRight: number[];
  79522. /**
  79523. * Event raised when the camera collide with a mesh in the scene.
  79524. */
  79525. onCollide: (collidedMesh: AbstractMesh) => void;
  79526. private _collider;
  79527. private _needMoveForGravity;
  79528. private _oldPosition;
  79529. private _diffPosition;
  79530. private _newPosition;
  79531. /** @hidden */
  79532. _localDirection: Vector3;
  79533. /** @hidden */
  79534. _transformedDirection: Vector3;
  79535. /**
  79536. * Instantiates a Free Camera.
  79537. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79538. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79539. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79540. * @param name Define the name of the camera in the scene
  79541. * @param position Define the start position of the camera in the scene
  79542. * @param scene Define the scene the camera belongs to
  79543. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79544. */
  79545. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79546. /**
  79547. * Attached controls to the current camera.
  79548. * @param element Defines the element the controls should be listened from
  79549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79550. */
  79551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79552. /**
  79553. * Detach the current controls from the camera.
  79554. * The camera will stop reacting to inputs.
  79555. * @param element Defines the element to stop listening the inputs from
  79556. */
  79557. detachControl(element: HTMLElement): void;
  79558. private _collisionMask;
  79559. /**
  79560. * Define a collision mask to limit the list of object the camera can collide with
  79561. */
  79562. collisionMask: number;
  79563. /** @hidden */
  79564. _collideWithWorld(displacement: Vector3): void;
  79565. private _onCollisionPositionChange;
  79566. /** @hidden */
  79567. _checkInputs(): void;
  79568. /** @hidden */
  79569. _decideIfNeedsToMove(): boolean;
  79570. /** @hidden */
  79571. _updatePosition(): void;
  79572. /**
  79573. * Destroy the camera and release the current resources hold by it.
  79574. */
  79575. dispose(): void;
  79576. /**
  79577. * Gets the current object class name.
  79578. * @return the class name
  79579. */
  79580. getClassName(): string;
  79581. }
  79582. }
  79583. declare module BABYLON {
  79584. /**
  79585. * Represents a gamepad control stick position
  79586. */
  79587. export class StickValues {
  79588. /**
  79589. * The x component of the control stick
  79590. */
  79591. x: number;
  79592. /**
  79593. * The y component of the control stick
  79594. */
  79595. y: number;
  79596. /**
  79597. * Initializes the gamepad x and y control stick values
  79598. * @param x The x component of the gamepad control stick value
  79599. * @param y The y component of the gamepad control stick value
  79600. */
  79601. constructor(
  79602. /**
  79603. * The x component of the control stick
  79604. */
  79605. x: number,
  79606. /**
  79607. * The y component of the control stick
  79608. */
  79609. y: number);
  79610. }
  79611. /**
  79612. * An interface which manages callbacks for gamepad button changes
  79613. */
  79614. export interface GamepadButtonChanges {
  79615. /**
  79616. * Called when a gamepad has been changed
  79617. */
  79618. changed: boolean;
  79619. /**
  79620. * Called when a gamepad press event has been triggered
  79621. */
  79622. pressChanged: boolean;
  79623. /**
  79624. * Called when a touch event has been triggered
  79625. */
  79626. touchChanged: boolean;
  79627. /**
  79628. * Called when a value has changed
  79629. */
  79630. valueChanged: boolean;
  79631. }
  79632. /**
  79633. * Represents a gamepad
  79634. */
  79635. export class Gamepad {
  79636. /**
  79637. * The id of the gamepad
  79638. */
  79639. id: string;
  79640. /**
  79641. * The index of the gamepad
  79642. */
  79643. index: number;
  79644. /**
  79645. * The browser gamepad
  79646. */
  79647. browserGamepad: any;
  79648. /**
  79649. * Specifies what type of gamepad this represents
  79650. */
  79651. type: number;
  79652. private _leftStick;
  79653. private _rightStick;
  79654. /** @hidden */
  79655. _isConnected: boolean;
  79656. private _leftStickAxisX;
  79657. private _leftStickAxisY;
  79658. private _rightStickAxisX;
  79659. private _rightStickAxisY;
  79660. /**
  79661. * Triggered when the left control stick has been changed
  79662. */
  79663. private _onleftstickchanged;
  79664. /**
  79665. * Triggered when the right control stick has been changed
  79666. */
  79667. private _onrightstickchanged;
  79668. /**
  79669. * Represents a gamepad controller
  79670. */
  79671. static GAMEPAD: number;
  79672. /**
  79673. * Represents a generic controller
  79674. */
  79675. static GENERIC: number;
  79676. /**
  79677. * Represents an XBox controller
  79678. */
  79679. static XBOX: number;
  79680. /**
  79681. * Represents a pose-enabled controller
  79682. */
  79683. static POSE_ENABLED: number;
  79684. /**
  79685. * Represents an Dual Shock controller
  79686. */
  79687. static DUALSHOCK: number;
  79688. /**
  79689. * Specifies whether the left control stick should be Y-inverted
  79690. */
  79691. protected _invertLeftStickY: boolean;
  79692. /**
  79693. * Specifies if the gamepad has been connected
  79694. */
  79695. readonly isConnected: boolean;
  79696. /**
  79697. * Initializes the gamepad
  79698. * @param id The id of the gamepad
  79699. * @param index The index of the gamepad
  79700. * @param browserGamepad The browser gamepad
  79701. * @param leftStickX The x component of the left joystick
  79702. * @param leftStickY The y component of the left joystick
  79703. * @param rightStickX The x component of the right joystick
  79704. * @param rightStickY The y component of the right joystick
  79705. */
  79706. constructor(
  79707. /**
  79708. * The id of the gamepad
  79709. */
  79710. id: string,
  79711. /**
  79712. * The index of the gamepad
  79713. */
  79714. index: number,
  79715. /**
  79716. * The browser gamepad
  79717. */
  79718. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79719. /**
  79720. * Callback triggered when the left joystick has changed
  79721. * @param callback
  79722. */
  79723. onleftstickchanged(callback: (values: StickValues) => void): void;
  79724. /**
  79725. * Callback triggered when the right joystick has changed
  79726. * @param callback
  79727. */
  79728. onrightstickchanged(callback: (values: StickValues) => void): void;
  79729. /**
  79730. * Gets the left joystick
  79731. */
  79732. /**
  79733. * Sets the left joystick values
  79734. */
  79735. leftStick: StickValues;
  79736. /**
  79737. * Gets the right joystick
  79738. */
  79739. /**
  79740. * Sets the right joystick value
  79741. */
  79742. rightStick: StickValues;
  79743. /**
  79744. * Updates the gamepad joystick positions
  79745. */
  79746. update(): void;
  79747. /**
  79748. * Disposes the gamepad
  79749. */
  79750. dispose(): void;
  79751. }
  79752. /**
  79753. * Represents a generic gamepad
  79754. */
  79755. export class GenericPad extends Gamepad {
  79756. private _buttons;
  79757. private _onbuttondown;
  79758. private _onbuttonup;
  79759. /**
  79760. * Observable triggered when a button has been pressed
  79761. */
  79762. onButtonDownObservable: Observable<number>;
  79763. /**
  79764. * Observable triggered when a button has been released
  79765. */
  79766. onButtonUpObservable: Observable<number>;
  79767. /**
  79768. * Callback triggered when a button has been pressed
  79769. * @param callback Called when a button has been pressed
  79770. */
  79771. onbuttondown(callback: (buttonPressed: number) => void): void;
  79772. /**
  79773. * Callback triggered when a button has been released
  79774. * @param callback Called when a button has been released
  79775. */
  79776. onbuttonup(callback: (buttonReleased: number) => void): void;
  79777. /**
  79778. * Initializes the generic gamepad
  79779. * @param id The id of the generic gamepad
  79780. * @param index The index of the generic gamepad
  79781. * @param browserGamepad The browser gamepad
  79782. */
  79783. constructor(id: string, index: number, browserGamepad: any);
  79784. private _setButtonValue;
  79785. /**
  79786. * Updates the generic gamepad
  79787. */
  79788. update(): void;
  79789. /**
  79790. * Disposes the generic gamepad
  79791. */
  79792. dispose(): void;
  79793. }
  79794. }
  79795. declare module BABYLON {
  79796. interface Engine {
  79797. /**
  79798. * Creates a raw texture
  79799. * @param data defines the data to store in the texture
  79800. * @param width defines the width of the texture
  79801. * @param height defines the height of the texture
  79802. * @param format defines the format of the data
  79803. * @param generateMipMaps defines if the engine should generate the mip levels
  79804. * @param invertY defines if data must be stored with Y axis inverted
  79805. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79806. * @param compression defines the compression used (null by default)
  79807. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79808. * @returns the raw texture inside an InternalTexture
  79809. */
  79810. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79811. /**
  79812. * Update a raw texture
  79813. * @param texture defines the texture to update
  79814. * @param data defines the data to store in the texture
  79815. * @param format defines the format of the data
  79816. * @param invertY defines if data must be stored with Y axis inverted
  79817. */
  79818. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79819. /**
  79820. * Update a raw texture
  79821. * @param texture defines the texture to update
  79822. * @param data defines the data to store in the texture
  79823. * @param format defines the format of the data
  79824. * @param invertY defines if data must be stored with Y axis inverted
  79825. * @param compression defines the compression used (null by default)
  79826. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79827. */
  79828. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79829. /**
  79830. * Creates a new raw cube texture
  79831. * @param data defines the array of data to use to create each face
  79832. * @param size defines the size of the textures
  79833. * @param format defines the format of the data
  79834. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79835. * @param generateMipMaps defines if the engine should generate the mip levels
  79836. * @param invertY defines if data must be stored with Y axis inverted
  79837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79838. * @param compression defines the compression used (null by default)
  79839. * @returns the cube texture as an InternalTexture
  79840. */
  79841. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79842. /**
  79843. * Update a raw cube texture
  79844. * @param texture defines the texture to udpdate
  79845. * @param data defines the data to store
  79846. * @param format defines the data format
  79847. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79848. * @param invertY defines if data must be stored with Y axis inverted
  79849. */
  79850. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79851. /**
  79852. * Update a raw cube texture
  79853. * @param texture defines the texture to udpdate
  79854. * @param data defines the data to store
  79855. * @param format defines the data format
  79856. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79857. * @param invertY defines if data must be stored with Y axis inverted
  79858. * @param compression defines the compression used (null by default)
  79859. */
  79860. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79861. /**
  79862. * Update a raw cube texture
  79863. * @param texture defines the texture to udpdate
  79864. * @param data defines the data to store
  79865. * @param format defines the data format
  79866. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79867. * @param invertY defines if data must be stored with Y axis inverted
  79868. * @param compression defines the compression used (null by default)
  79869. * @param level defines which level of the texture to update
  79870. */
  79871. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79872. /**
  79873. * Creates a new raw cube texture from a specified url
  79874. * @param url defines the url where the data is located
  79875. * @param scene defines the current scene
  79876. * @param size defines the size of the textures
  79877. * @param format defines the format of the data
  79878. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79879. * @param noMipmap defines if the engine should avoid generating the mip levels
  79880. * @param callback defines a callback used to extract texture data from loaded data
  79881. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79882. * @param onLoad defines a callback called when texture is loaded
  79883. * @param onError defines a callback called if there is an error
  79884. * @returns the cube texture as an InternalTexture
  79885. */
  79886. 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;
  79887. /**
  79888. * Creates a new raw cube texture from a specified url
  79889. * @param url defines the url where the data is located
  79890. * @param scene defines the current scene
  79891. * @param size defines the size of the textures
  79892. * @param format defines the format of the data
  79893. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79894. * @param noMipmap defines if the engine should avoid generating the mip levels
  79895. * @param callback defines a callback used to extract texture data from loaded data
  79896. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79897. * @param onLoad defines a callback called when texture is loaded
  79898. * @param onError defines a callback called if there is an error
  79899. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79900. * @param invertY defines if data must be stored with Y axis inverted
  79901. * @returns the cube texture as an InternalTexture
  79902. */
  79903. 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;
  79904. /**
  79905. * Creates a new raw 3D texture
  79906. * @param data defines the data used to create the texture
  79907. * @param width defines the width of the texture
  79908. * @param height defines the height of the texture
  79909. * @param depth defines the depth of the texture
  79910. * @param format defines the format of the texture
  79911. * @param generateMipMaps defines if the engine must generate mip levels
  79912. * @param invertY defines if data must be stored with Y axis inverted
  79913. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79914. * @param compression defines the compressed used (can be null)
  79915. * @param textureType defines the compressed used (can be null)
  79916. * @returns a new raw 3D texture (stored in an InternalTexture)
  79917. */
  79918. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79919. /**
  79920. * Update a raw 3D texture
  79921. * @param texture defines the texture to update
  79922. * @param data defines the data to store
  79923. * @param format defines the data format
  79924. * @param invertY defines if data must be stored with Y axis inverted
  79925. */
  79926. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79927. /**
  79928. * Update a raw 3D texture
  79929. * @param texture defines the texture to update
  79930. * @param data defines the data to store
  79931. * @param format defines the data format
  79932. * @param invertY defines if data must be stored with Y axis inverted
  79933. * @param compression defines the used compression (can be null)
  79934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79935. */
  79936. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79937. }
  79938. }
  79939. declare module BABYLON {
  79940. /**
  79941. * Raw texture can help creating a texture directly from an array of data.
  79942. * This can be super useful if you either get the data from an uncompressed source or
  79943. * if you wish to create your texture pixel by pixel.
  79944. */
  79945. export class RawTexture extends Texture {
  79946. /**
  79947. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79948. */
  79949. format: number;
  79950. private _engine;
  79951. /**
  79952. * Instantiates a new RawTexture.
  79953. * Raw texture can help creating a texture directly from an array of data.
  79954. * This can be super useful if you either get the data from an uncompressed source or
  79955. * if you wish to create your texture pixel by pixel.
  79956. * @param data define the array of data to use to create the texture
  79957. * @param width define the width of the texture
  79958. * @param height define the height of the texture
  79959. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79960. * @param scene define the scene the texture belongs to
  79961. * @param generateMipMaps define whether mip maps should be generated or not
  79962. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79963. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79964. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79965. */
  79966. constructor(data: ArrayBufferView, width: number, height: number,
  79967. /**
  79968. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79969. */
  79970. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79971. /**
  79972. * Updates the texture underlying data.
  79973. * @param data Define the new data of the texture
  79974. */
  79975. update(data: ArrayBufferView): void;
  79976. /**
  79977. * Creates a luminance texture from some data.
  79978. * @param data Define the texture data
  79979. * @param width Define the width of the texture
  79980. * @param height Define the height of the texture
  79981. * @param scene Define the scene the texture belongs to
  79982. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79983. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79984. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79985. * @returns the luminance texture
  79986. */
  79987. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79988. /**
  79989. * Creates a luminance alpha texture from some data.
  79990. * @param data Define the texture data
  79991. * @param width Define the width of the texture
  79992. * @param height Define the height of the texture
  79993. * @param scene Define the scene the texture belongs to
  79994. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79995. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79996. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79997. * @returns the luminance alpha texture
  79998. */
  79999. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80000. /**
  80001. * Creates an alpha texture from some data.
  80002. * @param data Define the texture data
  80003. * @param width Define the width of the texture
  80004. * @param height Define the height of the texture
  80005. * @param scene Define the scene the texture belongs to
  80006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80009. * @returns the alpha texture
  80010. */
  80011. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80012. /**
  80013. * Creates a RGB texture from some data.
  80014. * @param data Define the texture data
  80015. * @param width Define the width of the texture
  80016. * @param height Define the height of the texture
  80017. * @param scene Define the scene the texture belongs to
  80018. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80019. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80020. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80021. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80022. * @returns the RGB alpha texture
  80023. */
  80024. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80025. /**
  80026. * Creates a RGBA texture from some data.
  80027. * @param data Define the texture data
  80028. * @param width Define the width of the texture
  80029. * @param height Define the height of the texture
  80030. * @param scene Define the scene the texture belongs to
  80031. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80032. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80033. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80034. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80035. * @returns the RGBA texture
  80036. */
  80037. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80038. /**
  80039. * Creates a R texture from some data.
  80040. * @param data Define the texture data
  80041. * @param width Define the width of the texture
  80042. * @param height Define the height of the texture
  80043. * @param scene Define the scene the texture belongs to
  80044. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80045. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80046. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80047. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80048. * @returns the R texture
  80049. */
  80050. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80051. }
  80052. }
  80053. declare module BABYLON {
  80054. /**
  80055. * Interface for the size containing width and height
  80056. */
  80057. export interface ISize {
  80058. /**
  80059. * Width
  80060. */
  80061. width: number;
  80062. /**
  80063. * Heighht
  80064. */
  80065. height: number;
  80066. }
  80067. /**
  80068. * Size containing widht and height
  80069. */
  80070. export class Size implements ISize {
  80071. /**
  80072. * Width
  80073. */
  80074. width: number;
  80075. /**
  80076. * Height
  80077. */
  80078. height: number;
  80079. /**
  80080. * Creates a Size object from the given width and height (floats).
  80081. * @param width width of the new size
  80082. * @param height height of the new size
  80083. */
  80084. constructor(width: number, height: number);
  80085. /**
  80086. * Returns a string with the Size width and height
  80087. * @returns a string with the Size width and height
  80088. */
  80089. toString(): string;
  80090. /**
  80091. * "Size"
  80092. * @returns the string "Size"
  80093. */
  80094. getClassName(): string;
  80095. /**
  80096. * Returns the Size hash code.
  80097. * @returns a hash code for a unique width and height
  80098. */
  80099. getHashCode(): number;
  80100. /**
  80101. * Updates the current size from the given one.
  80102. * @param src the given size
  80103. */
  80104. copyFrom(src: Size): void;
  80105. /**
  80106. * Updates in place the current Size from the given floats.
  80107. * @param width width of the new size
  80108. * @param height height of the new size
  80109. * @returns the updated Size.
  80110. */
  80111. copyFromFloats(width: number, height: number): Size;
  80112. /**
  80113. * Updates in place the current Size from the given floats.
  80114. * @param width width to set
  80115. * @param height height to set
  80116. * @returns the updated Size.
  80117. */
  80118. set(width: number, height: number): Size;
  80119. /**
  80120. * Multiplies the width and height by numbers
  80121. * @param w factor to multiple the width by
  80122. * @param h factor to multiple the height by
  80123. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80124. */
  80125. multiplyByFloats(w: number, h: number): Size;
  80126. /**
  80127. * Clones the size
  80128. * @returns a new Size copied from the given one.
  80129. */
  80130. clone(): Size;
  80131. /**
  80132. * True if the current Size and the given one width and height are strictly equal.
  80133. * @param other the other size to compare against
  80134. * @returns True if the current Size and the given one width and height are strictly equal.
  80135. */
  80136. equals(other: Size): boolean;
  80137. /**
  80138. * The surface of the Size : width * height (float).
  80139. */
  80140. readonly surface: number;
  80141. /**
  80142. * Create a new size of zero
  80143. * @returns a new Size set to (0.0, 0.0)
  80144. */
  80145. static Zero(): Size;
  80146. /**
  80147. * Sums the width and height of two sizes
  80148. * @param otherSize size to add to this size
  80149. * @returns a new Size set as the addition result of the current Size and the given one.
  80150. */
  80151. add(otherSize: Size): Size;
  80152. /**
  80153. * Subtracts the width and height of two
  80154. * @param otherSize size to subtract to this size
  80155. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80156. */
  80157. subtract(otherSize: Size): Size;
  80158. /**
  80159. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80160. * @param start starting size to lerp between
  80161. * @param end end size to lerp between
  80162. * @param amount amount to lerp between the start and end values
  80163. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80164. */
  80165. static Lerp(start: Size, end: Size, amount: number): Size;
  80166. }
  80167. }
  80168. declare module BABYLON {
  80169. /**
  80170. * Defines a runtime animation
  80171. */
  80172. export class RuntimeAnimation {
  80173. private _events;
  80174. /**
  80175. * The current frame of the runtime animation
  80176. */
  80177. private _currentFrame;
  80178. /**
  80179. * The animation used by the runtime animation
  80180. */
  80181. private _animation;
  80182. /**
  80183. * The target of the runtime animation
  80184. */
  80185. private _target;
  80186. /**
  80187. * The initiating animatable
  80188. */
  80189. private _host;
  80190. /**
  80191. * The original value of the runtime animation
  80192. */
  80193. private _originalValue;
  80194. /**
  80195. * The original blend value of the runtime animation
  80196. */
  80197. private _originalBlendValue;
  80198. /**
  80199. * The offsets cache of the runtime animation
  80200. */
  80201. private _offsetsCache;
  80202. /**
  80203. * The high limits cache of the runtime animation
  80204. */
  80205. private _highLimitsCache;
  80206. /**
  80207. * Specifies if the runtime animation has been stopped
  80208. */
  80209. private _stopped;
  80210. /**
  80211. * The blending factor of the runtime animation
  80212. */
  80213. private _blendingFactor;
  80214. /**
  80215. * The BabylonJS scene
  80216. */
  80217. private _scene;
  80218. /**
  80219. * The current value of the runtime animation
  80220. */
  80221. private _currentValue;
  80222. /** @hidden */
  80223. _animationState: _IAnimationState;
  80224. /**
  80225. * The active target of the runtime animation
  80226. */
  80227. private _activeTargets;
  80228. private _currentActiveTarget;
  80229. private _directTarget;
  80230. /**
  80231. * The target path of the runtime animation
  80232. */
  80233. private _targetPath;
  80234. /**
  80235. * The weight of the runtime animation
  80236. */
  80237. private _weight;
  80238. /**
  80239. * The ratio offset of the runtime animation
  80240. */
  80241. private _ratioOffset;
  80242. /**
  80243. * The previous delay of the runtime animation
  80244. */
  80245. private _previousDelay;
  80246. /**
  80247. * The previous ratio of the runtime animation
  80248. */
  80249. private _previousRatio;
  80250. private _enableBlending;
  80251. private _keys;
  80252. private _minFrame;
  80253. private _maxFrame;
  80254. private _minValue;
  80255. private _maxValue;
  80256. private _targetIsArray;
  80257. /**
  80258. * Gets the current frame of the runtime animation
  80259. */
  80260. readonly currentFrame: number;
  80261. /**
  80262. * Gets the weight of the runtime animation
  80263. */
  80264. readonly weight: number;
  80265. /**
  80266. * Gets the current value of the runtime animation
  80267. */
  80268. readonly currentValue: any;
  80269. /**
  80270. * Gets the target path of the runtime animation
  80271. */
  80272. readonly targetPath: string;
  80273. /**
  80274. * Gets the actual target of the runtime animation
  80275. */
  80276. readonly target: any;
  80277. /** @hidden */
  80278. _onLoop: () => void;
  80279. /**
  80280. * Create a new RuntimeAnimation object
  80281. * @param target defines the target of the animation
  80282. * @param animation defines the source animation object
  80283. * @param scene defines the hosting scene
  80284. * @param host defines the initiating Animatable
  80285. */
  80286. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80287. private _preparePath;
  80288. /**
  80289. * Gets the animation from the runtime animation
  80290. */
  80291. readonly animation: Animation;
  80292. /**
  80293. * Resets the runtime animation to the beginning
  80294. * @param restoreOriginal defines whether to restore the target property to the original value
  80295. */
  80296. reset(restoreOriginal?: boolean): void;
  80297. /**
  80298. * Specifies if the runtime animation is stopped
  80299. * @returns Boolean specifying if the runtime animation is stopped
  80300. */
  80301. isStopped(): boolean;
  80302. /**
  80303. * Disposes of the runtime animation
  80304. */
  80305. dispose(): void;
  80306. /**
  80307. * Apply the interpolated value to the target
  80308. * @param currentValue defines the value computed by the animation
  80309. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80310. */
  80311. setValue(currentValue: any, weight: number): void;
  80312. private _getOriginalValues;
  80313. private _setValue;
  80314. /**
  80315. * Gets the loop pmode of the runtime animation
  80316. * @returns Loop Mode
  80317. */
  80318. private _getCorrectLoopMode;
  80319. /**
  80320. * Move the current animation to a given frame
  80321. * @param frame defines the frame to move to
  80322. */
  80323. goToFrame(frame: number): void;
  80324. /**
  80325. * @hidden Internal use only
  80326. */
  80327. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80328. /**
  80329. * Execute the current animation
  80330. * @param delay defines the delay to add to the current frame
  80331. * @param from defines the lower bound of the animation range
  80332. * @param to defines the upper bound of the animation range
  80333. * @param loop defines if the current animation must loop
  80334. * @param speedRatio defines the current speed ratio
  80335. * @param weight defines the weight of the animation (default is -1 so no weight)
  80336. * @param onLoop optional callback called when animation loops
  80337. * @returns a boolean indicating if the animation is running
  80338. */
  80339. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80340. }
  80341. }
  80342. declare module BABYLON {
  80343. /**
  80344. * Class used to store an actual running animation
  80345. */
  80346. export class Animatable {
  80347. /** defines the target object */
  80348. target: any;
  80349. /** defines the starting frame number (default is 0) */
  80350. fromFrame: number;
  80351. /** defines the ending frame number (default is 100) */
  80352. toFrame: number;
  80353. /** defines if the animation must loop (default is false) */
  80354. loopAnimation: boolean;
  80355. /** defines a callback to call when animation ends if it is not looping */
  80356. onAnimationEnd?: (() => void) | null | undefined;
  80357. /** defines a callback to call when animation loops */
  80358. onAnimationLoop?: (() => void) | null | undefined;
  80359. private _localDelayOffset;
  80360. private _pausedDelay;
  80361. private _runtimeAnimations;
  80362. private _paused;
  80363. private _scene;
  80364. private _speedRatio;
  80365. private _weight;
  80366. private _syncRoot;
  80367. /**
  80368. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80369. * This will only apply for non looping animation (default is true)
  80370. */
  80371. disposeOnEnd: boolean;
  80372. /**
  80373. * Gets a boolean indicating if the animation has started
  80374. */
  80375. animationStarted: boolean;
  80376. /**
  80377. * Observer raised when the animation ends
  80378. */
  80379. onAnimationEndObservable: Observable<Animatable>;
  80380. /**
  80381. * Observer raised when the animation loops
  80382. */
  80383. onAnimationLoopObservable: Observable<Animatable>;
  80384. /**
  80385. * Gets the root Animatable used to synchronize and normalize animations
  80386. */
  80387. readonly syncRoot: Nullable<Animatable>;
  80388. /**
  80389. * Gets the current frame of the first RuntimeAnimation
  80390. * Used to synchronize Animatables
  80391. */
  80392. readonly masterFrame: number;
  80393. /**
  80394. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80395. */
  80396. weight: number;
  80397. /**
  80398. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80399. */
  80400. speedRatio: number;
  80401. /**
  80402. * Creates a new Animatable
  80403. * @param scene defines the hosting scene
  80404. * @param target defines the target object
  80405. * @param fromFrame defines the starting frame number (default is 0)
  80406. * @param toFrame defines the ending frame number (default is 100)
  80407. * @param loopAnimation defines if the animation must loop (default is false)
  80408. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80409. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80410. * @param animations defines a group of animation to add to the new Animatable
  80411. * @param onAnimationLoop defines a callback to call when animation loops
  80412. */
  80413. constructor(scene: Scene,
  80414. /** defines the target object */
  80415. target: any,
  80416. /** defines the starting frame number (default is 0) */
  80417. fromFrame?: number,
  80418. /** defines the ending frame number (default is 100) */
  80419. toFrame?: number,
  80420. /** defines if the animation must loop (default is false) */
  80421. loopAnimation?: boolean, speedRatio?: number,
  80422. /** defines a callback to call when animation ends if it is not looping */
  80423. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80424. /** defines a callback to call when animation loops */
  80425. onAnimationLoop?: (() => void) | null | undefined);
  80426. /**
  80427. * Synchronize and normalize current Animatable with a source Animatable
  80428. * This is useful when using animation weights and when animations are not of the same length
  80429. * @param root defines the root Animatable to synchronize with
  80430. * @returns the current Animatable
  80431. */
  80432. syncWith(root: Animatable): Animatable;
  80433. /**
  80434. * Gets the list of runtime animations
  80435. * @returns an array of RuntimeAnimation
  80436. */
  80437. getAnimations(): RuntimeAnimation[];
  80438. /**
  80439. * Adds more animations to the current animatable
  80440. * @param target defines the target of the animations
  80441. * @param animations defines the new animations to add
  80442. */
  80443. appendAnimations(target: any, animations: Animation[]): void;
  80444. /**
  80445. * Gets the source animation for a specific property
  80446. * @param property defines the propertyu to look for
  80447. * @returns null or the source animation for the given property
  80448. */
  80449. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80450. /**
  80451. * Gets the runtime animation for a specific property
  80452. * @param property defines the propertyu to look for
  80453. * @returns null or the runtime animation for the given property
  80454. */
  80455. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80456. /**
  80457. * Resets the animatable to its original state
  80458. */
  80459. reset(): void;
  80460. /**
  80461. * Allows the animatable to blend with current running animations
  80462. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80463. * @param blendingSpeed defines the blending speed to use
  80464. */
  80465. enableBlending(blendingSpeed: number): void;
  80466. /**
  80467. * Disable animation blending
  80468. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80469. */
  80470. disableBlending(): void;
  80471. /**
  80472. * Jump directly to a given frame
  80473. * @param frame defines the frame to jump to
  80474. */
  80475. goToFrame(frame: number): void;
  80476. /**
  80477. * Pause the animation
  80478. */
  80479. pause(): void;
  80480. /**
  80481. * Restart the animation
  80482. */
  80483. restart(): void;
  80484. private _raiseOnAnimationEnd;
  80485. /**
  80486. * Stop and delete the current animation
  80487. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80488. * @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)
  80489. */
  80490. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80491. /**
  80492. * Wait asynchronously for the animation to end
  80493. * @returns a promise which will be fullfilled when the animation ends
  80494. */
  80495. waitAsync(): Promise<Animatable>;
  80496. /** @hidden */
  80497. _animate(delay: number): boolean;
  80498. }
  80499. interface Scene {
  80500. /** @hidden */
  80501. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80502. /** @hidden */
  80503. _processLateAnimationBindingsForMatrices(holder: {
  80504. totalWeight: number;
  80505. animations: RuntimeAnimation[];
  80506. originalValue: Matrix;
  80507. }): any;
  80508. /** @hidden */
  80509. _processLateAnimationBindingsForQuaternions(holder: {
  80510. totalWeight: number;
  80511. animations: RuntimeAnimation[];
  80512. originalValue: Quaternion;
  80513. }, refQuaternion: Quaternion): Quaternion;
  80514. /** @hidden */
  80515. _processLateAnimationBindings(): void;
  80516. /**
  80517. * Will start the animation sequence of a given target
  80518. * @param target defines the target
  80519. * @param from defines from which frame should animation start
  80520. * @param to defines until which frame should animation run.
  80521. * @param weight defines the weight to apply to the animation (1.0 by default)
  80522. * @param loop defines if the animation loops
  80523. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80524. * @param onAnimationEnd defines the function to be executed when the animation ends
  80525. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80526. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80527. * @param onAnimationLoop defines the callback to call when an animation loops
  80528. * @returns the animatable object created for this animation
  80529. */
  80530. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80531. /**
  80532. * Will start the animation sequence of a given target
  80533. * @param target defines the target
  80534. * @param from defines from which frame should animation start
  80535. * @param to defines until which frame should animation run.
  80536. * @param loop defines if the animation loops
  80537. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80538. * @param onAnimationEnd defines the function to be executed when the animation ends
  80539. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80540. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80541. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80542. * @param onAnimationLoop defines the callback to call when an animation loops
  80543. * @returns the animatable object created for this animation
  80544. */
  80545. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80546. /**
  80547. * Will start the animation sequence of a given target and its hierarchy
  80548. * @param target defines the target
  80549. * @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.
  80550. * @param from defines from which frame should animation start
  80551. * @param to defines until which frame should animation run.
  80552. * @param loop defines if the animation loops
  80553. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80554. * @param onAnimationEnd defines the function to be executed when the animation ends
  80555. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80556. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80557. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80558. * @param onAnimationLoop defines the callback to call when an animation loops
  80559. * @returns the list of created animatables
  80560. */
  80561. 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[];
  80562. /**
  80563. * Begin a new animation on a given node
  80564. * @param target defines the target where the animation will take place
  80565. * @param animations defines the list of animations to start
  80566. * @param from defines the initial value
  80567. * @param to defines the final value
  80568. * @param loop defines if you want animation to loop (off by default)
  80569. * @param speedRatio defines the speed ratio to apply to all animations
  80570. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80571. * @param onAnimationLoop defines the callback to call when an animation loops
  80572. * @returns the list of created animatables
  80573. */
  80574. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80575. /**
  80576. * Begin a new animation on a given node and its hierarchy
  80577. * @param target defines the root node where the animation will take place
  80578. * @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.
  80579. * @param animations defines the list of animations to start
  80580. * @param from defines the initial value
  80581. * @param to defines the final value
  80582. * @param loop defines if you want animation to loop (off by default)
  80583. * @param speedRatio defines the speed ratio to apply to all animations
  80584. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80585. * @param onAnimationLoop defines the callback to call when an animation loops
  80586. * @returns the list of animatables created for all nodes
  80587. */
  80588. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80589. /**
  80590. * Gets the animatable associated with a specific target
  80591. * @param target defines the target of the animatable
  80592. * @returns the required animatable if found
  80593. */
  80594. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80595. /**
  80596. * Gets all animatables associated with a given target
  80597. * @param target defines the target to look animatables for
  80598. * @returns an array of Animatables
  80599. */
  80600. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80601. /**
  80602. * Stops and removes all animations that have been applied to the scene
  80603. */
  80604. stopAllAnimations(): void;
  80605. /**
  80606. * Gets the current delta time used by animation engine
  80607. */
  80608. deltaTime: number;
  80609. }
  80610. interface Bone {
  80611. /**
  80612. * Copy an animation range from another bone
  80613. * @param source defines the source bone
  80614. * @param rangeName defines the range name to copy
  80615. * @param frameOffset defines the frame offset
  80616. * @param rescaleAsRequired defines if rescaling must be applied if required
  80617. * @param skelDimensionsRatio defines the scaling ratio
  80618. * @returns true if operation was successful
  80619. */
  80620. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80621. }
  80622. }
  80623. declare module BABYLON {
  80624. /**
  80625. * Class used to override all child animations of a given target
  80626. */
  80627. export class AnimationPropertiesOverride {
  80628. /**
  80629. * Gets or sets a value indicating if animation blending must be used
  80630. */
  80631. enableBlending: boolean;
  80632. /**
  80633. * Gets or sets the blending speed to use when enableBlending is true
  80634. */
  80635. blendingSpeed: number;
  80636. /**
  80637. * Gets or sets the default loop mode to use
  80638. */
  80639. loopMode: number;
  80640. }
  80641. }
  80642. declare module BABYLON {
  80643. /**
  80644. * Class used to handle skinning animations
  80645. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80646. */
  80647. export class Skeleton implements IAnimatable {
  80648. /** defines the skeleton name */
  80649. name: string;
  80650. /** defines the skeleton Id */
  80651. id: string;
  80652. /**
  80653. * Defines the list of child bones
  80654. */
  80655. bones: Bone[];
  80656. /**
  80657. * Defines an estimate of the dimension of the skeleton at rest
  80658. */
  80659. dimensionsAtRest: Vector3;
  80660. /**
  80661. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80662. */
  80663. needInitialSkinMatrix: boolean;
  80664. /**
  80665. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80666. */
  80667. overrideMesh: Nullable<AbstractMesh>;
  80668. /**
  80669. * Gets the list of animations attached to this skeleton
  80670. */
  80671. animations: Array<Animation>;
  80672. private _scene;
  80673. private _isDirty;
  80674. private _transformMatrices;
  80675. private _transformMatrixTexture;
  80676. private _meshesWithPoseMatrix;
  80677. private _animatables;
  80678. private _identity;
  80679. private _synchronizedWithMesh;
  80680. private _ranges;
  80681. private _lastAbsoluteTransformsUpdateId;
  80682. private _canUseTextureForBones;
  80683. private _uniqueId;
  80684. /** @hidden */
  80685. _numBonesWithLinkedTransformNode: number;
  80686. /** @hidden */
  80687. _hasWaitingData: Nullable<boolean>;
  80688. /**
  80689. * Specifies if the skeleton should be serialized
  80690. */
  80691. doNotSerialize: boolean;
  80692. private _useTextureToStoreBoneMatrices;
  80693. /**
  80694. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80695. * Please note that this option is not available if the hardware does not support it
  80696. */
  80697. useTextureToStoreBoneMatrices: boolean;
  80698. private _animationPropertiesOverride;
  80699. /**
  80700. * Gets or sets the animation properties override
  80701. */
  80702. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80703. /**
  80704. * List of inspectable custom properties (used by the Inspector)
  80705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80706. */
  80707. inspectableCustomProperties: IInspectable[];
  80708. /**
  80709. * An observable triggered before computing the skeleton's matrices
  80710. */
  80711. onBeforeComputeObservable: Observable<Skeleton>;
  80712. /**
  80713. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80714. */
  80715. readonly isUsingTextureForMatrices: boolean;
  80716. /**
  80717. * Gets the unique ID of this skeleton
  80718. */
  80719. readonly uniqueId: number;
  80720. /**
  80721. * Creates a new skeleton
  80722. * @param name defines the skeleton name
  80723. * @param id defines the skeleton Id
  80724. * @param scene defines the hosting scene
  80725. */
  80726. constructor(
  80727. /** defines the skeleton name */
  80728. name: string,
  80729. /** defines the skeleton Id */
  80730. id: string, scene: Scene);
  80731. /**
  80732. * Gets the current object class name.
  80733. * @return the class name
  80734. */
  80735. getClassName(): string;
  80736. /**
  80737. * Returns an array containing the root bones
  80738. * @returns an array containing the root bones
  80739. */
  80740. getChildren(): Array<Bone>;
  80741. /**
  80742. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80743. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80744. * @returns a Float32Array containing matrices data
  80745. */
  80746. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80747. /**
  80748. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80749. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80750. * @returns a raw texture containing the data
  80751. */
  80752. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80753. /**
  80754. * Gets the current hosting scene
  80755. * @returns a scene object
  80756. */
  80757. getScene(): Scene;
  80758. /**
  80759. * Gets a string representing the current skeleton data
  80760. * @param fullDetails defines a boolean indicating if we want a verbose version
  80761. * @returns a string representing the current skeleton data
  80762. */
  80763. toString(fullDetails?: boolean): string;
  80764. /**
  80765. * Get bone's index searching by name
  80766. * @param name defines bone's name to search for
  80767. * @return the indice of the bone. Returns -1 if not found
  80768. */
  80769. getBoneIndexByName(name: string): number;
  80770. /**
  80771. * Creater a new animation range
  80772. * @param name defines the name of the range
  80773. * @param from defines the start key
  80774. * @param to defines the end key
  80775. */
  80776. createAnimationRange(name: string, from: number, to: number): void;
  80777. /**
  80778. * Delete a specific animation range
  80779. * @param name defines the name of the range
  80780. * @param deleteFrames defines if frames must be removed as well
  80781. */
  80782. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80783. /**
  80784. * Gets a specific animation range
  80785. * @param name defines the name of the range to look for
  80786. * @returns the requested animation range or null if not found
  80787. */
  80788. getAnimationRange(name: string): Nullable<AnimationRange>;
  80789. /**
  80790. * Gets the list of all animation ranges defined on this skeleton
  80791. * @returns an array
  80792. */
  80793. getAnimationRanges(): Nullable<AnimationRange>[];
  80794. /**
  80795. * Copy animation range from a source skeleton.
  80796. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80797. * @param source defines the source skeleton
  80798. * @param name defines the name of the range to copy
  80799. * @param rescaleAsRequired defines if rescaling must be applied if required
  80800. * @returns true if operation was successful
  80801. */
  80802. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80803. /**
  80804. * Forces the skeleton to go to rest pose
  80805. */
  80806. returnToRest(): void;
  80807. private _getHighestAnimationFrame;
  80808. /**
  80809. * Begin a specific animation range
  80810. * @param name defines the name of the range to start
  80811. * @param loop defines if looping must be turned on (false by default)
  80812. * @param speedRatio defines the speed ratio to apply (1 by default)
  80813. * @param onAnimationEnd defines a callback which will be called when animation will end
  80814. * @returns a new animatable
  80815. */
  80816. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80817. /** @hidden */
  80818. _markAsDirty(): void;
  80819. /** @hidden */
  80820. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80821. /** @hidden */
  80822. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80823. private _computeTransformMatrices;
  80824. /**
  80825. * Build all resources required to render a skeleton
  80826. */
  80827. prepare(): void;
  80828. /**
  80829. * Gets the list of animatables currently running for this skeleton
  80830. * @returns an array of animatables
  80831. */
  80832. getAnimatables(): IAnimatable[];
  80833. /**
  80834. * Clone the current skeleton
  80835. * @param name defines the name of the new skeleton
  80836. * @param id defines the id of the new skeleton
  80837. * @returns the new skeleton
  80838. */
  80839. clone(name: string, id: string): Skeleton;
  80840. /**
  80841. * Enable animation blending for this skeleton
  80842. * @param blendingSpeed defines the blending speed to apply
  80843. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80844. */
  80845. enableBlending(blendingSpeed?: number): void;
  80846. /**
  80847. * Releases all resources associated with the current skeleton
  80848. */
  80849. dispose(): void;
  80850. /**
  80851. * Serialize the skeleton in a JSON object
  80852. * @returns a JSON object
  80853. */
  80854. serialize(): any;
  80855. /**
  80856. * Creates a new skeleton from serialized data
  80857. * @param parsedSkeleton defines the serialized data
  80858. * @param scene defines the hosting scene
  80859. * @returns a new skeleton
  80860. */
  80861. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80862. /**
  80863. * Compute all node absolute transforms
  80864. * @param forceUpdate defines if computation must be done even if cache is up to date
  80865. */
  80866. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80867. /**
  80868. * Gets the root pose matrix
  80869. * @returns a matrix
  80870. */
  80871. getPoseMatrix(): Nullable<Matrix>;
  80872. /**
  80873. * Sorts bones per internal index
  80874. */
  80875. sortBones(): void;
  80876. private _sortBones;
  80877. }
  80878. }
  80879. declare module BABYLON {
  80880. /**
  80881. * Class used to store bone information
  80882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80883. */
  80884. export class Bone extends Node {
  80885. /**
  80886. * defines the bone name
  80887. */
  80888. name: string;
  80889. private static _tmpVecs;
  80890. private static _tmpQuat;
  80891. private static _tmpMats;
  80892. /**
  80893. * Gets the list of child bones
  80894. */
  80895. children: Bone[];
  80896. /** Gets the animations associated with this bone */
  80897. animations: Animation[];
  80898. /**
  80899. * Gets or sets bone length
  80900. */
  80901. length: number;
  80902. /**
  80903. * @hidden Internal only
  80904. * Set this value to map this bone to a different index in the transform matrices
  80905. * Set this value to -1 to exclude the bone from the transform matrices
  80906. */
  80907. _index: Nullable<number>;
  80908. private _skeleton;
  80909. private _localMatrix;
  80910. private _restPose;
  80911. private _baseMatrix;
  80912. private _absoluteTransform;
  80913. private _invertedAbsoluteTransform;
  80914. private _parent;
  80915. private _scalingDeterminant;
  80916. private _worldTransform;
  80917. private _localScaling;
  80918. private _localRotation;
  80919. private _localPosition;
  80920. private _needToDecompose;
  80921. private _needToCompose;
  80922. /** @hidden */
  80923. _linkedTransformNode: Nullable<TransformNode>;
  80924. /** @hidden */
  80925. _waitingTransformNodeId: Nullable<string>;
  80926. /** @hidden */
  80927. /** @hidden */
  80928. _matrix: Matrix;
  80929. /**
  80930. * Create a new bone
  80931. * @param name defines the bone name
  80932. * @param skeleton defines the parent skeleton
  80933. * @param parentBone defines the parent (can be null if the bone is the root)
  80934. * @param localMatrix defines the local matrix
  80935. * @param restPose defines the rest pose matrix
  80936. * @param baseMatrix defines the base matrix
  80937. * @param index defines index of the bone in the hiearchy
  80938. */
  80939. constructor(
  80940. /**
  80941. * defines the bone name
  80942. */
  80943. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80944. /**
  80945. * Gets the current object class name.
  80946. * @return the class name
  80947. */
  80948. getClassName(): string;
  80949. /**
  80950. * Gets the parent skeleton
  80951. * @returns a skeleton
  80952. */
  80953. getSkeleton(): Skeleton;
  80954. /**
  80955. * Gets parent bone
  80956. * @returns a bone or null if the bone is the root of the bone hierarchy
  80957. */
  80958. getParent(): Nullable<Bone>;
  80959. /**
  80960. * Returns an array containing the root bones
  80961. * @returns an array containing the root bones
  80962. */
  80963. getChildren(): Array<Bone>;
  80964. /**
  80965. * Sets the parent bone
  80966. * @param parent defines the parent (can be null if the bone is the root)
  80967. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80968. */
  80969. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80970. /**
  80971. * Gets the local matrix
  80972. * @returns a matrix
  80973. */
  80974. getLocalMatrix(): Matrix;
  80975. /**
  80976. * Gets the base matrix (initial matrix which remains unchanged)
  80977. * @returns a matrix
  80978. */
  80979. getBaseMatrix(): Matrix;
  80980. /**
  80981. * Gets the rest pose matrix
  80982. * @returns a matrix
  80983. */
  80984. getRestPose(): Matrix;
  80985. /**
  80986. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80987. */
  80988. getWorldMatrix(): Matrix;
  80989. /**
  80990. * Sets the local matrix to rest pose matrix
  80991. */
  80992. returnToRest(): void;
  80993. /**
  80994. * Gets the inverse of the absolute transform matrix.
  80995. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80996. * @returns a matrix
  80997. */
  80998. getInvertedAbsoluteTransform(): Matrix;
  80999. /**
  81000. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81001. * @returns a matrix
  81002. */
  81003. getAbsoluteTransform(): Matrix;
  81004. /**
  81005. * Links with the given transform node.
  81006. * The local matrix of this bone is copied from the transform node every frame.
  81007. * @param transformNode defines the transform node to link to
  81008. */
  81009. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81010. /**
  81011. * Gets the node used to drive the bone's transformation
  81012. * @returns a transform node or null
  81013. */
  81014. getTransformNode(): Nullable<TransformNode>;
  81015. /** Gets or sets current position (in local space) */
  81016. position: Vector3;
  81017. /** Gets or sets current rotation (in local space) */
  81018. rotation: Vector3;
  81019. /** Gets or sets current rotation quaternion (in local space) */
  81020. rotationQuaternion: Quaternion;
  81021. /** Gets or sets current scaling (in local space) */
  81022. scaling: Vector3;
  81023. /**
  81024. * Gets the animation properties override
  81025. */
  81026. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81027. private _decompose;
  81028. private _compose;
  81029. /**
  81030. * Update the base and local matrices
  81031. * @param matrix defines the new base or local matrix
  81032. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81033. * @param updateLocalMatrix defines if the local matrix should be updated
  81034. */
  81035. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81036. /** @hidden */
  81037. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81038. /**
  81039. * Flag the bone as dirty (Forcing it to update everything)
  81040. */
  81041. markAsDirty(): void;
  81042. /** @hidden */
  81043. _markAsDirtyAndCompose(): void;
  81044. private _markAsDirtyAndDecompose;
  81045. /**
  81046. * Translate the bone in local or world space
  81047. * @param vec The amount to translate the bone
  81048. * @param space The space that the translation is in
  81049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81050. */
  81051. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81052. /**
  81053. * Set the postion of the bone in local or world space
  81054. * @param position The position to set the bone
  81055. * @param space The space that the position is in
  81056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81057. */
  81058. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81059. /**
  81060. * Set the absolute position of the bone (world space)
  81061. * @param position The position to set the bone
  81062. * @param mesh The mesh that this bone is attached to
  81063. */
  81064. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81065. /**
  81066. * Scale the bone on the x, y and z axes (in local space)
  81067. * @param x The amount to scale the bone on the x axis
  81068. * @param y The amount to scale the bone on the y axis
  81069. * @param z The amount to scale the bone on the z axis
  81070. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81071. */
  81072. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81073. /**
  81074. * Set the bone scaling in local space
  81075. * @param scale defines the scaling vector
  81076. */
  81077. setScale(scale: Vector3): void;
  81078. /**
  81079. * Gets the current scaling in local space
  81080. * @returns the current scaling vector
  81081. */
  81082. getScale(): Vector3;
  81083. /**
  81084. * Gets the current scaling in local space and stores it in a target vector
  81085. * @param result defines the target vector
  81086. */
  81087. getScaleToRef(result: Vector3): void;
  81088. /**
  81089. * Set the yaw, pitch, and roll of the bone in local or world space
  81090. * @param yaw The rotation of the bone on the y axis
  81091. * @param pitch The rotation of the bone on the x axis
  81092. * @param roll The rotation of the bone on the z axis
  81093. * @param space The space that the axes of rotation are in
  81094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81095. */
  81096. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81097. /**
  81098. * Add a rotation to the bone on an axis in local or world space
  81099. * @param axis The axis to rotate the bone on
  81100. * @param amount The amount to rotate the bone
  81101. * @param space The space that the axis is in
  81102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81103. */
  81104. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81105. /**
  81106. * Set the rotation of the bone to a particular axis angle in local or world space
  81107. * @param axis The axis to rotate the bone on
  81108. * @param angle The angle that the bone should be rotated to
  81109. * @param space The space that the axis is in
  81110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81111. */
  81112. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81113. /**
  81114. * Set the euler rotation of the bone in local of world space
  81115. * @param rotation The euler rotation that the bone should be set to
  81116. * @param space The space that the rotation is in
  81117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81118. */
  81119. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81120. /**
  81121. * Set the quaternion rotation of the bone in local of world space
  81122. * @param quat The quaternion rotation that the bone should be set to
  81123. * @param space The space that the rotation is in
  81124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81125. */
  81126. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81127. /**
  81128. * Set the rotation matrix of the bone in local of world space
  81129. * @param rotMat The rotation matrix that the bone should be set to
  81130. * @param space The space that the rotation is in
  81131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81132. */
  81133. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81134. private _rotateWithMatrix;
  81135. private _getNegativeRotationToRef;
  81136. /**
  81137. * Get the position of the bone in local or world space
  81138. * @param space The space that the returned position is in
  81139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81140. * @returns The position of the bone
  81141. */
  81142. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81143. /**
  81144. * Copy the position of the bone to a vector3 in local or world space
  81145. * @param space The space that the returned position is in
  81146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81147. * @param result The vector3 to copy the position to
  81148. */
  81149. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81150. /**
  81151. * Get the absolute position of the bone (world space)
  81152. * @param mesh The mesh that this bone is attached to
  81153. * @returns The absolute position of the bone
  81154. */
  81155. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81156. /**
  81157. * Copy the absolute position of the bone (world space) to the result param
  81158. * @param mesh The mesh that this bone is attached to
  81159. * @param result The vector3 to copy the absolute position to
  81160. */
  81161. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81162. /**
  81163. * Compute the absolute transforms of this bone and its children
  81164. */
  81165. computeAbsoluteTransforms(): void;
  81166. /**
  81167. * Get the world direction from an axis that is in the local space of the bone
  81168. * @param localAxis The local direction that is used to compute the world direction
  81169. * @param mesh The mesh that this bone is attached to
  81170. * @returns The world direction
  81171. */
  81172. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81173. /**
  81174. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81175. * @param localAxis The local direction that is used to compute the world direction
  81176. * @param mesh The mesh that this bone is attached to
  81177. * @param result The vector3 that the world direction will be copied to
  81178. */
  81179. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81180. /**
  81181. * Get the euler rotation of the bone in local or world space
  81182. * @param space The space that the rotation should be in
  81183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81184. * @returns The euler rotation
  81185. */
  81186. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81187. /**
  81188. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81189. * @param space The space that the rotation should be in
  81190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81191. * @param result The vector3 that the rotation should be copied to
  81192. */
  81193. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81194. /**
  81195. * Get the quaternion rotation of the bone in either local or world space
  81196. * @param space The space that the rotation should be in
  81197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81198. * @returns The quaternion rotation
  81199. */
  81200. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81201. /**
  81202. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81203. * @param space The space that the rotation should be in
  81204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81205. * @param result The quaternion that the rotation should be copied to
  81206. */
  81207. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81208. /**
  81209. * Get the rotation matrix of the bone in local or world space
  81210. * @param space The space that the rotation should be in
  81211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81212. * @returns The rotation matrix
  81213. */
  81214. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81215. /**
  81216. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81217. * @param space The space that the rotation should be in
  81218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81219. * @param result The quaternion that the rotation should be copied to
  81220. */
  81221. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81222. /**
  81223. * Get the world position of a point that is in the local space of the bone
  81224. * @param position The local position
  81225. * @param mesh The mesh that this bone is attached to
  81226. * @returns The world position
  81227. */
  81228. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81229. /**
  81230. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81231. * @param position The local position
  81232. * @param mesh The mesh that this bone is attached to
  81233. * @param result The vector3 that the world position should be copied to
  81234. */
  81235. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81236. /**
  81237. * Get the local position of a point that is in world space
  81238. * @param position The world position
  81239. * @param mesh The mesh that this bone is attached to
  81240. * @returns The local position
  81241. */
  81242. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81243. /**
  81244. * Get the local position of a point that is in world space and copy it to the result param
  81245. * @param position The world position
  81246. * @param mesh The mesh that this bone is attached to
  81247. * @param result The vector3 that the local position should be copied to
  81248. */
  81249. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81250. }
  81251. }
  81252. declare module BABYLON {
  81253. /**
  81254. * 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.
  81255. * @see https://doc.babylonjs.com/how_to/transformnode
  81256. */
  81257. export class TransformNode extends Node {
  81258. /**
  81259. * Object will not rotate to face the camera
  81260. */
  81261. static BILLBOARDMODE_NONE: number;
  81262. /**
  81263. * Object will rotate to face the camera but only on the x axis
  81264. */
  81265. static BILLBOARDMODE_X: number;
  81266. /**
  81267. * Object will rotate to face the camera but only on the y axis
  81268. */
  81269. static BILLBOARDMODE_Y: number;
  81270. /**
  81271. * Object will rotate to face the camera but only on the z axis
  81272. */
  81273. static BILLBOARDMODE_Z: number;
  81274. /**
  81275. * Object will rotate to face the camera
  81276. */
  81277. static BILLBOARDMODE_ALL: number;
  81278. /**
  81279. * Object will rotate to face the camera's position instead of orientation
  81280. */
  81281. static BILLBOARDMODE_USE_POSITION: number;
  81282. private _forward;
  81283. private _forwardInverted;
  81284. private _up;
  81285. private _right;
  81286. private _rightInverted;
  81287. private _position;
  81288. private _rotation;
  81289. private _rotationQuaternion;
  81290. protected _scaling: Vector3;
  81291. protected _isDirty: boolean;
  81292. private _transformToBoneReferal;
  81293. private _isAbsoluteSynced;
  81294. private _billboardMode;
  81295. /**
  81296. * Gets or sets the billboard mode. Default is 0.
  81297. *
  81298. * | Value | Type | Description |
  81299. * | --- | --- | --- |
  81300. * | 0 | BILLBOARDMODE_NONE | |
  81301. * | 1 | BILLBOARDMODE_X | |
  81302. * | 2 | BILLBOARDMODE_Y | |
  81303. * | 4 | BILLBOARDMODE_Z | |
  81304. * | 7 | BILLBOARDMODE_ALL | |
  81305. *
  81306. */
  81307. billboardMode: number;
  81308. private _preserveParentRotationForBillboard;
  81309. /**
  81310. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81311. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81312. */
  81313. preserveParentRotationForBillboard: boolean;
  81314. /**
  81315. * 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
  81316. */
  81317. scalingDeterminant: number;
  81318. private _infiniteDistance;
  81319. /**
  81320. * Gets or sets the distance of the object to max, often used by skybox
  81321. */
  81322. infiniteDistance: boolean;
  81323. /**
  81324. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81325. * By default the system will update normals to compensate
  81326. */
  81327. ignoreNonUniformScaling: boolean;
  81328. /**
  81329. * 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
  81330. */
  81331. reIntegrateRotationIntoRotationQuaternion: boolean;
  81332. /** @hidden */
  81333. _poseMatrix: Nullable<Matrix>;
  81334. /** @hidden */
  81335. _localMatrix: Matrix;
  81336. private _usePivotMatrix;
  81337. private _absolutePosition;
  81338. private _absoluteScaling;
  81339. private _absoluteRotationQuaternion;
  81340. private _pivotMatrix;
  81341. private _pivotMatrixInverse;
  81342. protected _postMultiplyPivotMatrix: boolean;
  81343. protected _isWorldMatrixFrozen: boolean;
  81344. /** @hidden */
  81345. _indexInSceneTransformNodesArray: number;
  81346. /**
  81347. * An event triggered after the world matrix is updated
  81348. */
  81349. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81350. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81351. /**
  81352. * Gets a string identifying the name of the class
  81353. * @returns "TransformNode" string
  81354. */
  81355. getClassName(): string;
  81356. /**
  81357. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81358. */
  81359. position: Vector3;
  81360. /**
  81361. * 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)).
  81362. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81363. */
  81364. rotation: Vector3;
  81365. /**
  81366. * 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)).
  81367. */
  81368. scaling: Vector3;
  81369. /**
  81370. * 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).
  81371. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81372. */
  81373. rotationQuaternion: Nullable<Quaternion>;
  81374. /**
  81375. * The forward direction of that transform in world space.
  81376. */
  81377. readonly forward: Vector3;
  81378. /**
  81379. * The up direction of that transform in world space.
  81380. */
  81381. readonly up: Vector3;
  81382. /**
  81383. * The right direction of that transform in world space.
  81384. */
  81385. readonly right: Vector3;
  81386. /**
  81387. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81388. * @param matrix the matrix to copy the pose from
  81389. * @returns this TransformNode.
  81390. */
  81391. updatePoseMatrix(matrix: Matrix): TransformNode;
  81392. /**
  81393. * Returns the mesh Pose matrix.
  81394. * @returns the pose matrix
  81395. */
  81396. getPoseMatrix(): Matrix;
  81397. /** @hidden */
  81398. _isSynchronized(): boolean;
  81399. /** @hidden */
  81400. _initCache(): void;
  81401. /**
  81402. * Flag the transform node as dirty (Forcing it to update everything)
  81403. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81404. * @returns this transform node
  81405. */
  81406. markAsDirty(property: string): TransformNode;
  81407. /**
  81408. * Returns the current mesh absolute position.
  81409. * Returns a Vector3.
  81410. */
  81411. readonly absolutePosition: Vector3;
  81412. /**
  81413. * Returns the current mesh absolute scaling.
  81414. * Returns a Vector3.
  81415. */
  81416. readonly absoluteScaling: Vector3;
  81417. /**
  81418. * Returns the current mesh absolute rotation.
  81419. * Returns a Quaternion.
  81420. */
  81421. readonly absoluteRotationQuaternion: Quaternion;
  81422. /**
  81423. * Sets a new matrix to apply before all other transformation
  81424. * @param matrix defines the transform matrix
  81425. * @returns the current TransformNode
  81426. */
  81427. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81428. /**
  81429. * Sets a new pivot matrix to the current node
  81430. * @param matrix defines the new pivot matrix to use
  81431. * @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
  81432. * @returns the current TransformNode
  81433. */
  81434. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81435. /**
  81436. * Returns the mesh pivot matrix.
  81437. * Default : Identity.
  81438. * @returns the matrix
  81439. */
  81440. getPivotMatrix(): Matrix;
  81441. /**
  81442. * Instantiate (when possible) or clone that node with its hierarchy
  81443. * @param newParent defines the new parent to use for the instance (or clone)
  81444. * @returns an instance (or a clone) of the current node with its hiearchy
  81445. */
  81446. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  81447. /**
  81448. * Prevents the World matrix to be computed any longer
  81449. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81450. * @returns the TransformNode.
  81451. */
  81452. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81453. /**
  81454. * Allows back the World matrix computation.
  81455. * @returns the TransformNode.
  81456. */
  81457. unfreezeWorldMatrix(): this;
  81458. /**
  81459. * True if the World matrix has been frozen.
  81460. */
  81461. readonly isWorldMatrixFrozen: boolean;
  81462. /**
  81463. * Retuns the mesh absolute position in the World.
  81464. * @returns a Vector3.
  81465. */
  81466. getAbsolutePosition(): Vector3;
  81467. /**
  81468. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81469. * @param absolutePosition the absolute position to set
  81470. * @returns the TransformNode.
  81471. */
  81472. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81473. /**
  81474. * Sets the mesh position in its local space.
  81475. * @param vector3 the position to set in localspace
  81476. * @returns the TransformNode.
  81477. */
  81478. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81479. /**
  81480. * Returns the mesh position in the local space from the current World matrix values.
  81481. * @returns a new Vector3.
  81482. */
  81483. getPositionExpressedInLocalSpace(): Vector3;
  81484. /**
  81485. * Translates the mesh along the passed Vector3 in its local space.
  81486. * @param vector3 the distance to translate in localspace
  81487. * @returns the TransformNode.
  81488. */
  81489. locallyTranslate(vector3: Vector3): TransformNode;
  81490. private static _lookAtVectorCache;
  81491. /**
  81492. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81493. * @param targetPoint the position (must be in same space as current mesh) to look at
  81494. * @param yawCor optional yaw (y-axis) correction in radians
  81495. * @param pitchCor optional pitch (x-axis) correction in radians
  81496. * @param rollCor optional roll (z-axis) correction in radians
  81497. * @param space the choosen space of the target
  81498. * @returns the TransformNode.
  81499. */
  81500. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81501. /**
  81502. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81503. * This Vector3 is expressed in the World space.
  81504. * @param localAxis axis to rotate
  81505. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81506. */
  81507. getDirection(localAxis: Vector3): Vector3;
  81508. /**
  81509. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81510. * localAxis is expressed in the mesh local space.
  81511. * result is computed in the Wordl space from the mesh World matrix.
  81512. * @param localAxis axis to rotate
  81513. * @param result the resulting transformnode
  81514. * @returns this TransformNode.
  81515. */
  81516. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81517. /**
  81518. * Sets this transform node rotation to the given local axis.
  81519. * @param localAxis the axis in local space
  81520. * @param yawCor optional yaw (y-axis) correction in radians
  81521. * @param pitchCor optional pitch (x-axis) correction in radians
  81522. * @param rollCor optional roll (z-axis) correction in radians
  81523. * @returns this TransformNode
  81524. */
  81525. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81526. /**
  81527. * Sets a new pivot point to the current node
  81528. * @param point defines the new pivot point to use
  81529. * @param space defines if the point is in world or local space (local by default)
  81530. * @returns the current TransformNode
  81531. */
  81532. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81533. /**
  81534. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81535. * @returns the pivot point
  81536. */
  81537. getPivotPoint(): Vector3;
  81538. /**
  81539. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81540. * @param result the vector3 to store the result
  81541. * @returns this TransformNode.
  81542. */
  81543. getPivotPointToRef(result: Vector3): TransformNode;
  81544. /**
  81545. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81546. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81547. */
  81548. getAbsolutePivotPoint(): Vector3;
  81549. /**
  81550. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81551. * @param result vector3 to store the result
  81552. * @returns this TransformNode.
  81553. */
  81554. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81555. /**
  81556. * Defines the passed node as the parent of the current node.
  81557. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81558. * @see https://doc.babylonjs.com/how_to/parenting
  81559. * @param node the node ot set as the parent
  81560. * @returns this TransformNode.
  81561. */
  81562. setParent(node: Nullable<Node>): TransformNode;
  81563. private _nonUniformScaling;
  81564. /**
  81565. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81566. */
  81567. readonly nonUniformScaling: boolean;
  81568. /** @hidden */
  81569. _updateNonUniformScalingState(value: boolean): boolean;
  81570. /**
  81571. * Attach the current TransformNode to another TransformNode associated with a bone
  81572. * @param bone Bone affecting the TransformNode
  81573. * @param affectedTransformNode TransformNode associated with the bone
  81574. * @returns this object
  81575. */
  81576. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81577. /**
  81578. * Detach the transform node if its associated with a bone
  81579. * @returns this object
  81580. */
  81581. detachFromBone(): TransformNode;
  81582. private static _rotationAxisCache;
  81583. /**
  81584. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81585. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81586. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81587. * The passed axis is also normalized.
  81588. * @param axis the axis to rotate around
  81589. * @param amount the amount to rotate in radians
  81590. * @param space Space to rotate in (Default: local)
  81591. * @returns the TransformNode.
  81592. */
  81593. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81594. /**
  81595. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81596. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81597. * The passed axis is also normalized. .
  81598. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81599. * @param point the point to rotate around
  81600. * @param axis the axis to rotate around
  81601. * @param amount the amount to rotate in radians
  81602. * @returns the TransformNode
  81603. */
  81604. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81605. /**
  81606. * Translates the mesh along the axis vector for the passed distance in the given space.
  81607. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81608. * @param axis the axis to translate in
  81609. * @param distance the distance to translate
  81610. * @param space Space to rotate in (Default: local)
  81611. * @returns the TransformNode.
  81612. */
  81613. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81614. /**
  81615. * Adds a rotation step to the mesh current rotation.
  81616. * x, y, z are Euler angles expressed in radians.
  81617. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81618. * This means this rotation is made in the mesh local space only.
  81619. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81620. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81621. * ```javascript
  81622. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81623. * ```
  81624. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81625. * 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.
  81626. * @param x Rotation to add
  81627. * @param y Rotation to add
  81628. * @param z Rotation to add
  81629. * @returns the TransformNode.
  81630. */
  81631. addRotation(x: number, y: number, z: number): TransformNode;
  81632. /**
  81633. * @hidden
  81634. */
  81635. protected _getEffectiveParent(): Nullable<Node>;
  81636. /**
  81637. * Computes the world matrix of the node
  81638. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81639. * @returns the world matrix
  81640. */
  81641. computeWorldMatrix(force?: boolean): Matrix;
  81642. protected _afterComputeWorldMatrix(): void;
  81643. /**
  81644. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81645. * @param func callback function to add
  81646. *
  81647. * @returns the TransformNode.
  81648. */
  81649. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81650. /**
  81651. * Removes a registered callback function.
  81652. * @param func callback function to remove
  81653. * @returns the TransformNode.
  81654. */
  81655. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81656. /**
  81657. * Gets the position of the current mesh in camera space
  81658. * @param camera defines the camera to use
  81659. * @returns a position
  81660. */
  81661. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81662. /**
  81663. * Returns the distance from the mesh to the active camera
  81664. * @param camera defines the camera to use
  81665. * @returns the distance
  81666. */
  81667. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81668. /**
  81669. * Clone the current transform node
  81670. * @param name Name of the new clone
  81671. * @param newParent New parent for the clone
  81672. * @param doNotCloneChildren Do not clone children hierarchy
  81673. * @returns the new transform node
  81674. */
  81675. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81676. /**
  81677. * Serializes the objects information.
  81678. * @param currentSerializationObject defines the object to serialize in
  81679. * @returns the serialized object
  81680. */
  81681. serialize(currentSerializationObject?: any): any;
  81682. /**
  81683. * Returns a new TransformNode object parsed from the source provided.
  81684. * @param parsedTransformNode is the source.
  81685. * @param scene the scne the object belongs to
  81686. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81687. * @returns a new TransformNode object parsed from the source provided.
  81688. */
  81689. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81690. /**
  81691. * Get all child-transformNodes of this node
  81692. * @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
  81693. * @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
  81694. * @returns an array of TransformNode
  81695. */
  81696. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81697. /**
  81698. * Releases resources associated with this transform node.
  81699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81701. */
  81702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81703. /**
  81704. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81705. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81706. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81707. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81708. * @returns the current mesh
  81709. */
  81710. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81711. private _syncAbsoluteScalingAndRotation;
  81712. }
  81713. }
  81714. declare module BABYLON {
  81715. /**
  81716. * Defines the types of pose enabled controllers that are supported
  81717. */
  81718. export enum PoseEnabledControllerType {
  81719. /**
  81720. * HTC Vive
  81721. */
  81722. VIVE = 0,
  81723. /**
  81724. * Oculus Rift
  81725. */
  81726. OCULUS = 1,
  81727. /**
  81728. * Windows mixed reality
  81729. */
  81730. WINDOWS = 2,
  81731. /**
  81732. * Samsung gear VR
  81733. */
  81734. GEAR_VR = 3,
  81735. /**
  81736. * Google Daydream
  81737. */
  81738. DAYDREAM = 4,
  81739. /**
  81740. * Generic
  81741. */
  81742. GENERIC = 5
  81743. }
  81744. /**
  81745. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81746. */
  81747. export interface MutableGamepadButton {
  81748. /**
  81749. * Value of the button/trigger
  81750. */
  81751. value: number;
  81752. /**
  81753. * If the button/trigger is currently touched
  81754. */
  81755. touched: boolean;
  81756. /**
  81757. * If the button/trigger is currently pressed
  81758. */
  81759. pressed: boolean;
  81760. }
  81761. /**
  81762. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81763. * @hidden
  81764. */
  81765. export interface ExtendedGamepadButton extends GamepadButton {
  81766. /**
  81767. * If the button/trigger is currently pressed
  81768. */
  81769. readonly pressed: boolean;
  81770. /**
  81771. * If the button/trigger is currently touched
  81772. */
  81773. readonly touched: boolean;
  81774. /**
  81775. * Value of the button/trigger
  81776. */
  81777. readonly value: number;
  81778. }
  81779. /** @hidden */
  81780. export interface _GamePadFactory {
  81781. /**
  81782. * Returns wether or not the current gamepad can be created for this type of controller.
  81783. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81784. * @returns true if it can be created, otherwise false
  81785. */
  81786. canCreate(gamepadInfo: any): boolean;
  81787. /**
  81788. * Creates a new instance of the Gamepad.
  81789. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81790. * @returns the new gamepad instance
  81791. */
  81792. create(gamepadInfo: any): Gamepad;
  81793. }
  81794. /**
  81795. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81796. */
  81797. export class PoseEnabledControllerHelper {
  81798. /** @hidden */
  81799. static _ControllerFactories: _GamePadFactory[];
  81800. /** @hidden */
  81801. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81802. /**
  81803. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81804. * @param vrGamepad the gamepad to initialized
  81805. * @returns a vr controller of the type the gamepad identified as
  81806. */
  81807. static InitiateController(vrGamepad: any): Gamepad;
  81808. }
  81809. /**
  81810. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81811. */
  81812. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81813. /**
  81814. * If the controller is used in a webXR session
  81815. */
  81816. isXR: boolean;
  81817. private _deviceRoomPosition;
  81818. private _deviceRoomRotationQuaternion;
  81819. /**
  81820. * The device position in babylon space
  81821. */
  81822. devicePosition: Vector3;
  81823. /**
  81824. * The device rotation in babylon space
  81825. */
  81826. deviceRotationQuaternion: Quaternion;
  81827. /**
  81828. * The scale factor of the device in babylon space
  81829. */
  81830. deviceScaleFactor: number;
  81831. /**
  81832. * (Likely devicePosition should be used instead) The device position in its room space
  81833. */
  81834. position: Vector3;
  81835. /**
  81836. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81837. */
  81838. rotationQuaternion: Quaternion;
  81839. /**
  81840. * The type of controller (Eg. Windows mixed reality)
  81841. */
  81842. controllerType: PoseEnabledControllerType;
  81843. protected _calculatedPosition: Vector3;
  81844. private _calculatedRotation;
  81845. /**
  81846. * The raw pose from the device
  81847. */
  81848. rawPose: DevicePose;
  81849. private _trackPosition;
  81850. private _maxRotationDistFromHeadset;
  81851. private _draggedRoomRotation;
  81852. /**
  81853. * @hidden
  81854. */
  81855. _disableTrackPosition(fixedPosition: Vector3): void;
  81856. /**
  81857. * Internal, the mesh attached to the controller
  81858. * @hidden
  81859. */
  81860. _mesh: Nullable<AbstractMesh>;
  81861. private _poseControlledCamera;
  81862. private _leftHandSystemQuaternion;
  81863. /**
  81864. * Internal, matrix used to convert room space to babylon space
  81865. * @hidden
  81866. */
  81867. _deviceToWorld: Matrix;
  81868. /**
  81869. * Node to be used when casting a ray from the controller
  81870. * @hidden
  81871. */
  81872. _pointingPoseNode: Nullable<TransformNode>;
  81873. /**
  81874. * Name of the child mesh that can be used to cast a ray from the controller
  81875. */
  81876. static readonly POINTING_POSE: string;
  81877. /**
  81878. * Creates a new PoseEnabledController from a gamepad
  81879. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81880. */
  81881. constructor(browserGamepad: any);
  81882. private _workingMatrix;
  81883. /**
  81884. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81885. */
  81886. update(): void;
  81887. /**
  81888. * Updates only the pose device and mesh without doing any button event checking
  81889. */
  81890. protected _updatePoseAndMesh(): void;
  81891. /**
  81892. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81893. * @param poseData raw pose fromthe device
  81894. */
  81895. updateFromDevice(poseData: DevicePose): void;
  81896. /**
  81897. * @hidden
  81898. */
  81899. _meshAttachedObservable: Observable<AbstractMesh>;
  81900. /**
  81901. * Attaches a mesh to the controller
  81902. * @param mesh the mesh to be attached
  81903. */
  81904. attachToMesh(mesh: AbstractMesh): void;
  81905. /**
  81906. * Attaches the controllers mesh to a camera
  81907. * @param camera the camera the mesh should be attached to
  81908. */
  81909. attachToPoseControlledCamera(camera: TargetCamera): void;
  81910. /**
  81911. * Disposes of the controller
  81912. */
  81913. dispose(): void;
  81914. /**
  81915. * The mesh that is attached to the controller
  81916. */
  81917. readonly mesh: Nullable<AbstractMesh>;
  81918. /**
  81919. * Gets the ray of the controller in the direction the controller is pointing
  81920. * @param length the length the resulting ray should be
  81921. * @returns a ray in the direction the controller is pointing
  81922. */
  81923. getForwardRay(length?: number): Ray;
  81924. }
  81925. }
  81926. declare module BABYLON {
  81927. /**
  81928. * Defines the WebVRController object that represents controllers tracked in 3D space
  81929. */
  81930. export abstract class WebVRController extends PoseEnabledController {
  81931. /**
  81932. * Internal, the default controller model for the controller
  81933. */
  81934. protected _defaultModel: Nullable<AbstractMesh>;
  81935. /**
  81936. * Fired when the trigger state has changed
  81937. */
  81938. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81939. /**
  81940. * Fired when the main button state has changed
  81941. */
  81942. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81943. /**
  81944. * Fired when the secondary button state has changed
  81945. */
  81946. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81947. /**
  81948. * Fired when the pad state has changed
  81949. */
  81950. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81951. /**
  81952. * Fired when controllers stick values have changed
  81953. */
  81954. onPadValuesChangedObservable: Observable<StickValues>;
  81955. /**
  81956. * Array of button availible on the controller
  81957. */
  81958. protected _buttons: Array<MutableGamepadButton>;
  81959. private _onButtonStateChange;
  81960. /**
  81961. * Fired when a controller button's state has changed
  81962. * @param callback the callback containing the button that was modified
  81963. */
  81964. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81965. /**
  81966. * X and Y axis corresponding to the controllers joystick
  81967. */
  81968. pad: StickValues;
  81969. /**
  81970. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81971. */
  81972. hand: string;
  81973. /**
  81974. * The default controller model for the controller
  81975. */
  81976. readonly defaultModel: Nullable<AbstractMesh>;
  81977. /**
  81978. * Creates a new WebVRController from a gamepad
  81979. * @param vrGamepad the gamepad that the WebVRController should be created from
  81980. */
  81981. constructor(vrGamepad: any);
  81982. /**
  81983. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81984. */
  81985. update(): void;
  81986. /**
  81987. * Function to be called when a button is modified
  81988. */
  81989. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81990. /**
  81991. * Loads a mesh and attaches it to the controller
  81992. * @param scene the scene the mesh should be added to
  81993. * @param meshLoaded callback for when the mesh has been loaded
  81994. */
  81995. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81996. private _setButtonValue;
  81997. private _changes;
  81998. private _checkChanges;
  81999. /**
  82000. * Disposes of th webVRCOntroller
  82001. */
  82002. dispose(): void;
  82003. }
  82004. }
  82005. declare module BABYLON {
  82006. /**
  82007. * The HemisphericLight simulates the ambient environment light,
  82008. * so the passed direction is the light reflection direction, not the incoming direction.
  82009. */
  82010. export class HemisphericLight extends Light {
  82011. /**
  82012. * The groundColor is the light in the opposite direction to the one specified during creation.
  82013. * 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.
  82014. */
  82015. groundColor: Color3;
  82016. /**
  82017. * The light reflection direction, not the incoming direction.
  82018. */
  82019. direction: Vector3;
  82020. /**
  82021. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82022. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82023. * The HemisphericLight can't cast shadows.
  82024. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82025. * @param name The friendly name of the light
  82026. * @param direction The direction of the light reflection
  82027. * @param scene The scene the light belongs to
  82028. */
  82029. constructor(name: string, direction: Vector3, scene: Scene);
  82030. protected _buildUniformLayout(): void;
  82031. /**
  82032. * Returns the string "HemisphericLight".
  82033. * @return The class name
  82034. */
  82035. getClassName(): string;
  82036. /**
  82037. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82038. * Returns the updated direction.
  82039. * @param target The target the direction should point to
  82040. * @return The computed direction
  82041. */
  82042. setDirectionToTarget(target: Vector3): Vector3;
  82043. /**
  82044. * Returns the shadow generator associated to the light.
  82045. * @returns Always null for hemispheric lights because it does not support shadows.
  82046. */
  82047. getShadowGenerator(): Nullable<IShadowGenerator>;
  82048. /**
  82049. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82050. * @param effect The effect to update
  82051. * @param lightIndex The index of the light in the effect to update
  82052. * @returns The hemispheric light
  82053. */
  82054. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82055. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82056. /**
  82057. * Computes the world matrix of the node
  82058. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82059. * @param useWasUpdatedFlag defines a reserved property
  82060. * @returns the world matrix
  82061. */
  82062. computeWorldMatrix(): Matrix;
  82063. /**
  82064. * Returns the integer 3.
  82065. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82066. */
  82067. getTypeID(): number;
  82068. /**
  82069. * Prepares the list of defines specific to the light type.
  82070. * @param defines the list of defines
  82071. * @param lightIndex defines the index of the light for the effect
  82072. */
  82073. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82074. }
  82075. }
  82076. declare module BABYLON {
  82077. /** @hidden */
  82078. export var vrMultiviewToSingleviewPixelShader: {
  82079. name: string;
  82080. shader: string;
  82081. };
  82082. }
  82083. declare module BABYLON {
  82084. /**
  82085. * Renders to multiple views with a single draw call
  82086. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82087. */
  82088. export class MultiviewRenderTarget extends RenderTargetTexture {
  82089. /**
  82090. * Creates a multiview render target
  82091. * @param scene scene used with the render target
  82092. * @param size the size of the render target (used for each view)
  82093. */
  82094. constructor(scene: Scene, size?: number | {
  82095. width: number;
  82096. height: number;
  82097. } | {
  82098. ratio: number;
  82099. });
  82100. /**
  82101. * @hidden
  82102. * @param faceIndex the face index, if its a cube texture
  82103. */
  82104. _bindFrameBuffer(faceIndex?: number): void;
  82105. /**
  82106. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82107. * @returns the view count
  82108. */
  82109. getViewCount(): number;
  82110. }
  82111. }
  82112. declare module BABYLON {
  82113. /**
  82114. * Represents a camera frustum
  82115. */
  82116. export class Frustum {
  82117. /**
  82118. * Gets the planes representing the frustum
  82119. * @param transform matrix to be applied to the returned planes
  82120. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82121. */
  82122. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82123. /**
  82124. * Gets the near frustum plane transformed by the transform matrix
  82125. * @param transform transformation matrix to be applied to the resulting frustum plane
  82126. * @param frustumPlane the resuling frustum plane
  82127. */
  82128. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82129. /**
  82130. * Gets the far frustum plane transformed by the transform matrix
  82131. * @param transform transformation matrix to be applied to the resulting frustum plane
  82132. * @param frustumPlane the resuling frustum plane
  82133. */
  82134. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82135. /**
  82136. * Gets the left frustum plane transformed by the transform matrix
  82137. * @param transform transformation matrix to be applied to the resulting frustum plane
  82138. * @param frustumPlane the resuling frustum plane
  82139. */
  82140. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82141. /**
  82142. * Gets the right frustum plane transformed by the transform matrix
  82143. * @param transform transformation matrix to be applied to the resulting frustum plane
  82144. * @param frustumPlane the resuling frustum plane
  82145. */
  82146. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82147. /**
  82148. * Gets the top frustum plane transformed by the transform matrix
  82149. * @param transform transformation matrix to be applied to the resulting frustum plane
  82150. * @param frustumPlane the resuling frustum plane
  82151. */
  82152. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82153. /**
  82154. * Gets the bottom frustum plane transformed by the transform matrix
  82155. * @param transform transformation matrix to be applied to the resulting frustum plane
  82156. * @param frustumPlane the resuling frustum plane
  82157. */
  82158. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82159. /**
  82160. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82161. * @param transform transformation matrix to be applied to the resulting frustum planes
  82162. * @param frustumPlanes the resuling frustum planes
  82163. */
  82164. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82165. }
  82166. }
  82167. declare module BABYLON {
  82168. interface Engine {
  82169. /**
  82170. * Creates a new multiview render target
  82171. * @param width defines the width of the texture
  82172. * @param height defines the height of the texture
  82173. * @returns the created multiview texture
  82174. */
  82175. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82176. /**
  82177. * Binds a multiview framebuffer to be drawn to
  82178. * @param multiviewTexture texture to bind
  82179. */
  82180. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82181. }
  82182. interface Camera {
  82183. /**
  82184. * @hidden
  82185. * 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)
  82186. */
  82187. _useMultiviewToSingleView: boolean;
  82188. /**
  82189. * @hidden
  82190. * 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)
  82191. */
  82192. _multiviewTexture: Nullable<RenderTargetTexture>;
  82193. /**
  82194. * @hidden
  82195. * ensures the multiview texture of the camera exists and has the specified width/height
  82196. * @param width height to set on the multiview texture
  82197. * @param height width to set on the multiview texture
  82198. */
  82199. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82200. }
  82201. interface Scene {
  82202. /** @hidden */
  82203. _transformMatrixR: Matrix;
  82204. /** @hidden */
  82205. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82206. /** @hidden */
  82207. _createMultiviewUbo(): void;
  82208. /** @hidden */
  82209. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82210. /** @hidden */
  82211. _renderMultiviewToSingleView(camera: Camera): void;
  82212. }
  82213. }
  82214. declare module BABYLON {
  82215. /**
  82216. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82217. * This will not be used for webXR as it supports displaying texture arrays directly
  82218. */
  82219. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82220. /**
  82221. * Initializes a VRMultiviewToSingleview
  82222. * @param name name of the post process
  82223. * @param camera camera to be applied to
  82224. * @param scaleFactor scaling factor to the size of the output texture
  82225. */
  82226. constructor(name: string, camera: Camera, scaleFactor: number);
  82227. }
  82228. }
  82229. declare module BABYLON {
  82230. interface Engine {
  82231. /** @hidden */
  82232. _vrDisplay: any;
  82233. /** @hidden */
  82234. _vrSupported: boolean;
  82235. /** @hidden */
  82236. _oldSize: Size;
  82237. /** @hidden */
  82238. _oldHardwareScaleFactor: number;
  82239. /** @hidden */
  82240. _vrExclusivePointerMode: boolean;
  82241. /** @hidden */
  82242. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82243. /** @hidden */
  82244. _onVRDisplayPointerRestricted: () => void;
  82245. /** @hidden */
  82246. _onVRDisplayPointerUnrestricted: () => void;
  82247. /** @hidden */
  82248. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82249. /** @hidden */
  82250. _onVrDisplayDisconnect: Nullable<() => void>;
  82251. /** @hidden */
  82252. _onVrDisplayPresentChange: Nullable<() => void>;
  82253. /**
  82254. * Observable signaled when VR display mode changes
  82255. */
  82256. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82257. /**
  82258. * Observable signaled when VR request present is complete
  82259. */
  82260. onVRRequestPresentComplete: Observable<boolean>;
  82261. /**
  82262. * Observable signaled when VR request present starts
  82263. */
  82264. onVRRequestPresentStart: Observable<Engine>;
  82265. /**
  82266. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82267. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82268. */
  82269. isInVRExclusivePointerMode: boolean;
  82270. /**
  82271. * Gets a boolean indicating if a webVR device was detected
  82272. * @returns true if a webVR device was detected
  82273. */
  82274. isVRDevicePresent(): boolean;
  82275. /**
  82276. * Gets the current webVR device
  82277. * @returns the current webVR device (or null)
  82278. */
  82279. getVRDevice(): any;
  82280. /**
  82281. * Initializes a webVR display and starts listening to display change events
  82282. * The onVRDisplayChangedObservable will be notified upon these changes
  82283. * @returns A promise containing a VRDisplay and if vr is supported
  82284. */
  82285. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82286. /** @hidden */
  82287. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82288. /**
  82289. * Call this function to switch to webVR mode
  82290. * Will do nothing if webVR is not supported or if there is no webVR device
  82291. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82292. */
  82293. enableVR(): void;
  82294. /** @hidden */
  82295. _onVRFullScreenTriggered(): void;
  82296. }
  82297. }
  82298. declare module BABYLON {
  82299. /**
  82300. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82301. * IMPORTANT!! The data is right-hand data.
  82302. * @export
  82303. * @interface DevicePose
  82304. */
  82305. export interface DevicePose {
  82306. /**
  82307. * The position of the device, values in array are [x,y,z].
  82308. */
  82309. readonly position: Nullable<Float32Array>;
  82310. /**
  82311. * The linearVelocity of the device, values in array are [x,y,z].
  82312. */
  82313. readonly linearVelocity: Nullable<Float32Array>;
  82314. /**
  82315. * The linearAcceleration of the device, values in array are [x,y,z].
  82316. */
  82317. readonly linearAcceleration: Nullable<Float32Array>;
  82318. /**
  82319. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82320. */
  82321. readonly orientation: Nullable<Float32Array>;
  82322. /**
  82323. * The angularVelocity of the device, values in array are [x,y,z].
  82324. */
  82325. readonly angularVelocity: Nullable<Float32Array>;
  82326. /**
  82327. * The angularAcceleration of the device, values in array are [x,y,z].
  82328. */
  82329. readonly angularAcceleration: Nullable<Float32Array>;
  82330. }
  82331. /**
  82332. * Interface representing a pose controlled object in Babylon.
  82333. * A pose controlled object has both regular pose values as well as pose values
  82334. * from an external device such as a VR head mounted display
  82335. */
  82336. export interface PoseControlled {
  82337. /**
  82338. * The position of the object in babylon space.
  82339. */
  82340. position: Vector3;
  82341. /**
  82342. * The rotation quaternion of the object in babylon space.
  82343. */
  82344. rotationQuaternion: Quaternion;
  82345. /**
  82346. * The position of the device in babylon space.
  82347. */
  82348. devicePosition?: Vector3;
  82349. /**
  82350. * The rotation quaternion of the device in babylon space.
  82351. */
  82352. deviceRotationQuaternion: Quaternion;
  82353. /**
  82354. * The raw pose coming from the device.
  82355. */
  82356. rawPose: Nullable<DevicePose>;
  82357. /**
  82358. * The scale of the device to be used when translating from device space to babylon space.
  82359. */
  82360. deviceScaleFactor: number;
  82361. /**
  82362. * Updates the poseControlled values based on the input device pose.
  82363. * @param poseData the pose data to update the object with
  82364. */
  82365. updateFromDevice(poseData: DevicePose): void;
  82366. }
  82367. /**
  82368. * Set of options to customize the webVRCamera
  82369. */
  82370. export interface WebVROptions {
  82371. /**
  82372. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82373. */
  82374. trackPosition?: boolean;
  82375. /**
  82376. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82377. */
  82378. positionScale?: number;
  82379. /**
  82380. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82381. */
  82382. displayName?: string;
  82383. /**
  82384. * Should the native controller meshes be initialized. (default: true)
  82385. */
  82386. controllerMeshes?: boolean;
  82387. /**
  82388. * Creating a default HemiLight only on controllers. (default: true)
  82389. */
  82390. defaultLightingOnControllers?: boolean;
  82391. /**
  82392. * If you don't want to use the default VR button of the helper. (default: false)
  82393. */
  82394. useCustomVRButton?: boolean;
  82395. /**
  82396. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82397. */
  82398. customVRButton?: HTMLButtonElement;
  82399. /**
  82400. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82401. */
  82402. rayLength?: number;
  82403. /**
  82404. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82405. */
  82406. defaultHeight?: number;
  82407. /**
  82408. * If multiview should be used if availible (default: false)
  82409. */
  82410. useMultiview?: boolean;
  82411. }
  82412. /**
  82413. * This represents a WebVR camera.
  82414. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82415. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82416. */
  82417. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82418. private webVROptions;
  82419. /**
  82420. * @hidden
  82421. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82422. */
  82423. _vrDevice: any;
  82424. /**
  82425. * The rawPose of the vrDevice.
  82426. */
  82427. rawPose: Nullable<DevicePose>;
  82428. private _onVREnabled;
  82429. private _specsVersion;
  82430. private _attached;
  82431. private _frameData;
  82432. protected _descendants: Array<Node>;
  82433. private _deviceRoomPosition;
  82434. /** @hidden */
  82435. _deviceRoomRotationQuaternion: Quaternion;
  82436. private _standingMatrix;
  82437. /**
  82438. * Represents device position in babylon space.
  82439. */
  82440. devicePosition: Vector3;
  82441. /**
  82442. * Represents device rotation in babylon space.
  82443. */
  82444. deviceRotationQuaternion: Quaternion;
  82445. /**
  82446. * The scale of the device to be used when translating from device space to babylon space.
  82447. */
  82448. deviceScaleFactor: number;
  82449. private _deviceToWorld;
  82450. private _worldToDevice;
  82451. /**
  82452. * References to the webVR controllers for the vrDevice.
  82453. */
  82454. controllers: Array<WebVRController>;
  82455. /**
  82456. * Emits an event when a controller is attached.
  82457. */
  82458. onControllersAttachedObservable: Observable<WebVRController[]>;
  82459. /**
  82460. * Emits an event when a controller's mesh has been loaded;
  82461. */
  82462. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82463. /**
  82464. * Emits an event when the HMD's pose has been updated.
  82465. */
  82466. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82467. private _poseSet;
  82468. /**
  82469. * If the rig cameras be used as parent instead of this camera.
  82470. */
  82471. rigParenting: boolean;
  82472. private _lightOnControllers;
  82473. private _defaultHeight?;
  82474. /**
  82475. * Instantiates a WebVRFreeCamera.
  82476. * @param name The name of the WebVRFreeCamera
  82477. * @param position The starting anchor position for the camera
  82478. * @param scene The scene the camera belongs to
  82479. * @param webVROptions a set of customizable options for the webVRCamera
  82480. */
  82481. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82482. /**
  82483. * Gets the device distance from the ground in meters.
  82484. * @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.
  82485. */
  82486. deviceDistanceToRoomGround(): number;
  82487. /**
  82488. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82489. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82490. */
  82491. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82492. /**
  82493. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82494. * @returns A promise with a boolean set to if the standing matrix is supported.
  82495. */
  82496. useStandingMatrixAsync(): Promise<boolean>;
  82497. /**
  82498. * Disposes the camera
  82499. */
  82500. dispose(): void;
  82501. /**
  82502. * Gets a vrController by name.
  82503. * @param name The name of the controller to retreive
  82504. * @returns the controller matching the name specified or null if not found
  82505. */
  82506. getControllerByName(name: string): Nullable<WebVRController>;
  82507. private _leftController;
  82508. /**
  82509. * The controller corresponding to the users left hand.
  82510. */
  82511. readonly leftController: Nullable<WebVRController>;
  82512. private _rightController;
  82513. /**
  82514. * The controller corresponding to the users right hand.
  82515. */
  82516. readonly rightController: Nullable<WebVRController>;
  82517. /**
  82518. * Casts a ray forward from the vrCamera's gaze.
  82519. * @param length Length of the ray (default: 100)
  82520. * @returns the ray corresponding to the gaze
  82521. */
  82522. getForwardRay(length?: number): Ray;
  82523. /**
  82524. * @hidden
  82525. * Updates the camera based on device's frame data
  82526. */
  82527. _checkInputs(): void;
  82528. /**
  82529. * Updates the poseControlled values based on the input device pose.
  82530. * @param poseData Pose coming from the device
  82531. */
  82532. updateFromDevice(poseData: DevicePose): void;
  82533. private _htmlElementAttached;
  82534. private _detachIfAttached;
  82535. /**
  82536. * WebVR's attach control will start broadcasting frames to the device.
  82537. * Note that in certain browsers (chrome for example) this function must be called
  82538. * within a user-interaction callback. Example:
  82539. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82540. *
  82541. * @param element html element to attach the vrDevice to
  82542. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82543. */
  82544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82545. /**
  82546. * Detaches the camera from the html element and disables VR
  82547. *
  82548. * @param element html element to detach from
  82549. */
  82550. detachControl(element: HTMLElement): void;
  82551. /**
  82552. * @returns the name of this class
  82553. */
  82554. getClassName(): string;
  82555. /**
  82556. * Calls resetPose on the vrDisplay
  82557. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82558. */
  82559. resetToCurrentRotation(): void;
  82560. /**
  82561. * @hidden
  82562. * Updates the rig cameras (left and right eye)
  82563. */
  82564. _updateRigCameras(): void;
  82565. private _workingVector;
  82566. private _oneVector;
  82567. private _workingMatrix;
  82568. private updateCacheCalled;
  82569. private _correctPositionIfNotTrackPosition;
  82570. /**
  82571. * @hidden
  82572. * Updates the cached values of the camera
  82573. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82574. */
  82575. _updateCache(ignoreParentClass?: boolean): void;
  82576. /**
  82577. * @hidden
  82578. * Get current device position in babylon world
  82579. */
  82580. _computeDevicePosition(): void;
  82581. /**
  82582. * Updates the current device position and rotation in the babylon world
  82583. */
  82584. update(): void;
  82585. /**
  82586. * @hidden
  82587. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82588. * @returns an identity matrix
  82589. */
  82590. _getViewMatrix(): Matrix;
  82591. private _tmpMatrix;
  82592. /**
  82593. * This function is called by the two RIG cameras.
  82594. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82595. * @hidden
  82596. */
  82597. _getWebVRViewMatrix(): Matrix;
  82598. /** @hidden */
  82599. _getWebVRProjectionMatrix(): Matrix;
  82600. private _onGamepadConnectedObserver;
  82601. private _onGamepadDisconnectedObserver;
  82602. private _updateCacheWhenTrackingDisabledObserver;
  82603. /**
  82604. * Initializes the controllers and their meshes
  82605. */
  82606. initControllers(): void;
  82607. }
  82608. }
  82609. declare module BABYLON {
  82610. /**
  82611. * Size options for a post process
  82612. */
  82613. export type PostProcessOptions = {
  82614. width: number;
  82615. height: number;
  82616. };
  82617. /**
  82618. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82619. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82620. */
  82621. export class PostProcess {
  82622. /** Name of the PostProcess. */
  82623. name: string;
  82624. /**
  82625. * Gets or sets the unique id of the post process
  82626. */
  82627. uniqueId: number;
  82628. /**
  82629. * Width of the texture to apply the post process on
  82630. */
  82631. width: number;
  82632. /**
  82633. * Height of the texture to apply the post process on
  82634. */
  82635. height: number;
  82636. /**
  82637. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82638. * @hidden
  82639. */
  82640. _outputTexture: Nullable<InternalTexture>;
  82641. /**
  82642. * Sampling mode used by the shader
  82643. * See https://doc.babylonjs.com/classes/3.1/texture
  82644. */
  82645. renderTargetSamplingMode: number;
  82646. /**
  82647. * Clear color to use when screen clearing
  82648. */
  82649. clearColor: Color4;
  82650. /**
  82651. * If the buffer needs to be cleared before applying the post process. (default: true)
  82652. * Should be set to false if shader will overwrite all previous pixels.
  82653. */
  82654. autoClear: boolean;
  82655. /**
  82656. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82657. */
  82658. alphaMode: number;
  82659. /**
  82660. * Sets the setAlphaBlendConstants of the babylon engine
  82661. */
  82662. alphaConstants: Color4;
  82663. /**
  82664. * Animations to be used for the post processing
  82665. */
  82666. animations: Animation[];
  82667. /**
  82668. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82669. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82670. */
  82671. enablePixelPerfectMode: boolean;
  82672. /**
  82673. * Force the postprocess to be applied without taking in account viewport
  82674. */
  82675. forceFullscreenViewport: boolean;
  82676. /**
  82677. * List of inspectable custom properties (used by the Inspector)
  82678. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82679. */
  82680. inspectableCustomProperties: IInspectable[];
  82681. /**
  82682. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82683. *
  82684. * | Value | Type | Description |
  82685. * | ----- | ----------------------------------- | ----------- |
  82686. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82687. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82688. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82689. *
  82690. */
  82691. scaleMode: number;
  82692. /**
  82693. * Force textures to be a power of two (default: false)
  82694. */
  82695. alwaysForcePOT: boolean;
  82696. private _samples;
  82697. /**
  82698. * Number of sample textures (default: 1)
  82699. */
  82700. samples: number;
  82701. /**
  82702. * Modify the scale of the post process to be the same as the viewport (default: false)
  82703. */
  82704. adaptScaleToCurrentViewport: boolean;
  82705. private _camera;
  82706. private _scene;
  82707. private _engine;
  82708. private _options;
  82709. private _reusable;
  82710. private _textureType;
  82711. /**
  82712. * Smart array of input and output textures for the post process.
  82713. * @hidden
  82714. */
  82715. _textures: SmartArray<InternalTexture>;
  82716. /**
  82717. * The index in _textures that corresponds to the output texture.
  82718. * @hidden
  82719. */
  82720. _currentRenderTextureInd: number;
  82721. private _effect;
  82722. private _samplers;
  82723. private _fragmentUrl;
  82724. private _vertexUrl;
  82725. private _parameters;
  82726. private _scaleRatio;
  82727. protected _indexParameters: any;
  82728. private _shareOutputWithPostProcess;
  82729. private _texelSize;
  82730. private _forcedOutputTexture;
  82731. /**
  82732. * Returns the fragment url or shader name used in the post process.
  82733. * @returns the fragment url or name in the shader store.
  82734. */
  82735. getEffectName(): string;
  82736. /**
  82737. * An event triggered when the postprocess is activated.
  82738. */
  82739. onActivateObservable: Observable<Camera>;
  82740. private _onActivateObserver;
  82741. /**
  82742. * A function that is added to the onActivateObservable
  82743. */
  82744. onActivate: Nullable<(camera: Camera) => void>;
  82745. /**
  82746. * An event triggered when the postprocess changes its size.
  82747. */
  82748. onSizeChangedObservable: Observable<PostProcess>;
  82749. private _onSizeChangedObserver;
  82750. /**
  82751. * A function that is added to the onSizeChangedObservable
  82752. */
  82753. onSizeChanged: (postProcess: PostProcess) => void;
  82754. /**
  82755. * An event triggered when the postprocess applies its effect.
  82756. */
  82757. onApplyObservable: Observable<Effect>;
  82758. private _onApplyObserver;
  82759. /**
  82760. * A function that is added to the onApplyObservable
  82761. */
  82762. onApply: (effect: Effect) => void;
  82763. /**
  82764. * An event triggered before rendering the postprocess
  82765. */
  82766. onBeforeRenderObservable: Observable<Effect>;
  82767. private _onBeforeRenderObserver;
  82768. /**
  82769. * A function that is added to the onBeforeRenderObservable
  82770. */
  82771. onBeforeRender: (effect: Effect) => void;
  82772. /**
  82773. * An event triggered after rendering the postprocess
  82774. */
  82775. onAfterRenderObservable: Observable<Effect>;
  82776. private _onAfterRenderObserver;
  82777. /**
  82778. * A function that is added to the onAfterRenderObservable
  82779. */
  82780. onAfterRender: (efect: Effect) => void;
  82781. /**
  82782. * 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
  82783. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82784. */
  82785. inputTexture: InternalTexture;
  82786. /**
  82787. * Gets the camera which post process is applied to.
  82788. * @returns The camera the post process is applied to.
  82789. */
  82790. getCamera(): Camera;
  82791. /**
  82792. * Gets the texel size of the postprocess.
  82793. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82794. */
  82795. readonly texelSize: Vector2;
  82796. /**
  82797. * Creates a new instance PostProcess
  82798. * @param name The name of the PostProcess.
  82799. * @param fragmentUrl The url of the fragment shader to be used.
  82800. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82801. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82802. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82803. * @param camera The camera to apply the render pass to.
  82804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82805. * @param engine The engine which the post process will be applied. (default: current engine)
  82806. * @param reusable If the post process can be reused on the same frame. (default: false)
  82807. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82808. * @param textureType Type of textures used when performing the post process. (default: 0)
  82809. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82810. * @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
  82811. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82812. */
  82813. constructor(
  82814. /** Name of the PostProcess. */
  82815. 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);
  82816. /**
  82817. * Gets a string idenfifying the name of the class
  82818. * @returns "PostProcess" string
  82819. */
  82820. getClassName(): string;
  82821. /**
  82822. * Gets the engine which this post process belongs to.
  82823. * @returns The engine the post process was enabled with.
  82824. */
  82825. getEngine(): Engine;
  82826. /**
  82827. * The effect that is created when initializing the post process.
  82828. * @returns The created effect corresponding the the postprocess.
  82829. */
  82830. getEffect(): Effect;
  82831. /**
  82832. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82833. * @param postProcess The post process to share the output with.
  82834. * @returns This post process.
  82835. */
  82836. shareOutputWith(postProcess: PostProcess): PostProcess;
  82837. /**
  82838. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82839. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82840. */
  82841. useOwnOutput(): void;
  82842. /**
  82843. * Updates the effect with the current post process compile time values and recompiles the shader.
  82844. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82845. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82846. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82847. * @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
  82848. * @param onCompiled Called when the shader has been compiled.
  82849. * @param onError Called if there is an error when compiling a shader.
  82850. */
  82851. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82852. /**
  82853. * The post process is reusable if it can be used multiple times within one frame.
  82854. * @returns If the post process is reusable
  82855. */
  82856. isReusable(): boolean;
  82857. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82858. markTextureDirty(): void;
  82859. /**
  82860. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82861. * 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.
  82862. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82863. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82864. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82865. * @returns The target texture that was bound to be written to.
  82866. */
  82867. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82868. /**
  82869. * If the post process is supported.
  82870. */
  82871. readonly isSupported: boolean;
  82872. /**
  82873. * The aspect ratio of the output texture.
  82874. */
  82875. readonly aspectRatio: number;
  82876. /**
  82877. * Get a value indicating if the post-process is ready to be used
  82878. * @returns true if the post-process is ready (shader is compiled)
  82879. */
  82880. isReady(): boolean;
  82881. /**
  82882. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82883. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82884. */
  82885. apply(): Nullable<Effect>;
  82886. private _disposeTextures;
  82887. /**
  82888. * Disposes the post process.
  82889. * @param camera The camera to dispose the post process on.
  82890. */
  82891. dispose(camera?: Camera): void;
  82892. }
  82893. }
  82894. declare module BABYLON {
  82895. /** @hidden */
  82896. export var kernelBlurVaryingDeclaration: {
  82897. name: string;
  82898. shader: string;
  82899. };
  82900. }
  82901. declare module BABYLON {
  82902. /** @hidden */
  82903. export var kernelBlurFragment: {
  82904. name: string;
  82905. shader: string;
  82906. };
  82907. }
  82908. declare module BABYLON {
  82909. /** @hidden */
  82910. export var kernelBlurFragment2: {
  82911. name: string;
  82912. shader: string;
  82913. };
  82914. }
  82915. declare module BABYLON {
  82916. /** @hidden */
  82917. export var kernelBlurPixelShader: {
  82918. name: string;
  82919. shader: string;
  82920. };
  82921. }
  82922. declare module BABYLON {
  82923. /** @hidden */
  82924. export var kernelBlurVertex: {
  82925. name: string;
  82926. shader: string;
  82927. };
  82928. }
  82929. declare module BABYLON {
  82930. /** @hidden */
  82931. export var kernelBlurVertexShader: {
  82932. name: string;
  82933. shader: string;
  82934. };
  82935. }
  82936. declare module BABYLON {
  82937. /**
  82938. * The Blur Post Process which blurs an image based on a kernel and direction.
  82939. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82940. */
  82941. export class BlurPostProcess extends PostProcess {
  82942. /** The direction in which to blur the image. */
  82943. direction: Vector2;
  82944. private blockCompilation;
  82945. protected _kernel: number;
  82946. protected _idealKernel: number;
  82947. protected _packedFloat: boolean;
  82948. private _staticDefines;
  82949. /**
  82950. * Sets the length in pixels of the blur sample region
  82951. */
  82952. /**
  82953. * Gets the length in pixels of the blur sample region
  82954. */
  82955. kernel: number;
  82956. /**
  82957. * Sets wether or not the blur needs to unpack/repack floats
  82958. */
  82959. /**
  82960. * Gets wether or not the blur is unpacking/repacking floats
  82961. */
  82962. packedFloat: boolean;
  82963. /**
  82964. * Creates a new instance BlurPostProcess
  82965. * @param name The name of the effect.
  82966. * @param direction The direction in which to blur the image.
  82967. * @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.
  82968. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82969. * @param camera The camera to apply the render pass to.
  82970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82971. * @param engine The engine which the post process will be applied. (default: current engine)
  82972. * @param reusable If the post process can be reused on the same frame. (default: false)
  82973. * @param textureType Type of textures used when performing the post process. (default: 0)
  82974. * @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)
  82975. */
  82976. constructor(name: string,
  82977. /** The direction in which to blur the image. */
  82978. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82979. /**
  82980. * Updates the effect with the current post process compile time values and recompiles the shader.
  82981. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82982. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82983. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82984. * @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
  82985. * @param onCompiled Called when the shader has been compiled.
  82986. * @param onError Called if there is an error when compiling a shader.
  82987. */
  82988. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82989. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82990. /**
  82991. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82992. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82993. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82994. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82995. * The gaps between physical kernels are compensated for in the weighting of the samples
  82996. * @param idealKernel Ideal blur kernel.
  82997. * @return Nearest best kernel.
  82998. */
  82999. protected _nearestBestKernel(idealKernel: number): number;
  83000. /**
  83001. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83002. * @param x The point on the Gaussian distribution to sample.
  83003. * @return the value of the Gaussian function at x.
  83004. */
  83005. protected _gaussianWeight(x: number): number;
  83006. /**
  83007. * Generates a string that can be used as a floating point number in GLSL.
  83008. * @param x Value to print.
  83009. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83010. * @return GLSL float string.
  83011. */
  83012. protected _glslFloat(x: number, decimalFigures?: number): string;
  83013. }
  83014. }
  83015. declare module BABYLON {
  83016. /**
  83017. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83018. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83019. * You can then easily use it as a reflectionTexture on a flat surface.
  83020. * In case the surface is not a plane, please consider relying on reflection probes.
  83021. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83022. */
  83023. export class MirrorTexture extends RenderTargetTexture {
  83024. private scene;
  83025. /**
  83026. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83027. * 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.
  83028. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83029. */
  83030. mirrorPlane: Plane;
  83031. /**
  83032. * Define the blur ratio used to blur the reflection if needed.
  83033. */
  83034. blurRatio: number;
  83035. /**
  83036. * Define the adaptive blur kernel used to blur the reflection if needed.
  83037. * This will autocompute the closest best match for the `blurKernel`
  83038. */
  83039. adaptiveBlurKernel: number;
  83040. /**
  83041. * Define the blur kernel used to blur the reflection if needed.
  83042. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83043. */
  83044. blurKernel: number;
  83045. /**
  83046. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83047. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83048. */
  83049. blurKernelX: number;
  83050. /**
  83051. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83052. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83053. */
  83054. blurKernelY: number;
  83055. private _autoComputeBlurKernel;
  83056. protected _onRatioRescale(): void;
  83057. private _updateGammaSpace;
  83058. private _imageProcessingConfigChangeObserver;
  83059. private _transformMatrix;
  83060. private _mirrorMatrix;
  83061. private _savedViewMatrix;
  83062. private _blurX;
  83063. private _blurY;
  83064. private _adaptiveBlurKernel;
  83065. private _blurKernelX;
  83066. private _blurKernelY;
  83067. private _blurRatio;
  83068. /**
  83069. * Instantiates a Mirror Texture.
  83070. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83071. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83072. * You can then easily use it as a reflectionTexture on a flat surface.
  83073. * In case the surface is not a plane, please consider relying on reflection probes.
  83074. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83075. * @param name
  83076. * @param size
  83077. * @param scene
  83078. * @param generateMipMaps
  83079. * @param type
  83080. * @param samplingMode
  83081. * @param generateDepthBuffer
  83082. */
  83083. constructor(name: string, size: number | {
  83084. width: number;
  83085. height: number;
  83086. } | {
  83087. ratio: number;
  83088. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83089. private _preparePostProcesses;
  83090. /**
  83091. * Clone the mirror texture.
  83092. * @returns the cloned texture
  83093. */
  83094. clone(): MirrorTexture;
  83095. /**
  83096. * Serialize the texture to a JSON representation you could use in Parse later on
  83097. * @returns the serialized JSON representation
  83098. */
  83099. serialize(): any;
  83100. /**
  83101. * Dispose the texture and release its associated resources.
  83102. */
  83103. dispose(): void;
  83104. }
  83105. }
  83106. declare module BABYLON {
  83107. /**
  83108. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83109. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83110. */
  83111. export class Texture extends BaseTexture {
  83112. /**
  83113. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83114. */
  83115. static SerializeBuffers: boolean;
  83116. /** @hidden */
  83117. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83118. /** @hidden */
  83119. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83120. /** @hidden */
  83121. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83122. /** nearest is mag = nearest and min = nearest and mip = linear */
  83123. static readonly NEAREST_SAMPLINGMODE: number;
  83124. /** nearest is mag = nearest and min = nearest and mip = linear */
  83125. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83126. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83127. static readonly BILINEAR_SAMPLINGMODE: number;
  83128. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83129. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83130. /** Trilinear is mag = linear and min = linear and mip = linear */
  83131. static readonly TRILINEAR_SAMPLINGMODE: number;
  83132. /** Trilinear is mag = linear and min = linear and mip = linear */
  83133. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83134. /** mag = nearest and min = nearest and mip = nearest */
  83135. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83136. /** mag = nearest and min = linear and mip = nearest */
  83137. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83138. /** mag = nearest and min = linear and mip = linear */
  83139. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83140. /** mag = nearest and min = linear and mip = none */
  83141. static readonly NEAREST_LINEAR: number;
  83142. /** mag = nearest and min = nearest and mip = none */
  83143. static readonly NEAREST_NEAREST: number;
  83144. /** mag = linear and min = nearest and mip = nearest */
  83145. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83146. /** mag = linear and min = nearest and mip = linear */
  83147. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83148. /** mag = linear and min = linear and mip = none */
  83149. static readonly LINEAR_LINEAR: number;
  83150. /** mag = linear and min = nearest and mip = none */
  83151. static readonly LINEAR_NEAREST: number;
  83152. /** Explicit coordinates mode */
  83153. static readonly EXPLICIT_MODE: number;
  83154. /** Spherical coordinates mode */
  83155. static readonly SPHERICAL_MODE: number;
  83156. /** Planar coordinates mode */
  83157. static readonly PLANAR_MODE: number;
  83158. /** Cubic coordinates mode */
  83159. static readonly CUBIC_MODE: number;
  83160. /** Projection coordinates mode */
  83161. static readonly PROJECTION_MODE: number;
  83162. /** Inverse Cubic coordinates mode */
  83163. static readonly SKYBOX_MODE: number;
  83164. /** Inverse Cubic coordinates mode */
  83165. static readonly INVCUBIC_MODE: number;
  83166. /** Equirectangular coordinates mode */
  83167. static readonly EQUIRECTANGULAR_MODE: number;
  83168. /** Equirectangular Fixed coordinates mode */
  83169. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83170. /** Equirectangular Fixed Mirrored coordinates mode */
  83171. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83172. /** Texture is not repeating outside of 0..1 UVs */
  83173. static readonly CLAMP_ADDRESSMODE: number;
  83174. /** Texture is repeating outside of 0..1 UVs */
  83175. static readonly WRAP_ADDRESSMODE: number;
  83176. /** Texture is repeating and mirrored */
  83177. static readonly MIRROR_ADDRESSMODE: number;
  83178. /**
  83179. * 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
  83180. */
  83181. static UseSerializedUrlIfAny: boolean;
  83182. /**
  83183. * Define the url of the texture.
  83184. */
  83185. url: Nullable<string>;
  83186. /**
  83187. * Define an offset on the texture to offset the u coordinates of the UVs
  83188. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83189. */
  83190. uOffset: number;
  83191. /**
  83192. * Define an offset on the texture to offset the v coordinates of the UVs
  83193. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83194. */
  83195. vOffset: number;
  83196. /**
  83197. * Define an offset on the texture to scale the u coordinates of the UVs
  83198. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83199. */
  83200. uScale: number;
  83201. /**
  83202. * Define an offset on the texture to scale the v coordinates of the UVs
  83203. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83204. */
  83205. vScale: number;
  83206. /**
  83207. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83208. * @see http://doc.babylonjs.com/how_to/more_materials
  83209. */
  83210. uAng: number;
  83211. /**
  83212. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83213. * @see http://doc.babylonjs.com/how_to/more_materials
  83214. */
  83215. vAng: number;
  83216. /**
  83217. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83218. * @see http://doc.babylonjs.com/how_to/more_materials
  83219. */
  83220. wAng: number;
  83221. /**
  83222. * Defines the center of rotation (U)
  83223. */
  83224. uRotationCenter: number;
  83225. /**
  83226. * Defines the center of rotation (V)
  83227. */
  83228. vRotationCenter: number;
  83229. /**
  83230. * Defines the center of rotation (W)
  83231. */
  83232. wRotationCenter: number;
  83233. /**
  83234. * Are mip maps generated for this texture or not.
  83235. */
  83236. readonly noMipmap: boolean;
  83237. /**
  83238. * List of inspectable custom properties (used by the Inspector)
  83239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83240. */
  83241. inspectableCustomProperties: Nullable<IInspectable[]>;
  83242. private _noMipmap;
  83243. /** @hidden */
  83244. _invertY: boolean;
  83245. private _rowGenerationMatrix;
  83246. private _cachedTextureMatrix;
  83247. private _projectionModeMatrix;
  83248. private _t0;
  83249. private _t1;
  83250. private _t2;
  83251. private _cachedUOffset;
  83252. private _cachedVOffset;
  83253. private _cachedUScale;
  83254. private _cachedVScale;
  83255. private _cachedUAng;
  83256. private _cachedVAng;
  83257. private _cachedWAng;
  83258. private _cachedProjectionMatrixId;
  83259. private _cachedCoordinatesMode;
  83260. /** @hidden */
  83261. protected _initialSamplingMode: number;
  83262. /** @hidden */
  83263. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83264. private _deleteBuffer;
  83265. protected _format: Nullable<number>;
  83266. private _delayedOnLoad;
  83267. private _delayedOnError;
  83268. private _mimeType?;
  83269. /**
  83270. * Observable triggered once the texture has been loaded.
  83271. */
  83272. onLoadObservable: Observable<Texture>;
  83273. protected _isBlocking: boolean;
  83274. /**
  83275. * Is the texture preventing material to render while loading.
  83276. * If false, a default texture will be used instead of the loading one during the preparation step.
  83277. */
  83278. isBlocking: boolean;
  83279. /**
  83280. * Get the current sampling mode associated with the texture.
  83281. */
  83282. readonly samplingMode: number;
  83283. /**
  83284. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83285. */
  83286. readonly invertY: boolean;
  83287. /**
  83288. * Instantiates a new texture.
  83289. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83290. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83291. * @param url defines the url of the picture to load as a texture
  83292. * @param scene defines the scene or engine the texture will belong to
  83293. * @param noMipmap defines if the texture will require mip maps or not
  83294. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83295. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83296. * @param onLoad defines a callback triggered when the texture has been loaded
  83297. * @param onError defines a callback triggered when an error occurred during the loading session
  83298. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83299. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83300. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83301. * @param mimeType defines an optional mime type information
  83302. */
  83303. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83304. /**
  83305. * Update the url (and optional buffer) of this texture if url was null during construction.
  83306. * @param url the url of the texture
  83307. * @param buffer the buffer of the texture (defaults to null)
  83308. * @param onLoad callback called when the texture is loaded (defaults to null)
  83309. */
  83310. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83311. /**
  83312. * Finish the loading sequence of a texture flagged as delayed load.
  83313. * @hidden
  83314. */
  83315. delayLoad(): void;
  83316. private _prepareRowForTextureGeneration;
  83317. /**
  83318. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83319. * @returns the transform matrix of the texture.
  83320. */
  83321. getTextureMatrix(): Matrix;
  83322. /**
  83323. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83324. * @returns The reflection texture transform
  83325. */
  83326. getReflectionTextureMatrix(): Matrix;
  83327. /**
  83328. * Clones the texture.
  83329. * @returns the cloned texture
  83330. */
  83331. clone(): Texture;
  83332. /**
  83333. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83334. * @returns The JSON representation of the texture
  83335. */
  83336. serialize(): any;
  83337. /**
  83338. * Get the current class name of the texture useful for serialization or dynamic coding.
  83339. * @returns "Texture"
  83340. */
  83341. getClassName(): string;
  83342. /**
  83343. * Dispose the texture and release its associated resources.
  83344. */
  83345. dispose(): void;
  83346. /**
  83347. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83348. * @param parsedTexture Define the JSON representation of the texture
  83349. * @param scene Define the scene the parsed texture should be instantiated in
  83350. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83351. * @returns The parsed texture if successful
  83352. */
  83353. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83354. /**
  83355. * Creates a texture from its base 64 representation.
  83356. * @param data Define the base64 payload without the data: prefix
  83357. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83358. * @param scene Define the scene the texture should belong to
  83359. * @param noMipmap Forces the texture to not create mip map information if true
  83360. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83361. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83362. * @param onLoad define a callback triggered when the texture has been loaded
  83363. * @param onError define a callback triggered when an error occurred during the loading session
  83364. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83365. * @returns the created texture
  83366. */
  83367. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83368. /**
  83369. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83370. * @param data Define the base64 payload without the data: prefix
  83371. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83372. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83373. * @param scene Define the scene the texture should belong to
  83374. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83375. * @param noMipmap Forces the texture to not create mip map information if true
  83376. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83377. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83378. * @param onLoad define a callback triggered when the texture has been loaded
  83379. * @param onError define a callback triggered when an error occurred during the loading session
  83380. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83381. * @returns the created texture
  83382. */
  83383. 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;
  83384. }
  83385. }
  83386. declare module BABYLON {
  83387. /**
  83388. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83389. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83390. */
  83391. export class PostProcessManager {
  83392. private _scene;
  83393. private _indexBuffer;
  83394. private _vertexBuffers;
  83395. /**
  83396. * Creates a new instance PostProcess
  83397. * @param scene The scene that the post process is associated with.
  83398. */
  83399. constructor(scene: Scene);
  83400. private _prepareBuffers;
  83401. private _buildIndexBuffer;
  83402. /**
  83403. * Rebuilds the vertex buffers of the manager.
  83404. * @hidden
  83405. */
  83406. _rebuild(): void;
  83407. /**
  83408. * Prepares a frame to be run through a post process.
  83409. * @param sourceTexture The input texture to the post procesess. (default: null)
  83410. * @param postProcesses An array of post processes to be run. (default: null)
  83411. * @returns True if the post processes were able to be run.
  83412. * @hidden
  83413. */
  83414. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83415. /**
  83416. * Manually render a set of post processes to a texture.
  83417. * @param postProcesses An array of post processes to be run.
  83418. * @param targetTexture The target texture to render to.
  83419. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83420. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83421. * @param lodLevel defines which lod of the texture to render to
  83422. */
  83423. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83424. /**
  83425. * Finalize the result of the output of the postprocesses.
  83426. * @param doNotPresent If true the result will not be displayed to the screen.
  83427. * @param targetTexture The target texture to render to.
  83428. * @param faceIndex The index of the face to bind the target texture to.
  83429. * @param postProcesses The array of post processes to render.
  83430. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83431. * @hidden
  83432. */
  83433. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83434. /**
  83435. * Disposes of the post process manager.
  83436. */
  83437. dispose(): void;
  83438. }
  83439. }
  83440. declare module BABYLON {
  83441. /** Interface used by value gradients (color, factor, ...) */
  83442. export interface IValueGradient {
  83443. /**
  83444. * Gets or sets the gradient value (between 0 and 1)
  83445. */
  83446. gradient: number;
  83447. }
  83448. /** Class used to store color4 gradient */
  83449. export class ColorGradient implements IValueGradient {
  83450. /**
  83451. * Gets or sets the gradient value (between 0 and 1)
  83452. */
  83453. gradient: number;
  83454. /**
  83455. * Gets or sets first associated color
  83456. */
  83457. color1: Color4;
  83458. /**
  83459. * Gets or sets second associated color
  83460. */
  83461. color2?: Color4;
  83462. /**
  83463. * Will get a color picked randomly between color1 and color2.
  83464. * If color2 is undefined then color1 will be used
  83465. * @param result defines the target Color4 to store the result in
  83466. */
  83467. getColorToRef(result: Color4): void;
  83468. }
  83469. /** Class used to store color 3 gradient */
  83470. export class Color3Gradient implements IValueGradient {
  83471. /**
  83472. * Gets or sets the gradient value (between 0 and 1)
  83473. */
  83474. gradient: number;
  83475. /**
  83476. * Gets or sets the associated color
  83477. */
  83478. color: Color3;
  83479. }
  83480. /** Class used to store factor gradient */
  83481. export class FactorGradient implements IValueGradient {
  83482. /**
  83483. * Gets or sets the gradient value (between 0 and 1)
  83484. */
  83485. gradient: number;
  83486. /**
  83487. * Gets or sets first associated factor
  83488. */
  83489. factor1: number;
  83490. /**
  83491. * Gets or sets second associated factor
  83492. */
  83493. factor2?: number;
  83494. /**
  83495. * Will get a number picked randomly between factor1 and factor2.
  83496. * If factor2 is undefined then factor1 will be used
  83497. * @returns the picked number
  83498. */
  83499. getFactor(): number;
  83500. }
  83501. /**
  83502. * Helper used to simplify some generic gradient tasks
  83503. */
  83504. export class GradientHelper {
  83505. /**
  83506. * Gets the current gradient from an array of IValueGradient
  83507. * @param ratio defines the current ratio to get
  83508. * @param gradients defines the array of IValueGradient
  83509. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83510. */
  83511. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83512. }
  83513. }
  83514. declare module BABYLON {
  83515. interface ThinEngine {
  83516. /**
  83517. * Creates a dynamic texture
  83518. * @param width defines the width of the texture
  83519. * @param height defines the height of the texture
  83520. * @param generateMipMaps defines if the engine should generate the mip levels
  83521. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83522. * @returns the dynamic texture inside an InternalTexture
  83523. */
  83524. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83525. /**
  83526. * Update the content of a dynamic texture
  83527. * @param texture defines the texture to update
  83528. * @param canvas defines the canvas containing the source
  83529. * @param invertY defines if data must be stored with Y axis inverted
  83530. * @param premulAlpha defines if alpha is stored as premultiplied
  83531. * @param format defines the format of the data
  83532. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83533. */
  83534. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83535. }
  83536. }
  83537. declare module BABYLON {
  83538. /**
  83539. * Helper class used to generate a canvas to manipulate images
  83540. */
  83541. export class CanvasGenerator {
  83542. /**
  83543. * Create a new canvas (or offscreen canvas depending on the context)
  83544. * @param width defines the expected width
  83545. * @param height defines the expected height
  83546. * @return a new canvas or offscreen canvas
  83547. */
  83548. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83549. }
  83550. }
  83551. declare module BABYLON {
  83552. /**
  83553. * A class extending Texture allowing drawing on a texture
  83554. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83555. */
  83556. export class DynamicTexture extends Texture {
  83557. private _generateMipMaps;
  83558. private _canvas;
  83559. private _context;
  83560. private _engine;
  83561. /**
  83562. * Creates a DynamicTexture
  83563. * @param name defines the name of the texture
  83564. * @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
  83565. * @param scene defines the scene where you want the texture
  83566. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83567. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83568. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83569. */
  83570. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83571. /**
  83572. * Get the current class name of the texture useful for serialization or dynamic coding.
  83573. * @returns "DynamicTexture"
  83574. */
  83575. getClassName(): string;
  83576. /**
  83577. * Gets the current state of canRescale
  83578. */
  83579. readonly canRescale: boolean;
  83580. private _recreate;
  83581. /**
  83582. * Scales the texture
  83583. * @param ratio the scale factor to apply to both width and height
  83584. */
  83585. scale(ratio: number): void;
  83586. /**
  83587. * Resizes the texture
  83588. * @param width the new width
  83589. * @param height the new height
  83590. */
  83591. scaleTo(width: number, height: number): void;
  83592. /**
  83593. * Gets the context of the canvas used by the texture
  83594. * @returns the canvas context of the dynamic texture
  83595. */
  83596. getContext(): CanvasRenderingContext2D;
  83597. /**
  83598. * Clears the texture
  83599. */
  83600. clear(): void;
  83601. /**
  83602. * Updates the texture
  83603. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83604. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83605. */
  83606. update(invertY?: boolean, premulAlpha?: boolean): void;
  83607. /**
  83608. * Draws text onto the texture
  83609. * @param text defines the text to be drawn
  83610. * @param x defines the placement of the text from the left
  83611. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83612. * @param font defines the font to be used with font-style, font-size, font-name
  83613. * @param color defines the color used for the text
  83614. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83615. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83616. * @param update defines whether texture is immediately update (default is true)
  83617. */
  83618. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83619. /**
  83620. * Clones the texture
  83621. * @returns the clone of the texture.
  83622. */
  83623. clone(): DynamicTexture;
  83624. /**
  83625. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83626. * @returns a serialized dynamic texture object
  83627. */
  83628. serialize(): any;
  83629. /** @hidden */
  83630. _rebuild(): void;
  83631. }
  83632. }
  83633. declare module BABYLON {
  83634. interface AbstractScene {
  83635. /**
  83636. * The list of procedural textures added to the scene
  83637. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83638. */
  83639. proceduralTextures: Array<ProceduralTexture>;
  83640. }
  83641. /**
  83642. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83643. * in a given scene.
  83644. */
  83645. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83646. /**
  83647. * The component name helpfull to identify the component in the list of scene components.
  83648. */
  83649. readonly name: string;
  83650. /**
  83651. * The scene the component belongs to.
  83652. */
  83653. scene: Scene;
  83654. /**
  83655. * Creates a new instance of the component for the given scene
  83656. * @param scene Defines the scene to register the component in
  83657. */
  83658. constructor(scene: Scene);
  83659. /**
  83660. * Registers the component in a given scene
  83661. */
  83662. register(): void;
  83663. /**
  83664. * Rebuilds the elements related to this component in case of
  83665. * context lost for instance.
  83666. */
  83667. rebuild(): void;
  83668. /**
  83669. * Disposes the component and the associated ressources.
  83670. */
  83671. dispose(): void;
  83672. private _beforeClear;
  83673. }
  83674. }
  83675. declare module BABYLON {
  83676. interface ThinEngine {
  83677. /**
  83678. * Creates a new render target cube texture
  83679. * @param size defines the size of the texture
  83680. * @param options defines the options used to create the texture
  83681. * @returns a new render target cube texture stored in an InternalTexture
  83682. */
  83683. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83684. }
  83685. }
  83686. declare module BABYLON {
  83687. /** @hidden */
  83688. export var proceduralVertexShader: {
  83689. name: string;
  83690. shader: string;
  83691. };
  83692. }
  83693. declare module BABYLON {
  83694. /**
  83695. * 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.
  83696. * This is the base class of any Procedural texture and contains most of the shareable code.
  83697. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83698. */
  83699. export class ProceduralTexture extends Texture {
  83700. isCube: boolean;
  83701. /**
  83702. * Define if the texture is enabled or not (disabled texture will not render)
  83703. */
  83704. isEnabled: boolean;
  83705. /**
  83706. * Define if the texture must be cleared before rendering (default is true)
  83707. */
  83708. autoClear: boolean;
  83709. /**
  83710. * Callback called when the texture is generated
  83711. */
  83712. onGenerated: () => void;
  83713. /**
  83714. * Event raised when the texture is generated
  83715. */
  83716. onGeneratedObservable: Observable<ProceduralTexture>;
  83717. /** @hidden */
  83718. _generateMipMaps: boolean;
  83719. /** @hidden **/
  83720. _effect: Effect;
  83721. /** @hidden */
  83722. _textures: {
  83723. [key: string]: Texture;
  83724. };
  83725. private _size;
  83726. private _currentRefreshId;
  83727. private _refreshRate;
  83728. private _vertexBuffers;
  83729. private _indexBuffer;
  83730. private _uniforms;
  83731. private _samplers;
  83732. private _fragment;
  83733. private _floats;
  83734. private _ints;
  83735. private _floatsArrays;
  83736. private _colors3;
  83737. private _colors4;
  83738. private _vectors2;
  83739. private _vectors3;
  83740. private _matrices;
  83741. private _fallbackTexture;
  83742. private _fallbackTextureUsed;
  83743. private _engine;
  83744. private _cachedDefines;
  83745. private _contentUpdateId;
  83746. private _contentData;
  83747. /**
  83748. * Instantiates a new procedural texture.
  83749. * 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.
  83750. * This is the base class of any Procedural texture and contains most of the shareable code.
  83751. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83752. * @param name Define the name of the texture
  83753. * @param size Define the size of the texture to create
  83754. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83755. * @param scene Define the scene the texture belongs to
  83756. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83757. * @param generateMipMaps Define if the texture should creates mip maps or not
  83758. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83759. */
  83760. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83761. /**
  83762. * The effect that is created when initializing the post process.
  83763. * @returns The created effect corresponding the the postprocess.
  83764. */
  83765. getEffect(): Effect;
  83766. /**
  83767. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83768. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83769. */
  83770. getContent(): Nullable<ArrayBufferView>;
  83771. private _createIndexBuffer;
  83772. /** @hidden */
  83773. _rebuild(): void;
  83774. /**
  83775. * Resets the texture in order to recreate its associated resources.
  83776. * This can be called in case of context loss
  83777. */
  83778. reset(): void;
  83779. protected _getDefines(): string;
  83780. /**
  83781. * Is the texture ready to be used ? (rendered at least once)
  83782. * @returns true if ready, otherwise, false.
  83783. */
  83784. isReady(): boolean;
  83785. /**
  83786. * Resets the refresh counter of the texture and start bak from scratch.
  83787. * Could be useful to regenerate the texture if it is setup to render only once.
  83788. */
  83789. resetRefreshCounter(): void;
  83790. /**
  83791. * Set the fragment shader to use in order to render the texture.
  83792. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83793. */
  83794. setFragment(fragment: any): void;
  83795. /**
  83796. * Define the refresh rate of the texture or the rendering frequency.
  83797. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83798. */
  83799. refreshRate: number;
  83800. /** @hidden */
  83801. _shouldRender(): boolean;
  83802. /**
  83803. * Get the size the texture is rendering at.
  83804. * @returns the size (texture is always squared)
  83805. */
  83806. getRenderSize(): number;
  83807. /**
  83808. * Resize the texture to new value.
  83809. * @param size Define the new size the texture should have
  83810. * @param generateMipMaps Define whether the new texture should create mip maps
  83811. */
  83812. resize(size: number, generateMipMaps: boolean): void;
  83813. private _checkUniform;
  83814. /**
  83815. * Set a texture in the shader program used to render.
  83816. * @param name Define the name of the uniform samplers as defined in the shader
  83817. * @param texture Define the texture to bind to this sampler
  83818. * @return the texture itself allowing "fluent" like uniform updates
  83819. */
  83820. setTexture(name: string, texture: Texture): ProceduralTexture;
  83821. /**
  83822. * Set a float in the shader.
  83823. * @param name Define the name of the uniform as defined in the shader
  83824. * @param value Define the value to give to the uniform
  83825. * @return the texture itself allowing "fluent" like uniform updates
  83826. */
  83827. setFloat(name: string, value: number): ProceduralTexture;
  83828. /**
  83829. * Set a int in the shader.
  83830. * @param name Define the name of the uniform as defined in the shader
  83831. * @param value Define the value to give to the uniform
  83832. * @return the texture itself allowing "fluent" like uniform updates
  83833. */
  83834. setInt(name: string, value: number): ProceduralTexture;
  83835. /**
  83836. * Set an array of floats in the shader.
  83837. * @param name Define the name of the uniform as defined in the shader
  83838. * @param value Define the value to give to the uniform
  83839. * @return the texture itself allowing "fluent" like uniform updates
  83840. */
  83841. setFloats(name: string, value: number[]): ProceduralTexture;
  83842. /**
  83843. * Set a vec3 in the shader from a Color3.
  83844. * @param name Define the name of the uniform as defined in the shader
  83845. * @param value Define the value to give to the uniform
  83846. * @return the texture itself allowing "fluent" like uniform updates
  83847. */
  83848. setColor3(name: string, value: Color3): ProceduralTexture;
  83849. /**
  83850. * Set a vec4 in the shader from a Color4.
  83851. * @param name Define the name of the uniform as defined in the shader
  83852. * @param value Define the value to give to the uniform
  83853. * @return the texture itself allowing "fluent" like uniform updates
  83854. */
  83855. setColor4(name: string, value: Color4): ProceduralTexture;
  83856. /**
  83857. * Set a vec2 in the shader from a Vector2.
  83858. * @param name Define the name of the uniform as defined in the shader
  83859. * @param value Define the value to give to the uniform
  83860. * @return the texture itself allowing "fluent" like uniform updates
  83861. */
  83862. setVector2(name: string, value: Vector2): ProceduralTexture;
  83863. /**
  83864. * Set a vec3 in the shader from a Vector3.
  83865. * @param name Define the name of the uniform as defined in the shader
  83866. * @param value Define the value to give to the uniform
  83867. * @return the texture itself allowing "fluent" like uniform updates
  83868. */
  83869. setVector3(name: string, value: Vector3): ProceduralTexture;
  83870. /**
  83871. * Set a mat4 in the shader from a MAtrix.
  83872. * @param name Define the name of the uniform as defined in the shader
  83873. * @param value Define the value to give to the uniform
  83874. * @return the texture itself allowing "fluent" like uniform updates
  83875. */
  83876. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83877. /**
  83878. * Render the texture to its associated render target.
  83879. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83880. */
  83881. render(useCameraPostProcess?: boolean): void;
  83882. /**
  83883. * Clone the texture.
  83884. * @returns the cloned texture
  83885. */
  83886. clone(): ProceduralTexture;
  83887. /**
  83888. * Dispose the texture and release its asoociated resources.
  83889. */
  83890. dispose(): void;
  83891. }
  83892. }
  83893. declare module BABYLON {
  83894. /**
  83895. * This represents the base class for particle system in Babylon.
  83896. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  83897. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83898. * @example https://doc.babylonjs.com/babylon101/particles
  83899. */
  83900. export class BaseParticleSystem {
  83901. /**
  83902. * Source color is added to the destination color without alpha affecting the result
  83903. */
  83904. static BLENDMODE_ONEONE: number;
  83905. /**
  83906. * Blend current color and particle color using particle’s alpha
  83907. */
  83908. static BLENDMODE_STANDARD: number;
  83909. /**
  83910. * Add current color and particle color multiplied by particle’s alpha
  83911. */
  83912. static BLENDMODE_ADD: number;
  83913. /**
  83914. * Multiply current color with particle color
  83915. */
  83916. static BLENDMODE_MULTIPLY: number;
  83917. /**
  83918. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83919. */
  83920. static BLENDMODE_MULTIPLYADD: number;
  83921. /**
  83922. * List of animations used by the particle system.
  83923. */
  83924. animations: Animation[];
  83925. /**
  83926. * The id of the Particle system.
  83927. */
  83928. id: string;
  83929. /**
  83930. * The friendly name of the Particle system.
  83931. */
  83932. name: string;
  83933. /**
  83934. * The rendering group used by the Particle system to chose when to render.
  83935. */
  83936. renderingGroupId: number;
  83937. /**
  83938. * The emitter represents the Mesh or position we are attaching the particle system to.
  83939. */
  83940. emitter: Nullable<AbstractMesh | Vector3>;
  83941. /**
  83942. * The maximum number of particles to emit per frame
  83943. */
  83944. emitRate: number;
  83945. /**
  83946. * If you want to launch only a few particles at once, that can be done, as well.
  83947. */
  83948. manualEmitCount: number;
  83949. /**
  83950. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83951. */
  83952. updateSpeed: number;
  83953. /**
  83954. * The amount of time the particle system is running (depends of the overall update speed).
  83955. */
  83956. targetStopDuration: number;
  83957. /**
  83958. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83959. */
  83960. disposeOnStop: boolean;
  83961. /**
  83962. * Minimum power of emitting particles.
  83963. */
  83964. minEmitPower: number;
  83965. /**
  83966. * Maximum power of emitting particles.
  83967. */
  83968. maxEmitPower: number;
  83969. /**
  83970. * Minimum life time of emitting particles.
  83971. */
  83972. minLifeTime: number;
  83973. /**
  83974. * Maximum life time of emitting particles.
  83975. */
  83976. maxLifeTime: number;
  83977. /**
  83978. * Minimum Size of emitting particles.
  83979. */
  83980. minSize: number;
  83981. /**
  83982. * Maximum Size of emitting particles.
  83983. */
  83984. maxSize: number;
  83985. /**
  83986. * Minimum scale of emitting particles on X axis.
  83987. */
  83988. minScaleX: number;
  83989. /**
  83990. * Maximum scale of emitting particles on X axis.
  83991. */
  83992. maxScaleX: number;
  83993. /**
  83994. * Minimum scale of emitting particles on Y axis.
  83995. */
  83996. minScaleY: number;
  83997. /**
  83998. * Maximum scale of emitting particles on Y axis.
  83999. */
  84000. maxScaleY: number;
  84001. /**
  84002. * Gets or sets the minimal initial rotation in radians.
  84003. */
  84004. minInitialRotation: number;
  84005. /**
  84006. * Gets or sets the maximal initial rotation in radians.
  84007. */
  84008. maxInitialRotation: number;
  84009. /**
  84010. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84011. */
  84012. minAngularSpeed: number;
  84013. /**
  84014. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84015. */
  84016. maxAngularSpeed: number;
  84017. /**
  84018. * The texture used to render each particle. (this can be a spritesheet)
  84019. */
  84020. particleTexture: Nullable<Texture>;
  84021. /**
  84022. * The layer mask we are rendering the particles through.
  84023. */
  84024. layerMask: number;
  84025. /**
  84026. * This can help using your own shader to render the particle system.
  84027. * The according effect will be created
  84028. */
  84029. customShader: any;
  84030. /**
  84031. * By default particle system starts as soon as they are created. This prevents the
  84032. * automatic start to happen and let you decide when to start emitting particles.
  84033. */
  84034. preventAutoStart: boolean;
  84035. private _noiseTexture;
  84036. /**
  84037. * Gets or sets a texture used to add random noise to particle positions
  84038. */
  84039. noiseTexture: Nullable<ProceduralTexture>;
  84040. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84041. noiseStrength: Vector3;
  84042. /**
  84043. * Callback triggered when the particle animation is ending.
  84044. */
  84045. onAnimationEnd: Nullable<() => void>;
  84046. /**
  84047. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84048. */
  84049. blendMode: number;
  84050. /**
  84051. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84052. * to override the particles.
  84053. */
  84054. forceDepthWrite: boolean;
  84055. /** 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 */
  84056. preWarmCycles: number;
  84057. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84058. preWarmStepOffset: number;
  84059. /**
  84060. * 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)
  84061. */
  84062. spriteCellChangeSpeed: number;
  84063. /**
  84064. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84065. */
  84066. startSpriteCellID: number;
  84067. /**
  84068. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84069. */
  84070. endSpriteCellID: number;
  84071. /**
  84072. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84073. */
  84074. spriteCellWidth: number;
  84075. /**
  84076. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84077. */
  84078. spriteCellHeight: number;
  84079. /**
  84080. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84081. */
  84082. spriteRandomStartCell: boolean;
  84083. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84084. translationPivot: Vector2;
  84085. /** @hidden */
  84086. protected _isAnimationSheetEnabled: boolean;
  84087. /**
  84088. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84089. */
  84090. beginAnimationOnStart: boolean;
  84091. /**
  84092. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84093. */
  84094. beginAnimationFrom: number;
  84095. /**
  84096. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84097. */
  84098. beginAnimationTo: number;
  84099. /**
  84100. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84101. */
  84102. beginAnimationLoop: boolean;
  84103. /**
  84104. * Gets or sets a world offset applied to all particles
  84105. */
  84106. worldOffset: Vector3;
  84107. /**
  84108. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84109. */
  84110. isAnimationSheetEnabled: boolean;
  84111. /**
  84112. * Get hosting scene
  84113. * @returns the scene
  84114. */
  84115. getScene(): Scene;
  84116. /**
  84117. * You can use gravity if you want to give an orientation to your particles.
  84118. */
  84119. gravity: Vector3;
  84120. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84121. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84122. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84123. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84124. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84125. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84126. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84127. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84128. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84129. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84130. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84131. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84132. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84133. /**
  84134. * Defines the delay in milliseconds before starting the system (0 by default)
  84135. */
  84136. startDelay: number;
  84137. /**
  84138. * Gets the current list of drag gradients.
  84139. * You must use addDragGradient and removeDragGradient to udpate this list
  84140. * @returns the list of drag gradients
  84141. */
  84142. getDragGradients(): Nullable<Array<FactorGradient>>;
  84143. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84144. limitVelocityDamping: number;
  84145. /**
  84146. * Gets the current list of limit velocity gradients.
  84147. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84148. * @returns the list of limit velocity gradients
  84149. */
  84150. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84151. /**
  84152. * Gets the current list of color gradients.
  84153. * You must use addColorGradient and removeColorGradient to udpate this list
  84154. * @returns the list of color gradients
  84155. */
  84156. getColorGradients(): Nullable<Array<ColorGradient>>;
  84157. /**
  84158. * Gets the current list of size gradients.
  84159. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84160. * @returns the list of size gradients
  84161. */
  84162. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84163. /**
  84164. * Gets the current list of color remap gradients.
  84165. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84166. * @returns the list of color remap gradients
  84167. */
  84168. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84169. /**
  84170. * Gets the current list of alpha remap gradients.
  84171. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84172. * @returns the list of alpha remap gradients
  84173. */
  84174. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84175. /**
  84176. * Gets the current list of life time gradients.
  84177. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84178. * @returns the list of life time gradients
  84179. */
  84180. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84181. /**
  84182. * Gets the current list of angular speed gradients.
  84183. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84184. * @returns the list of angular speed gradients
  84185. */
  84186. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84187. /**
  84188. * Gets the current list of velocity gradients.
  84189. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84190. * @returns the list of velocity gradients
  84191. */
  84192. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84193. /**
  84194. * Gets the current list of start size gradients.
  84195. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84196. * @returns the list of start size gradients
  84197. */
  84198. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84199. /**
  84200. * Gets the current list of emit rate gradients.
  84201. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84202. * @returns the list of emit rate gradients
  84203. */
  84204. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84205. /**
  84206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84207. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84208. */
  84209. direction1: Vector3;
  84210. /**
  84211. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84212. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84213. */
  84214. direction2: Vector3;
  84215. /**
  84216. * 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.
  84217. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84218. */
  84219. minEmitBox: Vector3;
  84220. /**
  84221. * 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.
  84222. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84223. */
  84224. maxEmitBox: Vector3;
  84225. /**
  84226. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84227. */
  84228. color1: Color4;
  84229. /**
  84230. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84231. */
  84232. color2: Color4;
  84233. /**
  84234. * Color the particle will have at the end of its lifetime
  84235. */
  84236. colorDead: Color4;
  84237. /**
  84238. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84239. */
  84240. textureMask: Color4;
  84241. /**
  84242. * The particle emitter type defines the emitter used by the particle system.
  84243. * It can be for example box, sphere, or cone...
  84244. */
  84245. particleEmitterType: IParticleEmitterType;
  84246. /** @hidden */
  84247. _isSubEmitter: boolean;
  84248. /**
  84249. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84250. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84251. */
  84252. billboardMode: number;
  84253. protected _isBillboardBased: boolean;
  84254. /**
  84255. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84256. */
  84257. isBillboardBased: boolean;
  84258. /**
  84259. * The scene the particle system belongs to.
  84260. */
  84261. protected _scene: Scene;
  84262. /**
  84263. * Local cache of defines for image processing.
  84264. */
  84265. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84266. /**
  84267. * Default configuration related to image processing available in the standard Material.
  84268. */
  84269. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84270. /**
  84271. * Gets the image processing configuration used either in this material.
  84272. */
  84273. /**
  84274. * Sets the Default image processing configuration used either in the this material.
  84275. *
  84276. * If sets to null, the scene one is in use.
  84277. */
  84278. imageProcessingConfiguration: ImageProcessingConfiguration;
  84279. /**
  84280. * Attaches a new image processing configuration to the Standard Material.
  84281. * @param configuration
  84282. */
  84283. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84284. /** @hidden */
  84285. protected _reset(): void;
  84286. /** @hidden */
  84287. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84288. /**
  84289. * Instantiates a particle system.
  84290. * 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.
  84291. * @param name The name of the particle system
  84292. */
  84293. constructor(name: string);
  84294. /**
  84295. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84298. * @returns the emitter
  84299. */
  84300. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84301. /**
  84302. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84303. * @param radius The radius of the hemisphere to emit from
  84304. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84305. * @returns the emitter
  84306. */
  84307. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84308. /**
  84309. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84310. * @param radius The radius of the sphere to emit from
  84311. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84312. * @returns the emitter
  84313. */
  84314. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84315. /**
  84316. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84317. * @param radius The radius of the sphere to emit from
  84318. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84319. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84320. * @returns the emitter
  84321. */
  84322. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84323. /**
  84324. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84325. * @param radius The radius of the emission cylinder
  84326. * @param height The height of the emission cylinder
  84327. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84328. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84329. * @returns the emitter
  84330. */
  84331. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84332. /**
  84333. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84334. * @param radius The radius of the cylinder to emit from
  84335. * @param height The height of the emission cylinder
  84336. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84337. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84338. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84339. * @returns the emitter
  84340. */
  84341. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84342. /**
  84343. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84344. * @param radius The radius of the cone to emit from
  84345. * @param angle The base angle of the cone
  84346. * @returns the emitter
  84347. */
  84348. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84349. /**
  84350. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84351. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84352. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84353. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84354. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84355. * @returns the emitter
  84356. */
  84357. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84358. }
  84359. }
  84360. declare module BABYLON {
  84361. /**
  84362. * Type of sub emitter
  84363. */
  84364. export enum SubEmitterType {
  84365. /**
  84366. * Attached to the particle over it's lifetime
  84367. */
  84368. ATTACHED = 0,
  84369. /**
  84370. * Created when the particle dies
  84371. */
  84372. END = 1
  84373. }
  84374. /**
  84375. * Sub emitter class used to emit particles from an existing particle
  84376. */
  84377. export class SubEmitter {
  84378. /**
  84379. * the particle system to be used by the sub emitter
  84380. */
  84381. particleSystem: ParticleSystem;
  84382. /**
  84383. * Type of the submitter (Default: END)
  84384. */
  84385. type: SubEmitterType;
  84386. /**
  84387. * 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)
  84388. * Note: This only is supported when using an emitter of type Mesh
  84389. */
  84390. inheritDirection: boolean;
  84391. /**
  84392. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84393. */
  84394. inheritedVelocityAmount: number;
  84395. /**
  84396. * Creates a sub emitter
  84397. * @param particleSystem the particle system to be used by the sub emitter
  84398. */
  84399. constructor(
  84400. /**
  84401. * the particle system to be used by the sub emitter
  84402. */
  84403. particleSystem: ParticleSystem);
  84404. /**
  84405. * Clones the sub emitter
  84406. * @returns the cloned sub emitter
  84407. */
  84408. clone(): SubEmitter;
  84409. /**
  84410. * Serialize current object to a JSON object
  84411. * @returns the serialized object
  84412. */
  84413. serialize(): any;
  84414. /** @hidden */
  84415. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84416. /**
  84417. * Creates a new SubEmitter from a serialized JSON version
  84418. * @param serializationObject defines the JSON object to read from
  84419. * @param scene defines the hosting scene
  84420. * @param rootUrl defines the rootUrl for data loading
  84421. * @returns a new SubEmitter
  84422. */
  84423. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84424. /** Release associated resources */
  84425. dispose(): void;
  84426. }
  84427. }
  84428. declare module BABYLON {
  84429. /** @hidden */
  84430. export var clipPlaneFragmentDeclaration: {
  84431. name: string;
  84432. shader: string;
  84433. };
  84434. }
  84435. declare module BABYLON {
  84436. /** @hidden */
  84437. export var imageProcessingDeclaration: {
  84438. name: string;
  84439. shader: string;
  84440. };
  84441. }
  84442. declare module BABYLON {
  84443. /** @hidden */
  84444. export var imageProcessingFunctions: {
  84445. name: string;
  84446. shader: string;
  84447. };
  84448. }
  84449. declare module BABYLON {
  84450. /** @hidden */
  84451. export var clipPlaneFragment: {
  84452. name: string;
  84453. shader: string;
  84454. };
  84455. }
  84456. declare module BABYLON {
  84457. /** @hidden */
  84458. export var particlesPixelShader: {
  84459. name: string;
  84460. shader: string;
  84461. };
  84462. }
  84463. declare module BABYLON {
  84464. /** @hidden */
  84465. export var clipPlaneVertexDeclaration: {
  84466. name: string;
  84467. shader: string;
  84468. };
  84469. }
  84470. declare module BABYLON {
  84471. /** @hidden */
  84472. export var clipPlaneVertex: {
  84473. name: string;
  84474. shader: string;
  84475. };
  84476. }
  84477. declare module BABYLON {
  84478. /** @hidden */
  84479. export var particlesVertexShader: {
  84480. name: string;
  84481. shader: string;
  84482. };
  84483. }
  84484. declare module BABYLON {
  84485. /**
  84486. * This represents a particle system in Babylon.
  84487. * 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.
  84488. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84489. * @example https://doc.babylonjs.com/babylon101/particles
  84490. */
  84491. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84492. /**
  84493. * Billboard mode will only apply to Y axis
  84494. */
  84495. static readonly BILLBOARDMODE_Y: number;
  84496. /**
  84497. * Billboard mode will apply to all axes
  84498. */
  84499. static readonly BILLBOARDMODE_ALL: number;
  84500. /**
  84501. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84502. */
  84503. static readonly BILLBOARDMODE_STRETCHED: number;
  84504. /**
  84505. * This function can be defined to provide custom update for active particles.
  84506. * This function will be called instead of regular update (age, position, color, etc.).
  84507. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84508. */
  84509. updateFunction: (particles: Particle[]) => void;
  84510. private _emitterWorldMatrix;
  84511. /**
  84512. * This function can be defined to specify initial direction for every new particle.
  84513. * It by default use the emitterType defined function
  84514. */
  84515. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84516. /**
  84517. * This function can be defined to specify initial position for every new particle.
  84518. * It by default use the emitterType defined function
  84519. */
  84520. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84521. /**
  84522. * @hidden
  84523. */
  84524. _inheritedVelocityOffset: Vector3;
  84525. /**
  84526. * An event triggered when the system is disposed
  84527. */
  84528. onDisposeObservable: Observable<ParticleSystem>;
  84529. private _onDisposeObserver;
  84530. /**
  84531. * Sets a callback that will be triggered when the system is disposed
  84532. */
  84533. onDispose: () => void;
  84534. private _particles;
  84535. private _epsilon;
  84536. private _capacity;
  84537. private _stockParticles;
  84538. private _newPartsExcess;
  84539. private _vertexData;
  84540. private _vertexBuffer;
  84541. private _vertexBuffers;
  84542. private _spriteBuffer;
  84543. private _indexBuffer;
  84544. private _effect;
  84545. private _customEffect;
  84546. private _cachedDefines;
  84547. private _scaledColorStep;
  84548. private _colorDiff;
  84549. private _scaledDirection;
  84550. private _scaledGravity;
  84551. private _currentRenderId;
  84552. private _alive;
  84553. private _useInstancing;
  84554. private _started;
  84555. private _stopped;
  84556. private _actualFrame;
  84557. private _scaledUpdateSpeed;
  84558. private _vertexBufferSize;
  84559. /** @hidden */
  84560. _currentEmitRateGradient: Nullable<FactorGradient>;
  84561. /** @hidden */
  84562. _currentEmitRate1: number;
  84563. /** @hidden */
  84564. _currentEmitRate2: number;
  84565. /** @hidden */
  84566. _currentStartSizeGradient: Nullable<FactorGradient>;
  84567. /** @hidden */
  84568. _currentStartSize1: number;
  84569. /** @hidden */
  84570. _currentStartSize2: number;
  84571. private readonly _rawTextureWidth;
  84572. private _rampGradientsTexture;
  84573. private _useRampGradients;
  84574. /** Gets or sets a boolean indicating that ramp gradients must be used
  84575. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84576. */
  84577. useRampGradients: boolean;
  84578. /**
  84579. * 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.
  84580. * 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: [])
  84581. */
  84582. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84583. private _subEmitters;
  84584. /**
  84585. * @hidden
  84586. * If the particle systems emitter should be disposed when the particle system is disposed
  84587. */
  84588. _disposeEmitterOnDispose: boolean;
  84589. /**
  84590. * The current active Sub-systems, this property is used by the root particle system only.
  84591. */
  84592. activeSubSystems: Array<ParticleSystem>;
  84593. private _rootParticleSystem;
  84594. /**
  84595. * Gets the current list of active particles
  84596. */
  84597. readonly particles: Particle[];
  84598. /**
  84599. * Returns the string "ParticleSystem"
  84600. * @returns a string containing the class name
  84601. */
  84602. getClassName(): string;
  84603. /**
  84604. * Instantiates a particle system.
  84605. * 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.
  84606. * @param name The name of the particle system
  84607. * @param capacity The max number of particles alive at the same time
  84608. * @param scene The scene the particle system belongs to
  84609. * @param customEffect a custom effect used to change the way particles are rendered by default
  84610. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84611. * @param epsilon Offset used to render the particles
  84612. */
  84613. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84614. private _addFactorGradient;
  84615. private _removeFactorGradient;
  84616. /**
  84617. * Adds a new life time gradient
  84618. * @param gradient defines the gradient to use (between 0 and 1)
  84619. * @param factor defines the life time factor to affect to the specified gradient
  84620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84621. * @returns the current particle system
  84622. */
  84623. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84624. /**
  84625. * Remove a specific life time gradient
  84626. * @param gradient defines the gradient to remove
  84627. * @returns the current particle system
  84628. */
  84629. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84630. /**
  84631. * Adds a new size gradient
  84632. * @param gradient defines the gradient to use (between 0 and 1)
  84633. * @param factor defines the size factor to affect to the specified gradient
  84634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84635. * @returns the current particle system
  84636. */
  84637. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84638. /**
  84639. * Remove a specific size gradient
  84640. * @param gradient defines the gradient to remove
  84641. * @returns the current particle system
  84642. */
  84643. removeSizeGradient(gradient: number): IParticleSystem;
  84644. /**
  84645. * Adds a new color remap gradient
  84646. * @param gradient defines the gradient to use (between 0 and 1)
  84647. * @param min defines the color remap minimal range
  84648. * @param max defines the color remap maximal range
  84649. * @returns the current particle system
  84650. */
  84651. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84652. /**
  84653. * Remove a specific color remap gradient
  84654. * @param gradient defines the gradient to remove
  84655. * @returns the current particle system
  84656. */
  84657. removeColorRemapGradient(gradient: number): IParticleSystem;
  84658. /**
  84659. * Adds a new alpha remap gradient
  84660. * @param gradient defines the gradient to use (between 0 and 1)
  84661. * @param min defines the alpha remap minimal range
  84662. * @param max defines the alpha remap maximal range
  84663. * @returns the current particle system
  84664. */
  84665. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84666. /**
  84667. * Remove a specific alpha remap gradient
  84668. * @param gradient defines the gradient to remove
  84669. * @returns the current particle system
  84670. */
  84671. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84672. /**
  84673. * Adds a new angular speed gradient
  84674. * @param gradient defines the gradient to use (between 0 and 1)
  84675. * @param factor defines the angular speed to affect to the specified gradient
  84676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84677. * @returns the current particle system
  84678. */
  84679. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84680. /**
  84681. * Remove a specific angular speed gradient
  84682. * @param gradient defines the gradient to remove
  84683. * @returns the current particle system
  84684. */
  84685. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84686. /**
  84687. * Adds a new velocity gradient
  84688. * @param gradient defines the gradient to use (between 0 and 1)
  84689. * @param factor defines the velocity to affect to the specified gradient
  84690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84691. * @returns the current particle system
  84692. */
  84693. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84694. /**
  84695. * Remove a specific velocity gradient
  84696. * @param gradient defines the gradient to remove
  84697. * @returns the current particle system
  84698. */
  84699. removeVelocityGradient(gradient: number): IParticleSystem;
  84700. /**
  84701. * Adds a new limit velocity gradient
  84702. * @param gradient defines the gradient to use (between 0 and 1)
  84703. * @param factor defines the limit velocity value to affect to the specified gradient
  84704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84705. * @returns the current particle system
  84706. */
  84707. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84708. /**
  84709. * Remove a specific limit velocity gradient
  84710. * @param gradient defines the gradient to remove
  84711. * @returns the current particle system
  84712. */
  84713. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84714. /**
  84715. * Adds a new drag gradient
  84716. * @param gradient defines the gradient to use (between 0 and 1)
  84717. * @param factor defines the drag value to affect to the specified gradient
  84718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84719. * @returns the current particle system
  84720. */
  84721. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84722. /**
  84723. * Remove a specific drag gradient
  84724. * @param gradient defines the gradient to remove
  84725. * @returns the current particle system
  84726. */
  84727. removeDragGradient(gradient: number): IParticleSystem;
  84728. /**
  84729. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84730. * @param gradient defines the gradient to use (between 0 and 1)
  84731. * @param factor defines the emit rate value to affect to the specified gradient
  84732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84733. * @returns the current particle system
  84734. */
  84735. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84736. /**
  84737. * Remove a specific emit rate gradient
  84738. * @param gradient defines the gradient to remove
  84739. * @returns the current particle system
  84740. */
  84741. removeEmitRateGradient(gradient: number): IParticleSystem;
  84742. /**
  84743. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84744. * @param gradient defines the gradient to use (between 0 and 1)
  84745. * @param factor defines the start size value to affect to the specified gradient
  84746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84747. * @returns the current particle system
  84748. */
  84749. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84750. /**
  84751. * Remove a specific start size gradient
  84752. * @param gradient defines the gradient to remove
  84753. * @returns the current particle system
  84754. */
  84755. removeStartSizeGradient(gradient: number): IParticleSystem;
  84756. private _createRampGradientTexture;
  84757. /**
  84758. * Gets the current list of ramp gradients.
  84759. * You must use addRampGradient and removeRampGradient to udpate this list
  84760. * @returns the list of ramp gradients
  84761. */
  84762. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84763. /**
  84764. * Adds a new ramp gradient used to remap particle colors
  84765. * @param gradient defines the gradient to use (between 0 and 1)
  84766. * @param color defines the color to affect to the specified gradient
  84767. * @returns the current particle system
  84768. */
  84769. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84770. /**
  84771. * Remove a specific ramp gradient
  84772. * @param gradient defines the gradient to remove
  84773. * @returns the current particle system
  84774. */
  84775. removeRampGradient(gradient: number): ParticleSystem;
  84776. /**
  84777. * Adds a new color gradient
  84778. * @param gradient defines the gradient to use (between 0 and 1)
  84779. * @param color1 defines the color to affect to the specified gradient
  84780. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84781. * @returns this particle system
  84782. */
  84783. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84784. /**
  84785. * Remove a specific color gradient
  84786. * @param gradient defines the gradient to remove
  84787. * @returns this particle system
  84788. */
  84789. removeColorGradient(gradient: number): IParticleSystem;
  84790. private _fetchR;
  84791. protected _reset(): void;
  84792. private _resetEffect;
  84793. private _createVertexBuffers;
  84794. private _createIndexBuffer;
  84795. /**
  84796. * Gets the maximum number of particles active at the same time.
  84797. * @returns The max number of active particles.
  84798. */
  84799. getCapacity(): number;
  84800. /**
  84801. * Gets whether there are still active particles in the system.
  84802. * @returns True if it is alive, otherwise false.
  84803. */
  84804. isAlive(): boolean;
  84805. /**
  84806. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84807. * @returns True if it has been started, otherwise false.
  84808. */
  84809. isStarted(): boolean;
  84810. private _prepareSubEmitterInternalArray;
  84811. /**
  84812. * Starts the particle system and begins to emit
  84813. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84814. */
  84815. start(delay?: number): void;
  84816. /**
  84817. * Stops the particle system.
  84818. * @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.
  84819. */
  84820. stop(stopSubEmitters?: boolean): void;
  84821. /**
  84822. * Remove all active particles
  84823. */
  84824. reset(): void;
  84825. /**
  84826. * @hidden (for internal use only)
  84827. */
  84828. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84829. /**
  84830. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84831. * Its lifetime will start back at 0.
  84832. */
  84833. recycleParticle: (particle: Particle) => void;
  84834. private _stopSubEmitters;
  84835. private _createParticle;
  84836. private _removeFromRoot;
  84837. private _emitFromParticle;
  84838. private _update;
  84839. /** @hidden */
  84840. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84841. /** @hidden */
  84842. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84843. /** @hidden */
  84844. private _getEffect;
  84845. /**
  84846. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84847. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84848. */
  84849. animate(preWarmOnly?: boolean): void;
  84850. private _appendParticleVertices;
  84851. /**
  84852. * Rebuilds the particle system.
  84853. */
  84854. rebuild(): void;
  84855. /**
  84856. * Is this system ready to be used/rendered
  84857. * @return true if the system is ready
  84858. */
  84859. isReady(): boolean;
  84860. private _render;
  84861. /**
  84862. * Renders the particle system in its current state.
  84863. * @returns the current number of particles
  84864. */
  84865. render(): number;
  84866. /**
  84867. * Disposes the particle system and free the associated resources
  84868. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84869. */
  84870. dispose(disposeTexture?: boolean): void;
  84871. /**
  84872. * Clones the particle system.
  84873. * @param name The name of the cloned object
  84874. * @param newEmitter The new emitter to use
  84875. * @returns the cloned particle system
  84876. */
  84877. clone(name: string, newEmitter: any): ParticleSystem;
  84878. /**
  84879. * Serializes the particle system to a JSON object.
  84880. * @returns the JSON object
  84881. */
  84882. serialize(): any;
  84883. /** @hidden */
  84884. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84885. /** @hidden */
  84886. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84887. /**
  84888. * Parses a JSON object to create a particle system.
  84889. * @param parsedParticleSystem The JSON object to parse
  84890. * @param scene The scene to create the particle system in
  84891. * @param rootUrl The root url to use to load external dependencies like texture
  84892. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84893. * @returns the Parsed particle system
  84894. */
  84895. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84896. }
  84897. }
  84898. declare module BABYLON {
  84899. /**
  84900. * A particle represents one of the element emitted by a particle system.
  84901. * This is mainly define by its coordinates, direction, velocity and age.
  84902. */
  84903. export class Particle {
  84904. /**
  84905. * The particle system the particle belongs to.
  84906. */
  84907. particleSystem: ParticleSystem;
  84908. private static _Count;
  84909. /**
  84910. * Unique ID of the particle
  84911. */
  84912. id: number;
  84913. /**
  84914. * The world position of the particle in the scene.
  84915. */
  84916. position: Vector3;
  84917. /**
  84918. * The world direction of the particle in the scene.
  84919. */
  84920. direction: Vector3;
  84921. /**
  84922. * The color of the particle.
  84923. */
  84924. color: Color4;
  84925. /**
  84926. * The color change of the particle per step.
  84927. */
  84928. colorStep: Color4;
  84929. /**
  84930. * Defines how long will the life of the particle be.
  84931. */
  84932. lifeTime: number;
  84933. /**
  84934. * The current age of the particle.
  84935. */
  84936. age: number;
  84937. /**
  84938. * The current size of the particle.
  84939. */
  84940. size: number;
  84941. /**
  84942. * The current scale of the particle.
  84943. */
  84944. scale: Vector2;
  84945. /**
  84946. * The current angle of the particle.
  84947. */
  84948. angle: number;
  84949. /**
  84950. * Defines how fast is the angle changing.
  84951. */
  84952. angularSpeed: number;
  84953. /**
  84954. * Defines the cell index used by the particle to be rendered from a sprite.
  84955. */
  84956. cellIndex: number;
  84957. /**
  84958. * The information required to support color remapping
  84959. */
  84960. remapData: Vector4;
  84961. /** @hidden */
  84962. _randomCellOffset?: number;
  84963. /** @hidden */
  84964. _initialDirection: Nullable<Vector3>;
  84965. /** @hidden */
  84966. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84967. /** @hidden */
  84968. _initialStartSpriteCellID: number;
  84969. /** @hidden */
  84970. _initialEndSpriteCellID: number;
  84971. /** @hidden */
  84972. _currentColorGradient: Nullable<ColorGradient>;
  84973. /** @hidden */
  84974. _currentColor1: Color4;
  84975. /** @hidden */
  84976. _currentColor2: Color4;
  84977. /** @hidden */
  84978. _currentSizeGradient: Nullable<FactorGradient>;
  84979. /** @hidden */
  84980. _currentSize1: number;
  84981. /** @hidden */
  84982. _currentSize2: number;
  84983. /** @hidden */
  84984. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84985. /** @hidden */
  84986. _currentAngularSpeed1: number;
  84987. /** @hidden */
  84988. _currentAngularSpeed2: number;
  84989. /** @hidden */
  84990. _currentVelocityGradient: Nullable<FactorGradient>;
  84991. /** @hidden */
  84992. _currentVelocity1: number;
  84993. /** @hidden */
  84994. _currentVelocity2: number;
  84995. /** @hidden */
  84996. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84997. /** @hidden */
  84998. _currentLimitVelocity1: number;
  84999. /** @hidden */
  85000. _currentLimitVelocity2: number;
  85001. /** @hidden */
  85002. _currentDragGradient: Nullable<FactorGradient>;
  85003. /** @hidden */
  85004. _currentDrag1: number;
  85005. /** @hidden */
  85006. _currentDrag2: number;
  85007. /** @hidden */
  85008. _randomNoiseCoordinates1: Vector3;
  85009. /** @hidden */
  85010. _randomNoiseCoordinates2: Vector3;
  85011. /**
  85012. * Creates a new instance Particle
  85013. * @param particleSystem the particle system the particle belongs to
  85014. */
  85015. constructor(
  85016. /**
  85017. * The particle system the particle belongs to.
  85018. */
  85019. particleSystem: ParticleSystem);
  85020. private updateCellInfoFromSystem;
  85021. /**
  85022. * Defines how the sprite cell index is updated for the particle
  85023. */
  85024. updateCellIndex(): void;
  85025. /** @hidden */
  85026. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85027. /** @hidden */
  85028. _inheritParticleInfoToSubEmitters(): void;
  85029. /** @hidden */
  85030. _reset(): void;
  85031. /**
  85032. * Copy the properties of particle to another one.
  85033. * @param other the particle to copy the information to.
  85034. */
  85035. copyTo(other: Particle): void;
  85036. }
  85037. }
  85038. declare module BABYLON {
  85039. /**
  85040. * Particle emitter represents a volume emitting particles.
  85041. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85042. */
  85043. export interface IParticleEmitterType {
  85044. /**
  85045. * Called by the particle System when the direction is computed for the created particle.
  85046. * @param worldMatrix is the world matrix of the particle system
  85047. * @param directionToUpdate is the direction vector to update with the result
  85048. * @param particle is the particle we are computed the direction for
  85049. */
  85050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85051. /**
  85052. * Called by the particle System when the position is computed for the created particle.
  85053. * @param worldMatrix is the world matrix of the particle system
  85054. * @param positionToUpdate is the position vector to update with the result
  85055. * @param particle is the particle we are computed the position for
  85056. */
  85057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85058. /**
  85059. * Clones the current emitter and returns a copy of it
  85060. * @returns the new emitter
  85061. */
  85062. clone(): IParticleEmitterType;
  85063. /**
  85064. * Called by the GPUParticleSystem to setup the update shader
  85065. * @param effect defines the update shader
  85066. */
  85067. applyToShader(effect: Effect): void;
  85068. /**
  85069. * Returns a string to use to update the GPU particles update shader
  85070. * @returns the effect defines string
  85071. */
  85072. getEffectDefines(): string;
  85073. /**
  85074. * Returns a string representing the class name
  85075. * @returns a string containing the class name
  85076. */
  85077. getClassName(): string;
  85078. /**
  85079. * Serializes the particle system to a JSON object.
  85080. * @returns the JSON object
  85081. */
  85082. serialize(): any;
  85083. /**
  85084. * Parse properties from a JSON object
  85085. * @param serializationObject defines the JSON object
  85086. */
  85087. parse(serializationObject: any): void;
  85088. }
  85089. }
  85090. declare module BABYLON {
  85091. /**
  85092. * Particle emitter emitting particles from the inside of a box.
  85093. * It emits the particles randomly between 2 given directions.
  85094. */
  85095. export class BoxParticleEmitter implements IParticleEmitterType {
  85096. /**
  85097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85098. */
  85099. direction1: Vector3;
  85100. /**
  85101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85102. */
  85103. direction2: Vector3;
  85104. /**
  85105. * 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.
  85106. */
  85107. minEmitBox: Vector3;
  85108. /**
  85109. * 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.
  85110. */
  85111. maxEmitBox: Vector3;
  85112. /**
  85113. * Creates a new instance BoxParticleEmitter
  85114. */
  85115. constructor();
  85116. /**
  85117. * Called by the particle System when the direction is computed for the created particle.
  85118. * @param worldMatrix is the world matrix of the particle system
  85119. * @param directionToUpdate is the direction vector to update with the result
  85120. * @param particle is the particle we are computed the direction for
  85121. */
  85122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85123. /**
  85124. * Called by the particle System when the position is computed for the created particle.
  85125. * @param worldMatrix is the world matrix of the particle system
  85126. * @param positionToUpdate is the position vector to update with the result
  85127. * @param particle is the particle we are computed the position for
  85128. */
  85129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85130. /**
  85131. * Clones the current emitter and returns a copy of it
  85132. * @returns the new emitter
  85133. */
  85134. clone(): BoxParticleEmitter;
  85135. /**
  85136. * Called by the GPUParticleSystem to setup the update shader
  85137. * @param effect defines the update shader
  85138. */
  85139. applyToShader(effect: Effect): void;
  85140. /**
  85141. * Returns a string to use to update the GPU particles update shader
  85142. * @returns a string containng the defines string
  85143. */
  85144. getEffectDefines(): string;
  85145. /**
  85146. * Returns the string "BoxParticleEmitter"
  85147. * @returns a string containing the class name
  85148. */
  85149. getClassName(): string;
  85150. /**
  85151. * Serializes the particle system to a JSON object.
  85152. * @returns the JSON object
  85153. */
  85154. serialize(): any;
  85155. /**
  85156. * Parse properties from a JSON object
  85157. * @param serializationObject defines the JSON object
  85158. */
  85159. parse(serializationObject: any): void;
  85160. }
  85161. }
  85162. declare module BABYLON {
  85163. /**
  85164. * Particle emitter emitting particles from the inside of a cone.
  85165. * It emits the particles alongside the cone volume from the base to the particle.
  85166. * The emission direction might be randomized.
  85167. */
  85168. export class ConeParticleEmitter implements IParticleEmitterType {
  85169. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85170. directionRandomizer: number;
  85171. private _radius;
  85172. private _angle;
  85173. private _height;
  85174. /**
  85175. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85176. */
  85177. radiusRange: number;
  85178. /**
  85179. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85180. */
  85181. heightRange: number;
  85182. /**
  85183. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85184. */
  85185. emitFromSpawnPointOnly: boolean;
  85186. /**
  85187. * Gets or sets the radius of the emission cone
  85188. */
  85189. radius: number;
  85190. /**
  85191. * Gets or sets the angle of the emission cone
  85192. */
  85193. angle: number;
  85194. private _buildHeight;
  85195. /**
  85196. * Creates a new instance ConeParticleEmitter
  85197. * @param radius the radius of the emission cone (1 by default)
  85198. * @param angle the cone base angle (PI by default)
  85199. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85200. */
  85201. constructor(radius?: number, angle?: number,
  85202. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85203. directionRandomizer?: number);
  85204. /**
  85205. * Called by the particle System when the direction is computed for the created particle.
  85206. * @param worldMatrix is the world matrix of the particle system
  85207. * @param directionToUpdate is the direction vector to update with the result
  85208. * @param particle is the particle we are computed the direction for
  85209. */
  85210. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85211. /**
  85212. * Called by the particle System when the position is computed for the created particle.
  85213. * @param worldMatrix is the world matrix of the particle system
  85214. * @param positionToUpdate is the position vector to update with the result
  85215. * @param particle is the particle we are computed the position for
  85216. */
  85217. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85218. /**
  85219. * Clones the current emitter and returns a copy of it
  85220. * @returns the new emitter
  85221. */
  85222. clone(): ConeParticleEmitter;
  85223. /**
  85224. * Called by the GPUParticleSystem to setup the update shader
  85225. * @param effect defines the update shader
  85226. */
  85227. applyToShader(effect: Effect): void;
  85228. /**
  85229. * Returns a string to use to update the GPU particles update shader
  85230. * @returns a string containng the defines string
  85231. */
  85232. getEffectDefines(): string;
  85233. /**
  85234. * Returns the string "ConeParticleEmitter"
  85235. * @returns a string containing the class name
  85236. */
  85237. getClassName(): string;
  85238. /**
  85239. * Serializes the particle system to a JSON object.
  85240. * @returns the JSON object
  85241. */
  85242. serialize(): any;
  85243. /**
  85244. * Parse properties from a JSON object
  85245. * @param serializationObject defines the JSON object
  85246. */
  85247. parse(serializationObject: any): void;
  85248. }
  85249. }
  85250. declare module BABYLON {
  85251. /**
  85252. * Particle emitter emitting particles from the inside of a cylinder.
  85253. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85254. */
  85255. export class CylinderParticleEmitter implements IParticleEmitterType {
  85256. /**
  85257. * The radius of the emission cylinder.
  85258. */
  85259. radius: number;
  85260. /**
  85261. * The height of the emission cylinder.
  85262. */
  85263. height: number;
  85264. /**
  85265. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85266. */
  85267. radiusRange: number;
  85268. /**
  85269. * How much to randomize the particle direction [0-1].
  85270. */
  85271. directionRandomizer: number;
  85272. /**
  85273. * Creates a new instance CylinderParticleEmitter
  85274. * @param radius the radius of the emission cylinder (1 by default)
  85275. * @param height the height of the emission cylinder (1 by default)
  85276. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85277. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85278. */
  85279. constructor(
  85280. /**
  85281. * The radius of the emission cylinder.
  85282. */
  85283. radius?: number,
  85284. /**
  85285. * The height of the emission cylinder.
  85286. */
  85287. height?: number,
  85288. /**
  85289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85290. */
  85291. radiusRange?: number,
  85292. /**
  85293. * How much to randomize the particle direction [0-1].
  85294. */
  85295. directionRandomizer?: number);
  85296. /**
  85297. * Called by the particle System when the direction is computed for the created particle.
  85298. * @param worldMatrix is the world matrix of the particle system
  85299. * @param directionToUpdate is the direction vector to update with the result
  85300. * @param particle is the particle we are computed the direction for
  85301. */
  85302. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85303. /**
  85304. * Called by the particle System when the position is computed for the created particle.
  85305. * @param worldMatrix is the world matrix of the particle system
  85306. * @param positionToUpdate is the position vector to update with the result
  85307. * @param particle is the particle we are computed the position for
  85308. */
  85309. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85310. /**
  85311. * Clones the current emitter and returns a copy of it
  85312. * @returns the new emitter
  85313. */
  85314. clone(): CylinderParticleEmitter;
  85315. /**
  85316. * Called by the GPUParticleSystem to setup the update shader
  85317. * @param effect defines the update shader
  85318. */
  85319. applyToShader(effect: Effect): void;
  85320. /**
  85321. * Returns a string to use to update the GPU particles update shader
  85322. * @returns a string containng the defines string
  85323. */
  85324. getEffectDefines(): string;
  85325. /**
  85326. * Returns the string "CylinderParticleEmitter"
  85327. * @returns a string containing the class name
  85328. */
  85329. getClassName(): string;
  85330. /**
  85331. * Serializes the particle system to a JSON object.
  85332. * @returns the JSON object
  85333. */
  85334. serialize(): any;
  85335. /**
  85336. * Parse properties from a JSON object
  85337. * @param serializationObject defines the JSON object
  85338. */
  85339. parse(serializationObject: any): void;
  85340. }
  85341. /**
  85342. * Particle emitter emitting particles from the inside of a cylinder.
  85343. * It emits the particles randomly between two vectors.
  85344. */
  85345. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85346. /**
  85347. * The min limit of the emission direction.
  85348. */
  85349. direction1: Vector3;
  85350. /**
  85351. * The max limit of the emission direction.
  85352. */
  85353. direction2: Vector3;
  85354. /**
  85355. * Creates a new instance CylinderDirectedParticleEmitter
  85356. * @param radius the radius of the emission cylinder (1 by default)
  85357. * @param height the height of the emission cylinder (1 by default)
  85358. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85359. * @param direction1 the min limit of the emission direction (up vector by default)
  85360. * @param direction2 the max limit of the emission direction (up vector by default)
  85361. */
  85362. constructor(radius?: number, height?: number, radiusRange?: number,
  85363. /**
  85364. * The min limit of the emission direction.
  85365. */
  85366. direction1?: Vector3,
  85367. /**
  85368. * The max limit of the emission direction.
  85369. */
  85370. direction2?: Vector3);
  85371. /**
  85372. * Called by the particle System when the direction is computed for the created particle.
  85373. * @param worldMatrix is the world matrix of the particle system
  85374. * @param directionToUpdate is the direction vector to update with the result
  85375. * @param particle is the particle we are computed the direction for
  85376. */
  85377. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85378. /**
  85379. * Clones the current emitter and returns a copy of it
  85380. * @returns the new emitter
  85381. */
  85382. clone(): CylinderDirectedParticleEmitter;
  85383. /**
  85384. * Called by the GPUParticleSystem to setup the update shader
  85385. * @param effect defines the update shader
  85386. */
  85387. applyToShader(effect: Effect): void;
  85388. /**
  85389. * Returns a string to use to update the GPU particles update shader
  85390. * @returns a string containng the defines string
  85391. */
  85392. getEffectDefines(): string;
  85393. /**
  85394. * Returns the string "CylinderDirectedParticleEmitter"
  85395. * @returns a string containing the class name
  85396. */
  85397. getClassName(): string;
  85398. /**
  85399. * Serializes the particle system to a JSON object.
  85400. * @returns the JSON object
  85401. */
  85402. serialize(): any;
  85403. /**
  85404. * Parse properties from a JSON object
  85405. * @param serializationObject defines the JSON object
  85406. */
  85407. parse(serializationObject: any): void;
  85408. }
  85409. }
  85410. declare module BABYLON {
  85411. /**
  85412. * Particle emitter emitting particles from the inside of a hemisphere.
  85413. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85414. */
  85415. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85416. /**
  85417. * The radius of the emission hemisphere.
  85418. */
  85419. radius: number;
  85420. /**
  85421. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85422. */
  85423. radiusRange: number;
  85424. /**
  85425. * How much to randomize the particle direction [0-1].
  85426. */
  85427. directionRandomizer: number;
  85428. /**
  85429. * Creates a new instance HemisphericParticleEmitter
  85430. * @param radius the radius of the emission hemisphere (1 by default)
  85431. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85432. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85433. */
  85434. constructor(
  85435. /**
  85436. * The radius of the emission hemisphere.
  85437. */
  85438. radius?: number,
  85439. /**
  85440. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85441. */
  85442. radiusRange?: number,
  85443. /**
  85444. * How much to randomize the particle direction [0-1].
  85445. */
  85446. directionRandomizer?: number);
  85447. /**
  85448. * Called by the particle System when the direction is computed for the created particle.
  85449. * @param worldMatrix is the world matrix of the particle system
  85450. * @param directionToUpdate is the direction vector to update with the result
  85451. * @param particle is the particle we are computed the direction for
  85452. */
  85453. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85454. /**
  85455. * Called by the particle System when the position is computed for the created particle.
  85456. * @param worldMatrix is the world matrix of the particle system
  85457. * @param positionToUpdate is the position vector to update with the result
  85458. * @param particle is the particle we are computed the position for
  85459. */
  85460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85461. /**
  85462. * Clones the current emitter and returns a copy of it
  85463. * @returns the new emitter
  85464. */
  85465. clone(): HemisphericParticleEmitter;
  85466. /**
  85467. * Called by the GPUParticleSystem to setup the update shader
  85468. * @param effect defines the update shader
  85469. */
  85470. applyToShader(effect: Effect): void;
  85471. /**
  85472. * Returns a string to use to update the GPU particles update shader
  85473. * @returns a string containng the defines string
  85474. */
  85475. getEffectDefines(): string;
  85476. /**
  85477. * Returns the string "HemisphericParticleEmitter"
  85478. * @returns a string containing the class name
  85479. */
  85480. getClassName(): string;
  85481. /**
  85482. * Serializes the particle system to a JSON object.
  85483. * @returns the JSON object
  85484. */
  85485. serialize(): any;
  85486. /**
  85487. * Parse properties from a JSON object
  85488. * @param serializationObject defines the JSON object
  85489. */
  85490. parse(serializationObject: any): void;
  85491. }
  85492. }
  85493. declare module BABYLON {
  85494. /**
  85495. * Particle emitter emitting particles from a point.
  85496. * It emits the particles randomly between 2 given directions.
  85497. */
  85498. export class PointParticleEmitter implements IParticleEmitterType {
  85499. /**
  85500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85501. */
  85502. direction1: Vector3;
  85503. /**
  85504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85505. */
  85506. direction2: Vector3;
  85507. /**
  85508. * Creates a new instance PointParticleEmitter
  85509. */
  85510. constructor();
  85511. /**
  85512. * Called by the particle System when the direction is computed for the created particle.
  85513. * @param worldMatrix is the world matrix of the particle system
  85514. * @param directionToUpdate is the direction vector to update with the result
  85515. * @param particle is the particle we are computed the direction for
  85516. */
  85517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85518. /**
  85519. * Called by the particle System when the position is computed for the created particle.
  85520. * @param worldMatrix is the world matrix of the particle system
  85521. * @param positionToUpdate is the position vector to update with the result
  85522. * @param particle is the particle we are computed the position for
  85523. */
  85524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85525. /**
  85526. * Clones the current emitter and returns a copy of it
  85527. * @returns the new emitter
  85528. */
  85529. clone(): PointParticleEmitter;
  85530. /**
  85531. * Called by the GPUParticleSystem to setup the update shader
  85532. * @param effect defines the update shader
  85533. */
  85534. applyToShader(effect: Effect): void;
  85535. /**
  85536. * Returns a string to use to update the GPU particles update shader
  85537. * @returns a string containng the defines string
  85538. */
  85539. getEffectDefines(): string;
  85540. /**
  85541. * Returns the string "PointParticleEmitter"
  85542. * @returns a string containing the class name
  85543. */
  85544. getClassName(): string;
  85545. /**
  85546. * Serializes the particle system to a JSON object.
  85547. * @returns the JSON object
  85548. */
  85549. serialize(): any;
  85550. /**
  85551. * Parse properties from a JSON object
  85552. * @param serializationObject defines the JSON object
  85553. */
  85554. parse(serializationObject: any): void;
  85555. }
  85556. }
  85557. declare module BABYLON {
  85558. /**
  85559. * Particle emitter emitting particles from the inside of a sphere.
  85560. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85561. */
  85562. export class SphereParticleEmitter implements IParticleEmitterType {
  85563. /**
  85564. * The radius of the emission sphere.
  85565. */
  85566. radius: number;
  85567. /**
  85568. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85569. */
  85570. radiusRange: number;
  85571. /**
  85572. * How much to randomize the particle direction [0-1].
  85573. */
  85574. directionRandomizer: number;
  85575. /**
  85576. * Creates a new instance SphereParticleEmitter
  85577. * @param radius the radius of the emission sphere (1 by default)
  85578. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85579. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85580. */
  85581. constructor(
  85582. /**
  85583. * The radius of the emission sphere.
  85584. */
  85585. radius?: number,
  85586. /**
  85587. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85588. */
  85589. radiusRange?: number,
  85590. /**
  85591. * How much to randomize the particle direction [0-1].
  85592. */
  85593. directionRandomizer?: number);
  85594. /**
  85595. * Called by the particle System when the direction is computed for the created particle.
  85596. * @param worldMatrix is the world matrix of the particle system
  85597. * @param directionToUpdate is the direction vector to update with the result
  85598. * @param particle is the particle we are computed the direction for
  85599. */
  85600. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85601. /**
  85602. * Called by the particle System when the position is computed for the created particle.
  85603. * @param worldMatrix is the world matrix of the particle system
  85604. * @param positionToUpdate is the position vector to update with the result
  85605. * @param particle is the particle we are computed the position for
  85606. */
  85607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85608. /**
  85609. * Clones the current emitter and returns a copy of it
  85610. * @returns the new emitter
  85611. */
  85612. clone(): SphereParticleEmitter;
  85613. /**
  85614. * Called by the GPUParticleSystem to setup the update shader
  85615. * @param effect defines the update shader
  85616. */
  85617. applyToShader(effect: Effect): void;
  85618. /**
  85619. * Returns a string to use to update the GPU particles update shader
  85620. * @returns a string containng the defines string
  85621. */
  85622. getEffectDefines(): string;
  85623. /**
  85624. * Returns the string "SphereParticleEmitter"
  85625. * @returns a string containing the class name
  85626. */
  85627. getClassName(): string;
  85628. /**
  85629. * Serializes the particle system to a JSON object.
  85630. * @returns the JSON object
  85631. */
  85632. serialize(): any;
  85633. /**
  85634. * Parse properties from a JSON object
  85635. * @param serializationObject defines the JSON object
  85636. */
  85637. parse(serializationObject: any): void;
  85638. }
  85639. /**
  85640. * Particle emitter emitting particles from the inside of a sphere.
  85641. * It emits the particles randomly between two vectors.
  85642. */
  85643. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85644. /**
  85645. * The min limit of the emission direction.
  85646. */
  85647. direction1: Vector3;
  85648. /**
  85649. * The max limit of the emission direction.
  85650. */
  85651. direction2: Vector3;
  85652. /**
  85653. * Creates a new instance SphereDirectedParticleEmitter
  85654. * @param radius the radius of the emission sphere (1 by default)
  85655. * @param direction1 the min limit of the emission direction (up vector by default)
  85656. * @param direction2 the max limit of the emission direction (up vector by default)
  85657. */
  85658. constructor(radius?: number,
  85659. /**
  85660. * The min limit of the emission direction.
  85661. */
  85662. direction1?: Vector3,
  85663. /**
  85664. * The max limit of the emission direction.
  85665. */
  85666. direction2?: Vector3);
  85667. /**
  85668. * Called by the particle System when the direction is computed for the created particle.
  85669. * @param worldMatrix is the world matrix of the particle system
  85670. * @param directionToUpdate is the direction vector to update with the result
  85671. * @param particle is the particle we are computed the direction for
  85672. */
  85673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85674. /**
  85675. * Clones the current emitter and returns a copy of it
  85676. * @returns the new emitter
  85677. */
  85678. clone(): SphereDirectedParticleEmitter;
  85679. /**
  85680. * Called by the GPUParticleSystem to setup the update shader
  85681. * @param effect defines the update shader
  85682. */
  85683. applyToShader(effect: Effect): void;
  85684. /**
  85685. * Returns a string to use to update the GPU particles update shader
  85686. * @returns a string containng the defines string
  85687. */
  85688. getEffectDefines(): string;
  85689. /**
  85690. * Returns the string "SphereDirectedParticleEmitter"
  85691. * @returns a string containing the class name
  85692. */
  85693. getClassName(): string;
  85694. /**
  85695. * Serializes the particle system to a JSON object.
  85696. * @returns the JSON object
  85697. */
  85698. serialize(): any;
  85699. /**
  85700. * Parse properties from a JSON object
  85701. * @param serializationObject defines the JSON object
  85702. */
  85703. parse(serializationObject: any): void;
  85704. }
  85705. }
  85706. declare module BABYLON {
  85707. /**
  85708. * Interface representing a particle system in Babylon.js.
  85709. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85710. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85711. */
  85712. export interface IParticleSystem {
  85713. /**
  85714. * List of animations used by the particle system.
  85715. */
  85716. animations: Animation[];
  85717. /**
  85718. * The id of the Particle system.
  85719. */
  85720. id: string;
  85721. /**
  85722. * The name of the Particle system.
  85723. */
  85724. name: string;
  85725. /**
  85726. * The emitter represents the Mesh or position we are attaching the particle system to.
  85727. */
  85728. emitter: Nullable<AbstractMesh | Vector3>;
  85729. /**
  85730. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85731. */
  85732. isBillboardBased: boolean;
  85733. /**
  85734. * The rendering group used by the Particle system to chose when to render.
  85735. */
  85736. renderingGroupId: number;
  85737. /**
  85738. * The layer mask we are rendering the particles through.
  85739. */
  85740. layerMask: number;
  85741. /**
  85742. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85743. */
  85744. updateSpeed: number;
  85745. /**
  85746. * The amount of time the particle system is running (depends of the overall update speed).
  85747. */
  85748. targetStopDuration: number;
  85749. /**
  85750. * The texture used to render each particle. (this can be a spritesheet)
  85751. */
  85752. particleTexture: Nullable<Texture>;
  85753. /**
  85754. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85755. */
  85756. blendMode: number;
  85757. /**
  85758. * Minimum life time of emitting particles.
  85759. */
  85760. minLifeTime: number;
  85761. /**
  85762. * Maximum life time of emitting particles.
  85763. */
  85764. maxLifeTime: number;
  85765. /**
  85766. * Minimum Size of emitting particles.
  85767. */
  85768. minSize: number;
  85769. /**
  85770. * Maximum Size of emitting particles.
  85771. */
  85772. maxSize: number;
  85773. /**
  85774. * Minimum scale of emitting particles on X axis.
  85775. */
  85776. minScaleX: number;
  85777. /**
  85778. * Maximum scale of emitting particles on X axis.
  85779. */
  85780. maxScaleX: number;
  85781. /**
  85782. * Minimum scale of emitting particles on Y axis.
  85783. */
  85784. minScaleY: number;
  85785. /**
  85786. * Maximum scale of emitting particles on Y axis.
  85787. */
  85788. maxScaleY: number;
  85789. /**
  85790. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85791. */
  85792. color1: Color4;
  85793. /**
  85794. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85795. */
  85796. color2: Color4;
  85797. /**
  85798. * Color the particle will have at the end of its lifetime.
  85799. */
  85800. colorDead: Color4;
  85801. /**
  85802. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85803. */
  85804. emitRate: number;
  85805. /**
  85806. * You can use gravity if you want to give an orientation to your particles.
  85807. */
  85808. gravity: Vector3;
  85809. /**
  85810. * Minimum power of emitting particles.
  85811. */
  85812. minEmitPower: number;
  85813. /**
  85814. * Maximum power of emitting particles.
  85815. */
  85816. maxEmitPower: number;
  85817. /**
  85818. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85819. */
  85820. minAngularSpeed: number;
  85821. /**
  85822. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85823. */
  85824. maxAngularSpeed: number;
  85825. /**
  85826. * Gets or sets the minimal initial rotation in radians.
  85827. */
  85828. minInitialRotation: number;
  85829. /**
  85830. * Gets or sets the maximal initial rotation in radians.
  85831. */
  85832. maxInitialRotation: number;
  85833. /**
  85834. * The particle emitter type defines the emitter used by the particle system.
  85835. * It can be for example box, sphere, or cone...
  85836. */
  85837. particleEmitterType: Nullable<IParticleEmitterType>;
  85838. /**
  85839. * Defines the delay in milliseconds before starting the system (0 by default)
  85840. */
  85841. startDelay: number;
  85842. /**
  85843. * 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
  85844. */
  85845. preWarmCycles: number;
  85846. /**
  85847. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85848. */
  85849. preWarmStepOffset: number;
  85850. /**
  85851. * 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)
  85852. */
  85853. spriteCellChangeSpeed: number;
  85854. /**
  85855. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85856. */
  85857. startSpriteCellID: number;
  85858. /**
  85859. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85860. */
  85861. endSpriteCellID: number;
  85862. /**
  85863. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85864. */
  85865. spriteCellWidth: number;
  85866. /**
  85867. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85868. */
  85869. spriteCellHeight: number;
  85870. /**
  85871. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85872. */
  85873. spriteRandomStartCell: boolean;
  85874. /**
  85875. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85876. */
  85877. isAnimationSheetEnabled: boolean;
  85878. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85879. translationPivot: Vector2;
  85880. /**
  85881. * Gets or sets a texture used to add random noise to particle positions
  85882. */
  85883. noiseTexture: Nullable<BaseTexture>;
  85884. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85885. noiseStrength: Vector3;
  85886. /**
  85887. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85888. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85889. */
  85890. billboardMode: number;
  85891. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85892. limitVelocityDamping: number;
  85893. /**
  85894. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85895. */
  85896. beginAnimationOnStart: boolean;
  85897. /**
  85898. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85899. */
  85900. beginAnimationFrom: number;
  85901. /**
  85902. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85903. */
  85904. beginAnimationTo: number;
  85905. /**
  85906. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85907. */
  85908. beginAnimationLoop: boolean;
  85909. /**
  85910. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85911. */
  85912. disposeOnStop: boolean;
  85913. /**
  85914. * Gets the maximum number of particles active at the same time.
  85915. * @returns The max number of active particles.
  85916. */
  85917. getCapacity(): number;
  85918. /**
  85919. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85920. * @returns True if it has been started, otherwise false.
  85921. */
  85922. isStarted(): boolean;
  85923. /**
  85924. * Animates the particle system for this frame.
  85925. */
  85926. animate(): void;
  85927. /**
  85928. * Renders the particle system in its current state.
  85929. * @returns the current number of particles
  85930. */
  85931. render(): number;
  85932. /**
  85933. * Dispose the particle system and frees its associated resources.
  85934. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85935. */
  85936. dispose(disposeTexture?: boolean): void;
  85937. /**
  85938. * Clones the particle system.
  85939. * @param name The name of the cloned object
  85940. * @param newEmitter The new emitter to use
  85941. * @returns the cloned particle system
  85942. */
  85943. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85944. /**
  85945. * Serializes the particle system to a JSON object.
  85946. * @returns the JSON object
  85947. */
  85948. serialize(): any;
  85949. /**
  85950. * Rebuild the particle system
  85951. */
  85952. rebuild(): void;
  85953. /**
  85954. * Starts the particle system and begins to emit
  85955. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85956. */
  85957. start(delay?: number): void;
  85958. /**
  85959. * Stops the particle system.
  85960. */
  85961. stop(): void;
  85962. /**
  85963. * Remove all active particles
  85964. */
  85965. reset(): void;
  85966. /**
  85967. * Is this system ready to be used/rendered
  85968. * @return true if the system is ready
  85969. */
  85970. isReady(): boolean;
  85971. /**
  85972. * Adds a new color gradient
  85973. * @param gradient defines the gradient to use (between 0 and 1)
  85974. * @param color1 defines the color to affect to the specified gradient
  85975. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85976. * @returns the current particle system
  85977. */
  85978. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85979. /**
  85980. * Remove a specific color gradient
  85981. * @param gradient defines the gradient to remove
  85982. * @returns the current particle system
  85983. */
  85984. removeColorGradient(gradient: number): IParticleSystem;
  85985. /**
  85986. * Adds a new size gradient
  85987. * @param gradient defines the gradient to use (between 0 and 1)
  85988. * @param factor defines the size factor to affect to the specified gradient
  85989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85990. * @returns the current particle system
  85991. */
  85992. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85993. /**
  85994. * Remove a specific size gradient
  85995. * @param gradient defines the gradient to remove
  85996. * @returns the current particle system
  85997. */
  85998. removeSizeGradient(gradient: number): IParticleSystem;
  85999. /**
  86000. * Gets the current list of color gradients.
  86001. * You must use addColorGradient and removeColorGradient to udpate this list
  86002. * @returns the list of color gradients
  86003. */
  86004. getColorGradients(): Nullable<Array<ColorGradient>>;
  86005. /**
  86006. * Gets the current list of size gradients.
  86007. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86008. * @returns the list of size gradients
  86009. */
  86010. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86011. /**
  86012. * Gets the current list of angular speed gradients.
  86013. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86014. * @returns the list of angular speed gradients
  86015. */
  86016. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86017. /**
  86018. * Adds a new angular speed gradient
  86019. * @param gradient defines the gradient to use (between 0 and 1)
  86020. * @param factor defines the angular speed to affect to the specified gradient
  86021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86022. * @returns the current particle system
  86023. */
  86024. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86025. /**
  86026. * Remove a specific angular speed gradient
  86027. * @param gradient defines the gradient to remove
  86028. * @returns the current particle system
  86029. */
  86030. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86031. /**
  86032. * Gets the current list of velocity gradients.
  86033. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86034. * @returns the list of velocity gradients
  86035. */
  86036. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86037. /**
  86038. * Adds a new velocity gradient
  86039. * @param gradient defines the gradient to use (between 0 and 1)
  86040. * @param factor defines the velocity to affect to the specified gradient
  86041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86042. * @returns the current particle system
  86043. */
  86044. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86045. /**
  86046. * Remove a specific velocity gradient
  86047. * @param gradient defines the gradient to remove
  86048. * @returns the current particle system
  86049. */
  86050. removeVelocityGradient(gradient: number): IParticleSystem;
  86051. /**
  86052. * Gets the current list of limit velocity gradients.
  86053. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86054. * @returns the list of limit velocity gradients
  86055. */
  86056. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86057. /**
  86058. * Adds a new limit velocity gradient
  86059. * @param gradient defines the gradient to use (between 0 and 1)
  86060. * @param factor defines the limit velocity to affect to the specified gradient
  86061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86062. * @returns the current particle system
  86063. */
  86064. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86065. /**
  86066. * Remove a specific limit velocity gradient
  86067. * @param gradient defines the gradient to remove
  86068. * @returns the current particle system
  86069. */
  86070. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86071. /**
  86072. * Adds a new drag gradient
  86073. * @param gradient defines the gradient to use (between 0 and 1)
  86074. * @param factor defines the drag to affect to the specified gradient
  86075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86076. * @returns the current particle system
  86077. */
  86078. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86079. /**
  86080. * Remove a specific drag gradient
  86081. * @param gradient defines the gradient to remove
  86082. * @returns the current particle system
  86083. */
  86084. removeDragGradient(gradient: number): IParticleSystem;
  86085. /**
  86086. * Gets the current list of drag gradients.
  86087. * You must use addDragGradient and removeDragGradient to udpate this list
  86088. * @returns the list of drag gradients
  86089. */
  86090. getDragGradients(): Nullable<Array<FactorGradient>>;
  86091. /**
  86092. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86093. * @param gradient defines the gradient to use (between 0 and 1)
  86094. * @param factor defines the emit rate to affect to the specified gradient
  86095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86096. * @returns the current particle system
  86097. */
  86098. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86099. /**
  86100. * Remove a specific emit rate gradient
  86101. * @param gradient defines the gradient to remove
  86102. * @returns the current particle system
  86103. */
  86104. removeEmitRateGradient(gradient: number): IParticleSystem;
  86105. /**
  86106. * Gets the current list of emit rate gradients.
  86107. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86108. * @returns the list of emit rate gradients
  86109. */
  86110. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86111. /**
  86112. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86113. * @param gradient defines the gradient to use (between 0 and 1)
  86114. * @param factor defines the start size to affect to the specified gradient
  86115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86116. * @returns the current particle system
  86117. */
  86118. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86119. /**
  86120. * Remove a specific start size gradient
  86121. * @param gradient defines the gradient to remove
  86122. * @returns the current particle system
  86123. */
  86124. removeStartSizeGradient(gradient: number): IParticleSystem;
  86125. /**
  86126. * Gets the current list of start size gradients.
  86127. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86128. * @returns the list of start size gradients
  86129. */
  86130. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86131. /**
  86132. * Adds a new life time gradient
  86133. * @param gradient defines the gradient to use (between 0 and 1)
  86134. * @param factor defines the life time factor to affect to the specified gradient
  86135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86136. * @returns the current particle system
  86137. */
  86138. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86139. /**
  86140. * Remove a specific life time gradient
  86141. * @param gradient defines the gradient to remove
  86142. * @returns the current particle system
  86143. */
  86144. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86145. /**
  86146. * Gets the current list of life time gradients.
  86147. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86148. * @returns the list of life time gradients
  86149. */
  86150. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86151. /**
  86152. * Gets the current list of color gradients.
  86153. * You must use addColorGradient and removeColorGradient to udpate this list
  86154. * @returns the list of color gradients
  86155. */
  86156. getColorGradients(): Nullable<Array<ColorGradient>>;
  86157. /**
  86158. * Adds a new ramp gradient used to remap particle colors
  86159. * @param gradient defines the gradient to use (between 0 and 1)
  86160. * @param color defines the color to affect to the specified gradient
  86161. * @returns the current particle system
  86162. */
  86163. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86164. /**
  86165. * Gets the current list of ramp gradients.
  86166. * You must use addRampGradient and removeRampGradient to udpate this list
  86167. * @returns the list of ramp gradients
  86168. */
  86169. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86170. /** Gets or sets a boolean indicating that ramp gradients must be used
  86171. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86172. */
  86173. useRampGradients: boolean;
  86174. /**
  86175. * Adds a new color remap gradient
  86176. * @param gradient defines the gradient to use (between 0 and 1)
  86177. * @param min defines the color remap minimal range
  86178. * @param max defines the color remap maximal range
  86179. * @returns the current particle system
  86180. */
  86181. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86182. /**
  86183. * Gets the current list of color remap gradients.
  86184. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86185. * @returns the list of color remap gradients
  86186. */
  86187. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86188. /**
  86189. * Adds a new alpha remap gradient
  86190. * @param gradient defines the gradient to use (between 0 and 1)
  86191. * @param min defines the alpha remap minimal range
  86192. * @param max defines the alpha remap maximal range
  86193. * @returns the current particle system
  86194. */
  86195. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86196. /**
  86197. * Gets the current list of alpha remap gradients.
  86198. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86199. * @returns the list of alpha remap gradients
  86200. */
  86201. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86202. /**
  86203. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86204. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86205. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86206. * @returns the emitter
  86207. */
  86208. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86209. /**
  86210. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86211. * @param radius The radius of the hemisphere to emit from
  86212. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86213. * @returns the emitter
  86214. */
  86215. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86216. /**
  86217. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86218. * @param radius The radius of the sphere to emit from
  86219. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86220. * @returns the emitter
  86221. */
  86222. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86223. /**
  86224. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86225. * @param radius The radius of the sphere to emit from
  86226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86228. * @returns the emitter
  86229. */
  86230. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86231. /**
  86232. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86233. * @param radius The radius of the emission cylinder
  86234. * @param height The height of the emission cylinder
  86235. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86236. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86237. * @returns the emitter
  86238. */
  86239. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86240. /**
  86241. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86242. * @param radius The radius of the cylinder to emit from
  86243. * @param height The height of the emission cylinder
  86244. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86245. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86246. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86247. * @returns the emitter
  86248. */
  86249. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86250. /**
  86251. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86252. * @param radius The radius of the cone to emit from
  86253. * @param angle The base angle of the cone
  86254. * @returns the emitter
  86255. */
  86256. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86257. /**
  86258. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86259. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86260. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86261. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86262. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86263. * @returns the emitter
  86264. */
  86265. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86266. /**
  86267. * Get hosting scene
  86268. * @returns the scene
  86269. */
  86270. getScene(): Scene;
  86271. }
  86272. }
  86273. declare module BABYLON {
  86274. /**
  86275. * Creates an instance based on a source mesh.
  86276. */
  86277. export class InstancedMesh extends AbstractMesh {
  86278. private _sourceMesh;
  86279. private _currentLOD;
  86280. /** @hidden */
  86281. _indexInSourceMeshInstanceArray: number;
  86282. constructor(name: string, source: Mesh);
  86283. /**
  86284. * Returns the string "InstancedMesh".
  86285. */
  86286. getClassName(): string;
  86287. /** Gets the list of lights affecting that mesh */
  86288. readonly lightSources: Light[];
  86289. _resyncLightSources(): void;
  86290. _resyncLighSource(light: Light): void;
  86291. _removeLightSource(light: Light, dispose: boolean): void;
  86292. /**
  86293. * If the source mesh receives shadows
  86294. */
  86295. readonly receiveShadows: boolean;
  86296. /**
  86297. * The material of the source mesh
  86298. */
  86299. readonly material: Nullable<Material>;
  86300. /**
  86301. * Visibility of the source mesh
  86302. */
  86303. readonly visibility: number;
  86304. /**
  86305. * Skeleton of the source mesh
  86306. */
  86307. readonly skeleton: Nullable<Skeleton>;
  86308. /**
  86309. * Rendering ground id of the source mesh
  86310. */
  86311. renderingGroupId: number;
  86312. /**
  86313. * Returns the total number of vertices (integer).
  86314. */
  86315. getTotalVertices(): number;
  86316. /**
  86317. * Returns a positive integer : the total number of indices in this mesh geometry.
  86318. * @returns the numner of indices or zero if the mesh has no geometry.
  86319. */
  86320. getTotalIndices(): number;
  86321. /**
  86322. * The source mesh of the instance
  86323. */
  86324. readonly sourceMesh: Mesh;
  86325. /**
  86326. * Is this node ready to be used/rendered
  86327. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86328. * @return {boolean} is it ready
  86329. */
  86330. isReady(completeCheck?: boolean): boolean;
  86331. /**
  86332. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86333. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86334. * @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.
  86335. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86336. */
  86337. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86338. /**
  86339. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86340. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86341. * The `data` are either a numeric array either a Float32Array.
  86342. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86343. * 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).
  86344. * Note that a new underlying VertexBuffer object is created each call.
  86345. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86346. *
  86347. * Possible `kind` values :
  86348. * - VertexBuffer.PositionKind
  86349. * - VertexBuffer.UVKind
  86350. * - VertexBuffer.UV2Kind
  86351. * - VertexBuffer.UV3Kind
  86352. * - VertexBuffer.UV4Kind
  86353. * - VertexBuffer.UV5Kind
  86354. * - VertexBuffer.UV6Kind
  86355. * - VertexBuffer.ColorKind
  86356. * - VertexBuffer.MatricesIndicesKind
  86357. * - VertexBuffer.MatricesIndicesExtraKind
  86358. * - VertexBuffer.MatricesWeightsKind
  86359. * - VertexBuffer.MatricesWeightsExtraKind
  86360. *
  86361. * Returns the Mesh.
  86362. */
  86363. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86364. /**
  86365. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86366. * If the mesh has no geometry, it is simply returned as it is.
  86367. * The `data` are either a numeric array either a Float32Array.
  86368. * No new underlying VertexBuffer object is created.
  86369. * 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.
  86370. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86371. *
  86372. * Possible `kind` values :
  86373. * - VertexBuffer.PositionKind
  86374. * - VertexBuffer.UVKind
  86375. * - VertexBuffer.UV2Kind
  86376. * - VertexBuffer.UV3Kind
  86377. * - VertexBuffer.UV4Kind
  86378. * - VertexBuffer.UV5Kind
  86379. * - VertexBuffer.UV6Kind
  86380. * - VertexBuffer.ColorKind
  86381. * - VertexBuffer.MatricesIndicesKind
  86382. * - VertexBuffer.MatricesIndicesExtraKind
  86383. * - VertexBuffer.MatricesWeightsKind
  86384. * - VertexBuffer.MatricesWeightsExtraKind
  86385. *
  86386. * Returns the Mesh.
  86387. */
  86388. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86389. /**
  86390. * Sets the mesh indices.
  86391. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86392. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86393. * This method creates a new index buffer each call.
  86394. * Returns the Mesh.
  86395. */
  86396. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86397. /**
  86398. * Boolean : True if the mesh owns the requested kind of data.
  86399. */
  86400. isVerticesDataPresent(kind: string): boolean;
  86401. /**
  86402. * Returns an array of indices (IndicesArray).
  86403. */
  86404. getIndices(): Nullable<IndicesArray>;
  86405. readonly _positions: Nullable<Vector3[]>;
  86406. /**
  86407. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86408. * This means the mesh underlying bounding box and sphere are recomputed.
  86409. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86410. * @returns the current mesh
  86411. */
  86412. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86413. /** @hidden */
  86414. _preActivate(): InstancedMesh;
  86415. /** @hidden */
  86416. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86417. /** @hidden */
  86418. _postActivate(): void;
  86419. getWorldMatrix(): Matrix;
  86420. readonly isAnInstance: boolean;
  86421. /**
  86422. * Returns the current associated LOD AbstractMesh.
  86423. */
  86424. getLOD(camera: Camera): AbstractMesh;
  86425. /** @hidden */
  86426. _syncSubMeshes(): InstancedMesh;
  86427. /** @hidden */
  86428. _generatePointsArray(): boolean;
  86429. /**
  86430. * Creates a new InstancedMesh from the current mesh.
  86431. * - name (string) : the cloned mesh name
  86432. * - newParent (optional Node) : the optional Node to parent the clone to.
  86433. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86434. *
  86435. * Returns the clone.
  86436. */
  86437. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86438. /**
  86439. * Disposes the InstancedMesh.
  86440. * Returns nothing.
  86441. */
  86442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86443. }
  86444. interface Mesh {
  86445. /**
  86446. * Register a custom buffer that will be instanced
  86447. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86448. * @param kind defines the buffer kind
  86449. * @param stride defines the stride in floats
  86450. */
  86451. registerInstancedBuffer(kind: string, stride: number): void;
  86452. /** @hidden */
  86453. _userInstancedBuffersStorage: {
  86454. data: {
  86455. [key: string]: Float32Array;
  86456. };
  86457. sizes: {
  86458. [key: string]: number;
  86459. };
  86460. vertexBuffers: {
  86461. [key: string]: Nullable<VertexBuffer>;
  86462. };
  86463. strides: {
  86464. [key: string]: number;
  86465. };
  86466. };
  86467. }
  86468. interface AbstractMesh {
  86469. /**
  86470. * Object used to store instanced buffers defined by user
  86471. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86472. */
  86473. instancedBuffers: {
  86474. [key: string]: any;
  86475. };
  86476. }
  86477. }
  86478. declare module BABYLON {
  86479. /**
  86480. * Defines the options associated with the creation of a shader material.
  86481. */
  86482. export interface IShaderMaterialOptions {
  86483. /**
  86484. * Does the material work in alpha blend mode
  86485. */
  86486. needAlphaBlending: boolean;
  86487. /**
  86488. * Does the material work in alpha test mode
  86489. */
  86490. needAlphaTesting: boolean;
  86491. /**
  86492. * The list of attribute names used in the shader
  86493. */
  86494. attributes: string[];
  86495. /**
  86496. * The list of unifrom names used in the shader
  86497. */
  86498. uniforms: string[];
  86499. /**
  86500. * The list of UBO names used in the shader
  86501. */
  86502. uniformBuffers: string[];
  86503. /**
  86504. * The list of sampler names used in the shader
  86505. */
  86506. samplers: string[];
  86507. /**
  86508. * The list of defines used in the shader
  86509. */
  86510. defines: string[];
  86511. }
  86512. /**
  86513. * 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.
  86514. *
  86515. * This returned material effects how the mesh will look based on the code in the shaders.
  86516. *
  86517. * @see http://doc.babylonjs.com/how_to/shader_material
  86518. */
  86519. export class ShaderMaterial extends Material {
  86520. private _shaderPath;
  86521. private _options;
  86522. private _textures;
  86523. private _textureArrays;
  86524. private _floats;
  86525. private _ints;
  86526. private _floatsArrays;
  86527. private _colors3;
  86528. private _colors3Arrays;
  86529. private _colors4;
  86530. private _colors4Arrays;
  86531. private _vectors2;
  86532. private _vectors3;
  86533. private _vectors4;
  86534. private _matrices;
  86535. private _matrices3x3;
  86536. private _matrices2x2;
  86537. private _vectors2Arrays;
  86538. private _vectors3Arrays;
  86539. private _vectors4Arrays;
  86540. private _cachedWorldViewMatrix;
  86541. private _cachedWorldViewProjectionMatrix;
  86542. private _renderId;
  86543. /**
  86544. * Instantiate a new shader material.
  86545. * 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.
  86546. * This returned material effects how the mesh will look based on the code in the shaders.
  86547. * @see http://doc.babylonjs.com/how_to/shader_material
  86548. * @param name Define the name of the material in the scene
  86549. * @param scene Define the scene the material belongs to
  86550. * @param shaderPath Defines the route to the shader code in one of three ways:
  86551. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86552. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86553. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86554. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86555. * @param options Define the options used to create the shader
  86556. */
  86557. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86558. /**
  86559. * Gets the options used to compile the shader.
  86560. * They can be modified to trigger a new compilation
  86561. */
  86562. readonly options: IShaderMaterialOptions;
  86563. /**
  86564. * Gets the current class name of the material e.g. "ShaderMaterial"
  86565. * Mainly use in serialization.
  86566. * @returns the class name
  86567. */
  86568. getClassName(): string;
  86569. /**
  86570. * Specifies if the material will require alpha blending
  86571. * @returns a boolean specifying if alpha blending is needed
  86572. */
  86573. needAlphaBlending(): boolean;
  86574. /**
  86575. * Specifies if this material should be rendered in alpha test mode
  86576. * @returns a boolean specifying if an alpha test is needed.
  86577. */
  86578. needAlphaTesting(): boolean;
  86579. private _checkUniform;
  86580. /**
  86581. * Set a texture in the shader.
  86582. * @param name Define the name of the uniform samplers as defined in the shader
  86583. * @param texture Define the texture to bind to this sampler
  86584. * @return the material itself allowing "fluent" like uniform updates
  86585. */
  86586. setTexture(name: string, texture: Texture): ShaderMaterial;
  86587. /**
  86588. * Set a texture array in the shader.
  86589. * @param name Define the name of the uniform sampler array as defined in the shader
  86590. * @param textures Define the list of textures to bind to this sampler
  86591. * @return the material itself allowing "fluent" like uniform updates
  86592. */
  86593. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86594. /**
  86595. * Set a float in the shader.
  86596. * @param name Define the name of the uniform as defined in the shader
  86597. * @param value Define the value to give to the uniform
  86598. * @return the material itself allowing "fluent" like uniform updates
  86599. */
  86600. setFloat(name: string, value: number): ShaderMaterial;
  86601. /**
  86602. * Set a int in the shader.
  86603. * @param name Define the name of the uniform as defined in the shader
  86604. * @param value Define the value to give to the uniform
  86605. * @return the material itself allowing "fluent" like uniform updates
  86606. */
  86607. setInt(name: string, value: number): ShaderMaterial;
  86608. /**
  86609. * Set an array of floats in the shader.
  86610. * @param name Define the name of the uniform as defined in the shader
  86611. * @param value Define the value to give to the uniform
  86612. * @return the material itself allowing "fluent" like uniform updates
  86613. */
  86614. setFloats(name: string, value: number[]): ShaderMaterial;
  86615. /**
  86616. * Set a vec3 in the shader from a Color3.
  86617. * @param name Define the name of the uniform as defined in the shader
  86618. * @param value Define the value to give to the uniform
  86619. * @return the material itself allowing "fluent" like uniform updates
  86620. */
  86621. setColor3(name: string, value: Color3): ShaderMaterial;
  86622. /**
  86623. * Set a vec3 array in the shader from a Color3 array.
  86624. * @param name Define the name of the uniform as defined in the shader
  86625. * @param value Define the value to give to the uniform
  86626. * @return the material itself allowing "fluent" like uniform updates
  86627. */
  86628. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86629. /**
  86630. * Set a vec4 in the shader from a Color4.
  86631. * @param name Define the name of the uniform as defined in the shader
  86632. * @param value Define the value to give to the uniform
  86633. * @return the material itself allowing "fluent" like uniform updates
  86634. */
  86635. setColor4(name: string, value: Color4): ShaderMaterial;
  86636. /**
  86637. * Set a vec4 array in the shader from a Color4 array.
  86638. * @param name Define the name of the uniform as defined in the shader
  86639. * @param value Define the value to give to the uniform
  86640. * @return the material itself allowing "fluent" like uniform updates
  86641. */
  86642. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86643. /**
  86644. * Set a vec2 in the shader from a Vector2.
  86645. * @param name Define the name of the uniform as defined in the shader
  86646. * @param value Define the value to give to the uniform
  86647. * @return the material itself allowing "fluent" like uniform updates
  86648. */
  86649. setVector2(name: string, value: Vector2): ShaderMaterial;
  86650. /**
  86651. * Set a vec3 in the shader from a Vector3.
  86652. * @param name Define the name of the uniform as defined in the shader
  86653. * @param value Define the value to give to the uniform
  86654. * @return the material itself allowing "fluent" like uniform updates
  86655. */
  86656. setVector3(name: string, value: Vector3): ShaderMaterial;
  86657. /**
  86658. * Set a vec4 in the shader from a Vector4.
  86659. * @param name Define the name of the uniform as defined in the shader
  86660. * @param value Define the value to give to the uniform
  86661. * @return the material itself allowing "fluent" like uniform updates
  86662. */
  86663. setVector4(name: string, value: Vector4): ShaderMaterial;
  86664. /**
  86665. * Set a mat4 in the shader from a Matrix.
  86666. * @param name Define the name of the uniform as defined in the shader
  86667. * @param value Define the value to give to the uniform
  86668. * @return the material itself allowing "fluent" like uniform updates
  86669. */
  86670. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86671. /**
  86672. * Set a mat3 in the shader from a Float32Array.
  86673. * @param name Define the name of the uniform as defined in the shader
  86674. * @param value Define the value to give to the uniform
  86675. * @return the material itself allowing "fluent" like uniform updates
  86676. */
  86677. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86678. /**
  86679. * Set a mat2 in the shader from a Float32Array.
  86680. * @param name Define the name of the uniform as defined in the shader
  86681. * @param value Define the value to give to the uniform
  86682. * @return the material itself allowing "fluent" like uniform updates
  86683. */
  86684. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86685. /**
  86686. * Set a vec2 array in the shader from a number array.
  86687. * @param name Define the name of the uniform as defined in the shader
  86688. * @param value Define the value to give to the uniform
  86689. * @return the material itself allowing "fluent" like uniform updates
  86690. */
  86691. setArray2(name: string, value: number[]): ShaderMaterial;
  86692. /**
  86693. * Set a vec3 array in the shader from a number array.
  86694. * @param name Define the name of the uniform as defined in the shader
  86695. * @param value Define the value to give to the uniform
  86696. * @return the material itself allowing "fluent" like uniform updates
  86697. */
  86698. setArray3(name: string, value: number[]): ShaderMaterial;
  86699. /**
  86700. * Set a vec4 array in the shader from a number array.
  86701. * @param name Define the name of the uniform as defined in the shader
  86702. * @param value Define the value to give to the uniform
  86703. * @return the material itself allowing "fluent" like uniform updates
  86704. */
  86705. setArray4(name: string, value: number[]): ShaderMaterial;
  86706. private _checkCache;
  86707. /**
  86708. * Specifies that the submesh is ready to be used
  86709. * @param mesh defines the mesh to check
  86710. * @param subMesh defines which submesh to check
  86711. * @param useInstances specifies that instances should be used
  86712. * @returns a boolean indicating that the submesh is ready or not
  86713. */
  86714. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86715. /**
  86716. * Checks if the material is ready to render the requested mesh
  86717. * @param mesh Define the mesh to render
  86718. * @param useInstances Define whether or not the material is used with instances
  86719. * @returns true if ready, otherwise false
  86720. */
  86721. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86722. /**
  86723. * Binds the world matrix to the material
  86724. * @param world defines the world transformation matrix
  86725. */
  86726. bindOnlyWorldMatrix(world: Matrix): void;
  86727. /**
  86728. * Binds the material to the mesh
  86729. * @param world defines the world transformation matrix
  86730. * @param mesh defines the mesh to bind the material to
  86731. */
  86732. bind(world: Matrix, mesh?: Mesh): void;
  86733. /**
  86734. * Gets the active textures from the material
  86735. * @returns an array of textures
  86736. */
  86737. getActiveTextures(): BaseTexture[];
  86738. /**
  86739. * Specifies if the material uses a texture
  86740. * @param texture defines the texture to check against the material
  86741. * @returns a boolean specifying if the material uses the texture
  86742. */
  86743. hasTexture(texture: BaseTexture): boolean;
  86744. /**
  86745. * Makes a duplicate of the material, and gives it a new name
  86746. * @param name defines the new name for the duplicated material
  86747. * @returns the cloned material
  86748. */
  86749. clone(name: string): ShaderMaterial;
  86750. /**
  86751. * Disposes the material
  86752. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86753. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86754. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86755. */
  86756. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86757. /**
  86758. * Serializes this material in a JSON representation
  86759. * @returns the serialized material object
  86760. */
  86761. serialize(): any;
  86762. /**
  86763. * Creates a shader material from parsed shader material data
  86764. * @param source defines the JSON represnetation of the material
  86765. * @param scene defines the hosting scene
  86766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86767. * @returns a new material
  86768. */
  86769. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86770. }
  86771. }
  86772. declare module BABYLON {
  86773. /** @hidden */
  86774. export var colorPixelShader: {
  86775. name: string;
  86776. shader: string;
  86777. };
  86778. }
  86779. declare module BABYLON {
  86780. /** @hidden */
  86781. export var colorVertexShader: {
  86782. name: string;
  86783. shader: string;
  86784. };
  86785. }
  86786. declare module BABYLON {
  86787. /**
  86788. * Line mesh
  86789. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86790. */
  86791. export class LinesMesh extends Mesh {
  86792. /**
  86793. * If vertex color should be applied to the mesh
  86794. */
  86795. readonly useVertexColor?: boolean | undefined;
  86796. /**
  86797. * If vertex alpha should be applied to the mesh
  86798. */
  86799. readonly useVertexAlpha?: boolean | undefined;
  86800. /**
  86801. * Color of the line (Default: White)
  86802. */
  86803. color: Color3;
  86804. /**
  86805. * Alpha of the line (Default: 1)
  86806. */
  86807. alpha: number;
  86808. /**
  86809. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86810. * This margin is expressed in world space coordinates, so its value may vary.
  86811. * Default value is 0.1
  86812. */
  86813. intersectionThreshold: number;
  86814. private _colorShader;
  86815. private color4;
  86816. /**
  86817. * Creates a new LinesMesh
  86818. * @param name defines the name
  86819. * @param scene defines the hosting scene
  86820. * @param parent defines the parent mesh if any
  86821. * @param source defines the optional source LinesMesh used to clone data from
  86822. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86823. * When false, achieved by calling a clone(), also passing False.
  86824. * This will make creation of children, recursive.
  86825. * @param useVertexColor defines if this LinesMesh supports vertex color
  86826. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86827. */
  86828. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86829. /**
  86830. * If vertex color should be applied to the mesh
  86831. */
  86832. useVertexColor?: boolean | undefined,
  86833. /**
  86834. * If vertex alpha should be applied to the mesh
  86835. */
  86836. useVertexAlpha?: boolean | undefined);
  86837. private _addClipPlaneDefine;
  86838. private _removeClipPlaneDefine;
  86839. isReady(): boolean;
  86840. /**
  86841. * Returns the string "LineMesh"
  86842. */
  86843. getClassName(): string;
  86844. /**
  86845. * @hidden
  86846. */
  86847. /**
  86848. * @hidden
  86849. */
  86850. material: Material;
  86851. /**
  86852. * @hidden
  86853. */
  86854. readonly checkCollisions: boolean;
  86855. /** @hidden */
  86856. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86857. /** @hidden */
  86858. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86859. /**
  86860. * Disposes of the line mesh
  86861. * @param doNotRecurse If children should be disposed
  86862. */
  86863. dispose(doNotRecurse?: boolean): void;
  86864. /**
  86865. * Returns a new LineMesh object cloned from the current one.
  86866. */
  86867. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86868. /**
  86869. * Creates a new InstancedLinesMesh object from the mesh model.
  86870. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86871. * @param name defines the name of the new instance
  86872. * @returns a new InstancedLinesMesh
  86873. */
  86874. createInstance(name: string): InstancedLinesMesh;
  86875. }
  86876. /**
  86877. * Creates an instance based on a source LinesMesh
  86878. */
  86879. export class InstancedLinesMesh extends InstancedMesh {
  86880. /**
  86881. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86882. * This margin is expressed in world space coordinates, so its value may vary.
  86883. * Initilized with the intersectionThreshold value of the source LinesMesh
  86884. */
  86885. intersectionThreshold: number;
  86886. constructor(name: string, source: LinesMesh);
  86887. /**
  86888. * Returns the string "InstancedLinesMesh".
  86889. */
  86890. getClassName(): string;
  86891. }
  86892. }
  86893. declare module BABYLON {
  86894. /** @hidden */
  86895. export var linePixelShader: {
  86896. name: string;
  86897. shader: string;
  86898. };
  86899. }
  86900. declare module BABYLON {
  86901. /** @hidden */
  86902. export var lineVertexShader: {
  86903. name: string;
  86904. shader: string;
  86905. };
  86906. }
  86907. declare module BABYLON {
  86908. interface AbstractMesh {
  86909. /**
  86910. * Gets the edgesRenderer associated with the mesh
  86911. */
  86912. edgesRenderer: Nullable<EdgesRenderer>;
  86913. }
  86914. interface LinesMesh {
  86915. /**
  86916. * Enables the edge rendering mode on the mesh.
  86917. * This mode makes the mesh edges visible
  86918. * @param epsilon defines the maximal distance between two angles to detect a face
  86919. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86920. * @returns the currentAbstractMesh
  86921. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86922. */
  86923. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86924. }
  86925. interface InstancedLinesMesh {
  86926. /**
  86927. * Enables the edge rendering mode on the mesh.
  86928. * This mode makes the mesh edges visible
  86929. * @param epsilon defines the maximal distance between two angles to detect a face
  86930. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86931. * @returns the current InstancedLinesMesh
  86932. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86933. */
  86934. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86935. }
  86936. /**
  86937. * Defines the minimum contract an Edges renderer should follow.
  86938. */
  86939. export interface IEdgesRenderer extends IDisposable {
  86940. /**
  86941. * Gets or sets a boolean indicating if the edgesRenderer is active
  86942. */
  86943. isEnabled: boolean;
  86944. /**
  86945. * Renders the edges of the attached mesh,
  86946. */
  86947. render(): void;
  86948. /**
  86949. * Checks wether or not the edges renderer is ready to render.
  86950. * @return true if ready, otherwise false.
  86951. */
  86952. isReady(): boolean;
  86953. }
  86954. /**
  86955. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86956. */
  86957. export class EdgesRenderer implements IEdgesRenderer {
  86958. /**
  86959. * Define the size of the edges with an orthographic camera
  86960. */
  86961. edgesWidthScalerForOrthographic: number;
  86962. /**
  86963. * Define the size of the edges with a perspective camera
  86964. */
  86965. edgesWidthScalerForPerspective: number;
  86966. protected _source: AbstractMesh;
  86967. protected _linesPositions: number[];
  86968. protected _linesNormals: number[];
  86969. protected _linesIndices: number[];
  86970. protected _epsilon: number;
  86971. protected _indicesCount: number;
  86972. protected _lineShader: ShaderMaterial;
  86973. protected _ib: DataBuffer;
  86974. protected _buffers: {
  86975. [key: string]: Nullable<VertexBuffer>;
  86976. };
  86977. protected _checkVerticesInsteadOfIndices: boolean;
  86978. private _meshRebuildObserver;
  86979. private _meshDisposeObserver;
  86980. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86981. isEnabled: boolean;
  86982. /**
  86983. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86984. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86985. * @param source Mesh used to create edges
  86986. * @param epsilon sum of angles in adjacency to check for edge
  86987. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86988. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86989. */
  86990. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86991. protected _prepareRessources(): void;
  86992. /** @hidden */
  86993. _rebuild(): void;
  86994. /**
  86995. * Releases the required resources for the edges renderer
  86996. */
  86997. dispose(): void;
  86998. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86999. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87000. /**
  87001. * Checks if the pair of p0 and p1 is en edge
  87002. * @param faceIndex
  87003. * @param edge
  87004. * @param faceNormals
  87005. * @param p0
  87006. * @param p1
  87007. * @private
  87008. */
  87009. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87010. /**
  87011. * push line into the position, normal and index buffer
  87012. * @protected
  87013. */
  87014. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87015. /**
  87016. * Generates lines edges from adjacencjes
  87017. * @private
  87018. */
  87019. _generateEdgesLines(): void;
  87020. /**
  87021. * Checks wether or not the edges renderer is ready to render.
  87022. * @return true if ready, otherwise false.
  87023. */
  87024. isReady(): boolean;
  87025. /**
  87026. * Renders the edges of the attached mesh,
  87027. */
  87028. render(): void;
  87029. }
  87030. /**
  87031. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87032. */
  87033. export class LineEdgesRenderer extends EdgesRenderer {
  87034. /**
  87035. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87036. * @param source LineMesh used to generate edges
  87037. * @param epsilon not important (specified angle for edge detection)
  87038. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87039. */
  87040. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87041. /**
  87042. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87043. */
  87044. _generateEdgesLines(): void;
  87045. }
  87046. }
  87047. declare module BABYLON {
  87048. /**
  87049. * This represents the object necessary to create a rendering group.
  87050. * This is exclusively used and created by the rendering manager.
  87051. * To modify the behavior, you use the available helpers in your scene or meshes.
  87052. * @hidden
  87053. */
  87054. export class RenderingGroup {
  87055. index: number;
  87056. private static _zeroVector;
  87057. private _scene;
  87058. private _opaqueSubMeshes;
  87059. private _transparentSubMeshes;
  87060. private _alphaTestSubMeshes;
  87061. private _depthOnlySubMeshes;
  87062. private _particleSystems;
  87063. private _spriteManagers;
  87064. private _opaqueSortCompareFn;
  87065. private _alphaTestSortCompareFn;
  87066. private _transparentSortCompareFn;
  87067. private _renderOpaque;
  87068. private _renderAlphaTest;
  87069. private _renderTransparent;
  87070. /** @hidden */
  87071. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87072. onBeforeTransparentRendering: () => void;
  87073. /**
  87074. * Set the opaque sort comparison function.
  87075. * If null the sub meshes will be render in the order they were created
  87076. */
  87077. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87078. /**
  87079. * Set the alpha test sort comparison function.
  87080. * If null the sub meshes will be render in the order they were created
  87081. */
  87082. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87083. /**
  87084. * Set the transparent sort comparison function.
  87085. * If null the sub meshes will be render in the order they were created
  87086. */
  87087. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87088. /**
  87089. * Creates a new rendering group.
  87090. * @param index The rendering group index
  87091. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87092. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87093. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87094. */
  87095. 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>);
  87096. /**
  87097. * Render all the sub meshes contained in the group.
  87098. * @param customRenderFunction Used to override the default render behaviour of the group.
  87099. * @returns true if rendered some submeshes.
  87100. */
  87101. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87102. /**
  87103. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87104. * @param subMeshes The submeshes to render
  87105. */
  87106. private renderOpaqueSorted;
  87107. /**
  87108. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87109. * @param subMeshes The submeshes to render
  87110. */
  87111. private renderAlphaTestSorted;
  87112. /**
  87113. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87114. * @param subMeshes The submeshes to render
  87115. */
  87116. private renderTransparentSorted;
  87117. /**
  87118. * Renders the submeshes in a specified order.
  87119. * @param subMeshes The submeshes to sort before render
  87120. * @param sortCompareFn The comparison function use to sort
  87121. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87122. * @param transparent Specifies to activate blending if true
  87123. */
  87124. private static renderSorted;
  87125. /**
  87126. * Renders the submeshes in the order they were dispatched (no sort applied).
  87127. * @param subMeshes The submeshes to render
  87128. */
  87129. private static renderUnsorted;
  87130. /**
  87131. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87132. * are rendered back to front if in the same alpha index.
  87133. *
  87134. * @param a The first submesh
  87135. * @param b The second submesh
  87136. * @returns The result of the comparison
  87137. */
  87138. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87139. /**
  87140. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87141. * are rendered back to front.
  87142. *
  87143. * @param a The first submesh
  87144. * @param b The second submesh
  87145. * @returns The result of the comparison
  87146. */
  87147. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87148. /**
  87149. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87150. * are rendered front to back (prevent overdraw).
  87151. *
  87152. * @param a The first submesh
  87153. * @param b The second submesh
  87154. * @returns The result of the comparison
  87155. */
  87156. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87157. /**
  87158. * Resets the different lists of submeshes to prepare a new frame.
  87159. */
  87160. prepare(): void;
  87161. dispose(): void;
  87162. /**
  87163. * Inserts the submesh in its correct queue depending on its material.
  87164. * @param subMesh The submesh to dispatch
  87165. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87166. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87167. */
  87168. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87169. dispatchSprites(spriteManager: ISpriteManager): void;
  87170. dispatchParticles(particleSystem: IParticleSystem): void;
  87171. private _renderParticles;
  87172. private _renderSprites;
  87173. }
  87174. }
  87175. declare module BABYLON {
  87176. /**
  87177. * Interface describing the different options available in the rendering manager
  87178. * regarding Auto Clear between groups.
  87179. */
  87180. export interface IRenderingManagerAutoClearSetup {
  87181. /**
  87182. * Defines whether or not autoclear is enable.
  87183. */
  87184. autoClear: boolean;
  87185. /**
  87186. * Defines whether or not to autoclear the depth buffer.
  87187. */
  87188. depth: boolean;
  87189. /**
  87190. * Defines whether or not to autoclear the stencil buffer.
  87191. */
  87192. stencil: boolean;
  87193. }
  87194. /**
  87195. * This class is used by the onRenderingGroupObservable
  87196. */
  87197. export class RenderingGroupInfo {
  87198. /**
  87199. * The Scene that being rendered
  87200. */
  87201. scene: Scene;
  87202. /**
  87203. * The camera currently used for the rendering pass
  87204. */
  87205. camera: Nullable<Camera>;
  87206. /**
  87207. * The ID of the renderingGroup being processed
  87208. */
  87209. renderingGroupId: number;
  87210. }
  87211. /**
  87212. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87213. * It is enable to manage the different groups as well as the different necessary sort functions.
  87214. * This should not be used directly aside of the few static configurations
  87215. */
  87216. export class RenderingManager {
  87217. /**
  87218. * The max id used for rendering groups (not included)
  87219. */
  87220. static MAX_RENDERINGGROUPS: number;
  87221. /**
  87222. * The min id used for rendering groups (included)
  87223. */
  87224. static MIN_RENDERINGGROUPS: number;
  87225. /**
  87226. * Used to globally prevent autoclearing scenes.
  87227. */
  87228. static AUTOCLEAR: boolean;
  87229. /**
  87230. * @hidden
  87231. */
  87232. _useSceneAutoClearSetup: boolean;
  87233. private _scene;
  87234. private _renderingGroups;
  87235. private _depthStencilBufferAlreadyCleaned;
  87236. private _autoClearDepthStencil;
  87237. private _customOpaqueSortCompareFn;
  87238. private _customAlphaTestSortCompareFn;
  87239. private _customTransparentSortCompareFn;
  87240. private _renderingGroupInfo;
  87241. /**
  87242. * Instantiates a new rendering group for a particular scene
  87243. * @param scene Defines the scene the groups belongs to
  87244. */
  87245. constructor(scene: Scene);
  87246. private _clearDepthStencilBuffer;
  87247. /**
  87248. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87249. * @hidden
  87250. */
  87251. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87252. /**
  87253. * Resets the different information of the group to prepare a new frame
  87254. * @hidden
  87255. */
  87256. reset(): void;
  87257. /**
  87258. * Dispose and release the group and its associated resources.
  87259. * @hidden
  87260. */
  87261. dispose(): void;
  87262. /**
  87263. * Clear the info related to rendering groups preventing retention points during dispose.
  87264. */
  87265. freeRenderingGroups(): void;
  87266. private _prepareRenderingGroup;
  87267. /**
  87268. * Add a sprite manager to the rendering manager in order to render it this frame.
  87269. * @param spriteManager Define the sprite manager to render
  87270. */
  87271. dispatchSprites(spriteManager: ISpriteManager): void;
  87272. /**
  87273. * Add a particle system to the rendering manager in order to render it this frame.
  87274. * @param particleSystem Define the particle system to render
  87275. */
  87276. dispatchParticles(particleSystem: IParticleSystem): void;
  87277. /**
  87278. * Add a submesh to the manager in order to render it this frame
  87279. * @param subMesh The submesh to dispatch
  87280. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87281. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87282. */
  87283. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87284. /**
  87285. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87286. * This allowed control for front to back rendering or reversly depending of the special needs.
  87287. *
  87288. * @param renderingGroupId The rendering group id corresponding to its index
  87289. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87290. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87291. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87292. */
  87293. 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;
  87294. /**
  87295. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87296. *
  87297. * @param renderingGroupId The rendering group id corresponding to its index
  87298. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87299. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87300. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87301. */
  87302. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87303. /**
  87304. * Gets the current auto clear configuration for one rendering group of the rendering
  87305. * manager.
  87306. * @param index the rendering group index to get the information for
  87307. * @returns The auto clear setup for the requested rendering group
  87308. */
  87309. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87310. }
  87311. }
  87312. declare module BABYLON {
  87313. /**
  87314. * This Helps creating a texture that will be created from a camera in your scene.
  87315. * It is basically a dynamic texture that could be used to create special effects for instance.
  87316. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87317. */
  87318. export class RenderTargetTexture extends Texture {
  87319. isCube: boolean;
  87320. /**
  87321. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87322. */
  87323. static readonly REFRESHRATE_RENDER_ONCE: number;
  87324. /**
  87325. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87326. */
  87327. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87328. /**
  87329. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87330. * the central point of your effect and can save a lot of performances.
  87331. */
  87332. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87333. /**
  87334. * Use this predicate to dynamically define the list of mesh you want to render.
  87335. * If set, the renderList property will be overwritten.
  87336. */
  87337. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87338. private _renderList;
  87339. /**
  87340. * Use this list to define the list of mesh you want to render.
  87341. */
  87342. renderList: Nullable<Array<AbstractMesh>>;
  87343. private _hookArray;
  87344. /**
  87345. * Define if particles should be rendered in your texture.
  87346. */
  87347. renderParticles: boolean;
  87348. /**
  87349. * Define if sprites should be rendered in your texture.
  87350. */
  87351. renderSprites: boolean;
  87352. /**
  87353. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87354. */
  87355. coordinatesMode: number;
  87356. /**
  87357. * Define the camera used to render the texture.
  87358. */
  87359. activeCamera: Nullable<Camera>;
  87360. /**
  87361. * Override the render function of the texture with your own one.
  87362. */
  87363. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87364. /**
  87365. * Define if camera post processes should be use while rendering the texture.
  87366. */
  87367. useCameraPostProcesses: boolean;
  87368. /**
  87369. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87370. */
  87371. ignoreCameraViewport: boolean;
  87372. private _postProcessManager;
  87373. private _postProcesses;
  87374. private _resizeObserver;
  87375. /**
  87376. * An event triggered when the texture is unbind.
  87377. */
  87378. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87379. /**
  87380. * An event triggered when the texture is unbind.
  87381. */
  87382. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87383. private _onAfterUnbindObserver;
  87384. /**
  87385. * Set a after unbind callback in the texture.
  87386. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87387. */
  87388. onAfterUnbind: () => void;
  87389. /**
  87390. * An event triggered before rendering the texture
  87391. */
  87392. onBeforeRenderObservable: Observable<number>;
  87393. private _onBeforeRenderObserver;
  87394. /**
  87395. * Set a before render callback in the texture.
  87396. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87397. */
  87398. onBeforeRender: (faceIndex: number) => void;
  87399. /**
  87400. * An event triggered after rendering the texture
  87401. */
  87402. onAfterRenderObservable: Observable<number>;
  87403. private _onAfterRenderObserver;
  87404. /**
  87405. * Set a after render callback in the texture.
  87406. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87407. */
  87408. onAfterRender: (faceIndex: number) => void;
  87409. /**
  87410. * An event triggered after the texture clear
  87411. */
  87412. onClearObservable: Observable<Engine>;
  87413. private _onClearObserver;
  87414. /**
  87415. * Set a clear callback in the texture.
  87416. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87417. */
  87418. onClear: (Engine: Engine) => void;
  87419. /**
  87420. * An event triggered when the texture is resized.
  87421. */
  87422. onResizeObservable: Observable<RenderTargetTexture>;
  87423. /**
  87424. * Define the clear color of the Render Target if it should be different from the scene.
  87425. */
  87426. clearColor: Color4;
  87427. protected _size: number | {
  87428. width: number;
  87429. height: number;
  87430. };
  87431. protected _initialSizeParameter: number | {
  87432. width: number;
  87433. height: number;
  87434. } | {
  87435. ratio: number;
  87436. };
  87437. protected _sizeRatio: Nullable<number>;
  87438. /** @hidden */
  87439. _generateMipMaps: boolean;
  87440. protected _renderingManager: RenderingManager;
  87441. /** @hidden */
  87442. _waitingRenderList: string[];
  87443. protected _doNotChangeAspectRatio: boolean;
  87444. protected _currentRefreshId: number;
  87445. protected _refreshRate: number;
  87446. protected _textureMatrix: Matrix;
  87447. protected _samples: number;
  87448. protected _renderTargetOptions: RenderTargetCreationOptions;
  87449. /**
  87450. * Gets render target creation options that were used.
  87451. */
  87452. readonly renderTargetOptions: RenderTargetCreationOptions;
  87453. protected _engine: Engine;
  87454. protected _onRatioRescale(): void;
  87455. /**
  87456. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87457. * It must define where the camera used to render the texture is set
  87458. */
  87459. boundingBoxPosition: Vector3;
  87460. private _boundingBoxSize;
  87461. /**
  87462. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87463. * When defined, the cubemap will switch to local mode
  87464. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87465. * @example https://www.babylonjs-playground.com/#RNASML
  87466. */
  87467. boundingBoxSize: Vector3;
  87468. /**
  87469. * In case the RTT has been created with a depth texture, get the associated
  87470. * depth texture.
  87471. * Otherwise, return null.
  87472. */
  87473. depthStencilTexture: Nullable<InternalTexture>;
  87474. /**
  87475. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87476. * or used a shadow, depth texture...
  87477. * @param name The friendly name of the texture
  87478. * @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)
  87479. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87480. * @param generateMipMaps True if mip maps need to be generated after render.
  87481. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87482. * @param type The type of the buffer in the RTT (int, half float, float...)
  87483. * @param isCube True if a cube texture needs to be created
  87484. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87485. * @param generateDepthBuffer True to generate a depth buffer
  87486. * @param generateStencilBuffer True to generate a stencil buffer
  87487. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87488. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87489. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87490. */
  87491. constructor(name: string, size: number | {
  87492. width: number;
  87493. height: number;
  87494. } | {
  87495. ratio: number;
  87496. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87497. /**
  87498. * Creates a depth stencil texture.
  87499. * This is only available in WebGL 2 or with the depth texture extension available.
  87500. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87501. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87502. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87503. */
  87504. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87505. private _processSizeParameter;
  87506. /**
  87507. * Define the number of samples to use in case of MSAA.
  87508. * It defaults to one meaning no MSAA has been enabled.
  87509. */
  87510. samples: number;
  87511. /**
  87512. * Resets the refresh counter of the texture and start bak from scratch.
  87513. * Could be useful to regenerate the texture if it is setup to render only once.
  87514. */
  87515. resetRefreshCounter(): void;
  87516. /**
  87517. * Define the refresh rate of the texture or the rendering frequency.
  87518. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87519. */
  87520. refreshRate: number;
  87521. /**
  87522. * Adds a post process to the render target rendering passes.
  87523. * @param postProcess define the post process to add
  87524. */
  87525. addPostProcess(postProcess: PostProcess): void;
  87526. /**
  87527. * Clear all the post processes attached to the render target
  87528. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87529. */
  87530. clearPostProcesses(dispose?: boolean): void;
  87531. /**
  87532. * Remove one of the post process from the list of attached post processes to the texture
  87533. * @param postProcess define the post process to remove from the list
  87534. */
  87535. removePostProcess(postProcess: PostProcess): void;
  87536. /** @hidden */
  87537. _shouldRender(): boolean;
  87538. /**
  87539. * Gets the actual render size of the texture.
  87540. * @returns the width of the render size
  87541. */
  87542. getRenderSize(): number;
  87543. /**
  87544. * Gets the actual render width of the texture.
  87545. * @returns the width of the render size
  87546. */
  87547. getRenderWidth(): number;
  87548. /**
  87549. * Gets the actual render height of the texture.
  87550. * @returns the height of the render size
  87551. */
  87552. getRenderHeight(): number;
  87553. /**
  87554. * Get if the texture can be rescaled or not.
  87555. */
  87556. readonly canRescale: boolean;
  87557. /**
  87558. * Resize the texture using a ratio.
  87559. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87560. */
  87561. scale(ratio: number): void;
  87562. /**
  87563. * Get the texture reflection matrix used to rotate/transform the reflection.
  87564. * @returns the reflection matrix
  87565. */
  87566. getReflectionTextureMatrix(): Matrix;
  87567. /**
  87568. * Resize the texture to a new desired size.
  87569. * Be carrefull as it will recreate all the data in the new texture.
  87570. * @param size Define the new size. It can be:
  87571. * - a number for squared texture,
  87572. * - an object containing { width: number, height: number }
  87573. * - or an object containing a ratio { ratio: number }
  87574. */
  87575. resize(size: number | {
  87576. width: number;
  87577. height: number;
  87578. } | {
  87579. ratio: number;
  87580. }): void;
  87581. /**
  87582. * Renders all the objects from the render list into the texture.
  87583. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87584. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87585. */
  87586. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87587. private _bestReflectionRenderTargetDimension;
  87588. /**
  87589. * @hidden
  87590. * @param faceIndex face index to bind to if this is a cubetexture
  87591. */
  87592. _bindFrameBuffer(faceIndex?: number): void;
  87593. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87594. private renderToTarget;
  87595. /**
  87596. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87597. * This allowed control for front to back rendering or reversly depending of the special needs.
  87598. *
  87599. * @param renderingGroupId The rendering group id corresponding to its index
  87600. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87601. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87602. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87603. */
  87604. 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;
  87605. /**
  87606. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87607. *
  87608. * @param renderingGroupId The rendering group id corresponding to its index
  87609. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87610. */
  87611. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87612. /**
  87613. * Clones the texture.
  87614. * @returns the cloned texture
  87615. */
  87616. clone(): RenderTargetTexture;
  87617. /**
  87618. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87619. * @returns The JSON representation of the texture
  87620. */
  87621. serialize(): any;
  87622. /**
  87623. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87624. */
  87625. disposeFramebufferObjects(): void;
  87626. /**
  87627. * Dispose the texture and release its associated resources.
  87628. */
  87629. dispose(): void;
  87630. /** @hidden */
  87631. _rebuild(): void;
  87632. /**
  87633. * Clear the info related to rendering groups preventing retention point in material dispose.
  87634. */
  87635. freeRenderingGroups(): void;
  87636. /**
  87637. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87638. * @returns the view count
  87639. */
  87640. getViewCount(): number;
  87641. }
  87642. }
  87643. declare module BABYLON {
  87644. /**
  87645. * Options for compiling materials.
  87646. */
  87647. export interface IMaterialCompilationOptions {
  87648. /**
  87649. * Defines whether clip planes are enabled.
  87650. */
  87651. clipPlane: boolean;
  87652. /**
  87653. * Defines whether instances are enabled.
  87654. */
  87655. useInstances: boolean;
  87656. }
  87657. /**
  87658. * Base class for the main features of a material in Babylon.js
  87659. */
  87660. export class Material implements IAnimatable {
  87661. /**
  87662. * Returns the triangle fill mode
  87663. */
  87664. static readonly TriangleFillMode: number;
  87665. /**
  87666. * Returns the wireframe mode
  87667. */
  87668. static readonly WireFrameFillMode: number;
  87669. /**
  87670. * Returns the point fill mode
  87671. */
  87672. static readonly PointFillMode: number;
  87673. /**
  87674. * Returns the point list draw mode
  87675. */
  87676. static readonly PointListDrawMode: number;
  87677. /**
  87678. * Returns the line list draw mode
  87679. */
  87680. static readonly LineListDrawMode: number;
  87681. /**
  87682. * Returns the line loop draw mode
  87683. */
  87684. static readonly LineLoopDrawMode: number;
  87685. /**
  87686. * Returns the line strip draw mode
  87687. */
  87688. static readonly LineStripDrawMode: number;
  87689. /**
  87690. * Returns the triangle strip draw mode
  87691. */
  87692. static readonly TriangleStripDrawMode: number;
  87693. /**
  87694. * Returns the triangle fan draw mode
  87695. */
  87696. static readonly TriangleFanDrawMode: number;
  87697. /**
  87698. * Stores the clock-wise side orientation
  87699. */
  87700. static readonly ClockWiseSideOrientation: number;
  87701. /**
  87702. * Stores the counter clock-wise side orientation
  87703. */
  87704. static readonly CounterClockWiseSideOrientation: number;
  87705. /**
  87706. * The dirty texture flag value
  87707. */
  87708. static readonly TextureDirtyFlag: number;
  87709. /**
  87710. * The dirty light flag value
  87711. */
  87712. static readonly LightDirtyFlag: number;
  87713. /**
  87714. * The dirty fresnel flag value
  87715. */
  87716. static readonly FresnelDirtyFlag: number;
  87717. /**
  87718. * The dirty attribute flag value
  87719. */
  87720. static readonly AttributesDirtyFlag: number;
  87721. /**
  87722. * The dirty misc flag value
  87723. */
  87724. static readonly MiscDirtyFlag: number;
  87725. /**
  87726. * The all dirty flag value
  87727. */
  87728. static readonly AllDirtyFlag: number;
  87729. /**
  87730. * The ID of the material
  87731. */
  87732. id: string;
  87733. /**
  87734. * Gets or sets the unique id of the material
  87735. */
  87736. uniqueId: number;
  87737. /**
  87738. * The name of the material
  87739. */
  87740. name: string;
  87741. /**
  87742. * Gets or sets user defined metadata
  87743. */
  87744. metadata: any;
  87745. /**
  87746. * For internal use only. Please do not use.
  87747. */
  87748. reservedDataStore: any;
  87749. /**
  87750. * Specifies if the ready state should be checked on each call
  87751. */
  87752. checkReadyOnEveryCall: boolean;
  87753. /**
  87754. * Specifies if the ready state should be checked once
  87755. */
  87756. checkReadyOnlyOnce: boolean;
  87757. /**
  87758. * The state of the material
  87759. */
  87760. state: string;
  87761. /**
  87762. * The alpha value of the material
  87763. */
  87764. protected _alpha: number;
  87765. /**
  87766. * List of inspectable custom properties (used by the Inspector)
  87767. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87768. */
  87769. inspectableCustomProperties: IInspectable[];
  87770. /**
  87771. * Sets the alpha value of the material
  87772. */
  87773. /**
  87774. * Gets the alpha value of the material
  87775. */
  87776. alpha: number;
  87777. /**
  87778. * Specifies if back face culling is enabled
  87779. */
  87780. protected _backFaceCulling: boolean;
  87781. /**
  87782. * Sets the back-face culling state
  87783. */
  87784. /**
  87785. * Gets the back-face culling state
  87786. */
  87787. backFaceCulling: boolean;
  87788. /**
  87789. * Stores the value for side orientation
  87790. */
  87791. sideOrientation: number;
  87792. /**
  87793. * Callback triggered when the material is compiled
  87794. */
  87795. onCompiled: Nullable<(effect: Effect) => void>;
  87796. /**
  87797. * Callback triggered when an error occurs
  87798. */
  87799. onError: Nullable<(effect: Effect, errors: string) => void>;
  87800. /**
  87801. * Callback triggered to get the render target textures
  87802. */
  87803. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87804. /**
  87805. * Gets a boolean indicating that current material needs to register RTT
  87806. */
  87807. readonly hasRenderTargetTextures: boolean;
  87808. /**
  87809. * Specifies if the material should be serialized
  87810. */
  87811. doNotSerialize: boolean;
  87812. /**
  87813. * @hidden
  87814. */
  87815. _storeEffectOnSubMeshes: boolean;
  87816. /**
  87817. * Stores the animations for the material
  87818. */
  87819. animations: Nullable<Array<Animation>>;
  87820. /**
  87821. * An event triggered when the material is disposed
  87822. */
  87823. onDisposeObservable: Observable<Material>;
  87824. /**
  87825. * An observer which watches for dispose events
  87826. */
  87827. private _onDisposeObserver;
  87828. private _onUnBindObservable;
  87829. /**
  87830. * Called during a dispose event
  87831. */
  87832. onDispose: () => void;
  87833. private _onBindObservable;
  87834. /**
  87835. * An event triggered when the material is bound
  87836. */
  87837. readonly onBindObservable: Observable<AbstractMesh>;
  87838. /**
  87839. * An observer which watches for bind events
  87840. */
  87841. private _onBindObserver;
  87842. /**
  87843. * Called during a bind event
  87844. */
  87845. onBind: (Mesh: AbstractMesh) => void;
  87846. /**
  87847. * An event triggered when the material is unbound
  87848. */
  87849. readonly onUnBindObservable: Observable<Material>;
  87850. /**
  87851. * Stores the value of the alpha mode
  87852. */
  87853. private _alphaMode;
  87854. /**
  87855. * Sets the value of the alpha mode.
  87856. *
  87857. * | Value | Type | Description |
  87858. * | --- | --- | --- |
  87859. * | 0 | ALPHA_DISABLE | |
  87860. * | 1 | ALPHA_ADD | |
  87861. * | 2 | ALPHA_COMBINE | |
  87862. * | 3 | ALPHA_SUBTRACT | |
  87863. * | 4 | ALPHA_MULTIPLY | |
  87864. * | 5 | ALPHA_MAXIMIZED | |
  87865. * | 6 | ALPHA_ONEONE | |
  87866. * | 7 | ALPHA_PREMULTIPLIED | |
  87867. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87868. * | 9 | ALPHA_INTERPOLATE | |
  87869. * | 10 | ALPHA_SCREENMODE | |
  87870. *
  87871. */
  87872. /**
  87873. * Gets the value of the alpha mode
  87874. */
  87875. alphaMode: number;
  87876. /**
  87877. * Stores the state of the need depth pre-pass value
  87878. */
  87879. private _needDepthPrePass;
  87880. /**
  87881. * Sets the need depth pre-pass value
  87882. */
  87883. /**
  87884. * Gets the depth pre-pass value
  87885. */
  87886. needDepthPrePass: boolean;
  87887. /**
  87888. * Specifies if depth writing should be disabled
  87889. */
  87890. disableDepthWrite: boolean;
  87891. /**
  87892. * Specifies if depth writing should be forced
  87893. */
  87894. forceDepthWrite: boolean;
  87895. /**
  87896. * Specifies if there should be a separate pass for culling
  87897. */
  87898. separateCullingPass: boolean;
  87899. /**
  87900. * Stores the state specifing if fog should be enabled
  87901. */
  87902. private _fogEnabled;
  87903. /**
  87904. * Sets the state for enabling fog
  87905. */
  87906. /**
  87907. * Gets the value of the fog enabled state
  87908. */
  87909. fogEnabled: boolean;
  87910. /**
  87911. * Stores the size of points
  87912. */
  87913. pointSize: number;
  87914. /**
  87915. * Stores the z offset value
  87916. */
  87917. zOffset: number;
  87918. /**
  87919. * Gets a value specifying if wireframe mode is enabled
  87920. */
  87921. /**
  87922. * Sets the state of wireframe mode
  87923. */
  87924. wireframe: boolean;
  87925. /**
  87926. * Gets the value specifying if point clouds are enabled
  87927. */
  87928. /**
  87929. * Sets the state of point cloud mode
  87930. */
  87931. pointsCloud: boolean;
  87932. /**
  87933. * Gets the material fill mode
  87934. */
  87935. /**
  87936. * Sets the material fill mode
  87937. */
  87938. fillMode: number;
  87939. /**
  87940. * @hidden
  87941. * Stores the effects for the material
  87942. */
  87943. _effect: Nullable<Effect>;
  87944. /**
  87945. * @hidden
  87946. * Specifies if the material was previously ready
  87947. */
  87948. _wasPreviouslyReady: boolean;
  87949. /**
  87950. * Specifies if uniform buffers should be used
  87951. */
  87952. private _useUBO;
  87953. /**
  87954. * Stores a reference to the scene
  87955. */
  87956. private _scene;
  87957. /**
  87958. * Stores the fill mode state
  87959. */
  87960. private _fillMode;
  87961. /**
  87962. * Specifies if the depth write state should be cached
  87963. */
  87964. private _cachedDepthWriteState;
  87965. /**
  87966. * Stores the uniform buffer
  87967. */
  87968. protected _uniformBuffer: UniformBuffer;
  87969. /** @hidden */
  87970. _indexInSceneMaterialArray: number;
  87971. /** @hidden */
  87972. meshMap: Nullable<{
  87973. [id: string]: AbstractMesh | undefined;
  87974. }>;
  87975. /**
  87976. * Creates a material instance
  87977. * @param name defines the name of the material
  87978. * @param scene defines the scene to reference
  87979. * @param doNotAdd specifies if the material should be added to the scene
  87980. */
  87981. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87982. /**
  87983. * Returns a string representation of the current material
  87984. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87985. * @returns a string with material information
  87986. */
  87987. toString(fullDetails?: boolean): string;
  87988. /**
  87989. * Gets the class name of the material
  87990. * @returns a string with the class name of the material
  87991. */
  87992. getClassName(): string;
  87993. /**
  87994. * Specifies if updates for the material been locked
  87995. */
  87996. readonly isFrozen: boolean;
  87997. /**
  87998. * Locks updates for the material
  87999. */
  88000. freeze(): void;
  88001. /**
  88002. * Unlocks updates for the material
  88003. */
  88004. unfreeze(): void;
  88005. /**
  88006. * Specifies if the material is ready to be used
  88007. * @param mesh defines the mesh to check
  88008. * @param useInstances specifies if instances should be used
  88009. * @returns a boolean indicating if the material is ready to be used
  88010. */
  88011. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88012. /**
  88013. * Specifies that the submesh is ready to be used
  88014. * @param mesh defines the mesh to check
  88015. * @param subMesh defines which submesh to check
  88016. * @param useInstances specifies that instances should be used
  88017. * @returns a boolean indicating that the submesh is ready or not
  88018. */
  88019. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88020. /**
  88021. * Returns the material effect
  88022. * @returns the effect associated with the material
  88023. */
  88024. getEffect(): Nullable<Effect>;
  88025. /**
  88026. * Returns the current scene
  88027. * @returns a Scene
  88028. */
  88029. getScene(): Scene;
  88030. /**
  88031. * Specifies if the material will require alpha blending
  88032. * @returns a boolean specifying if alpha blending is needed
  88033. */
  88034. needAlphaBlending(): boolean;
  88035. /**
  88036. * Specifies if the mesh will require alpha blending
  88037. * @param mesh defines the mesh to check
  88038. * @returns a boolean specifying if alpha blending is needed for the mesh
  88039. */
  88040. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88041. /**
  88042. * Specifies if this material should be rendered in alpha test mode
  88043. * @returns a boolean specifying if an alpha test is needed.
  88044. */
  88045. needAlphaTesting(): boolean;
  88046. /**
  88047. * Gets the texture used for the alpha test
  88048. * @returns the texture to use for alpha testing
  88049. */
  88050. getAlphaTestTexture(): Nullable<BaseTexture>;
  88051. /**
  88052. * Marks the material to indicate that it needs to be re-calculated
  88053. */
  88054. markDirty(): void;
  88055. /** @hidden */
  88056. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88057. /**
  88058. * Binds the material to the mesh
  88059. * @param world defines the world transformation matrix
  88060. * @param mesh defines the mesh to bind the material to
  88061. */
  88062. bind(world: Matrix, mesh?: Mesh): void;
  88063. /**
  88064. * Binds the submesh to the material
  88065. * @param world defines the world transformation matrix
  88066. * @param mesh defines the mesh containing the submesh
  88067. * @param subMesh defines the submesh to bind the material to
  88068. */
  88069. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88070. /**
  88071. * Binds the world matrix to the material
  88072. * @param world defines the world transformation matrix
  88073. */
  88074. bindOnlyWorldMatrix(world: Matrix): void;
  88075. /**
  88076. * Binds the scene's uniform buffer to the effect.
  88077. * @param effect defines the effect to bind to the scene uniform buffer
  88078. * @param sceneUbo defines the uniform buffer storing scene data
  88079. */
  88080. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88081. /**
  88082. * Binds the view matrix to the effect
  88083. * @param effect defines the effect to bind the view matrix to
  88084. */
  88085. bindView(effect: Effect): void;
  88086. /**
  88087. * Binds the view projection matrix to the effect
  88088. * @param effect defines the effect to bind the view projection matrix to
  88089. */
  88090. bindViewProjection(effect: Effect): void;
  88091. /**
  88092. * Specifies if material alpha testing should be turned on for the mesh
  88093. * @param mesh defines the mesh to check
  88094. */
  88095. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88096. /**
  88097. * Processes to execute after binding the material to a mesh
  88098. * @param mesh defines the rendered mesh
  88099. */
  88100. protected _afterBind(mesh?: Mesh): void;
  88101. /**
  88102. * Unbinds the material from the mesh
  88103. */
  88104. unbind(): void;
  88105. /**
  88106. * Gets the active textures from the material
  88107. * @returns an array of textures
  88108. */
  88109. getActiveTextures(): BaseTexture[];
  88110. /**
  88111. * Specifies if the material uses a texture
  88112. * @param texture defines the texture to check against the material
  88113. * @returns a boolean specifying if the material uses the texture
  88114. */
  88115. hasTexture(texture: BaseTexture): boolean;
  88116. /**
  88117. * Makes a duplicate of the material, and gives it a new name
  88118. * @param name defines the new name for the duplicated material
  88119. * @returns the cloned material
  88120. */
  88121. clone(name: string): Nullable<Material>;
  88122. /**
  88123. * Gets the meshes bound to the material
  88124. * @returns an array of meshes bound to the material
  88125. */
  88126. getBindedMeshes(): AbstractMesh[];
  88127. /**
  88128. * Force shader compilation
  88129. * @param mesh defines the mesh associated with this material
  88130. * @param onCompiled defines a function to execute once the material is compiled
  88131. * @param options defines the options to configure the compilation
  88132. * @param onError defines a function to execute if the material fails compiling
  88133. */
  88134. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88135. /**
  88136. * Force shader compilation
  88137. * @param mesh defines the mesh that will use this material
  88138. * @param options defines additional options for compiling the shaders
  88139. * @returns a promise that resolves when the compilation completes
  88140. */
  88141. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88142. private static readonly _AllDirtyCallBack;
  88143. private static readonly _ImageProcessingDirtyCallBack;
  88144. private static readonly _TextureDirtyCallBack;
  88145. private static readonly _FresnelDirtyCallBack;
  88146. private static readonly _MiscDirtyCallBack;
  88147. private static readonly _LightsDirtyCallBack;
  88148. private static readonly _AttributeDirtyCallBack;
  88149. private static _FresnelAndMiscDirtyCallBack;
  88150. private static _TextureAndMiscDirtyCallBack;
  88151. private static readonly _DirtyCallbackArray;
  88152. private static readonly _RunDirtyCallBacks;
  88153. /**
  88154. * Marks a define in the material to indicate that it needs to be re-computed
  88155. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88156. */
  88157. markAsDirty(flag: number): void;
  88158. /**
  88159. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88160. * @param func defines a function which checks material defines against the submeshes
  88161. */
  88162. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88163. /**
  88164. * Indicates that we need to re-calculated for all submeshes
  88165. */
  88166. protected _markAllSubMeshesAsAllDirty(): void;
  88167. /**
  88168. * Indicates that image processing needs to be re-calculated for all submeshes
  88169. */
  88170. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88171. /**
  88172. * Indicates that textures need to be re-calculated for all submeshes
  88173. */
  88174. protected _markAllSubMeshesAsTexturesDirty(): void;
  88175. /**
  88176. * Indicates that fresnel needs to be re-calculated for all submeshes
  88177. */
  88178. protected _markAllSubMeshesAsFresnelDirty(): void;
  88179. /**
  88180. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88181. */
  88182. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88183. /**
  88184. * Indicates that lights need to be re-calculated for all submeshes
  88185. */
  88186. protected _markAllSubMeshesAsLightsDirty(): void;
  88187. /**
  88188. * Indicates that attributes need to be re-calculated for all submeshes
  88189. */
  88190. protected _markAllSubMeshesAsAttributesDirty(): void;
  88191. /**
  88192. * Indicates that misc needs to be re-calculated for all submeshes
  88193. */
  88194. protected _markAllSubMeshesAsMiscDirty(): void;
  88195. /**
  88196. * Indicates that textures and misc need to be re-calculated for all submeshes
  88197. */
  88198. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88199. /**
  88200. * Disposes the material
  88201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88203. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88204. */
  88205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88206. /** @hidden */
  88207. private releaseVertexArrayObject;
  88208. /**
  88209. * Serializes this material
  88210. * @returns the serialized material object
  88211. */
  88212. serialize(): any;
  88213. /**
  88214. * Creates a material from parsed material data
  88215. * @param parsedMaterial defines parsed material data
  88216. * @param scene defines the hosting scene
  88217. * @param rootUrl defines the root URL to use to load textures
  88218. * @returns a new material
  88219. */
  88220. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88221. }
  88222. }
  88223. declare module BABYLON {
  88224. /**
  88225. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88226. * separate meshes. This can be use to improve performances.
  88227. * @see http://doc.babylonjs.com/how_to/multi_materials
  88228. */
  88229. export class MultiMaterial extends Material {
  88230. private _subMaterials;
  88231. /**
  88232. * Gets or Sets the list of Materials used within the multi material.
  88233. * They need to be ordered according to the submeshes order in the associated mesh
  88234. */
  88235. subMaterials: Nullable<Material>[];
  88236. /**
  88237. * Function used to align with Node.getChildren()
  88238. * @returns the list of Materials used within the multi material
  88239. */
  88240. getChildren(): Nullable<Material>[];
  88241. /**
  88242. * Instantiates a new Multi Material
  88243. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88244. * separate meshes. This can be use to improve performances.
  88245. * @see http://doc.babylonjs.com/how_to/multi_materials
  88246. * @param name Define the name in the scene
  88247. * @param scene Define the scene the material belongs to
  88248. */
  88249. constructor(name: string, scene: Scene);
  88250. private _hookArray;
  88251. /**
  88252. * Get one of the submaterial by its index in the submaterials array
  88253. * @param index The index to look the sub material at
  88254. * @returns The Material if the index has been defined
  88255. */
  88256. getSubMaterial(index: number): Nullable<Material>;
  88257. /**
  88258. * Get the list of active textures for the whole sub materials list.
  88259. * @returns All the textures that will be used during the rendering
  88260. */
  88261. getActiveTextures(): BaseTexture[];
  88262. /**
  88263. * Gets the current class name of the material e.g. "MultiMaterial"
  88264. * Mainly use in serialization.
  88265. * @returns the class name
  88266. */
  88267. getClassName(): string;
  88268. /**
  88269. * Checks if the material is ready to render the requested sub mesh
  88270. * @param mesh Define the mesh the submesh belongs to
  88271. * @param subMesh Define the sub mesh to look readyness for
  88272. * @param useInstances Define whether or not the material is used with instances
  88273. * @returns true if ready, otherwise false
  88274. */
  88275. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88276. /**
  88277. * Clones the current material and its related sub materials
  88278. * @param name Define the name of the newly cloned material
  88279. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88280. * @returns the cloned material
  88281. */
  88282. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88283. /**
  88284. * Serializes the materials into a JSON representation.
  88285. * @returns the JSON representation
  88286. */
  88287. serialize(): any;
  88288. /**
  88289. * Dispose the material and release its associated resources
  88290. * @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)
  88291. * @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)
  88292. * @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)
  88293. */
  88294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88295. /**
  88296. * Creates a MultiMaterial from parsed MultiMaterial data.
  88297. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88298. * @param scene defines the hosting scene
  88299. * @returns a new MultiMaterial
  88300. */
  88301. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88302. }
  88303. }
  88304. declare module BABYLON {
  88305. /**
  88306. * Base class for submeshes
  88307. */
  88308. export class BaseSubMesh {
  88309. /** @hidden */
  88310. _materialDefines: Nullable<MaterialDefines>;
  88311. /** @hidden */
  88312. _materialEffect: Nullable<Effect>;
  88313. /**
  88314. * Gets associated effect
  88315. */
  88316. readonly effect: Nullable<Effect>;
  88317. /**
  88318. * Sets associated effect (effect used to render this submesh)
  88319. * @param effect defines the effect to associate with
  88320. * @param defines defines the set of defines used to compile this effect
  88321. */
  88322. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88323. }
  88324. /**
  88325. * Defines a subdivision inside a mesh
  88326. */
  88327. export class SubMesh extends BaseSubMesh implements ICullable {
  88328. /** the material index to use */
  88329. materialIndex: number;
  88330. /** vertex index start */
  88331. verticesStart: number;
  88332. /** vertices count */
  88333. verticesCount: number;
  88334. /** index start */
  88335. indexStart: number;
  88336. /** indices count */
  88337. indexCount: number;
  88338. /** @hidden */
  88339. _linesIndexCount: number;
  88340. private _mesh;
  88341. private _renderingMesh;
  88342. private _boundingInfo;
  88343. private _linesIndexBuffer;
  88344. /** @hidden */
  88345. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88346. /** @hidden */
  88347. _trianglePlanes: Plane[];
  88348. /** @hidden */
  88349. _lastColliderTransformMatrix: Nullable<Matrix>;
  88350. /** @hidden */
  88351. _renderId: number;
  88352. /** @hidden */
  88353. _alphaIndex: number;
  88354. /** @hidden */
  88355. _distanceToCamera: number;
  88356. /** @hidden */
  88357. _id: number;
  88358. private _currentMaterial;
  88359. /**
  88360. * Add a new submesh to a mesh
  88361. * @param materialIndex defines the material index to use
  88362. * @param verticesStart defines vertex index start
  88363. * @param verticesCount defines vertices count
  88364. * @param indexStart defines index start
  88365. * @param indexCount defines indices count
  88366. * @param mesh defines the parent mesh
  88367. * @param renderingMesh defines an optional rendering mesh
  88368. * @param createBoundingBox defines if bounding box should be created for this submesh
  88369. * @returns the new submesh
  88370. */
  88371. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88372. /**
  88373. * Creates a new submesh
  88374. * @param materialIndex defines the material index to use
  88375. * @param verticesStart defines vertex index start
  88376. * @param verticesCount defines vertices count
  88377. * @param indexStart defines index start
  88378. * @param indexCount defines indices count
  88379. * @param mesh defines the parent mesh
  88380. * @param renderingMesh defines an optional rendering mesh
  88381. * @param createBoundingBox defines if bounding box should be created for this submesh
  88382. */
  88383. constructor(
  88384. /** the material index to use */
  88385. materialIndex: number,
  88386. /** vertex index start */
  88387. verticesStart: number,
  88388. /** vertices count */
  88389. verticesCount: number,
  88390. /** index start */
  88391. indexStart: number,
  88392. /** indices count */
  88393. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88394. /**
  88395. * Returns true if this submesh covers the entire parent mesh
  88396. * @ignorenaming
  88397. */
  88398. readonly IsGlobal: boolean;
  88399. /**
  88400. * Returns the submesh BoudingInfo object
  88401. * @returns current bounding info (or mesh's one if the submesh is global)
  88402. */
  88403. getBoundingInfo(): BoundingInfo;
  88404. /**
  88405. * Sets the submesh BoundingInfo
  88406. * @param boundingInfo defines the new bounding info to use
  88407. * @returns the SubMesh
  88408. */
  88409. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88410. /**
  88411. * Returns the mesh of the current submesh
  88412. * @return the parent mesh
  88413. */
  88414. getMesh(): AbstractMesh;
  88415. /**
  88416. * Returns the rendering mesh of the submesh
  88417. * @returns the rendering mesh (could be different from parent mesh)
  88418. */
  88419. getRenderingMesh(): Mesh;
  88420. /**
  88421. * Returns the submesh material
  88422. * @returns null or the current material
  88423. */
  88424. getMaterial(): Nullable<Material>;
  88425. /**
  88426. * Sets a new updated BoundingInfo object to the submesh
  88427. * @param data defines an optional position array to use to determine the bounding info
  88428. * @returns the SubMesh
  88429. */
  88430. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88431. /** @hidden */
  88432. _checkCollision(collider: Collider): boolean;
  88433. /**
  88434. * Updates the submesh BoundingInfo
  88435. * @param world defines the world matrix to use to update the bounding info
  88436. * @returns the submesh
  88437. */
  88438. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88439. /**
  88440. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88441. * @param frustumPlanes defines the frustum planes
  88442. * @returns true if the submesh is intersecting with the frustum
  88443. */
  88444. isInFrustum(frustumPlanes: Plane[]): boolean;
  88445. /**
  88446. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88447. * @param frustumPlanes defines the frustum planes
  88448. * @returns true if the submesh is inside the frustum
  88449. */
  88450. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88451. /**
  88452. * Renders the submesh
  88453. * @param enableAlphaMode defines if alpha needs to be used
  88454. * @returns the submesh
  88455. */
  88456. render(enableAlphaMode: boolean): SubMesh;
  88457. /**
  88458. * @hidden
  88459. */
  88460. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88461. /**
  88462. * Checks if the submesh intersects with a ray
  88463. * @param ray defines the ray to test
  88464. * @returns true is the passed ray intersects the submesh bounding box
  88465. */
  88466. canIntersects(ray: Ray): boolean;
  88467. /**
  88468. * Intersects current submesh with a ray
  88469. * @param ray defines the ray to test
  88470. * @param positions defines mesh's positions array
  88471. * @param indices defines mesh's indices array
  88472. * @param fastCheck defines if only bounding info should be used
  88473. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88474. * @returns intersection info or null if no intersection
  88475. */
  88476. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88477. /** @hidden */
  88478. private _intersectLines;
  88479. /** @hidden */
  88480. private _intersectUnIndexedLines;
  88481. /** @hidden */
  88482. private _intersectTriangles;
  88483. /** @hidden */
  88484. private _intersectUnIndexedTriangles;
  88485. /** @hidden */
  88486. _rebuild(): void;
  88487. /**
  88488. * Creates a new submesh from the passed mesh
  88489. * @param newMesh defines the new hosting mesh
  88490. * @param newRenderingMesh defines an optional rendering mesh
  88491. * @returns the new submesh
  88492. */
  88493. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88494. /**
  88495. * Release associated resources
  88496. */
  88497. dispose(): void;
  88498. /**
  88499. * Gets the class name
  88500. * @returns the string "SubMesh".
  88501. */
  88502. getClassName(): string;
  88503. /**
  88504. * Creates a new submesh from indices data
  88505. * @param materialIndex the index of the main mesh material
  88506. * @param startIndex the index where to start the copy in the mesh indices array
  88507. * @param indexCount the number of indices to copy then from the startIndex
  88508. * @param mesh the main mesh to create the submesh from
  88509. * @param renderingMesh the optional rendering mesh
  88510. * @returns a new submesh
  88511. */
  88512. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88513. }
  88514. }
  88515. declare module BABYLON {
  88516. /**
  88517. * Class used to represent data loading progression
  88518. */
  88519. export class SceneLoaderFlags {
  88520. private static _ForceFullSceneLoadingForIncremental;
  88521. private static _ShowLoadingScreen;
  88522. private static _CleanBoneMatrixWeights;
  88523. private static _loggingLevel;
  88524. /**
  88525. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88526. */
  88527. static ForceFullSceneLoadingForIncremental: boolean;
  88528. /**
  88529. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88530. */
  88531. static ShowLoadingScreen: boolean;
  88532. /**
  88533. * Defines the current logging level (while loading the scene)
  88534. * @ignorenaming
  88535. */
  88536. static loggingLevel: number;
  88537. /**
  88538. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88539. */
  88540. static CleanBoneMatrixWeights: boolean;
  88541. }
  88542. }
  88543. declare module BABYLON {
  88544. /**
  88545. * Class used to store geometry data (vertex buffers + index buffer)
  88546. */
  88547. export class Geometry implements IGetSetVerticesData {
  88548. /**
  88549. * Gets or sets the ID of the geometry
  88550. */
  88551. id: string;
  88552. /**
  88553. * Gets or sets the unique ID of the geometry
  88554. */
  88555. uniqueId: number;
  88556. /**
  88557. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88558. */
  88559. delayLoadState: number;
  88560. /**
  88561. * Gets the file containing the data to load when running in delay load state
  88562. */
  88563. delayLoadingFile: Nullable<string>;
  88564. /**
  88565. * Callback called when the geometry is updated
  88566. */
  88567. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88568. private _scene;
  88569. private _engine;
  88570. private _meshes;
  88571. private _totalVertices;
  88572. /** @hidden */
  88573. _indices: IndicesArray;
  88574. /** @hidden */
  88575. _vertexBuffers: {
  88576. [key: string]: VertexBuffer;
  88577. };
  88578. private _isDisposed;
  88579. private _extend;
  88580. private _boundingBias;
  88581. /** @hidden */
  88582. _delayInfo: Array<string>;
  88583. private _indexBuffer;
  88584. private _indexBufferIsUpdatable;
  88585. /** @hidden */
  88586. _boundingInfo: Nullable<BoundingInfo>;
  88587. /** @hidden */
  88588. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88589. /** @hidden */
  88590. _softwareSkinningFrameId: number;
  88591. private _vertexArrayObjects;
  88592. private _updatable;
  88593. /** @hidden */
  88594. _positions: Nullable<Vector3[]>;
  88595. /**
  88596. * 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
  88597. */
  88598. /**
  88599. * 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
  88600. */
  88601. boundingBias: Vector2;
  88602. /**
  88603. * Static function used to attach a new empty geometry to a mesh
  88604. * @param mesh defines the mesh to attach the geometry to
  88605. * @returns the new Geometry
  88606. */
  88607. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88608. /**
  88609. * Creates a new geometry
  88610. * @param id defines the unique ID
  88611. * @param scene defines the hosting scene
  88612. * @param vertexData defines the VertexData used to get geometry data
  88613. * @param updatable defines if geometry must be updatable (false by default)
  88614. * @param mesh defines the mesh that will be associated with the geometry
  88615. */
  88616. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88617. /**
  88618. * Gets the current extend of the geometry
  88619. */
  88620. readonly extend: {
  88621. minimum: Vector3;
  88622. maximum: Vector3;
  88623. };
  88624. /**
  88625. * Gets the hosting scene
  88626. * @returns the hosting Scene
  88627. */
  88628. getScene(): Scene;
  88629. /**
  88630. * Gets the hosting engine
  88631. * @returns the hosting Engine
  88632. */
  88633. getEngine(): Engine;
  88634. /**
  88635. * Defines if the geometry is ready to use
  88636. * @returns true if the geometry is ready to be used
  88637. */
  88638. isReady(): boolean;
  88639. /**
  88640. * Gets a value indicating that the geometry should not be serialized
  88641. */
  88642. readonly doNotSerialize: boolean;
  88643. /** @hidden */
  88644. _rebuild(): void;
  88645. /**
  88646. * Affects all geometry data in one call
  88647. * @param vertexData defines the geometry data
  88648. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88649. */
  88650. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88651. /**
  88652. * Set specific vertex data
  88653. * @param kind defines the data kind (Position, normal, etc...)
  88654. * @param data defines the vertex data to use
  88655. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88656. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88657. */
  88658. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88659. /**
  88660. * Removes a specific vertex data
  88661. * @param kind defines the data kind (Position, normal, etc...)
  88662. */
  88663. removeVerticesData(kind: string): void;
  88664. /**
  88665. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88666. * @param buffer defines the vertex buffer to use
  88667. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88668. */
  88669. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88670. /**
  88671. * Update a specific vertex buffer
  88672. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88673. * It will do nothing if the buffer is not updatable
  88674. * @param kind defines the data kind (Position, normal, etc...)
  88675. * @param data defines the data to use
  88676. * @param offset defines the offset in the target buffer where to store the data
  88677. * @param useBytes set to true if the offset is in bytes
  88678. */
  88679. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88680. /**
  88681. * Update a specific vertex buffer
  88682. * This function will create a new buffer if the current one is not updatable
  88683. * @param kind defines the data kind (Position, normal, etc...)
  88684. * @param data defines the data to use
  88685. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88686. */
  88687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88688. private _updateBoundingInfo;
  88689. /** @hidden */
  88690. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88691. /**
  88692. * Gets total number of vertices
  88693. * @returns the total number of vertices
  88694. */
  88695. getTotalVertices(): number;
  88696. /**
  88697. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88698. * @param kind defines the data kind (Position, normal, etc...)
  88699. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88700. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88701. * @returns a float array containing vertex data
  88702. */
  88703. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88704. /**
  88705. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88706. * @param kind defines the data kind (Position, normal, etc...)
  88707. * @returns true if the vertex buffer with the specified kind is updatable
  88708. */
  88709. isVertexBufferUpdatable(kind: string): boolean;
  88710. /**
  88711. * Gets a specific vertex buffer
  88712. * @param kind defines the data kind (Position, normal, etc...)
  88713. * @returns a VertexBuffer
  88714. */
  88715. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88716. /**
  88717. * Returns all vertex buffers
  88718. * @return an object holding all vertex buffers indexed by kind
  88719. */
  88720. getVertexBuffers(): Nullable<{
  88721. [key: string]: VertexBuffer;
  88722. }>;
  88723. /**
  88724. * Gets a boolean indicating if specific vertex buffer is present
  88725. * @param kind defines the data kind (Position, normal, etc...)
  88726. * @returns true if data is present
  88727. */
  88728. isVerticesDataPresent(kind: string): boolean;
  88729. /**
  88730. * Gets a list of all attached data kinds (Position, normal, etc...)
  88731. * @returns a list of string containing all kinds
  88732. */
  88733. getVerticesDataKinds(): string[];
  88734. /**
  88735. * Update index buffer
  88736. * @param indices defines the indices to store in the index buffer
  88737. * @param offset defines the offset in the target buffer where to store the data
  88738. * @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)
  88739. */
  88740. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88741. /**
  88742. * Creates a new index buffer
  88743. * @param indices defines the indices to store in the index buffer
  88744. * @param totalVertices defines the total number of vertices (could be null)
  88745. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88746. */
  88747. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88748. /**
  88749. * Return the total number of indices
  88750. * @returns the total number of indices
  88751. */
  88752. getTotalIndices(): number;
  88753. /**
  88754. * Gets the index buffer array
  88755. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88756. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88757. * @returns the index buffer array
  88758. */
  88759. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88760. /**
  88761. * Gets the index buffer
  88762. * @return the index buffer
  88763. */
  88764. getIndexBuffer(): Nullable<DataBuffer>;
  88765. /** @hidden */
  88766. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88767. /**
  88768. * Release the associated resources for a specific mesh
  88769. * @param mesh defines the source mesh
  88770. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88771. */
  88772. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88773. /**
  88774. * Apply current geometry to a given mesh
  88775. * @param mesh defines the mesh to apply geometry to
  88776. */
  88777. applyToMesh(mesh: Mesh): void;
  88778. private _updateExtend;
  88779. private _applyToMesh;
  88780. private notifyUpdate;
  88781. /**
  88782. * Load the geometry if it was flagged as delay loaded
  88783. * @param scene defines the hosting scene
  88784. * @param onLoaded defines a callback called when the geometry is loaded
  88785. */
  88786. load(scene: Scene, onLoaded?: () => void): void;
  88787. private _queueLoad;
  88788. /**
  88789. * Invert the geometry to move from a right handed system to a left handed one.
  88790. */
  88791. toLeftHanded(): void;
  88792. /** @hidden */
  88793. _resetPointsArrayCache(): void;
  88794. /** @hidden */
  88795. _generatePointsArray(): boolean;
  88796. /**
  88797. * Gets a value indicating if the geometry is disposed
  88798. * @returns true if the geometry was disposed
  88799. */
  88800. isDisposed(): boolean;
  88801. private _disposeVertexArrayObjects;
  88802. /**
  88803. * Free all associated resources
  88804. */
  88805. dispose(): void;
  88806. /**
  88807. * Clone the current geometry into a new geometry
  88808. * @param id defines the unique ID of the new geometry
  88809. * @returns a new geometry object
  88810. */
  88811. copy(id: string): Geometry;
  88812. /**
  88813. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88814. * @return a JSON representation of the current geometry data (without the vertices data)
  88815. */
  88816. serialize(): any;
  88817. private toNumberArray;
  88818. /**
  88819. * Serialize all vertices data into a JSON oject
  88820. * @returns a JSON representation of the current geometry data
  88821. */
  88822. serializeVerticeData(): any;
  88823. /**
  88824. * Extracts a clone of a mesh geometry
  88825. * @param mesh defines the source mesh
  88826. * @param id defines the unique ID of the new geometry object
  88827. * @returns the new geometry object
  88828. */
  88829. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88830. /**
  88831. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88832. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88833. * Be aware Math.random() could cause collisions, but:
  88834. * "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"
  88835. * @returns a string containing a new GUID
  88836. */
  88837. static RandomId(): string;
  88838. /** @hidden */
  88839. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88840. private static _CleanMatricesWeights;
  88841. /**
  88842. * Create a new geometry from persisted data (Using .babylon file format)
  88843. * @param parsedVertexData defines the persisted data
  88844. * @param scene defines the hosting scene
  88845. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88846. * @returns the new geometry object
  88847. */
  88848. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88849. }
  88850. }
  88851. declare module BABYLON {
  88852. /**
  88853. * Define an interface for all classes that will get and set the data on vertices
  88854. */
  88855. export interface IGetSetVerticesData {
  88856. /**
  88857. * Gets a boolean indicating if specific vertex data is present
  88858. * @param kind defines the vertex data kind to use
  88859. * @returns true is data kind is present
  88860. */
  88861. isVerticesDataPresent(kind: string): boolean;
  88862. /**
  88863. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88864. * @param kind defines the data kind (Position, normal, etc...)
  88865. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88866. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88867. * @returns a float array containing vertex data
  88868. */
  88869. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88870. /**
  88871. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88872. * @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.
  88873. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88874. * @returns the indices array or an empty array if the mesh has no geometry
  88875. */
  88876. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88877. /**
  88878. * Set specific vertex data
  88879. * @param kind defines the data kind (Position, normal, etc...)
  88880. * @param data defines the vertex data to use
  88881. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88882. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88883. */
  88884. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88885. /**
  88886. * Update a specific associated vertex buffer
  88887. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88888. * - VertexBuffer.PositionKind
  88889. * - VertexBuffer.UVKind
  88890. * - VertexBuffer.UV2Kind
  88891. * - VertexBuffer.UV3Kind
  88892. * - VertexBuffer.UV4Kind
  88893. * - VertexBuffer.UV5Kind
  88894. * - VertexBuffer.UV6Kind
  88895. * - VertexBuffer.ColorKind
  88896. * - VertexBuffer.MatricesIndicesKind
  88897. * - VertexBuffer.MatricesIndicesExtraKind
  88898. * - VertexBuffer.MatricesWeightsKind
  88899. * - VertexBuffer.MatricesWeightsExtraKind
  88900. * @param data defines the data source
  88901. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88902. * @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)
  88903. */
  88904. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88905. /**
  88906. * Creates a new index buffer
  88907. * @param indices defines the indices to store in the index buffer
  88908. * @param totalVertices defines the total number of vertices (could be null)
  88909. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88910. */
  88911. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88912. }
  88913. /**
  88914. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88915. */
  88916. export class VertexData {
  88917. /**
  88918. * Mesh side orientation : usually the external or front surface
  88919. */
  88920. static readonly FRONTSIDE: number;
  88921. /**
  88922. * Mesh side orientation : usually the internal or back surface
  88923. */
  88924. static readonly BACKSIDE: number;
  88925. /**
  88926. * Mesh side orientation : both internal and external or front and back surfaces
  88927. */
  88928. static readonly DOUBLESIDE: number;
  88929. /**
  88930. * Mesh side orientation : by default, `FRONTSIDE`
  88931. */
  88932. static readonly DEFAULTSIDE: number;
  88933. /**
  88934. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88935. */
  88936. positions: Nullable<FloatArray>;
  88937. /**
  88938. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88939. */
  88940. normals: Nullable<FloatArray>;
  88941. /**
  88942. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88943. */
  88944. tangents: Nullable<FloatArray>;
  88945. /**
  88946. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88947. */
  88948. uvs: Nullable<FloatArray>;
  88949. /**
  88950. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88951. */
  88952. uvs2: Nullable<FloatArray>;
  88953. /**
  88954. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88955. */
  88956. uvs3: Nullable<FloatArray>;
  88957. /**
  88958. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88959. */
  88960. uvs4: Nullable<FloatArray>;
  88961. /**
  88962. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88963. */
  88964. uvs5: Nullable<FloatArray>;
  88965. /**
  88966. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88967. */
  88968. uvs6: Nullable<FloatArray>;
  88969. /**
  88970. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88971. */
  88972. colors: Nullable<FloatArray>;
  88973. /**
  88974. * 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).
  88975. */
  88976. matricesIndices: Nullable<FloatArray>;
  88977. /**
  88978. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88979. */
  88980. matricesWeights: Nullable<FloatArray>;
  88981. /**
  88982. * An array extending the number of possible indices
  88983. */
  88984. matricesIndicesExtra: Nullable<FloatArray>;
  88985. /**
  88986. * An array extending the number of possible weights when the number of indices is extended
  88987. */
  88988. matricesWeightsExtra: Nullable<FloatArray>;
  88989. /**
  88990. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88991. */
  88992. indices: Nullable<IndicesArray>;
  88993. /**
  88994. * Uses the passed data array to set the set the values for the specified kind of data
  88995. * @param data a linear array of floating numbers
  88996. * @param kind the type of data that is being set, eg positions, colors etc
  88997. */
  88998. set(data: FloatArray, kind: string): void;
  88999. /**
  89000. * Associates the vertexData to the passed Mesh.
  89001. * Sets it as updatable or not (default `false`)
  89002. * @param mesh the mesh the vertexData is applied to
  89003. * @param updatable when used and having the value true allows new data to update the vertexData
  89004. * @returns the VertexData
  89005. */
  89006. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89007. /**
  89008. * Associates the vertexData to the passed Geometry.
  89009. * Sets it as updatable or not (default `false`)
  89010. * @param geometry the geometry the vertexData is applied to
  89011. * @param updatable when used and having the value true allows new data to update the vertexData
  89012. * @returns VertexData
  89013. */
  89014. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89015. /**
  89016. * Updates the associated mesh
  89017. * @param mesh the mesh to be updated
  89018. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89019. * @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
  89020. * @returns VertexData
  89021. */
  89022. updateMesh(mesh: Mesh): VertexData;
  89023. /**
  89024. * Updates the associated geometry
  89025. * @param geometry the geometry to be updated
  89026. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89027. * @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
  89028. * @returns VertexData.
  89029. */
  89030. updateGeometry(geometry: Geometry): VertexData;
  89031. private _applyTo;
  89032. private _update;
  89033. /**
  89034. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89035. * @param matrix the transforming matrix
  89036. * @returns the VertexData
  89037. */
  89038. transform(matrix: Matrix): VertexData;
  89039. /**
  89040. * Merges the passed VertexData into the current one
  89041. * @param other the VertexData to be merged into the current one
  89042. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89043. * @returns the modified VertexData
  89044. */
  89045. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89046. private _mergeElement;
  89047. private _validate;
  89048. /**
  89049. * Serializes the VertexData
  89050. * @returns a serialized object
  89051. */
  89052. serialize(): any;
  89053. /**
  89054. * Extracts the vertexData from a mesh
  89055. * @param mesh the mesh from which to extract the VertexData
  89056. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89057. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89058. * @returns the object VertexData associated to the passed mesh
  89059. */
  89060. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89061. /**
  89062. * Extracts the vertexData from the geometry
  89063. * @param geometry the geometry from which to extract the VertexData
  89064. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89065. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89066. * @returns the object VertexData associated to the passed mesh
  89067. */
  89068. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89069. private static _ExtractFrom;
  89070. /**
  89071. * Creates the VertexData for a Ribbon
  89072. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89073. * * pathArray array of paths, each of which an array of successive Vector3
  89074. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89075. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89076. * * 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
  89077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89078. * * 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)
  89079. * * 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)
  89080. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89081. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89082. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89083. * @returns the VertexData of the ribbon
  89084. */
  89085. static CreateRibbon(options: {
  89086. pathArray: Vector3[][];
  89087. closeArray?: boolean;
  89088. closePath?: boolean;
  89089. offset?: number;
  89090. sideOrientation?: number;
  89091. frontUVs?: Vector4;
  89092. backUVs?: Vector4;
  89093. invertUV?: boolean;
  89094. uvs?: Vector2[];
  89095. colors?: Color4[];
  89096. }): VertexData;
  89097. /**
  89098. * Creates the VertexData for a box
  89099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89100. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89101. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89102. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89103. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89104. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89105. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89106. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89107. * * 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)
  89108. * * 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)
  89109. * @returns the VertexData of the box
  89110. */
  89111. static CreateBox(options: {
  89112. size?: number;
  89113. width?: number;
  89114. height?: number;
  89115. depth?: number;
  89116. faceUV?: Vector4[];
  89117. faceColors?: Color4[];
  89118. sideOrientation?: number;
  89119. frontUVs?: Vector4;
  89120. backUVs?: Vector4;
  89121. }): VertexData;
  89122. /**
  89123. * Creates the VertexData for a tiled box
  89124. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89125. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89126. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89127. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89129. * @returns the VertexData of the box
  89130. */
  89131. static CreateTiledBox(options: {
  89132. pattern?: number;
  89133. width?: number;
  89134. height?: number;
  89135. depth?: number;
  89136. tileSize?: number;
  89137. tileWidth?: number;
  89138. tileHeight?: number;
  89139. alignHorizontal?: number;
  89140. alignVertical?: number;
  89141. faceUV?: Vector4[];
  89142. faceColors?: Color4[];
  89143. sideOrientation?: number;
  89144. }): VertexData;
  89145. /**
  89146. * Creates the VertexData for a tiled plane
  89147. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89148. * * pattern a limited pattern arrangement depending on the number
  89149. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89150. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89151. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89153. * * 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)
  89154. * * 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)
  89155. * @returns the VertexData of the tiled plane
  89156. */
  89157. static CreateTiledPlane(options: {
  89158. pattern?: number;
  89159. tileSize?: number;
  89160. tileWidth?: number;
  89161. tileHeight?: number;
  89162. size?: number;
  89163. width?: number;
  89164. height?: number;
  89165. alignHorizontal?: number;
  89166. alignVertical?: number;
  89167. sideOrientation?: number;
  89168. frontUVs?: Vector4;
  89169. backUVs?: Vector4;
  89170. }): VertexData;
  89171. /**
  89172. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89173. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89174. * * segments sets the number of horizontal strips optional, default 32
  89175. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89176. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89177. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89178. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89179. * * 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
  89180. * * 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
  89181. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89182. * * 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)
  89183. * * 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)
  89184. * @returns the VertexData of the ellipsoid
  89185. */
  89186. static CreateSphere(options: {
  89187. segments?: number;
  89188. diameter?: number;
  89189. diameterX?: number;
  89190. diameterY?: number;
  89191. diameterZ?: number;
  89192. arc?: number;
  89193. slice?: number;
  89194. sideOrientation?: number;
  89195. frontUVs?: Vector4;
  89196. backUVs?: Vector4;
  89197. }): VertexData;
  89198. /**
  89199. * Creates the VertexData for a cylinder, cone or prism
  89200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89201. * * height sets the height (y direction) of the cylinder, optional, default 2
  89202. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89203. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89204. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89205. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89206. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89207. * * 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
  89208. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89209. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89210. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89211. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89213. * * 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)
  89214. * * 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)
  89215. * @returns the VertexData of the cylinder, cone or prism
  89216. */
  89217. static CreateCylinder(options: {
  89218. height?: number;
  89219. diameterTop?: number;
  89220. diameterBottom?: number;
  89221. diameter?: number;
  89222. tessellation?: number;
  89223. subdivisions?: number;
  89224. arc?: number;
  89225. faceColors?: Color4[];
  89226. faceUV?: Vector4[];
  89227. hasRings?: boolean;
  89228. enclose?: boolean;
  89229. sideOrientation?: number;
  89230. frontUVs?: Vector4;
  89231. backUVs?: Vector4;
  89232. }): VertexData;
  89233. /**
  89234. * Creates the VertexData for a torus
  89235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89236. * * diameter the diameter of the torus, optional default 1
  89237. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89238. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89239. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89240. * * 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)
  89241. * * 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)
  89242. * @returns the VertexData of the torus
  89243. */
  89244. static CreateTorus(options: {
  89245. diameter?: number;
  89246. thickness?: number;
  89247. tessellation?: number;
  89248. sideOrientation?: number;
  89249. frontUVs?: Vector4;
  89250. backUVs?: Vector4;
  89251. }): VertexData;
  89252. /**
  89253. * Creates the VertexData of the LineSystem
  89254. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89255. * - lines an array of lines, each line being an array of successive Vector3
  89256. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89257. * @returns the VertexData of the LineSystem
  89258. */
  89259. static CreateLineSystem(options: {
  89260. lines: Vector3[][];
  89261. colors?: Nullable<Color4[][]>;
  89262. }): VertexData;
  89263. /**
  89264. * Create the VertexData for a DashedLines
  89265. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89266. * - points an array successive Vector3
  89267. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89268. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89269. * - dashNb the intended total number of dashes, optional, default 200
  89270. * @returns the VertexData for the DashedLines
  89271. */
  89272. static CreateDashedLines(options: {
  89273. points: Vector3[];
  89274. dashSize?: number;
  89275. gapSize?: number;
  89276. dashNb?: number;
  89277. }): VertexData;
  89278. /**
  89279. * Creates the VertexData for a Ground
  89280. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89281. * - width the width (x direction) of the ground, optional, default 1
  89282. * - height the height (z direction) of the ground, optional, default 1
  89283. * - subdivisions the number of subdivisions per side, optional, default 1
  89284. * @returns the VertexData of the Ground
  89285. */
  89286. static CreateGround(options: {
  89287. width?: number;
  89288. height?: number;
  89289. subdivisions?: number;
  89290. subdivisionsX?: number;
  89291. subdivisionsY?: number;
  89292. }): VertexData;
  89293. /**
  89294. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89295. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89296. * * xmin the ground minimum X coordinate, optional, default -1
  89297. * * zmin the ground minimum Z coordinate, optional, default -1
  89298. * * xmax the ground maximum X coordinate, optional, default 1
  89299. * * zmax the ground maximum Z coordinate, optional, default 1
  89300. * * 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}
  89301. * * 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}
  89302. * @returns the VertexData of the TiledGround
  89303. */
  89304. static CreateTiledGround(options: {
  89305. xmin: number;
  89306. zmin: number;
  89307. xmax: number;
  89308. zmax: number;
  89309. subdivisions?: {
  89310. w: number;
  89311. h: number;
  89312. };
  89313. precision?: {
  89314. w: number;
  89315. h: number;
  89316. };
  89317. }): VertexData;
  89318. /**
  89319. * Creates the VertexData of the Ground designed from a heightmap
  89320. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89321. * * width the width (x direction) of the ground
  89322. * * height the height (z direction) of the ground
  89323. * * subdivisions the number of subdivisions per side
  89324. * * minHeight the minimum altitude on the ground, optional, default 0
  89325. * * maxHeight the maximum altitude on the ground, optional default 1
  89326. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89327. * * buffer the array holding the image color data
  89328. * * bufferWidth the width of image
  89329. * * bufferHeight the height of image
  89330. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89331. * @returns the VertexData of the Ground designed from a heightmap
  89332. */
  89333. static CreateGroundFromHeightMap(options: {
  89334. width: number;
  89335. height: number;
  89336. subdivisions: number;
  89337. minHeight: number;
  89338. maxHeight: number;
  89339. colorFilter: Color3;
  89340. buffer: Uint8Array;
  89341. bufferWidth: number;
  89342. bufferHeight: number;
  89343. alphaFilter: number;
  89344. }): VertexData;
  89345. /**
  89346. * Creates the VertexData for a Plane
  89347. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89348. * * size sets the width and height of the plane to the value of size, optional default 1
  89349. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89350. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89352. * * 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)
  89353. * * 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)
  89354. * @returns the VertexData of the box
  89355. */
  89356. static CreatePlane(options: {
  89357. size?: number;
  89358. width?: number;
  89359. height?: number;
  89360. sideOrientation?: number;
  89361. frontUVs?: Vector4;
  89362. backUVs?: Vector4;
  89363. }): VertexData;
  89364. /**
  89365. * Creates the VertexData of the Disc or regular Polygon
  89366. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89367. * * radius the radius of the disc, optional default 0.5
  89368. * * tessellation the number of polygon sides, optional, default 64
  89369. * * 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
  89370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89371. * * 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)
  89372. * * 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)
  89373. * @returns the VertexData of the box
  89374. */
  89375. static CreateDisc(options: {
  89376. radius?: number;
  89377. tessellation?: number;
  89378. arc?: number;
  89379. sideOrientation?: number;
  89380. frontUVs?: Vector4;
  89381. backUVs?: Vector4;
  89382. }): VertexData;
  89383. /**
  89384. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89385. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89386. * @param polygon a mesh built from polygonTriangulation.build()
  89387. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89388. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89389. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89390. * @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)
  89391. * @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)
  89392. * @returns the VertexData of the Polygon
  89393. */
  89394. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89395. /**
  89396. * Creates the VertexData of the IcoSphere
  89397. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89398. * * radius the radius of the IcoSphere, optional default 1
  89399. * * radiusX allows stretching in the x direction, optional, default radius
  89400. * * radiusY allows stretching in the y direction, optional, default radius
  89401. * * radiusZ allows stretching in the z direction, optional, default radius
  89402. * * flat when true creates a flat shaded mesh, optional, default true
  89403. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89404. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89405. * * 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)
  89406. * * 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)
  89407. * @returns the VertexData of the IcoSphere
  89408. */
  89409. static CreateIcoSphere(options: {
  89410. radius?: number;
  89411. radiusX?: number;
  89412. radiusY?: number;
  89413. radiusZ?: number;
  89414. flat?: boolean;
  89415. subdivisions?: number;
  89416. sideOrientation?: number;
  89417. frontUVs?: Vector4;
  89418. backUVs?: Vector4;
  89419. }): VertexData;
  89420. /**
  89421. * Creates the VertexData for a Polyhedron
  89422. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89423. * * type provided types are:
  89424. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89425. * * 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)
  89426. * * size the size of the IcoSphere, optional default 1
  89427. * * sizeX allows stretching in the x direction, optional, default size
  89428. * * sizeY allows stretching in the y direction, optional, default size
  89429. * * sizeZ allows stretching in the z direction, optional, default size
  89430. * * 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
  89431. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89432. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89433. * * flat when true creates a flat shaded mesh, optional, default true
  89434. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89436. * * 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)
  89437. * * 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)
  89438. * @returns the VertexData of the Polyhedron
  89439. */
  89440. static CreatePolyhedron(options: {
  89441. type?: number;
  89442. size?: number;
  89443. sizeX?: number;
  89444. sizeY?: number;
  89445. sizeZ?: number;
  89446. custom?: any;
  89447. faceUV?: Vector4[];
  89448. faceColors?: Color4[];
  89449. flat?: boolean;
  89450. sideOrientation?: number;
  89451. frontUVs?: Vector4;
  89452. backUVs?: Vector4;
  89453. }): VertexData;
  89454. /**
  89455. * Creates the VertexData for a TorusKnot
  89456. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89457. * * radius the radius of the torus knot, optional, default 2
  89458. * * tube the thickness of the tube, optional, default 0.5
  89459. * * radialSegments the number of sides on each tube segments, optional, default 32
  89460. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89461. * * p the number of windings around the z axis, optional, default 2
  89462. * * q the number of windings around the x axis, optional, default 3
  89463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89464. * * 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)
  89465. * * 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)
  89466. * @returns the VertexData of the Torus Knot
  89467. */
  89468. static CreateTorusKnot(options: {
  89469. radius?: number;
  89470. tube?: number;
  89471. radialSegments?: number;
  89472. tubularSegments?: number;
  89473. p?: number;
  89474. q?: number;
  89475. sideOrientation?: number;
  89476. frontUVs?: Vector4;
  89477. backUVs?: Vector4;
  89478. }): VertexData;
  89479. /**
  89480. * Compute normals for given positions and indices
  89481. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89482. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89483. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89484. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89485. * * facetNormals : optional array of facet normals (vector3)
  89486. * * facetPositions : optional array of facet positions (vector3)
  89487. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89488. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89489. * * bInfo : optional bounding info, required for facetPartitioning computation
  89490. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89491. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89492. * * useRightHandedSystem: optional boolean to for right handed system computation
  89493. * * depthSort : optional boolean to enable the facet depth sort computation
  89494. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89495. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89496. */
  89497. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89498. facetNormals?: any;
  89499. facetPositions?: any;
  89500. facetPartitioning?: any;
  89501. ratio?: number;
  89502. bInfo?: any;
  89503. bbSize?: Vector3;
  89504. subDiv?: any;
  89505. useRightHandedSystem?: boolean;
  89506. depthSort?: boolean;
  89507. distanceTo?: Vector3;
  89508. depthSortedFacets?: any;
  89509. }): void;
  89510. /** @hidden */
  89511. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89512. /**
  89513. * Applies VertexData created from the imported parameters to the geometry
  89514. * @param parsedVertexData the parsed data from an imported file
  89515. * @param geometry the geometry to apply the VertexData to
  89516. */
  89517. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89518. }
  89519. }
  89520. declare module BABYLON {
  89521. /**
  89522. * Defines a target to use with MorphTargetManager
  89523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89524. */
  89525. export class MorphTarget implements IAnimatable {
  89526. /** defines the name of the target */
  89527. name: string;
  89528. /**
  89529. * Gets or sets the list of animations
  89530. */
  89531. animations: Animation[];
  89532. private _scene;
  89533. private _positions;
  89534. private _normals;
  89535. private _tangents;
  89536. private _uvs;
  89537. private _influence;
  89538. /**
  89539. * Observable raised when the influence changes
  89540. */
  89541. onInfluenceChanged: Observable<boolean>;
  89542. /** @hidden */
  89543. _onDataLayoutChanged: Observable<void>;
  89544. /**
  89545. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89546. */
  89547. influence: number;
  89548. /**
  89549. * Gets or sets the id of the morph Target
  89550. */
  89551. id: string;
  89552. private _animationPropertiesOverride;
  89553. /**
  89554. * Gets or sets the animation properties override
  89555. */
  89556. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89557. /**
  89558. * Creates a new MorphTarget
  89559. * @param name defines the name of the target
  89560. * @param influence defines the influence to use
  89561. * @param scene defines the scene the morphtarget belongs to
  89562. */
  89563. constructor(
  89564. /** defines the name of the target */
  89565. name: string, influence?: number, scene?: Nullable<Scene>);
  89566. /**
  89567. * Gets a boolean defining if the target contains position data
  89568. */
  89569. readonly hasPositions: boolean;
  89570. /**
  89571. * Gets a boolean defining if the target contains normal data
  89572. */
  89573. readonly hasNormals: boolean;
  89574. /**
  89575. * Gets a boolean defining if the target contains tangent data
  89576. */
  89577. readonly hasTangents: boolean;
  89578. /**
  89579. * Gets a boolean defining if the target contains texture coordinates data
  89580. */
  89581. readonly hasUVs: boolean;
  89582. /**
  89583. * Affects position data to this target
  89584. * @param data defines the position data to use
  89585. */
  89586. setPositions(data: Nullable<FloatArray>): void;
  89587. /**
  89588. * Gets the position data stored in this target
  89589. * @returns a FloatArray containing the position data (or null if not present)
  89590. */
  89591. getPositions(): Nullable<FloatArray>;
  89592. /**
  89593. * Affects normal data to this target
  89594. * @param data defines the normal data to use
  89595. */
  89596. setNormals(data: Nullable<FloatArray>): void;
  89597. /**
  89598. * Gets the normal data stored in this target
  89599. * @returns a FloatArray containing the normal data (or null if not present)
  89600. */
  89601. getNormals(): Nullable<FloatArray>;
  89602. /**
  89603. * Affects tangent data to this target
  89604. * @param data defines the tangent data to use
  89605. */
  89606. setTangents(data: Nullable<FloatArray>): void;
  89607. /**
  89608. * Gets the tangent data stored in this target
  89609. * @returns a FloatArray containing the tangent data (or null if not present)
  89610. */
  89611. getTangents(): Nullable<FloatArray>;
  89612. /**
  89613. * Affects texture coordinates data to this target
  89614. * @param data defines the texture coordinates data to use
  89615. */
  89616. setUVs(data: Nullable<FloatArray>): void;
  89617. /**
  89618. * Gets the texture coordinates data stored in this target
  89619. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89620. */
  89621. getUVs(): Nullable<FloatArray>;
  89622. /**
  89623. * Serializes the current target into a Serialization object
  89624. * @returns the serialized object
  89625. */
  89626. serialize(): any;
  89627. /**
  89628. * Returns the string "MorphTarget"
  89629. * @returns "MorphTarget"
  89630. */
  89631. getClassName(): string;
  89632. /**
  89633. * Creates a new target from serialized data
  89634. * @param serializationObject defines the serialized data to use
  89635. * @returns a new MorphTarget
  89636. */
  89637. static Parse(serializationObject: any): MorphTarget;
  89638. /**
  89639. * Creates a MorphTarget from mesh data
  89640. * @param mesh defines the source mesh
  89641. * @param name defines the name to use for the new target
  89642. * @param influence defines the influence to attach to the target
  89643. * @returns a new MorphTarget
  89644. */
  89645. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89646. }
  89647. }
  89648. declare module BABYLON {
  89649. /**
  89650. * This class is used to deform meshes using morphing between different targets
  89651. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89652. */
  89653. export class MorphTargetManager {
  89654. private _targets;
  89655. private _targetInfluenceChangedObservers;
  89656. private _targetDataLayoutChangedObservers;
  89657. private _activeTargets;
  89658. private _scene;
  89659. private _influences;
  89660. private _supportsNormals;
  89661. private _supportsTangents;
  89662. private _supportsUVs;
  89663. private _vertexCount;
  89664. private _uniqueId;
  89665. private _tempInfluences;
  89666. /**
  89667. * Gets or sets a boolean indicating if normals must be morphed
  89668. */
  89669. enableNormalMorphing: boolean;
  89670. /**
  89671. * Gets or sets a boolean indicating if tangents must be morphed
  89672. */
  89673. enableTangentMorphing: boolean;
  89674. /**
  89675. * Gets or sets a boolean indicating if UV must be morphed
  89676. */
  89677. enableUVMorphing: boolean;
  89678. /**
  89679. * Creates a new MorphTargetManager
  89680. * @param scene defines the current scene
  89681. */
  89682. constructor(scene?: Nullable<Scene>);
  89683. /**
  89684. * Gets the unique ID of this manager
  89685. */
  89686. readonly uniqueId: number;
  89687. /**
  89688. * Gets the number of vertices handled by this manager
  89689. */
  89690. readonly vertexCount: number;
  89691. /**
  89692. * Gets a boolean indicating if this manager supports morphing of normals
  89693. */
  89694. readonly supportsNormals: boolean;
  89695. /**
  89696. * Gets a boolean indicating if this manager supports morphing of tangents
  89697. */
  89698. readonly supportsTangents: boolean;
  89699. /**
  89700. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89701. */
  89702. readonly supportsUVs: boolean;
  89703. /**
  89704. * Gets the number of targets stored in this manager
  89705. */
  89706. readonly numTargets: number;
  89707. /**
  89708. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89709. */
  89710. readonly numInfluencers: number;
  89711. /**
  89712. * Gets the list of influences (one per target)
  89713. */
  89714. readonly influences: Float32Array;
  89715. /**
  89716. * Gets the active target at specified index. An active target is a target with an influence > 0
  89717. * @param index defines the index to check
  89718. * @returns the requested target
  89719. */
  89720. getActiveTarget(index: number): MorphTarget;
  89721. /**
  89722. * Gets the target at specified index
  89723. * @param index defines the index to check
  89724. * @returns the requested target
  89725. */
  89726. getTarget(index: number): MorphTarget;
  89727. /**
  89728. * Add a new target to this manager
  89729. * @param target defines the target to add
  89730. */
  89731. addTarget(target: MorphTarget): void;
  89732. /**
  89733. * Removes a target from the manager
  89734. * @param target defines the target to remove
  89735. */
  89736. removeTarget(target: MorphTarget): void;
  89737. /**
  89738. * Serializes the current manager into a Serialization object
  89739. * @returns the serialized object
  89740. */
  89741. serialize(): any;
  89742. private _syncActiveTargets;
  89743. /**
  89744. * Syncrhonize the targets with all the meshes using this morph target manager
  89745. */
  89746. synchronize(): void;
  89747. /**
  89748. * Creates a new MorphTargetManager from serialized data
  89749. * @param serializationObject defines the serialized data
  89750. * @param scene defines the hosting scene
  89751. * @returns the new MorphTargetManager
  89752. */
  89753. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89754. }
  89755. }
  89756. declare module BABYLON {
  89757. /**
  89758. * Class used to represent a specific level of detail of a mesh
  89759. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89760. */
  89761. export class MeshLODLevel {
  89762. /** Defines the distance where this level should start being displayed */
  89763. distance: number;
  89764. /** Defines the mesh to use to render this level */
  89765. mesh: Nullable<Mesh>;
  89766. /**
  89767. * Creates a new LOD level
  89768. * @param distance defines the distance where this level should star being displayed
  89769. * @param mesh defines the mesh to use to render this level
  89770. */
  89771. constructor(
  89772. /** Defines the distance where this level should start being displayed */
  89773. distance: number,
  89774. /** Defines the mesh to use to render this level */
  89775. mesh: Nullable<Mesh>);
  89776. }
  89777. }
  89778. declare module BABYLON {
  89779. /**
  89780. * Mesh representing the gorund
  89781. */
  89782. export class GroundMesh extends Mesh {
  89783. /** If octree should be generated */
  89784. generateOctree: boolean;
  89785. private _heightQuads;
  89786. /** @hidden */
  89787. _subdivisionsX: number;
  89788. /** @hidden */
  89789. _subdivisionsY: number;
  89790. /** @hidden */
  89791. _width: number;
  89792. /** @hidden */
  89793. _height: number;
  89794. /** @hidden */
  89795. _minX: number;
  89796. /** @hidden */
  89797. _maxX: number;
  89798. /** @hidden */
  89799. _minZ: number;
  89800. /** @hidden */
  89801. _maxZ: number;
  89802. constructor(name: string, scene: Scene);
  89803. /**
  89804. * "GroundMesh"
  89805. * @returns "GroundMesh"
  89806. */
  89807. getClassName(): string;
  89808. /**
  89809. * The minimum of x and y subdivisions
  89810. */
  89811. readonly subdivisions: number;
  89812. /**
  89813. * X subdivisions
  89814. */
  89815. readonly subdivisionsX: number;
  89816. /**
  89817. * Y subdivisions
  89818. */
  89819. readonly subdivisionsY: number;
  89820. /**
  89821. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89822. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89823. * @param chunksCount the number of subdivisions for x and y
  89824. * @param octreeBlocksSize (Default: 32)
  89825. */
  89826. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89827. /**
  89828. * Returns a height (y) value in the Worl system :
  89829. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89830. * @param x x coordinate
  89831. * @param z z coordinate
  89832. * @returns the ground y position if (x, z) are outside the ground surface.
  89833. */
  89834. getHeightAtCoordinates(x: number, z: number): number;
  89835. /**
  89836. * Returns a normalized vector (Vector3) orthogonal to the ground
  89837. * at the ground coordinates (x, z) expressed in the World system.
  89838. * @param x x coordinate
  89839. * @param z z coordinate
  89840. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89841. */
  89842. getNormalAtCoordinates(x: number, z: number): Vector3;
  89843. /**
  89844. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89845. * at the ground coordinates (x, z) expressed in the World system.
  89846. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89847. * @param x x coordinate
  89848. * @param z z coordinate
  89849. * @param ref vector to store the result
  89850. * @returns the GroundMesh.
  89851. */
  89852. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89853. /**
  89854. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89855. * if the ground has been updated.
  89856. * This can be used in the render loop.
  89857. * @returns the GroundMesh.
  89858. */
  89859. updateCoordinateHeights(): GroundMesh;
  89860. private _getFacetAt;
  89861. private _initHeightQuads;
  89862. private _computeHeightQuads;
  89863. /**
  89864. * Serializes this ground mesh
  89865. * @param serializationObject object to write serialization to
  89866. */
  89867. serialize(serializationObject: any): void;
  89868. /**
  89869. * Parses a serialized ground mesh
  89870. * @param parsedMesh the serialized mesh
  89871. * @param scene the scene to create the ground mesh in
  89872. * @returns the created ground mesh
  89873. */
  89874. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89875. }
  89876. }
  89877. declare module BABYLON {
  89878. /**
  89879. * Interface for Physics-Joint data
  89880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89881. */
  89882. export interface PhysicsJointData {
  89883. /**
  89884. * The main pivot of the joint
  89885. */
  89886. mainPivot?: Vector3;
  89887. /**
  89888. * The connected pivot of the joint
  89889. */
  89890. connectedPivot?: Vector3;
  89891. /**
  89892. * The main axis of the joint
  89893. */
  89894. mainAxis?: Vector3;
  89895. /**
  89896. * The connected axis of the joint
  89897. */
  89898. connectedAxis?: Vector3;
  89899. /**
  89900. * The collision of the joint
  89901. */
  89902. collision?: boolean;
  89903. /**
  89904. * Native Oimo/Cannon/Energy data
  89905. */
  89906. nativeParams?: any;
  89907. }
  89908. /**
  89909. * This is a holder class for the physics joint created by the physics plugin
  89910. * It holds a set of functions to control the underlying joint
  89911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89912. */
  89913. export class PhysicsJoint {
  89914. /**
  89915. * The type of the physics joint
  89916. */
  89917. type: number;
  89918. /**
  89919. * The data for the physics joint
  89920. */
  89921. jointData: PhysicsJointData;
  89922. private _physicsJoint;
  89923. protected _physicsPlugin: IPhysicsEnginePlugin;
  89924. /**
  89925. * Initializes the physics joint
  89926. * @param type The type of the physics joint
  89927. * @param jointData The data for the physics joint
  89928. */
  89929. constructor(
  89930. /**
  89931. * The type of the physics joint
  89932. */
  89933. type: number,
  89934. /**
  89935. * The data for the physics joint
  89936. */
  89937. jointData: PhysicsJointData);
  89938. /**
  89939. * Gets the physics joint
  89940. */
  89941. /**
  89942. * Sets the physics joint
  89943. */
  89944. physicsJoint: any;
  89945. /**
  89946. * Sets the physics plugin
  89947. */
  89948. physicsPlugin: IPhysicsEnginePlugin;
  89949. /**
  89950. * Execute a function that is physics-plugin specific.
  89951. * @param {Function} func the function that will be executed.
  89952. * It accepts two parameters: the physics world and the physics joint
  89953. */
  89954. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89955. /**
  89956. * Distance-Joint type
  89957. */
  89958. static DistanceJoint: number;
  89959. /**
  89960. * Hinge-Joint type
  89961. */
  89962. static HingeJoint: number;
  89963. /**
  89964. * Ball-and-Socket joint type
  89965. */
  89966. static BallAndSocketJoint: number;
  89967. /**
  89968. * Wheel-Joint type
  89969. */
  89970. static WheelJoint: number;
  89971. /**
  89972. * Slider-Joint type
  89973. */
  89974. static SliderJoint: number;
  89975. /**
  89976. * Prismatic-Joint type
  89977. */
  89978. static PrismaticJoint: number;
  89979. /**
  89980. * Universal-Joint type
  89981. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89982. */
  89983. static UniversalJoint: number;
  89984. /**
  89985. * Hinge-Joint 2 type
  89986. */
  89987. static Hinge2Joint: number;
  89988. /**
  89989. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89990. */
  89991. static PointToPointJoint: number;
  89992. /**
  89993. * Spring-Joint type
  89994. */
  89995. static SpringJoint: number;
  89996. /**
  89997. * Lock-Joint type
  89998. */
  89999. static LockJoint: number;
  90000. }
  90001. /**
  90002. * A class representing a physics distance joint
  90003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90004. */
  90005. export class DistanceJoint extends PhysicsJoint {
  90006. /**
  90007. *
  90008. * @param jointData The data for the Distance-Joint
  90009. */
  90010. constructor(jointData: DistanceJointData);
  90011. /**
  90012. * Update the predefined distance.
  90013. * @param maxDistance The maximum preferred distance
  90014. * @param minDistance The minimum preferred distance
  90015. */
  90016. updateDistance(maxDistance: number, minDistance?: number): void;
  90017. }
  90018. /**
  90019. * Represents a Motor-Enabled Joint
  90020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90021. */
  90022. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90023. /**
  90024. * Initializes the Motor-Enabled Joint
  90025. * @param type The type of the joint
  90026. * @param jointData The physica joint data for the joint
  90027. */
  90028. constructor(type: number, jointData: PhysicsJointData);
  90029. /**
  90030. * Set the motor values.
  90031. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90032. * @param force the force to apply
  90033. * @param maxForce max force for this motor.
  90034. */
  90035. setMotor(force?: number, maxForce?: number): void;
  90036. /**
  90037. * Set the motor's limits.
  90038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90039. * @param upperLimit The upper limit of the motor
  90040. * @param lowerLimit The lower limit of the motor
  90041. */
  90042. setLimit(upperLimit: number, lowerLimit?: number): void;
  90043. }
  90044. /**
  90045. * This class represents a single physics Hinge-Joint
  90046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90047. */
  90048. export class HingeJoint extends MotorEnabledJoint {
  90049. /**
  90050. * Initializes the Hinge-Joint
  90051. * @param jointData The joint data for the Hinge-Joint
  90052. */
  90053. constructor(jointData: PhysicsJointData);
  90054. /**
  90055. * Set the motor values.
  90056. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90057. * @param {number} force the force to apply
  90058. * @param {number} maxForce max force for this motor.
  90059. */
  90060. setMotor(force?: number, maxForce?: number): void;
  90061. /**
  90062. * Set the motor's limits.
  90063. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90064. * @param upperLimit The upper limit of the motor
  90065. * @param lowerLimit The lower limit of the motor
  90066. */
  90067. setLimit(upperLimit: number, lowerLimit?: number): void;
  90068. }
  90069. /**
  90070. * This class represents a dual hinge physics joint (same as wheel joint)
  90071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90072. */
  90073. export class Hinge2Joint extends MotorEnabledJoint {
  90074. /**
  90075. * Initializes the Hinge2-Joint
  90076. * @param jointData The joint data for the Hinge2-Joint
  90077. */
  90078. constructor(jointData: PhysicsJointData);
  90079. /**
  90080. * Set the motor values.
  90081. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90082. * @param {number} targetSpeed the speed the motor is to reach
  90083. * @param {number} maxForce max force for this motor.
  90084. * @param {motorIndex} the motor's index, 0 or 1.
  90085. */
  90086. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90087. /**
  90088. * Set the motor limits.
  90089. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90090. * @param {number} upperLimit the upper limit
  90091. * @param {number} lowerLimit lower limit
  90092. * @param {motorIndex} the motor's index, 0 or 1.
  90093. */
  90094. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90095. }
  90096. /**
  90097. * Interface for a motor enabled joint
  90098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90099. */
  90100. export interface IMotorEnabledJoint {
  90101. /**
  90102. * Physics joint
  90103. */
  90104. physicsJoint: any;
  90105. /**
  90106. * Sets the motor of the motor-enabled joint
  90107. * @param force The force of the motor
  90108. * @param maxForce The maximum force of the motor
  90109. * @param motorIndex The index of the motor
  90110. */
  90111. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90112. /**
  90113. * Sets the limit of the motor
  90114. * @param upperLimit The upper limit of the motor
  90115. * @param lowerLimit The lower limit of the motor
  90116. * @param motorIndex The index of the motor
  90117. */
  90118. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90119. }
  90120. /**
  90121. * Joint data for a Distance-Joint
  90122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90123. */
  90124. export interface DistanceJointData extends PhysicsJointData {
  90125. /**
  90126. * Max distance the 2 joint objects can be apart
  90127. */
  90128. maxDistance: number;
  90129. }
  90130. /**
  90131. * Joint data from a spring joint
  90132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90133. */
  90134. export interface SpringJointData extends PhysicsJointData {
  90135. /**
  90136. * Length of the spring
  90137. */
  90138. length: number;
  90139. /**
  90140. * Stiffness of the spring
  90141. */
  90142. stiffness: number;
  90143. /**
  90144. * Damping of the spring
  90145. */
  90146. damping: number;
  90147. /** this callback will be called when applying the force to the impostors. */
  90148. forceApplicationCallback: () => void;
  90149. }
  90150. }
  90151. declare module BABYLON {
  90152. /**
  90153. * Holds the data for the raycast result
  90154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90155. */
  90156. export class PhysicsRaycastResult {
  90157. private _hasHit;
  90158. private _hitDistance;
  90159. private _hitNormalWorld;
  90160. private _hitPointWorld;
  90161. private _rayFromWorld;
  90162. private _rayToWorld;
  90163. /**
  90164. * Gets if there was a hit
  90165. */
  90166. readonly hasHit: boolean;
  90167. /**
  90168. * Gets the distance from the hit
  90169. */
  90170. readonly hitDistance: number;
  90171. /**
  90172. * Gets the hit normal/direction in the world
  90173. */
  90174. readonly hitNormalWorld: Vector3;
  90175. /**
  90176. * Gets the hit point in the world
  90177. */
  90178. readonly hitPointWorld: Vector3;
  90179. /**
  90180. * Gets the ray "start point" of the ray in the world
  90181. */
  90182. readonly rayFromWorld: Vector3;
  90183. /**
  90184. * Gets the ray "end point" of the ray in the world
  90185. */
  90186. readonly rayToWorld: Vector3;
  90187. /**
  90188. * Sets the hit data (normal & point in world space)
  90189. * @param hitNormalWorld defines the normal in world space
  90190. * @param hitPointWorld defines the point in world space
  90191. */
  90192. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90193. /**
  90194. * Sets the distance from the start point to the hit point
  90195. * @param distance
  90196. */
  90197. setHitDistance(distance: number): void;
  90198. /**
  90199. * Calculates the distance manually
  90200. */
  90201. calculateHitDistance(): void;
  90202. /**
  90203. * Resets all the values to default
  90204. * @param from The from point on world space
  90205. * @param to The to point on world space
  90206. */
  90207. reset(from?: Vector3, to?: Vector3): void;
  90208. }
  90209. /**
  90210. * Interface for the size containing width and height
  90211. */
  90212. interface IXYZ {
  90213. /**
  90214. * X
  90215. */
  90216. x: number;
  90217. /**
  90218. * Y
  90219. */
  90220. y: number;
  90221. /**
  90222. * Z
  90223. */
  90224. z: number;
  90225. }
  90226. }
  90227. declare module BABYLON {
  90228. /**
  90229. * Interface used to describe a physics joint
  90230. */
  90231. export interface PhysicsImpostorJoint {
  90232. /** Defines the main impostor to which the joint is linked */
  90233. mainImpostor: PhysicsImpostor;
  90234. /** Defines the impostor that is connected to the main impostor using this joint */
  90235. connectedImpostor: PhysicsImpostor;
  90236. /** Defines the joint itself */
  90237. joint: PhysicsJoint;
  90238. }
  90239. /** @hidden */
  90240. export interface IPhysicsEnginePlugin {
  90241. world: any;
  90242. name: string;
  90243. setGravity(gravity: Vector3): void;
  90244. setTimeStep(timeStep: number): void;
  90245. getTimeStep(): number;
  90246. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90247. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90248. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90249. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90250. removePhysicsBody(impostor: PhysicsImpostor): void;
  90251. generateJoint(joint: PhysicsImpostorJoint): void;
  90252. removeJoint(joint: PhysicsImpostorJoint): void;
  90253. isSupported(): boolean;
  90254. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90255. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90256. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90257. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90258. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90259. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90260. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90261. getBodyMass(impostor: PhysicsImpostor): number;
  90262. getBodyFriction(impostor: PhysicsImpostor): number;
  90263. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90264. getBodyRestitution(impostor: PhysicsImpostor): number;
  90265. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90266. getBodyPressure?(impostor: PhysicsImpostor): number;
  90267. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90268. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90269. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90270. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90271. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90272. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90273. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90274. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90275. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90276. sleepBody(impostor: PhysicsImpostor): void;
  90277. wakeUpBody(impostor: PhysicsImpostor): void;
  90278. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90279. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90280. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90281. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90282. getRadius(impostor: PhysicsImpostor): number;
  90283. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90284. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90285. dispose(): void;
  90286. }
  90287. /**
  90288. * Interface used to define a physics engine
  90289. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90290. */
  90291. export interface IPhysicsEngine {
  90292. /**
  90293. * Gets the gravity vector used by the simulation
  90294. */
  90295. gravity: Vector3;
  90296. /**
  90297. * Sets the gravity vector used by the simulation
  90298. * @param gravity defines the gravity vector to use
  90299. */
  90300. setGravity(gravity: Vector3): void;
  90301. /**
  90302. * Set the time step of the physics engine.
  90303. * Default is 1/60.
  90304. * To slow it down, enter 1/600 for example.
  90305. * To speed it up, 1/30
  90306. * @param newTimeStep the new timestep to apply to this world.
  90307. */
  90308. setTimeStep(newTimeStep: number): void;
  90309. /**
  90310. * Get the time step of the physics engine.
  90311. * @returns the current time step
  90312. */
  90313. getTimeStep(): number;
  90314. /**
  90315. * Release all resources
  90316. */
  90317. dispose(): void;
  90318. /**
  90319. * Gets the name of the current physics plugin
  90320. * @returns the name of the plugin
  90321. */
  90322. getPhysicsPluginName(): string;
  90323. /**
  90324. * Adding a new impostor for the impostor tracking.
  90325. * This will be done by the impostor itself.
  90326. * @param impostor the impostor to add
  90327. */
  90328. addImpostor(impostor: PhysicsImpostor): void;
  90329. /**
  90330. * Remove an impostor from the engine.
  90331. * This impostor and its mesh will not longer be updated by the physics engine.
  90332. * @param impostor the impostor to remove
  90333. */
  90334. removeImpostor(impostor: PhysicsImpostor): void;
  90335. /**
  90336. * Add a joint to the physics engine
  90337. * @param mainImpostor defines the main impostor to which the joint is added.
  90338. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90339. * @param joint defines the joint that will connect both impostors.
  90340. */
  90341. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90342. /**
  90343. * Removes a joint from the simulation
  90344. * @param mainImpostor defines the impostor used with the joint
  90345. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90346. * @param joint defines the joint to remove
  90347. */
  90348. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90349. /**
  90350. * Gets the current plugin used to run the simulation
  90351. * @returns current plugin
  90352. */
  90353. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90354. /**
  90355. * Gets the list of physic impostors
  90356. * @returns an array of PhysicsImpostor
  90357. */
  90358. getImpostors(): Array<PhysicsImpostor>;
  90359. /**
  90360. * Gets the impostor for a physics enabled object
  90361. * @param object defines the object impersonated by the impostor
  90362. * @returns the PhysicsImpostor or null if not found
  90363. */
  90364. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90365. /**
  90366. * Gets the impostor for a physics body object
  90367. * @param body defines physics body used by the impostor
  90368. * @returns the PhysicsImpostor or null if not found
  90369. */
  90370. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90371. /**
  90372. * Does a raycast in the physics world
  90373. * @param from when should the ray start?
  90374. * @param to when should the ray end?
  90375. * @returns PhysicsRaycastResult
  90376. */
  90377. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90378. /**
  90379. * Called by the scene. No need to call it.
  90380. * @param delta defines the timespam between frames
  90381. */
  90382. _step(delta: number): void;
  90383. }
  90384. }
  90385. declare module BABYLON {
  90386. /**
  90387. * The interface for the physics imposter parameters
  90388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90389. */
  90390. export interface PhysicsImpostorParameters {
  90391. /**
  90392. * The mass of the physics imposter
  90393. */
  90394. mass: number;
  90395. /**
  90396. * The friction of the physics imposter
  90397. */
  90398. friction?: number;
  90399. /**
  90400. * The coefficient of restitution of the physics imposter
  90401. */
  90402. restitution?: number;
  90403. /**
  90404. * The native options of the physics imposter
  90405. */
  90406. nativeOptions?: any;
  90407. /**
  90408. * Specifies if the parent should be ignored
  90409. */
  90410. ignoreParent?: boolean;
  90411. /**
  90412. * Specifies if bi-directional transformations should be disabled
  90413. */
  90414. disableBidirectionalTransformation?: boolean;
  90415. /**
  90416. * The pressure inside the physics imposter, soft object only
  90417. */
  90418. pressure?: number;
  90419. /**
  90420. * The stiffness the physics imposter, soft object only
  90421. */
  90422. stiffness?: number;
  90423. /**
  90424. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90425. */
  90426. velocityIterations?: number;
  90427. /**
  90428. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90429. */
  90430. positionIterations?: number;
  90431. /**
  90432. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90433. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90434. * Add to fix multiple points
  90435. */
  90436. fixedPoints?: number;
  90437. /**
  90438. * The collision margin around a soft object
  90439. */
  90440. margin?: number;
  90441. /**
  90442. * The collision margin around a soft object
  90443. */
  90444. damping?: number;
  90445. /**
  90446. * The path for a rope based on an extrusion
  90447. */
  90448. path?: any;
  90449. /**
  90450. * The shape of an extrusion used for a rope based on an extrusion
  90451. */
  90452. shape?: any;
  90453. }
  90454. /**
  90455. * Interface for a physics-enabled object
  90456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90457. */
  90458. export interface IPhysicsEnabledObject {
  90459. /**
  90460. * The position of the physics-enabled object
  90461. */
  90462. position: Vector3;
  90463. /**
  90464. * The rotation of the physics-enabled object
  90465. */
  90466. rotationQuaternion: Nullable<Quaternion>;
  90467. /**
  90468. * The scale of the physics-enabled object
  90469. */
  90470. scaling: Vector3;
  90471. /**
  90472. * The rotation of the physics-enabled object
  90473. */
  90474. rotation?: Vector3;
  90475. /**
  90476. * The parent of the physics-enabled object
  90477. */
  90478. parent?: any;
  90479. /**
  90480. * The bounding info of the physics-enabled object
  90481. * @returns The bounding info of the physics-enabled object
  90482. */
  90483. getBoundingInfo(): BoundingInfo;
  90484. /**
  90485. * Computes the world matrix
  90486. * @param force Specifies if the world matrix should be computed by force
  90487. * @returns A world matrix
  90488. */
  90489. computeWorldMatrix(force: boolean): Matrix;
  90490. /**
  90491. * Gets the world matrix
  90492. * @returns A world matrix
  90493. */
  90494. getWorldMatrix?(): Matrix;
  90495. /**
  90496. * Gets the child meshes
  90497. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90498. * @returns An array of abstract meshes
  90499. */
  90500. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90501. /**
  90502. * Gets the vertex data
  90503. * @param kind The type of vertex data
  90504. * @returns A nullable array of numbers, or a float32 array
  90505. */
  90506. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90507. /**
  90508. * Gets the indices from the mesh
  90509. * @returns A nullable array of index arrays
  90510. */
  90511. getIndices?(): Nullable<IndicesArray>;
  90512. /**
  90513. * Gets the scene from the mesh
  90514. * @returns the indices array or null
  90515. */
  90516. getScene?(): Scene;
  90517. /**
  90518. * Gets the absolute position from the mesh
  90519. * @returns the absolute position
  90520. */
  90521. getAbsolutePosition(): Vector3;
  90522. /**
  90523. * Gets the absolute pivot point from the mesh
  90524. * @returns the absolute pivot point
  90525. */
  90526. getAbsolutePivotPoint(): Vector3;
  90527. /**
  90528. * Rotates the mesh
  90529. * @param axis The axis of rotation
  90530. * @param amount The amount of rotation
  90531. * @param space The space of the rotation
  90532. * @returns The rotation transform node
  90533. */
  90534. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90535. /**
  90536. * Translates the mesh
  90537. * @param axis The axis of translation
  90538. * @param distance The distance of translation
  90539. * @param space The space of the translation
  90540. * @returns The transform node
  90541. */
  90542. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90543. /**
  90544. * Sets the absolute position of the mesh
  90545. * @param absolutePosition The absolute position of the mesh
  90546. * @returns The transform node
  90547. */
  90548. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90549. /**
  90550. * Gets the class name of the mesh
  90551. * @returns The class name
  90552. */
  90553. getClassName(): string;
  90554. }
  90555. /**
  90556. * Represents a physics imposter
  90557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90558. */
  90559. export class PhysicsImpostor {
  90560. /**
  90561. * The physics-enabled object used as the physics imposter
  90562. */
  90563. object: IPhysicsEnabledObject;
  90564. /**
  90565. * The type of the physics imposter
  90566. */
  90567. type: number;
  90568. private _options;
  90569. private _scene?;
  90570. /**
  90571. * The default object size of the imposter
  90572. */
  90573. static DEFAULT_OBJECT_SIZE: Vector3;
  90574. /**
  90575. * The identity quaternion of the imposter
  90576. */
  90577. static IDENTITY_QUATERNION: Quaternion;
  90578. /** @hidden */
  90579. _pluginData: any;
  90580. private _physicsEngine;
  90581. private _physicsBody;
  90582. private _bodyUpdateRequired;
  90583. private _onBeforePhysicsStepCallbacks;
  90584. private _onAfterPhysicsStepCallbacks;
  90585. /** @hidden */
  90586. _onPhysicsCollideCallbacks: Array<{
  90587. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90588. otherImpostors: Array<PhysicsImpostor>;
  90589. }>;
  90590. private _deltaPosition;
  90591. private _deltaRotation;
  90592. private _deltaRotationConjugated;
  90593. /** @hidden */
  90594. _isFromLine: boolean;
  90595. private _parent;
  90596. private _isDisposed;
  90597. private static _tmpVecs;
  90598. private static _tmpQuat;
  90599. /**
  90600. * Specifies if the physics imposter is disposed
  90601. */
  90602. readonly isDisposed: boolean;
  90603. /**
  90604. * Gets the mass of the physics imposter
  90605. */
  90606. mass: number;
  90607. /**
  90608. * Gets the coefficient of friction
  90609. */
  90610. /**
  90611. * Sets the coefficient of friction
  90612. */
  90613. friction: number;
  90614. /**
  90615. * Gets the coefficient of restitution
  90616. */
  90617. /**
  90618. * Sets the coefficient of restitution
  90619. */
  90620. restitution: number;
  90621. /**
  90622. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90623. */
  90624. /**
  90625. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90626. */
  90627. pressure: number;
  90628. /**
  90629. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90630. */
  90631. /**
  90632. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90633. */
  90634. stiffness: number;
  90635. /**
  90636. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90637. */
  90638. /**
  90639. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90640. */
  90641. velocityIterations: number;
  90642. /**
  90643. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90644. */
  90645. /**
  90646. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90647. */
  90648. positionIterations: number;
  90649. /**
  90650. * The unique id of the physics imposter
  90651. * set by the physics engine when adding this impostor to the array
  90652. */
  90653. uniqueId: number;
  90654. /**
  90655. * @hidden
  90656. */
  90657. soft: boolean;
  90658. /**
  90659. * @hidden
  90660. */
  90661. segments: number;
  90662. private _joints;
  90663. /**
  90664. * Initializes the physics imposter
  90665. * @param object The physics-enabled object used as the physics imposter
  90666. * @param type The type of the physics imposter
  90667. * @param _options The options for the physics imposter
  90668. * @param _scene The Babylon scene
  90669. */
  90670. constructor(
  90671. /**
  90672. * The physics-enabled object used as the physics imposter
  90673. */
  90674. object: IPhysicsEnabledObject,
  90675. /**
  90676. * The type of the physics imposter
  90677. */
  90678. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90679. /**
  90680. * This function will completly initialize this impostor.
  90681. * It will create a new body - but only if this mesh has no parent.
  90682. * If it has, this impostor will not be used other than to define the impostor
  90683. * of the child mesh.
  90684. * @hidden
  90685. */
  90686. _init(): void;
  90687. private _getPhysicsParent;
  90688. /**
  90689. * Should a new body be generated.
  90690. * @returns boolean specifying if body initialization is required
  90691. */
  90692. isBodyInitRequired(): boolean;
  90693. /**
  90694. * Sets the updated scaling
  90695. * @param updated Specifies if the scaling is updated
  90696. */
  90697. setScalingUpdated(): void;
  90698. /**
  90699. * Force a regeneration of this or the parent's impostor's body.
  90700. * Use under cautious - This will remove all joints already implemented.
  90701. */
  90702. forceUpdate(): void;
  90703. /**
  90704. * Gets the body that holds this impostor. Either its own, or its parent.
  90705. */
  90706. /**
  90707. * Set the physics body. Used mainly by the physics engine/plugin
  90708. */
  90709. physicsBody: any;
  90710. /**
  90711. * Get the parent of the physics imposter
  90712. * @returns Physics imposter or null
  90713. */
  90714. /**
  90715. * Sets the parent of the physics imposter
  90716. */
  90717. parent: Nullable<PhysicsImpostor>;
  90718. /**
  90719. * Resets the update flags
  90720. */
  90721. resetUpdateFlags(): void;
  90722. /**
  90723. * Gets the object extend size
  90724. * @returns the object extend size
  90725. */
  90726. getObjectExtendSize(): Vector3;
  90727. /**
  90728. * Gets the object center
  90729. * @returns The object center
  90730. */
  90731. getObjectCenter(): Vector3;
  90732. /**
  90733. * Get a specific parametes from the options parameter
  90734. * @param paramName The object parameter name
  90735. * @returns The object parameter
  90736. */
  90737. getParam(paramName: string): any;
  90738. /**
  90739. * Sets a specific parameter in the options given to the physics plugin
  90740. * @param paramName The parameter name
  90741. * @param value The value of the parameter
  90742. */
  90743. setParam(paramName: string, value: number): void;
  90744. /**
  90745. * Specifically change the body's mass option. Won't recreate the physics body object
  90746. * @param mass The mass of the physics imposter
  90747. */
  90748. setMass(mass: number): void;
  90749. /**
  90750. * Gets the linear velocity
  90751. * @returns linear velocity or null
  90752. */
  90753. getLinearVelocity(): Nullable<Vector3>;
  90754. /**
  90755. * Sets the linear velocity
  90756. * @param velocity linear velocity or null
  90757. */
  90758. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90759. /**
  90760. * Gets the angular velocity
  90761. * @returns angular velocity or null
  90762. */
  90763. getAngularVelocity(): Nullable<Vector3>;
  90764. /**
  90765. * Sets the angular velocity
  90766. * @param velocity The velocity or null
  90767. */
  90768. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90769. /**
  90770. * Execute a function with the physics plugin native code
  90771. * Provide a function the will have two variables - the world object and the physics body object
  90772. * @param func The function to execute with the physics plugin native code
  90773. */
  90774. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90775. /**
  90776. * Register a function that will be executed before the physics world is stepping forward
  90777. * @param func The function to execute before the physics world is stepped forward
  90778. */
  90779. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90780. /**
  90781. * Unregister a function that will be executed before the physics world is stepping forward
  90782. * @param func The function to execute before the physics world is stepped forward
  90783. */
  90784. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90785. /**
  90786. * Register a function that will be executed after the physics step
  90787. * @param func The function to execute after physics step
  90788. */
  90789. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90790. /**
  90791. * Unregisters a function that will be executed after the physics step
  90792. * @param func The function to execute after physics step
  90793. */
  90794. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90795. /**
  90796. * register a function that will be executed when this impostor collides against a different body
  90797. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90798. * @param func Callback that is executed on collision
  90799. */
  90800. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90801. /**
  90802. * Unregisters the physics imposter on contact
  90803. * @param collideAgainst The physics object to collide against
  90804. * @param func Callback to execute on collision
  90805. */
  90806. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90807. private _tmpQuat;
  90808. private _tmpQuat2;
  90809. /**
  90810. * Get the parent rotation
  90811. * @returns The parent rotation
  90812. */
  90813. getParentsRotation(): Quaternion;
  90814. /**
  90815. * this function is executed by the physics engine.
  90816. */
  90817. beforeStep: () => void;
  90818. /**
  90819. * this function is executed by the physics engine
  90820. */
  90821. afterStep: () => void;
  90822. /**
  90823. * Legacy collision detection event support
  90824. */
  90825. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90826. /**
  90827. * event and body object due to cannon's event-based architecture.
  90828. */
  90829. onCollide: (e: {
  90830. body: any;
  90831. }) => void;
  90832. /**
  90833. * Apply a force
  90834. * @param force The force to apply
  90835. * @param contactPoint The contact point for the force
  90836. * @returns The physics imposter
  90837. */
  90838. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90839. /**
  90840. * Apply an impulse
  90841. * @param force The impulse force
  90842. * @param contactPoint The contact point for the impulse force
  90843. * @returns The physics imposter
  90844. */
  90845. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90846. /**
  90847. * A help function to create a joint
  90848. * @param otherImpostor A physics imposter used to create a joint
  90849. * @param jointType The type of joint
  90850. * @param jointData The data for the joint
  90851. * @returns The physics imposter
  90852. */
  90853. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90854. /**
  90855. * Add a joint to this impostor with a different impostor
  90856. * @param otherImpostor A physics imposter used to add a joint
  90857. * @param joint The joint to add
  90858. * @returns The physics imposter
  90859. */
  90860. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90861. /**
  90862. * Add an anchor to a cloth impostor
  90863. * @param otherImpostor rigid impostor to anchor to
  90864. * @param width ratio across width from 0 to 1
  90865. * @param height ratio up height from 0 to 1
  90866. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90867. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90868. * @returns impostor the soft imposter
  90869. */
  90870. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90871. /**
  90872. * Add a hook to a rope impostor
  90873. * @param otherImpostor rigid impostor to anchor to
  90874. * @param length ratio across rope from 0 to 1
  90875. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90876. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90877. * @returns impostor the rope imposter
  90878. */
  90879. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90880. /**
  90881. * Will keep this body still, in a sleep mode.
  90882. * @returns the physics imposter
  90883. */
  90884. sleep(): PhysicsImpostor;
  90885. /**
  90886. * Wake the body up.
  90887. * @returns The physics imposter
  90888. */
  90889. wakeUp(): PhysicsImpostor;
  90890. /**
  90891. * Clones the physics imposter
  90892. * @param newObject The physics imposter clones to this physics-enabled object
  90893. * @returns A nullable physics imposter
  90894. */
  90895. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90896. /**
  90897. * Disposes the physics imposter
  90898. */
  90899. dispose(): void;
  90900. /**
  90901. * Sets the delta position
  90902. * @param position The delta position amount
  90903. */
  90904. setDeltaPosition(position: Vector3): void;
  90905. /**
  90906. * Sets the delta rotation
  90907. * @param rotation The delta rotation amount
  90908. */
  90909. setDeltaRotation(rotation: Quaternion): void;
  90910. /**
  90911. * Gets the box size of the physics imposter and stores the result in the input parameter
  90912. * @param result Stores the box size
  90913. * @returns The physics imposter
  90914. */
  90915. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90916. /**
  90917. * Gets the radius of the physics imposter
  90918. * @returns Radius of the physics imposter
  90919. */
  90920. getRadius(): number;
  90921. /**
  90922. * Sync a bone with this impostor
  90923. * @param bone The bone to sync to the impostor.
  90924. * @param boneMesh The mesh that the bone is influencing.
  90925. * @param jointPivot The pivot of the joint / bone in local space.
  90926. * @param distToJoint Optional distance from the impostor to the joint.
  90927. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90928. */
  90929. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90930. /**
  90931. * Sync impostor to a bone
  90932. * @param bone The bone that the impostor will be synced to.
  90933. * @param boneMesh The mesh that the bone is influencing.
  90934. * @param jointPivot The pivot of the joint / bone in local space.
  90935. * @param distToJoint Optional distance from the impostor to the joint.
  90936. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90937. * @param boneAxis Optional vector3 axis the bone is aligned with
  90938. */
  90939. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90940. /**
  90941. * No-Imposter type
  90942. */
  90943. static NoImpostor: number;
  90944. /**
  90945. * Sphere-Imposter type
  90946. */
  90947. static SphereImpostor: number;
  90948. /**
  90949. * Box-Imposter type
  90950. */
  90951. static BoxImpostor: number;
  90952. /**
  90953. * Plane-Imposter type
  90954. */
  90955. static PlaneImpostor: number;
  90956. /**
  90957. * Mesh-imposter type
  90958. */
  90959. static MeshImpostor: number;
  90960. /**
  90961. * Capsule-Impostor type (Ammo.js plugin only)
  90962. */
  90963. static CapsuleImpostor: number;
  90964. /**
  90965. * Cylinder-Imposter type
  90966. */
  90967. static CylinderImpostor: number;
  90968. /**
  90969. * Particle-Imposter type
  90970. */
  90971. static ParticleImpostor: number;
  90972. /**
  90973. * Heightmap-Imposter type
  90974. */
  90975. static HeightmapImpostor: number;
  90976. /**
  90977. * ConvexHull-Impostor type (Ammo.js plugin only)
  90978. */
  90979. static ConvexHullImpostor: number;
  90980. /**
  90981. * Rope-Imposter type
  90982. */
  90983. static RopeImpostor: number;
  90984. /**
  90985. * Cloth-Imposter type
  90986. */
  90987. static ClothImpostor: number;
  90988. /**
  90989. * Softbody-Imposter type
  90990. */
  90991. static SoftbodyImpostor: number;
  90992. }
  90993. }
  90994. declare module BABYLON {
  90995. /**
  90996. * @hidden
  90997. **/
  90998. export class _CreationDataStorage {
  90999. closePath?: boolean;
  91000. closeArray?: boolean;
  91001. idx: number[];
  91002. dashSize: number;
  91003. gapSize: number;
  91004. path3D: Path3D;
  91005. pathArray: Vector3[][];
  91006. arc: number;
  91007. radius: number;
  91008. cap: number;
  91009. tessellation: number;
  91010. }
  91011. /**
  91012. * @hidden
  91013. **/
  91014. class _InstanceDataStorage {
  91015. visibleInstances: any;
  91016. batchCache: _InstancesBatch;
  91017. instancesBufferSize: number;
  91018. instancesBuffer: Nullable<Buffer>;
  91019. instancesData: Float32Array;
  91020. overridenInstanceCount: number;
  91021. isFrozen: boolean;
  91022. previousBatch: Nullable<_InstancesBatch>;
  91023. hardwareInstancedRendering: boolean;
  91024. sideOrientation: number;
  91025. }
  91026. /**
  91027. * @hidden
  91028. **/
  91029. export class _InstancesBatch {
  91030. mustReturn: boolean;
  91031. visibleInstances: Nullable<InstancedMesh[]>[];
  91032. renderSelf: boolean[];
  91033. hardwareInstancedRendering: boolean[];
  91034. }
  91035. /**
  91036. * Class used to represent renderable models
  91037. */
  91038. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91039. /**
  91040. * Mesh side orientation : usually the external or front surface
  91041. */
  91042. static readonly FRONTSIDE: number;
  91043. /**
  91044. * Mesh side orientation : usually the internal or back surface
  91045. */
  91046. static readonly BACKSIDE: number;
  91047. /**
  91048. * Mesh side orientation : both internal and external or front and back surfaces
  91049. */
  91050. static readonly DOUBLESIDE: number;
  91051. /**
  91052. * Mesh side orientation : by default, `FRONTSIDE`
  91053. */
  91054. static readonly DEFAULTSIDE: number;
  91055. /**
  91056. * Mesh cap setting : no cap
  91057. */
  91058. static readonly NO_CAP: number;
  91059. /**
  91060. * Mesh cap setting : one cap at the beginning of the mesh
  91061. */
  91062. static readonly CAP_START: number;
  91063. /**
  91064. * Mesh cap setting : one cap at the end of the mesh
  91065. */
  91066. static readonly CAP_END: number;
  91067. /**
  91068. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91069. */
  91070. static readonly CAP_ALL: number;
  91071. /**
  91072. * Mesh pattern setting : no flip or rotate
  91073. */
  91074. static readonly NO_FLIP: number;
  91075. /**
  91076. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91077. */
  91078. static readonly FLIP_TILE: number;
  91079. /**
  91080. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91081. */
  91082. static readonly ROTATE_TILE: number;
  91083. /**
  91084. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91085. */
  91086. static readonly FLIP_ROW: number;
  91087. /**
  91088. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91089. */
  91090. static readonly ROTATE_ROW: number;
  91091. /**
  91092. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91093. */
  91094. static readonly FLIP_N_ROTATE_TILE: number;
  91095. /**
  91096. * Mesh pattern setting : rotate pattern and rotate
  91097. */
  91098. static readonly FLIP_N_ROTATE_ROW: number;
  91099. /**
  91100. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91101. */
  91102. static readonly CENTER: number;
  91103. /**
  91104. * Mesh tile positioning : part tiles on left
  91105. */
  91106. static readonly LEFT: number;
  91107. /**
  91108. * Mesh tile positioning : part tiles on right
  91109. */
  91110. static readonly RIGHT: number;
  91111. /**
  91112. * Mesh tile positioning : part tiles on top
  91113. */
  91114. static readonly TOP: number;
  91115. /**
  91116. * Mesh tile positioning : part tiles on bottom
  91117. */
  91118. static readonly BOTTOM: number;
  91119. /**
  91120. * Gets the default side orientation.
  91121. * @param orientation the orientation to value to attempt to get
  91122. * @returns the default orientation
  91123. * @hidden
  91124. */
  91125. static _GetDefaultSideOrientation(orientation?: number): number;
  91126. private _internalMeshDataInfo;
  91127. /**
  91128. * An event triggered before rendering the mesh
  91129. */
  91130. readonly onBeforeRenderObservable: Observable<Mesh>;
  91131. /**
  91132. * An event triggered before binding the mesh
  91133. */
  91134. readonly onBeforeBindObservable: Observable<Mesh>;
  91135. /**
  91136. * An event triggered after rendering the mesh
  91137. */
  91138. readonly onAfterRenderObservable: Observable<Mesh>;
  91139. /**
  91140. * An event triggered before drawing the mesh
  91141. */
  91142. readonly onBeforeDrawObservable: Observable<Mesh>;
  91143. private _onBeforeDrawObserver;
  91144. /**
  91145. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91146. */
  91147. onBeforeDraw: () => void;
  91148. readonly hasInstances: boolean;
  91149. /**
  91150. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91151. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91152. */
  91153. delayLoadState: number;
  91154. /**
  91155. * Gets the list of instances created from this mesh
  91156. * it is not supposed to be modified manually.
  91157. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91158. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91159. */
  91160. instances: InstancedMesh[];
  91161. /**
  91162. * Gets the file containing delay loading data for this mesh
  91163. */
  91164. delayLoadingFile: string;
  91165. /** @hidden */
  91166. _binaryInfo: any;
  91167. /**
  91168. * User defined function used to change how LOD level selection is done
  91169. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91170. */
  91171. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91172. /**
  91173. * Gets or sets the morph target manager
  91174. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91175. */
  91176. morphTargetManager: Nullable<MorphTargetManager>;
  91177. /** @hidden */
  91178. _creationDataStorage: Nullable<_CreationDataStorage>;
  91179. /** @hidden */
  91180. _geometry: Nullable<Geometry>;
  91181. /** @hidden */
  91182. _delayInfo: Array<string>;
  91183. /** @hidden */
  91184. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91185. /** @hidden */
  91186. _instanceDataStorage: _InstanceDataStorage;
  91187. private _effectiveMaterial;
  91188. /** @hidden */
  91189. _shouldGenerateFlatShading: boolean;
  91190. /** @hidden */
  91191. _originalBuilderSideOrientation: number;
  91192. /**
  91193. * Use this property to change the original side orientation defined at construction time
  91194. */
  91195. overrideMaterialSideOrientation: Nullable<number>;
  91196. /**
  91197. * Gets the source mesh (the one used to clone this one from)
  91198. */
  91199. readonly source: Nullable<Mesh>;
  91200. /**
  91201. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91202. */
  91203. isUnIndexed: boolean;
  91204. /**
  91205. * @constructor
  91206. * @param name The value used by scene.getMeshByName() to do a lookup.
  91207. * @param scene The scene to add this mesh to.
  91208. * @param parent The parent of this mesh, if it has one
  91209. * @param source An optional Mesh from which geometry is shared, cloned.
  91210. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91211. * When false, achieved by calling a clone(), also passing False.
  91212. * This will make creation of children, recursive.
  91213. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91214. */
  91215. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91216. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  91217. /**
  91218. * Gets the class name
  91219. * @returns the string "Mesh".
  91220. */
  91221. getClassName(): string;
  91222. /** @hidden */
  91223. readonly _isMesh: boolean;
  91224. /**
  91225. * Returns a description of this mesh
  91226. * @param fullDetails define if full details about this mesh must be used
  91227. * @returns a descriptive string representing this mesh
  91228. */
  91229. toString(fullDetails?: boolean): string;
  91230. /** @hidden */
  91231. _unBindEffect(): void;
  91232. /**
  91233. * Gets a boolean indicating if this mesh has LOD
  91234. */
  91235. readonly hasLODLevels: boolean;
  91236. /**
  91237. * Gets the list of MeshLODLevel associated with the current mesh
  91238. * @returns an array of MeshLODLevel
  91239. */
  91240. getLODLevels(): MeshLODLevel[];
  91241. private _sortLODLevels;
  91242. /**
  91243. * Add a mesh as LOD level triggered at the given distance.
  91244. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91245. * @param distance The distance from the center of the object to show this level
  91246. * @param mesh The mesh to be added as LOD level (can be null)
  91247. * @return This mesh (for chaining)
  91248. */
  91249. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91250. /**
  91251. * Returns the LOD level mesh at the passed distance or null if not found.
  91252. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91253. * @param distance The distance from the center of the object to show this level
  91254. * @returns a Mesh or `null`
  91255. */
  91256. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91257. /**
  91258. * Remove a mesh from the LOD array
  91259. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91260. * @param mesh defines the mesh to be removed
  91261. * @return This mesh (for chaining)
  91262. */
  91263. removeLODLevel(mesh: Mesh): Mesh;
  91264. /**
  91265. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91266. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91267. * @param camera defines the camera to use to compute distance
  91268. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91269. * @return This mesh (for chaining)
  91270. */
  91271. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91272. /**
  91273. * Gets the mesh internal Geometry object
  91274. */
  91275. readonly geometry: Nullable<Geometry>;
  91276. /**
  91277. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91278. * @returns the total number of vertices
  91279. */
  91280. getTotalVertices(): number;
  91281. /**
  91282. * Returns the content of an associated vertex buffer
  91283. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91284. * - VertexBuffer.PositionKind
  91285. * - VertexBuffer.UVKind
  91286. * - VertexBuffer.UV2Kind
  91287. * - VertexBuffer.UV3Kind
  91288. * - VertexBuffer.UV4Kind
  91289. * - VertexBuffer.UV5Kind
  91290. * - VertexBuffer.UV6Kind
  91291. * - VertexBuffer.ColorKind
  91292. * - VertexBuffer.MatricesIndicesKind
  91293. * - VertexBuffer.MatricesIndicesExtraKind
  91294. * - VertexBuffer.MatricesWeightsKind
  91295. * - VertexBuffer.MatricesWeightsExtraKind
  91296. * @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
  91297. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91298. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91299. */
  91300. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91301. /**
  91302. * Returns the mesh VertexBuffer object from the requested `kind`
  91303. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91304. * - VertexBuffer.PositionKind
  91305. * - VertexBuffer.NormalKind
  91306. * - VertexBuffer.UVKind
  91307. * - VertexBuffer.UV2Kind
  91308. * - VertexBuffer.UV3Kind
  91309. * - VertexBuffer.UV4Kind
  91310. * - VertexBuffer.UV5Kind
  91311. * - VertexBuffer.UV6Kind
  91312. * - VertexBuffer.ColorKind
  91313. * - VertexBuffer.MatricesIndicesKind
  91314. * - VertexBuffer.MatricesIndicesExtraKind
  91315. * - VertexBuffer.MatricesWeightsKind
  91316. * - VertexBuffer.MatricesWeightsExtraKind
  91317. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91318. */
  91319. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91320. /**
  91321. * Tests if a specific vertex buffer is associated with this mesh
  91322. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91323. * - VertexBuffer.PositionKind
  91324. * - VertexBuffer.NormalKind
  91325. * - VertexBuffer.UVKind
  91326. * - VertexBuffer.UV2Kind
  91327. * - VertexBuffer.UV3Kind
  91328. * - VertexBuffer.UV4Kind
  91329. * - VertexBuffer.UV5Kind
  91330. * - VertexBuffer.UV6Kind
  91331. * - VertexBuffer.ColorKind
  91332. * - VertexBuffer.MatricesIndicesKind
  91333. * - VertexBuffer.MatricesIndicesExtraKind
  91334. * - VertexBuffer.MatricesWeightsKind
  91335. * - VertexBuffer.MatricesWeightsExtraKind
  91336. * @returns a boolean
  91337. */
  91338. isVerticesDataPresent(kind: string): boolean;
  91339. /**
  91340. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91341. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91342. * - VertexBuffer.PositionKind
  91343. * - VertexBuffer.UVKind
  91344. * - VertexBuffer.UV2Kind
  91345. * - VertexBuffer.UV3Kind
  91346. * - VertexBuffer.UV4Kind
  91347. * - VertexBuffer.UV5Kind
  91348. * - VertexBuffer.UV6Kind
  91349. * - VertexBuffer.ColorKind
  91350. * - VertexBuffer.MatricesIndicesKind
  91351. * - VertexBuffer.MatricesIndicesExtraKind
  91352. * - VertexBuffer.MatricesWeightsKind
  91353. * - VertexBuffer.MatricesWeightsExtraKind
  91354. * @returns a boolean
  91355. */
  91356. isVertexBufferUpdatable(kind: string): boolean;
  91357. /**
  91358. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91359. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91360. * - VertexBuffer.PositionKind
  91361. * - VertexBuffer.NormalKind
  91362. * - VertexBuffer.UVKind
  91363. * - VertexBuffer.UV2Kind
  91364. * - VertexBuffer.UV3Kind
  91365. * - VertexBuffer.UV4Kind
  91366. * - VertexBuffer.UV5Kind
  91367. * - VertexBuffer.UV6Kind
  91368. * - VertexBuffer.ColorKind
  91369. * - VertexBuffer.MatricesIndicesKind
  91370. * - VertexBuffer.MatricesIndicesExtraKind
  91371. * - VertexBuffer.MatricesWeightsKind
  91372. * - VertexBuffer.MatricesWeightsExtraKind
  91373. * @returns an array of strings
  91374. */
  91375. getVerticesDataKinds(): string[];
  91376. /**
  91377. * Returns a positive integer : the total number of indices in this mesh geometry.
  91378. * @returns the numner of indices or zero if the mesh has no geometry.
  91379. */
  91380. getTotalIndices(): number;
  91381. /**
  91382. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91383. * @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.
  91384. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91385. * @returns the indices array or an empty array if the mesh has no geometry
  91386. */
  91387. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91388. readonly isBlocked: boolean;
  91389. /**
  91390. * Determine if the current mesh is ready to be rendered
  91391. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91392. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91393. * @returns true if all associated assets are ready (material, textures, shaders)
  91394. */
  91395. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91396. /**
  91397. * 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.
  91398. */
  91399. readonly areNormalsFrozen: boolean;
  91400. /**
  91401. * 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.
  91402. * @returns the current mesh
  91403. */
  91404. freezeNormals(): Mesh;
  91405. /**
  91406. * 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
  91407. * @returns the current mesh
  91408. */
  91409. unfreezeNormals(): Mesh;
  91410. /**
  91411. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91412. */
  91413. overridenInstanceCount: number;
  91414. /** @hidden */
  91415. _preActivate(): Mesh;
  91416. /** @hidden */
  91417. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91418. /** @hidden */
  91419. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91420. /**
  91421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91422. * This means the mesh underlying bounding box and sphere are recomputed.
  91423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91424. * @returns the current mesh
  91425. */
  91426. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91427. /** @hidden */
  91428. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91429. /**
  91430. * This function will subdivide the mesh into multiple submeshes
  91431. * @param count defines the expected number of submeshes
  91432. */
  91433. subdivide(count: number): void;
  91434. /**
  91435. * Copy a FloatArray into a specific associated vertex buffer
  91436. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91437. * - VertexBuffer.PositionKind
  91438. * - VertexBuffer.UVKind
  91439. * - VertexBuffer.UV2Kind
  91440. * - VertexBuffer.UV3Kind
  91441. * - VertexBuffer.UV4Kind
  91442. * - VertexBuffer.UV5Kind
  91443. * - VertexBuffer.UV6Kind
  91444. * - VertexBuffer.ColorKind
  91445. * - VertexBuffer.MatricesIndicesKind
  91446. * - VertexBuffer.MatricesIndicesExtraKind
  91447. * - VertexBuffer.MatricesWeightsKind
  91448. * - VertexBuffer.MatricesWeightsExtraKind
  91449. * @param data defines the data source
  91450. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91451. * @param stride defines the data stride size (can be null)
  91452. * @returns the current mesh
  91453. */
  91454. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91455. /**
  91456. * Delete a vertex buffer associated with this mesh
  91457. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91458. * - VertexBuffer.PositionKind
  91459. * - VertexBuffer.UVKind
  91460. * - VertexBuffer.UV2Kind
  91461. * - VertexBuffer.UV3Kind
  91462. * - VertexBuffer.UV4Kind
  91463. * - VertexBuffer.UV5Kind
  91464. * - VertexBuffer.UV6Kind
  91465. * - VertexBuffer.ColorKind
  91466. * - VertexBuffer.MatricesIndicesKind
  91467. * - VertexBuffer.MatricesIndicesExtraKind
  91468. * - VertexBuffer.MatricesWeightsKind
  91469. * - VertexBuffer.MatricesWeightsExtraKind
  91470. */
  91471. removeVerticesData(kind: string): void;
  91472. /**
  91473. * Flags an associated vertex buffer as updatable
  91474. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91475. * - VertexBuffer.PositionKind
  91476. * - VertexBuffer.UVKind
  91477. * - VertexBuffer.UV2Kind
  91478. * - VertexBuffer.UV3Kind
  91479. * - VertexBuffer.UV4Kind
  91480. * - VertexBuffer.UV5Kind
  91481. * - VertexBuffer.UV6Kind
  91482. * - VertexBuffer.ColorKind
  91483. * - VertexBuffer.MatricesIndicesKind
  91484. * - VertexBuffer.MatricesIndicesExtraKind
  91485. * - VertexBuffer.MatricesWeightsKind
  91486. * - VertexBuffer.MatricesWeightsExtraKind
  91487. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91488. */
  91489. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91490. /**
  91491. * Sets the mesh global Vertex Buffer
  91492. * @param buffer defines the buffer to use
  91493. * @returns the current mesh
  91494. */
  91495. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91496. /**
  91497. * Update a specific associated vertex buffer
  91498. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91499. * - VertexBuffer.PositionKind
  91500. * - VertexBuffer.UVKind
  91501. * - VertexBuffer.UV2Kind
  91502. * - VertexBuffer.UV3Kind
  91503. * - VertexBuffer.UV4Kind
  91504. * - VertexBuffer.UV5Kind
  91505. * - VertexBuffer.UV6Kind
  91506. * - VertexBuffer.ColorKind
  91507. * - VertexBuffer.MatricesIndicesKind
  91508. * - VertexBuffer.MatricesIndicesExtraKind
  91509. * - VertexBuffer.MatricesWeightsKind
  91510. * - VertexBuffer.MatricesWeightsExtraKind
  91511. * @param data defines the data source
  91512. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91513. * @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)
  91514. * @returns the current mesh
  91515. */
  91516. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91517. /**
  91518. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91519. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91520. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91521. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91522. * @returns the current mesh
  91523. */
  91524. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91525. /**
  91526. * Creates a un-shared specific occurence of the geometry for the mesh.
  91527. * @returns the current mesh
  91528. */
  91529. makeGeometryUnique(): Mesh;
  91530. /**
  91531. * Set the index buffer of this mesh
  91532. * @param indices defines the source data
  91533. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91534. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91535. * @returns the current mesh
  91536. */
  91537. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91538. /**
  91539. * Update the current index buffer
  91540. * @param indices defines the source data
  91541. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91542. * @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)
  91543. * @returns the current mesh
  91544. */
  91545. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91546. /**
  91547. * Invert the geometry to move from a right handed system to a left handed one.
  91548. * @returns the current mesh
  91549. */
  91550. toLeftHanded(): Mesh;
  91551. /** @hidden */
  91552. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91553. /** @hidden */
  91554. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91555. /**
  91556. * Registers for this mesh a javascript function called just before the rendering process
  91557. * @param func defines the function to call before rendering this mesh
  91558. * @returns the current mesh
  91559. */
  91560. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91561. /**
  91562. * Disposes a previously registered javascript function called before the rendering
  91563. * @param func defines the function to remove
  91564. * @returns the current mesh
  91565. */
  91566. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91567. /**
  91568. * Registers for this mesh a javascript function called just after the rendering is complete
  91569. * @param func defines the function to call after rendering this mesh
  91570. * @returns the current mesh
  91571. */
  91572. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91573. /**
  91574. * Disposes a previously registered javascript function called after the rendering.
  91575. * @param func defines the function to remove
  91576. * @returns the current mesh
  91577. */
  91578. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91579. /** @hidden */
  91580. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91581. /** @hidden */
  91582. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91583. /** @hidden */
  91584. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  91585. /** @hidden */
  91586. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91587. /** @hidden */
  91588. _rebuild(): void;
  91589. /** @hidden */
  91590. _freeze(): void;
  91591. /** @hidden */
  91592. _unFreeze(): void;
  91593. /**
  91594. * 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
  91595. * @param subMesh defines the subMesh to render
  91596. * @param enableAlphaMode defines if alpha mode can be changed
  91597. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91598. * @returns the current mesh
  91599. */
  91600. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91601. private _onBeforeDraw;
  91602. /**
  91603. * Renormalize the mesh and patch it up if there are no weights
  91604. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91605. * However in the case of zero weights then we set just a single influence to 1.
  91606. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91607. */
  91608. cleanMatrixWeights(): void;
  91609. private normalizeSkinFourWeights;
  91610. private normalizeSkinWeightsAndExtra;
  91611. /**
  91612. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91613. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91614. * the user know there was an issue with importing the mesh
  91615. * @returns a validation object with skinned, valid and report string
  91616. */
  91617. validateSkinning(): {
  91618. skinned: boolean;
  91619. valid: boolean;
  91620. report: string;
  91621. };
  91622. /** @hidden */
  91623. _checkDelayState(): Mesh;
  91624. private _queueLoad;
  91625. /**
  91626. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91627. * A mesh is in the frustum if its bounding box intersects the frustum
  91628. * @param frustumPlanes defines the frustum to test
  91629. * @returns true if the mesh is in the frustum planes
  91630. */
  91631. isInFrustum(frustumPlanes: Plane[]): boolean;
  91632. /**
  91633. * Sets the mesh material by the material or multiMaterial `id` property
  91634. * @param id is a string identifying the material or the multiMaterial
  91635. * @returns the current mesh
  91636. */
  91637. setMaterialByID(id: string): Mesh;
  91638. /**
  91639. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91640. * @returns an array of IAnimatable
  91641. */
  91642. getAnimatables(): IAnimatable[];
  91643. /**
  91644. * Modifies the mesh geometry according to the passed transformation matrix.
  91645. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91646. * The mesh normals are modified using the same transformation.
  91647. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91648. * @param transform defines the transform matrix to use
  91649. * @see http://doc.babylonjs.com/resources/baking_transformations
  91650. * @returns the current mesh
  91651. */
  91652. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91653. /**
  91654. * Modifies the mesh geometry according to its own current World Matrix.
  91655. * The mesh World Matrix is then reset.
  91656. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91657. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91658. * @see http://doc.babylonjs.com/resources/baking_transformations
  91659. * @returns the current mesh
  91660. */
  91661. bakeCurrentTransformIntoVertices(): Mesh;
  91662. /** @hidden */
  91663. readonly _positions: Nullable<Vector3[]>;
  91664. /** @hidden */
  91665. _resetPointsArrayCache(): Mesh;
  91666. /** @hidden */
  91667. _generatePointsArray(): boolean;
  91668. /**
  91669. * Returns a new Mesh object generated from the current mesh properties.
  91670. * This method must not get confused with createInstance()
  91671. * @param name is a string, the name given to the new mesh
  91672. * @param newParent can be any Node object (default `null`)
  91673. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91674. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91675. * @returns a new mesh
  91676. */
  91677. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91678. /**
  91679. * Releases resources associated with this mesh.
  91680. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91681. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91682. */
  91683. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91684. /** @hidden */
  91685. _disposeInstanceSpecificData(): void;
  91686. /**
  91687. * Modifies the mesh geometry according to a displacement map.
  91688. * 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.
  91689. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91690. * @param url is a string, the URL from the image file is to be downloaded.
  91691. * @param minHeight is the lower limit of the displacement.
  91692. * @param maxHeight is the upper limit of the displacement.
  91693. * @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.
  91694. * @param uvOffset is an optional vector2 used to offset UV.
  91695. * @param uvScale is an optional vector2 used to scale UV.
  91696. * @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.
  91697. * @returns the Mesh.
  91698. */
  91699. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91700. /**
  91701. * Modifies the mesh geometry according to a displacementMap buffer.
  91702. * 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.
  91703. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91704. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91705. * @param heightMapWidth is the width of the buffer image.
  91706. * @param heightMapHeight is the height of the buffer image.
  91707. * @param minHeight is the lower limit of the displacement.
  91708. * @param maxHeight is the upper limit of the displacement.
  91709. * @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.
  91710. * @param uvOffset is an optional vector2 used to offset UV.
  91711. * @param uvScale is an optional vector2 used to scale UV.
  91712. * @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.
  91713. * @returns the Mesh.
  91714. */
  91715. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91716. /**
  91717. * Modify the mesh to get a flat shading rendering.
  91718. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91719. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91720. * @returns current mesh
  91721. */
  91722. convertToFlatShadedMesh(): Mesh;
  91723. /**
  91724. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91725. * In other words, more vertices, no more indices and a single bigger VBO.
  91726. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91727. * @returns current mesh
  91728. */
  91729. convertToUnIndexedMesh(): Mesh;
  91730. /**
  91731. * Inverses facet orientations.
  91732. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91733. * @param flipNormals will also inverts the normals
  91734. * @returns current mesh
  91735. */
  91736. flipFaces(flipNormals?: boolean): Mesh;
  91737. /**
  91738. * Increase the number of facets and hence vertices in a mesh
  91739. * Vertex normals are interpolated from existing vertex normals
  91740. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91741. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91742. */
  91743. increaseVertices(numberPerEdge: number): void;
  91744. /**
  91745. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91746. * This will undo any application of covertToFlatShadedMesh
  91747. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91748. */
  91749. forceSharedVertices(): void;
  91750. /** @hidden */
  91751. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91752. /** @hidden */
  91753. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91754. /**
  91755. * Creates a new InstancedMesh object from the mesh model.
  91756. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91757. * @param name defines the name of the new instance
  91758. * @returns a new InstancedMesh
  91759. */
  91760. createInstance(name: string): InstancedMesh;
  91761. /**
  91762. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91763. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91764. * @returns the current mesh
  91765. */
  91766. synchronizeInstances(): Mesh;
  91767. /**
  91768. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91769. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91770. * This should be used together with the simplification to avoid disappearing triangles.
  91771. * @param successCallback an optional success callback to be called after the optimization finished.
  91772. * @returns the current mesh
  91773. */
  91774. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91775. /**
  91776. * Serialize current mesh
  91777. * @param serializationObject defines the object which will receive the serialization data
  91778. */
  91779. serialize(serializationObject: any): void;
  91780. /** @hidden */
  91781. _syncGeometryWithMorphTargetManager(): void;
  91782. /** @hidden */
  91783. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91784. /**
  91785. * Returns a new Mesh object parsed from the source provided.
  91786. * @param parsedMesh is the source
  91787. * @param scene defines the hosting scene
  91788. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91789. * @returns a new Mesh
  91790. */
  91791. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91792. /**
  91793. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91794. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91795. * @param name defines the name of the mesh to create
  91796. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91797. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91798. * @param closePath creates a seam between the first and the last points of each path of the path array
  91799. * @param offset is taken in account only if the `pathArray` is containing a single path
  91800. * @param scene defines the hosting scene
  91801. * @param updatable defines if the mesh must be flagged as updatable
  91802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91803. * @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)
  91804. * @returns a new Mesh
  91805. */
  91806. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91807. /**
  91808. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91809. * @param name defines the name of the mesh to create
  91810. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91811. * @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
  91812. * @param scene defines the hosting scene
  91813. * @param updatable defines if the mesh must be flagged as updatable
  91814. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91815. * @returns a new Mesh
  91816. */
  91817. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91818. /**
  91819. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91820. * @param name defines the name of the mesh to create
  91821. * @param size sets the size (float) of each box side (default 1)
  91822. * @param scene defines the hosting scene
  91823. * @param updatable defines if the mesh must be flagged as updatable
  91824. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91825. * @returns a new Mesh
  91826. */
  91827. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91828. /**
  91829. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91830. * @param name defines the name of the mesh to create
  91831. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91832. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91833. * @param scene defines the hosting scene
  91834. * @param updatable defines if the mesh must be flagged as updatable
  91835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91836. * @returns a new Mesh
  91837. */
  91838. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91839. /**
  91840. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91841. * @param name defines the name of the mesh to create
  91842. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91843. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91844. * @param scene defines the hosting scene
  91845. * @returns a new Mesh
  91846. */
  91847. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91848. /**
  91849. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91850. * @param name defines the name of the mesh to create
  91851. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91852. * @param diameterTop set the top cap diameter (floats, default 1)
  91853. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91854. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91855. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91856. * @param scene defines the hosting scene
  91857. * @param updatable defines if the mesh must be flagged as updatable
  91858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91859. * @returns a new Mesh
  91860. */
  91861. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91862. /**
  91863. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91864. * @param name defines the name of the mesh to create
  91865. * @param diameter sets the diameter size (float) of the torus (default 1)
  91866. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91867. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91868. * @param scene defines the hosting scene
  91869. * @param updatable defines if the mesh must be flagged as updatable
  91870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91871. * @returns a new Mesh
  91872. */
  91873. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91874. /**
  91875. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91876. * @param name defines the name of the mesh to create
  91877. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91878. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91879. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91880. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91881. * @param p the number of windings on X axis (positive integers, default 2)
  91882. * @param q the number of windings on Y axis (positive integers, default 3)
  91883. * @param scene defines the hosting scene
  91884. * @param updatable defines if the mesh must be flagged as updatable
  91885. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91886. * @returns a new Mesh
  91887. */
  91888. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91889. /**
  91890. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91891. * @param name defines the name of the mesh to create
  91892. * @param points is an array successive Vector3
  91893. * @param scene defines the hosting scene
  91894. * @param updatable defines if the mesh must be flagged as updatable
  91895. * @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).
  91896. * @returns a new Mesh
  91897. */
  91898. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91899. /**
  91900. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91901. * @param name defines the name of the mesh to create
  91902. * @param points is an array successive Vector3
  91903. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91904. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91905. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91906. * @param scene defines the hosting scene
  91907. * @param updatable defines if the mesh must be flagged as updatable
  91908. * @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)
  91909. * @returns a new Mesh
  91910. */
  91911. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91912. /**
  91913. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91914. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91915. * 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.
  91916. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91917. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91918. * Remember you can only change the shape positions, not their number when updating a polygon.
  91919. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91920. * @param name defines the name of the mesh to create
  91921. * @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
  91922. * @param scene defines the hosting scene
  91923. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91924. * @param updatable defines if the mesh must be flagged as updatable
  91925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91926. * @param earcutInjection can be used to inject your own earcut reference
  91927. * @returns a new Mesh
  91928. */
  91929. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91930. /**
  91931. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91932. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91933. * @param name defines the name of the mesh to create
  91934. * @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
  91935. * @param depth defines the height of extrusion
  91936. * @param scene defines the hosting scene
  91937. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91938. * @param updatable defines if the mesh must be flagged as updatable
  91939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91940. * @param earcutInjection can be used to inject your own earcut reference
  91941. * @returns a new Mesh
  91942. */
  91943. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91944. /**
  91945. * Creates an extruded shape mesh.
  91946. * 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
  91947. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91948. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91949. * @param name defines the name of the mesh to create
  91950. * @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
  91951. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91952. * @param scale is the value to scale the shape
  91953. * @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
  91954. * @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
  91955. * @param scene defines the hosting scene
  91956. * @param updatable defines if the mesh must be flagged as updatable
  91957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91958. * @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)
  91959. * @returns a new Mesh
  91960. */
  91961. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91962. /**
  91963. * Creates an custom extruded shape mesh.
  91964. * The custom extrusion is a parametric shape.
  91965. * It has no predefined shape. Its final shape will depend on the input parameters.
  91966. * Please consider using the same method from the MeshBuilder class instead
  91967. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91968. * @param name defines the name of the mesh to create
  91969. * @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
  91970. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91971. * @param scaleFunction is a custom Javascript function called on each path point
  91972. * @param rotationFunction is a custom Javascript function called on each path point
  91973. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91974. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91975. * @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
  91976. * @param scene defines the hosting scene
  91977. * @param updatable defines if the mesh must be flagged as updatable
  91978. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91979. * @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)
  91980. * @returns a new Mesh
  91981. */
  91982. 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;
  91983. /**
  91984. * Creates lathe mesh.
  91985. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91986. * Please consider using the same method from the MeshBuilder class instead
  91987. * @param name defines the name of the mesh to create
  91988. * @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
  91989. * @param radius is the radius value of the lathe
  91990. * @param tessellation is the side number of the lathe.
  91991. * @param scene defines the hosting scene
  91992. * @param updatable defines if the mesh must be flagged as updatable
  91993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91994. * @returns a new Mesh
  91995. */
  91996. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91997. /**
  91998. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91999. * @param name defines the name of the mesh to create
  92000. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92001. * @param scene defines the hosting scene
  92002. * @param updatable defines if the mesh must be flagged as updatable
  92003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92004. * @returns a new Mesh
  92005. */
  92006. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92007. /**
  92008. * Creates a ground mesh.
  92009. * Please consider using the same method from the MeshBuilder class instead
  92010. * @param name defines the name of the mesh to create
  92011. * @param width set the width of the ground
  92012. * @param height set the height of the ground
  92013. * @param subdivisions sets the number of subdivisions per side
  92014. * @param scene defines the hosting scene
  92015. * @param updatable defines if the mesh must be flagged as updatable
  92016. * @returns a new Mesh
  92017. */
  92018. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92019. /**
  92020. * Creates a tiled ground mesh.
  92021. * Please consider using the same method from the MeshBuilder class instead
  92022. * @param name defines the name of the mesh to create
  92023. * @param xmin set the ground minimum X coordinate
  92024. * @param zmin set the ground minimum Y coordinate
  92025. * @param xmax set the ground maximum X coordinate
  92026. * @param zmax set the ground maximum Z coordinate
  92027. * @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
  92028. * @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
  92029. * @param scene defines the hosting scene
  92030. * @param updatable defines if the mesh must be flagged as updatable
  92031. * @returns a new Mesh
  92032. */
  92033. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92034. w: number;
  92035. h: number;
  92036. }, precision: {
  92037. w: number;
  92038. h: number;
  92039. }, scene: Scene, updatable?: boolean): Mesh;
  92040. /**
  92041. * Creates a ground mesh from a height map.
  92042. * Please consider using the same method from the MeshBuilder class instead
  92043. * @see http://doc.babylonjs.com/babylon101/height_map
  92044. * @param name defines the name of the mesh to create
  92045. * @param url sets the URL of the height map image resource
  92046. * @param width set the ground width size
  92047. * @param height set the ground height size
  92048. * @param subdivisions sets the number of subdivision per side
  92049. * @param minHeight is the minimum altitude on the ground
  92050. * @param maxHeight is the maximum altitude on the ground
  92051. * @param scene defines the hosting scene
  92052. * @param updatable defines if the mesh must be flagged as updatable
  92053. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92054. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92055. * @returns a new Mesh
  92056. */
  92057. 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;
  92058. /**
  92059. * Creates a tube mesh.
  92060. * The tube is a parametric shape.
  92061. * It has no predefined shape. Its final shape will depend on the input parameters.
  92062. * Please consider using the same method from the MeshBuilder class instead
  92063. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92064. * @param name defines the name of the mesh to create
  92065. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92066. * @param radius sets the tube radius size
  92067. * @param tessellation is the number of sides on the tubular surface
  92068. * @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
  92069. * @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
  92070. * @param scene defines the hosting scene
  92071. * @param updatable defines if the mesh must be flagged as updatable
  92072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92073. * @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)
  92074. * @returns a new Mesh
  92075. */
  92076. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92077. (i: number, distance: number): number;
  92078. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92079. /**
  92080. * Creates a polyhedron mesh.
  92081. * Please consider using the same method from the MeshBuilder class instead.
  92082. * * 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
  92083. * * The parameter `size` (positive float, default 1) sets the polygon size
  92084. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92085. * * 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`
  92086. * * 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
  92087. * * 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)`)
  92088. * * 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
  92089. * * 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
  92090. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92091. * * If you create a double-sided mesh, you can choose what parts of 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
  92092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92093. * @param name defines the name of the mesh to create
  92094. * @param options defines the options used to create the mesh
  92095. * @param scene defines the hosting scene
  92096. * @returns a new Mesh
  92097. */
  92098. static CreatePolyhedron(name: string, options: {
  92099. type?: number;
  92100. size?: number;
  92101. sizeX?: number;
  92102. sizeY?: number;
  92103. sizeZ?: number;
  92104. custom?: any;
  92105. faceUV?: Vector4[];
  92106. faceColors?: Color4[];
  92107. updatable?: boolean;
  92108. sideOrientation?: number;
  92109. }, scene: Scene): Mesh;
  92110. /**
  92111. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92112. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92113. * * 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`)
  92114. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92115. * * 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
  92116. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92117. * * If you create a double-sided mesh, you can choose what parts of 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
  92118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92119. * @param name defines the name of the mesh
  92120. * @param options defines the options used to create the mesh
  92121. * @param scene defines the hosting scene
  92122. * @returns a new Mesh
  92123. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92124. */
  92125. static CreateIcoSphere(name: string, options: {
  92126. radius?: number;
  92127. flat?: boolean;
  92128. subdivisions?: number;
  92129. sideOrientation?: number;
  92130. updatable?: boolean;
  92131. }, scene: Scene): Mesh;
  92132. /**
  92133. * Creates a decal mesh.
  92134. * Please consider using the same method from the MeshBuilder class instead.
  92135. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92136. * @param name defines the name of the mesh
  92137. * @param sourceMesh defines the mesh receiving the decal
  92138. * @param position sets the position of the decal in world coordinates
  92139. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92140. * @param size sets the decal scaling
  92141. * @param angle sets the angle to rotate the decal
  92142. * @returns a new Mesh
  92143. */
  92144. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92145. /**
  92146. * Prepare internal position array for software CPU skinning
  92147. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92148. */
  92149. setPositionsForCPUSkinning(): Float32Array;
  92150. /**
  92151. * Prepare internal normal array for software CPU skinning
  92152. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92153. */
  92154. setNormalsForCPUSkinning(): Float32Array;
  92155. /**
  92156. * Updates the vertex buffer by applying transformation from the bones
  92157. * @param skeleton defines the skeleton to apply to current mesh
  92158. * @returns the current mesh
  92159. */
  92160. applySkeleton(skeleton: Skeleton): Mesh;
  92161. /**
  92162. * 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
  92163. * @param meshes defines the list of meshes to scan
  92164. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92165. */
  92166. static MinMax(meshes: AbstractMesh[]): {
  92167. min: Vector3;
  92168. max: Vector3;
  92169. };
  92170. /**
  92171. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92172. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92173. * @returns a vector3
  92174. */
  92175. static Center(meshesOrMinMaxVector: {
  92176. min: Vector3;
  92177. max: Vector3;
  92178. } | AbstractMesh[]): Vector3;
  92179. /**
  92180. * Merge the array of meshes into a single mesh for performance reasons.
  92181. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92182. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92183. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92184. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92185. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92186. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92187. * @returns a new mesh
  92188. */
  92189. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92190. /** @hidden */
  92191. addInstance(instance: InstancedMesh): void;
  92192. /** @hidden */
  92193. removeInstance(instance: InstancedMesh): void;
  92194. }
  92195. }
  92196. declare module BABYLON {
  92197. /**
  92198. * This is the base class of all the camera used in the application.
  92199. * @see http://doc.babylonjs.com/features/cameras
  92200. */
  92201. export class Camera extends Node {
  92202. /** @hidden */
  92203. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92204. /**
  92205. * This is the default projection mode used by the cameras.
  92206. * It helps recreating a feeling of perspective and better appreciate depth.
  92207. * This is the best way to simulate real life cameras.
  92208. */
  92209. static readonly PERSPECTIVE_CAMERA: number;
  92210. /**
  92211. * This helps creating camera with an orthographic mode.
  92212. * 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.
  92213. */
  92214. static readonly ORTHOGRAPHIC_CAMERA: number;
  92215. /**
  92216. * This is the default FOV mode for perspective cameras.
  92217. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92218. */
  92219. static readonly FOVMODE_VERTICAL_FIXED: number;
  92220. /**
  92221. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92222. */
  92223. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92224. /**
  92225. * This specifies ther is no need for a camera rig.
  92226. * Basically only one eye is rendered corresponding to the camera.
  92227. */
  92228. static readonly RIG_MODE_NONE: number;
  92229. /**
  92230. * Simulates a camera Rig with one blue eye and one red eye.
  92231. * This can be use with 3d blue and red glasses.
  92232. */
  92233. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92234. /**
  92235. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92236. */
  92237. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92238. /**
  92239. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92240. */
  92241. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92242. /**
  92243. * Defines that both eyes of the camera will be rendered over under each other.
  92244. */
  92245. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92246. /**
  92247. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92248. */
  92249. static readonly RIG_MODE_VR: number;
  92250. /**
  92251. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92252. */
  92253. static readonly RIG_MODE_WEBVR: number;
  92254. /**
  92255. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92256. */
  92257. static readonly RIG_MODE_CUSTOM: number;
  92258. /**
  92259. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92260. */
  92261. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92262. /**
  92263. * Define the input manager associated with the camera.
  92264. */
  92265. inputs: CameraInputsManager<Camera>;
  92266. /** @hidden */
  92267. _position: Vector3;
  92268. /**
  92269. * Define the current local position of the camera in the scene
  92270. */
  92271. position: Vector3;
  92272. /**
  92273. * The vector the camera should consider as up.
  92274. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92275. */
  92276. upVector: Vector3;
  92277. /**
  92278. * Define the current limit on the left side for an orthographic camera
  92279. * In scene unit
  92280. */
  92281. orthoLeft: Nullable<number>;
  92282. /**
  92283. * Define the current limit on the right side for an orthographic camera
  92284. * In scene unit
  92285. */
  92286. orthoRight: Nullable<number>;
  92287. /**
  92288. * Define the current limit on the bottom side for an orthographic camera
  92289. * In scene unit
  92290. */
  92291. orthoBottom: Nullable<number>;
  92292. /**
  92293. * Define the current limit on the top side for an orthographic camera
  92294. * In scene unit
  92295. */
  92296. orthoTop: Nullable<number>;
  92297. /**
  92298. * Field Of View is set in Radians. (default is 0.8)
  92299. */
  92300. fov: number;
  92301. /**
  92302. * Define the minimum distance the camera can see from.
  92303. * This is important to note that the depth buffer are not infinite and the closer it starts
  92304. * the more your scene might encounter depth fighting issue.
  92305. */
  92306. minZ: number;
  92307. /**
  92308. * Define the maximum distance the camera can see to.
  92309. * This is important to note that the depth buffer are not infinite and the further it end
  92310. * the more your scene might encounter depth fighting issue.
  92311. */
  92312. maxZ: number;
  92313. /**
  92314. * Define the default inertia of the camera.
  92315. * This helps giving a smooth feeling to the camera movement.
  92316. */
  92317. inertia: number;
  92318. /**
  92319. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92320. */
  92321. mode: number;
  92322. /**
  92323. * Define wether the camera is intermediate.
  92324. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92325. */
  92326. isIntermediate: boolean;
  92327. /**
  92328. * Define the viewport of the camera.
  92329. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92330. */
  92331. viewport: Viewport;
  92332. /**
  92333. * Restricts the camera to viewing objects with the same layerMask.
  92334. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92335. */
  92336. layerMask: number;
  92337. /**
  92338. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92339. */
  92340. fovMode: number;
  92341. /**
  92342. * Rig mode of the camera.
  92343. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92344. * This is normally controlled byt the camera themselves as internal use.
  92345. */
  92346. cameraRigMode: number;
  92347. /**
  92348. * Defines the distance between both "eyes" in case of a RIG
  92349. */
  92350. interaxialDistance: number;
  92351. /**
  92352. * Defines if stereoscopic rendering is done side by side or over under.
  92353. */
  92354. isStereoscopicSideBySide: boolean;
  92355. /**
  92356. * 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
  92357. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92358. * else in the scene. (Eg. security camera)
  92359. *
  92360. * 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)
  92361. */
  92362. customRenderTargets: RenderTargetTexture[];
  92363. /**
  92364. * When set, the camera will render to this render target instead of the default canvas
  92365. *
  92366. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92367. */
  92368. outputRenderTarget: Nullable<RenderTargetTexture>;
  92369. /**
  92370. * Observable triggered when the camera view matrix has changed.
  92371. */
  92372. onViewMatrixChangedObservable: Observable<Camera>;
  92373. /**
  92374. * Observable triggered when the camera Projection matrix has changed.
  92375. */
  92376. onProjectionMatrixChangedObservable: Observable<Camera>;
  92377. /**
  92378. * Observable triggered when the inputs have been processed.
  92379. */
  92380. onAfterCheckInputsObservable: Observable<Camera>;
  92381. /**
  92382. * Observable triggered when reset has been called and applied to the camera.
  92383. */
  92384. onRestoreStateObservable: Observable<Camera>;
  92385. /** @hidden */
  92386. _cameraRigParams: any;
  92387. /** @hidden */
  92388. _rigCameras: Camera[];
  92389. /** @hidden */
  92390. _rigPostProcess: Nullable<PostProcess>;
  92391. protected _webvrViewMatrix: Matrix;
  92392. /** @hidden */
  92393. _skipRendering: boolean;
  92394. /** @hidden */
  92395. _projectionMatrix: Matrix;
  92396. /** @hidden */
  92397. _postProcesses: Nullable<PostProcess>[];
  92398. /** @hidden */
  92399. _activeMeshes: SmartArray<AbstractMesh>;
  92400. protected _globalPosition: Vector3;
  92401. /** @hidden */
  92402. _computedViewMatrix: Matrix;
  92403. private _doNotComputeProjectionMatrix;
  92404. private _transformMatrix;
  92405. private _frustumPlanes;
  92406. private _refreshFrustumPlanes;
  92407. private _storedFov;
  92408. private _stateStored;
  92409. /**
  92410. * Instantiates a new camera object.
  92411. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92412. * @see http://doc.babylonjs.com/features/cameras
  92413. * @param name Defines the name of the camera in the scene
  92414. * @param position Defines the position of the camera
  92415. * @param scene Defines the scene the camera belongs too
  92416. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92417. */
  92418. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92419. /**
  92420. * Store current camera state (fov, position, etc..)
  92421. * @returns the camera
  92422. */
  92423. storeState(): Camera;
  92424. /**
  92425. * Restores the camera state values if it has been stored. You must call storeState() first
  92426. */
  92427. protected _restoreStateValues(): boolean;
  92428. /**
  92429. * Restored camera state. You must call storeState() first.
  92430. * @returns true if restored and false otherwise
  92431. */
  92432. restoreState(): boolean;
  92433. /**
  92434. * Gets the class name of the camera.
  92435. * @returns the class name
  92436. */
  92437. getClassName(): string;
  92438. /** @hidden */
  92439. readonly _isCamera: boolean;
  92440. /**
  92441. * Gets a string representation of the camera useful for debug purpose.
  92442. * @param fullDetails Defines that a more verboe level of logging is required
  92443. * @returns the string representation
  92444. */
  92445. toString(fullDetails?: boolean): string;
  92446. /**
  92447. * Gets the current world space position of the camera.
  92448. */
  92449. readonly globalPosition: Vector3;
  92450. /**
  92451. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92452. * @returns the active meshe list
  92453. */
  92454. getActiveMeshes(): SmartArray<AbstractMesh>;
  92455. /**
  92456. * Check wether a mesh is part of the current active mesh list of the camera
  92457. * @param mesh Defines the mesh to check
  92458. * @returns true if active, false otherwise
  92459. */
  92460. isActiveMesh(mesh: Mesh): boolean;
  92461. /**
  92462. * Is this camera ready to be used/rendered
  92463. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92464. * @return true if the camera is ready
  92465. */
  92466. isReady(completeCheck?: boolean): boolean;
  92467. /** @hidden */
  92468. _initCache(): void;
  92469. /** @hidden */
  92470. _updateCache(ignoreParentClass?: boolean): void;
  92471. /** @hidden */
  92472. _isSynchronized(): boolean;
  92473. /** @hidden */
  92474. _isSynchronizedViewMatrix(): boolean;
  92475. /** @hidden */
  92476. _isSynchronizedProjectionMatrix(): boolean;
  92477. /**
  92478. * Attach the input controls to a specific dom element to get the input from.
  92479. * @param element Defines the element the controls should be listened from
  92480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92481. */
  92482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92483. /**
  92484. * Detach the current controls from the specified dom element.
  92485. * @param element Defines the element to stop listening the inputs from
  92486. */
  92487. detachControl(element: HTMLElement): void;
  92488. /**
  92489. * Update the camera state according to the different inputs gathered during the frame.
  92490. */
  92491. update(): void;
  92492. /** @hidden */
  92493. _checkInputs(): void;
  92494. /** @hidden */
  92495. readonly rigCameras: Camera[];
  92496. /**
  92497. * Gets the post process used by the rig cameras
  92498. */
  92499. readonly rigPostProcess: Nullable<PostProcess>;
  92500. /**
  92501. * Internal, gets the first post proces.
  92502. * @returns the first post process to be run on this camera.
  92503. */
  92504. _getFirstPostProcess(): Nullable<PostProcess>;
  92505. private _cascadePostProcessesToRigCams;
  92506. /**
  92507. * Attach a post process to the camera.
  92508. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92509. * @param postProcess The post process to attach to the camera
  92510. * @param insertAt The position of the post process in case several of them are in use in the scene
  92511. * @returns the position the post process has been inserted at
  92512. */
  92513. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92514. /**
  92515. * Detach a post process to the camera.
  92516. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92517. * @param postProcess The post process to detach from the camera
  92518. */
  92519. detachPostProcess(postProcess: PostProcess): void;
  92520. /**
  92521. * Gets the current world matrix of the camera
  92522. */
  92523. getWorldMatrix(): Matrix;
  92524. /** @hidden */
  92525. _getViewMatrix(): Matrix;
  92526. /**
  92527. * Gets the current view matrix of the camera.
  92528. * @param force forces the camera to recompute the matrix without looking at the cached state
  92529. * @returns the view matrix
  92530. */
  92531. getViewMatrix(force?: boolean): Matrix;
  92532. /**
  92533. * Freeze the projection matrix.
  92534. * It will prevent the cache check of the camera projection compute and can speed up perf
  92535. * if no parameter of the camera are meant to change
  92536. * @param projection Defines manually a projection if necessary
  92537. */
  92538. freezeProjectionMatrix(projection?: Matrix): void;
  92539. /**
  92540. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92541. */
  92542. unfreezeProjectionMatrix(): void;
  92543. /**
  92544. * Gets the current projection matrix of the camera.
  92545. * @param force forces the camera to recompute the matrix without looking at the cached state
  92546. * @returns the projection matrix
  92547. */
  92548. getProjectionMatrix(force?: boolean): Matrix;
  92549. /**
  92550. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92551. * @returns a Matrix
  92552. */
  92553. getTransformationMatrix(): Matrix;
  92554. private _updateFrustumPlanes;
  92555. /**
  92556. * Checks if a cullable object (mesh...) is in the camera frustum
  92557. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92558. * @param target The object to check
  92559. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92560. * @returns true if the object is in frustum otherwise false
  92561. */
  92562. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92563. /**
  92564. * Checks if a cullable object (mesh...) is in the camera frustum
  92565. * Unlike isInFrustum this cheks the full bounding box
  92566. * @param target The object to check
  92567. * @returns true if the object is in frustum otherwise false
  92568. */
  92569. isCompletelyInFrustum(target: ICullable): boolean;
  92570. /**
  92571. * Gets a ray in the forward direction from the camera.
  92572. * @param length Defines the length of the ray to create
  92573. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92574. * @param origin Defines the start point of the ray which defaults to the camera position
  92575. * @returns the forward ray
  92576. */
  92577. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92578. /**
  92579. * Releases resources associated with this node.
  92580. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92581. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92582. */
  92583. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92584. /** @hidden */
  92585. _isLeftCamera: boolean;
  92586. /**
  92587. * Gets the left camera of a rig setup in case of Rigged Camera
  92588. */
  92589. readonly isLeftCamera: boolean;
  92590. /** @hidden */
  92591. _isRightCamera: boolean;
  92592. /**
  92593. * Gets the right camera of a rig setup in case of Rigged Camera
  92594. */
  92595. readonly isRightCamera: boolean;
  92596. /**
  92597. * Gets the left camera of a rig setup in case of Rigged Camera
  92598. */
  92599. readonly leftCamera: Nullable<FreeCamera>;
  92600. /**
  92601. * Gets the right camera of a rig setup in case of Rigged Camera
  92602. */
  92603. readonly rightCamera: Nullable<FreeCamera>;
  92604. /**
  92605. * Gets the left camera target of a rig setup in case of Rigged Camera
  92606. * @returns the target position
  92607. */
  92608. getLeftTarget(): Nullable<Vector3>;
  92609. /**
  92610. * Gets the right camera target of a rig setup in case of Rigged Camera
  92611. * @returns the target position
  92612. */
  92613. getRightTarget(): Nullable<Vector3>;
  92614. /**
  92615. * @hidden
  92616. */
  92617. setCameraRigMode(mode: number, rigParams: any): void;
  92618. /** @hidden */
  92619. static _setStereoscopicRigMode(camera: Camera): void;
  92620. /** @hidden */
  92621. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92622. /** @hidden */
  92623. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92624. /** @hidden */
  92625. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92626. /** @hidden */
  92627. _getVRProjectionMatrix(): Matrix;
  92628. protected _updateCameraRotationMatrix(): void;
  92629. protected _updateWebVRCameraRotationMatrix(): void;
  92630. /**
  92631. * This function MUST be overwritten by the different WebVR cameras available.
  92632. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92633. * @hidden
  92634. */
  92635. _getWebVRProjectionMatrix(): Matrix;
  92636. /**
  92637. * This function MUST be overwritten by the different WebVR cameras available.
  92638. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92639. * @hidden
  92640. */
  92641. _getWebVRViewMatrix(): Matrix;
  92642. /** @hidden */
  92643. setCameraRigParameter(name: string, value: any): void;
  92644. /**
  92645. * needs to be overridden by children so sub has required properties to be copied
  92646. * @hidden
  92647. */
  92648. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92649. /**
  92650. * May need to be overridden by children
  92651. * @hidden
  92652. */
  92653. _updateRigCameras(): void;
  92654. /** @hidden */
  92655. _setupInputs(): void;
  92656. /**
  92657. * Serialiaze the camera setup to a json represention
  92658. * @returns the JSON representation
  92659. */
  92660. serialize(): any;
  92661. /**
  92662. * Clones the current camera.
  92663. * @param name The cloned camera name
  92664. * @returns the cloned camera
  92665. */
  92666. clone(name: string): Camera;
  92667. /**
  92668. * Gets the direction of the camera relative to a given local axis.
  92669. * @param localAxis Defines the reference axis to provide a relative direction.
  92670. * @return the direction
  92671. */
  92672. getDirection(localAxis: Vector3): Vector3;
  92673. /**
  92674. * Returns the current camera absolute rotation
  92675. */
  92676. readonly absoluteRotation: Quaternion;
  92677. /**
  92678. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92679. * @param localAxis Defines the reference axis to provide a relative direction.
  92680. * @param result Defines the vector to store the result in
  92681. */
  92682. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92683. /**
  92684. * Gets a camera constructor for a given camera type
  92685. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92686. * @param name The name of the camera the result will be able to instantiate
  92687. * @param scene The scene the result will construct the camera in
  92688. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92689. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92690. * @returns a factory method to construc the camera
  92691. */
  92692. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92693. /**
  92694. * Compute the world matrix of the camera.
  92695. * @returns the camera world matrix
  92696. */
  92697. computeWorldMatrix(): Matrix;
  92698. /**
  92699. * Parse a JSON and creates the camera from the parsed information
  92700. * @param parsedCamera The JSON to parse
  92701. * @param scene The scene to instantiate the camera in
  92702. * @returns the newly constructed camera
  92703. */
  92704. static Parse(parsedCamera: any, scene: Scene): Camera;
  92705. }
  92706. }
  92707. declare module BABYLON {
  92708. /**
  92709. * Class containing static functions to help procedurally build meshes
  92710. */
  92711. export class DiscBuilder {
  92712. /**
  92713. * Creates a plane polygonal mesh. By default, this is a disc
  92714. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92715. * * 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
  92716. * * 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
  92717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92720. * @param name defines the name of the mesh
  92721. * @param options defines the options used to create the mesh
  92722. * @param scene defines the hosting scene
  92723. * @returns the plane polygonal mesh
  92724. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92725. */
  92726. static CreateDisc(name: string, options: {
  92727. radius?: number;
  92728. tessellation?: number;
  92729. arc?: number;
  92730. updatable?: boolean;
  92731. sideOrientation?: number;
  92732. frontUVs?: Vector4;
  92733. backUVs?: Vector4;
  92734. }, scene?: Nullable<Scene>): Mesh;
  92735. }
  92736. }
  92737. declare module BABYLON {
  92738. /**
  92739. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92740. *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.
  92741. * The SPS is also a particle system. It provides some methods to manage the particles.
  92742. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92743. *
  92744. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92745. */
  92746. export class SolidParticleSystem implements IDisposable {
  92747. /**
  92748. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92749. * Example : var p = SPS.particles[i];
  92750. */
  92751. particles: SolidParticle[];
  92752. /**
  92753. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92754. */
  92755. nbParticles: number;
  92756. /**
  92757. * If the particles must ever face the camera (default false). Useful for planar particles.
  92758. */
  92759. billboard: boolean;
  92760. /**
  92761. * Recompute normals when adding a shape
  92762. */
  92763. recomputeNormals: boolean;
  92764. /**
  92765. * This a counter ofr your own usage. It's not set by any SPS functions.
  92766. */
  92767. counter: number;
  92768. /**
  92769. * The SPS name. This name is also given to the underlying mesh.
  92770. */
  92771. name: string;
  92772. /**
  92773. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92774. */
  92775. mesh: Mesh;
  92776. /**
  92777. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92778. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92779. */
  92780. vars: any;
  92781. /**
  92782. * This array is populated when the SPS is set as 'pickable'.
  92783. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92784. * Each element of this array is an object `{idx: int, faceId: int}`.
  92785. * `idx` is the picked particle index in the `SPS.particles` array
  92786. * `faceId` is the picked face index counted within this particle.
  92787. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92788. */
  92789. pickedParticles: {
  92790. idx: number;
  92791. faceId: number;
  92792. }[];
  92793. /**
  92794. * This array is populated when `enableDepthSort` is set to true.
  92795. * Each element of this array is an instance of the class DepthSortedParticle.
  92796. */
  92797. depthSortedParticles: DepthSortedParticle[];
  92798. /**
  92799. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92800. * @hidden
  92801. */
  92802. _bSphereOnly: boolean;
  92803. /**
  92804. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92805. * @hidden
  92806. */
  92807. _bSphereRadiusFactor: number;
  92808. private _scene;
  92809. private _positions;
  92810. private _indices;
  92811. private _normals;
  92812. private _colors;
  92813. private _uvs;
  92814. private _indices32;
  92815. private _positions32;
  92816. private _normals32;
  92817. private _fixedNormal32;
  92818. private _colors32;
  92819. private _uvs32;
  92820. private _index;
  92821. private _updatable;
  92822. private _pickable;
  92823. private _isVisibilityBoxLocked;
  92824. private _alwaysVisible;
  92825. private _depthSort;
  92826. private _expandable;
  92827. private _shapeCounter;
  92828. private _copy;
  92829. private _color;
  92830. private _computeParticleColor;
  92831. private _computeParticleTexture;
  92832. private _computeParticleRotation;
  92833. private _computeParticleVertex;
  92834. private _computeBoundingBox;
  92835. private _depthSortParticles;
  92836. private _camera;
  92837. private _mustUnrotateFixedNormals;
  92838. private _particlesIntersect;
  92839. private _needs32Bits;
  92840. private _isNotBuilt;
  92841. /**
  92842. * Creates a SPS (Solid Particle System) object.
  92843. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92844. * @param scene (Scene) is the scene in which the SPS is added.
  92845. * @param options defines the options of the sps e.g.
  92846. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92847. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92848. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92849. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92850. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92851. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92852. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92853. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92854. */
  92855. constructor(name: string, scene: Scene, options?: {
  92856. updatable?: boolean;
  92857. isPickable?: boolean;
  92858. enableDepthSort?: boolean;
  92859. particleIntersection?: boolean;
  92860. boundingSphereOnly?: boolean;
  92861. bSphereRadiusFactor?: number;
  92862. expandable?: boolean;
  92863. });
  92864. /**
  92865. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92866. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92867. * @returns the created mesh
  92868. */
  92869. buildMesh(): Mesh;
  92870. /**
  92871. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92872. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92873. * Thus the particles generated from `digest()` have their property `position` set yet.
  92874. * @param mesh ( Mesh ) is the mesh to be digested
  92875. * @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
  92876. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92877. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92878. * @returns the current SPS
  92879. */
  92880. digest(mesh: Mesh, options?: {
  92881. facetNb?: number;
  92882. number?: number;
  92883. delta?: number;
  92884. }): SolidParticleSystem;
  92885. private _unrotateFixedNormals;
  92886. private _resetCopy;
  92887. private _meshBuilder;
  92888. private _posToShape;
  92889. private _uvsToShapeUV;
  92890. private _addParticle;
  92891. /**
  92892. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92893. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92894. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92895. * @param nb (positive integer) the number of particles to be created from this model
  92896. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92897. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92898. * @returns the number of shapes in the system
  92899. */
  92900. addShape(mesh: Mesh, nb: number, options?: {
  92901. positionFunction?: any;
  92902. vertexFunction?: any;
  92903. }): number;
  92904. private _rebuildParticle;
  92905. /**
  92906. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92907. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  92908. * @returns the SPS.
  92909. */
  92910. rebuildMesh(reset?: boolean): SolidParticleSystem;
  92911. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  92912. * Returns an array with the removed particles.
  92913. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  92914. * The SPS can't be empty so at least one particle needs to remain in place.
  92915. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  92916. * @param start index of the first particle to remove
  92917. * @param end index of the last particle to remove (included)
  92918. * @returns an array populated with the removed particles
  92919. */
  92920. removeParticles(start: number, end: number): SolidParticle[];
  92921. /**
  92922. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92923. * This method calls `updateParticle()` for each particle of the SPS.
  92924. * For an animated SPS, it is usually called within the render loop.
  92925. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  92926. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92927. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92928. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92929. * @returns the SPS.
  92930. */
  92931. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92932. /**
  92933. * Disposes the SPS.
  92934. */
  92935. dispose(): void;
  92936. /**
  92937. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92938. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92939. * @returns the SPS.
  92940. */
  92941. refreshVisibleSize(): SolidParticleSystem;
  92942. /**
  92943. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92944. * @param size the size (float) of the visibility box
  92945. * note : this doesn't lock the SPS mesh bounding box.
  92946. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92947. */
  92948. setVisibilityBox(size: number): void;
  92949. /**
  92950. * Gets whether the SPS as always visible or not
  92951. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92952. */
  92953. /**
  92954. * Sets the SPS as always visible or not
  92955. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92956. */
  92957. isAlwaysVisible: boolean;
  92958. /**
  92959. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92960. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92961. */
  92962. /**
  92963. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92964. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92965. */
  92966. isVisibilityBoxLocked: boolean;
  92967. /**
  92968. * Tells to `setParticles()` to compute the particle rotations or not.
  92969. * Default value : true. The SPS is faster when it's set to false.
  92970. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92971. */
  92972. /**
  92973. * Gets if `setParticles()` computes the particle rotations or not.
  92974. * Default value : true. The SPS is faster when it's set to false.
  92975. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92976. */
  92977. computeParticleRotation: boolean;
  92978. /**
  92979. * Tells to `setParticles()` to compute the particle colors or not.
  92980. * Default value : true. The SPS is faster when it's set to false.
  92981. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92982. */
  92983. /**
  92984. * Gets if `setParticles()` computes the particle colors or not.
  92985. * Default value : true. The SPS is faster when it's set to false.
  92986. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92987. */
  92988. computeParticleColor: boolean;
  92989. /**
  92990. * Gets if `setParticles()` computes the particle textures or not.
  92991. * Default value : true. The SPS is faster when it's set to false.
  92992. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92993. */
  92994. computeParticleTexture: boolean;
  92995. /**
  92996. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92997. * Default value : false. The SPS is faster when it's set to false.
  92998. * Note : the particle custom vertex positions aren't stored values.
  92999. */
  93000. /**
  93001. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93002. * Default value : false. The SPS is faster when it's set to false.
  93003. * Note : the particle custom vertex positions aren't stored values.
  93004. */
  93005. computeParticleVertex: boolean;
  93006. /**
  93007. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93008. */
  93009. /**
  93010. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93011. */
  93012. computeBoundingBox: boolean;
  93013. /**
  93014. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93015. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93016. * Default : `true`
  93017. */
  93018. /**
  93019. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93020. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93021. * Default : `true`
  93022. */
  93023. depthSortParticles: boolean;
  93024. /**
  93025. * Gets if the SPS is created as expandable at construction time.
  93026. * Default : `false`
  93027. */
  93028. readonly expandable: boolean;
  93029. /**
  93030. * This function does nothing. It may be overwritten to set all the particle first values.
  93031. * The SPS doesn't call this function, you may have to call it by your own.
  93032. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93033. */
  93034. initParticles(): void;
  93035. /**
  93036. * This function does nothing. It may be overwritten to recycle a particle.
  93037. * The SPS doesn't call this function, you may have to call it by your own.
  93038. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93039. * @param particle The particle to recycle
  93040. * @returns the recycled particle
  93041. */
  93042. recycleParticle(particle: SolidParticle): SolidParticle;
  93043. /**
  93044. * Updates a particle : this function should be overwritten by the user.
  93045. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93046. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93047. * @example : just set a particle position or velocity and recycle conditions
  93048. * @param particle The particle to update
  93049. * @returns the updated particle
  93050. */
  93051. updateParticle(particle: SolidParticle): SolidParticle;
  93052. /**
  93053. * Updates a vertex of a particle : it can be overwritten by the user.
  93054. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93055. * @param particle the current particle
  93056. * @param vertex the current index of the current particle
  93057. * @param pt the index of the current vertex in the particle shape
  93058. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93059. * @example : just set a vertex particle position
  93060. * @returns the updated vertex
  93061. */
  93062. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93063. /**
  93064. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93065. * This does nothing and may be overwritten by the user.
  93066. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93067. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93068. * @param update the boolean update value actually passed to setParticles()
  93069. */
  93070. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93071. /**
  93072. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93073. * This will be passed three parameters.
  93074. * This does nothing and may be overwritten by the user.
  93075. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93076. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93077. * @param update the boolean update value actually passed to setParticles()
  93078. */
  93079. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93080. }
  93081. }
  93082. declare module BABYLON {
  93083. /**
  93084. * Represents one particle of a solid particle system.
  93085. */
  93086. export class SolidParticle {
  93087. /**
  93088. * particle global index
  93089. */
  93090. idx: number;
  93091. /**
  93092. * The color of the particle
  93093. */
  93094. color: Nullable<Color4>;
  93095. /**
  93096. * The world space position of the particle.
  93097. */
  93098. position: Vector3;
  93099. /**
  93100. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93101. */
  93102. rotation: Vector3;
  93103. /**
  93104. * The world space rotation quaternion of the particle.
  93105. */
  93106. rotationQuaternion: Nullable<Quaternion>;
  93107. /**
  93108. * The scaling of the particle.
  93109. */
  93110. scaling: Vector3;
  93111. /**
  93112. * The uvs of the particle.
  93113. */
  93114. uvs: Vector4;
  93115. /**
  93116. * The current speed of the particle.
  93117. */
  93118. velocity: Vector3;
  93119. /**
  93120. * The pivot point in the particle local space.
  93121. */
  93122. pivot: Vector3;
  93123. /**
  93124. * Must the particle be translated from its pivot point in its local space ?
  93125. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93126. * Default : false
  93127. */
  93128. translateFromPivot: boolean;
  93129. /**
  93130. * Is the particle active or not ?
  93131. */
  93132. alive: boolean;
  93133. /**
  93134. * Is the particle visible or not ?
  93135. */
  93136. isVisible: boolean;
  93137. /**
  93138. * Index of this particle in the global "positions" array (Internal use)
  93139. * @hidden
  93140. */
  93141. _pos: number;
  93142. /**
  93143. * @hidden Index of this particle in the global "indices" array (Internal use)
  93144. */
  93145. _ind: number;
  93146. /**
  93147. * @hidden ModelShape of this particle (Internal use)
  93148. */
  93149. _model: ModelShape;
  93150. /**
  93151. * ModelShape id of this particle
  93152. */
  93153. shapeId: number;
  93154. /**
  93155. * Index of the particle in its shape id
  93156. */
  93157. idxInShape: number;
  93158. /**
  93159. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93160. */
  93161. _modelBoundingInfo: BoundingInfo;
  93162. /**
  93163. * @hidden Particle BoundingInfo object (Internal use)
  93164. */
  93165. _boundingInfo: BoundingInfo;
  93166. /**
  93167. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93168. */
  93169. _sps: SolidParticleSystem;
  93170. /**
  93171. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93172. */
  93173. _stillInvisible: boolean;
  93174. /**
  93175. * @hidden Last computed particle rotation matrix
  93176. */
  93177. _rotationMatrix: number[];
  93178. /**
  93179. * Parent particle Id, if any.
  93180. * Default null.
  93181. */
  93182. parentId: Nullable<number>;
  93183. /**
  93184. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93185. * The possible values are :
  93186. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93187. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93188. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93190. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93191. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93192. * */
  93193. cullingStrategy: number;
  93194. /**
  93195. * @hidden Internal global position in the SPS.
  93196. */
  93197. _globalPosition: Vector3;
  93198. /**
  93199. * Creates a Solid Particle object.
  93200. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93201. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93202. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93203. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93204. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93205. * @param shapeId (integer) is the model shape identifier in the SPS.
  93206. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93207. * @param sps defines the sps it is associated to
  93208. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93209. */
  93210. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93211. /**
  93212. * Legacy support, changed scale to scaling
  93213. */
  93214. /**
  93215. * Legacy support, changed scale to scaling
  93216. */
  93217. scale: Vector3;
  93218. /**
  93219. * Legacy support, changed quaternion to rotationQuaternion
  93220. */
  93221. /**
  93222. * Legacy support, changed quaternion to rotationQuaternion
  93223. */
  93224. quaternion: Nullable<Quaternion>;
  93225. /**
  93226. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93227. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93228. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93229. * @returns true if it intersects
  93230. */
  93231. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93232. /**
  93233. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93234. * A particle is in the frustum if its bounding box intersects the frustum
  93235. * @param frustumPlanes defines the frustum to test
  93236. * @returns true if the particle is in the frustum planes
  93237. */
  93238. isInFrustum(frustumPlanes: Plane[]): boolean;
  93239. /**
  93240. * get the rotation matrix of the particle
  93241. * @hidden
  93242. */
  93243. getRotationMatrix(m: Matrix): void;
  93244. }
  93245. /**
  93246. * Represents the shape of the model used by one particle of a solid particle system.
  93247. * SPS internal tool, don't use it manually.
  93248. */
  93249. export class ModelShape {
  93250. /**
  93251. * The shape id
  93252. * @hidden
  93253. */
  93254. shapeID: number;
  93255. /**
  93256. * flat array of model positions (internal use)
  93257. * @hidden
  93258. */
  93259. _shape: Vector3[];
  93260. /**
  93261. * flat array of model UVs (internal use)
  93262. * @hidden
  93263. */
  93264. _shapeUV: number[];
  93265. /**
  93266. * color array of the model
  93267. * @hidden
  93268. */
  93269. _shapeColors: number[];
  93270. /**
  93271. * indices array of the model
  93272. * @hidden
  93273. */
  93274. _indices: number[];
  93275. /**
  93276. * normals array of the model
  93277. * @hidden
  93278. */
  93279. _normals: number[];
  93280. /**
  93281. * length of the shape in the model indices array (internal use)
  93282. * @hidden
  93283. */
  93284. _indicesLength: number;
  93285. /**
  93286. * Custom position function (internal use)
  93287. * @hidden
  93288. */
  93289. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93290. /**
  93291. * Custom vertex function (internal use)
  93292. * @hidden
  93293. */
  93294. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93295. /**
  93296. * 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.
  93297. * SPS internal tool, don't use it manually.
  93298. * @hidden
  93299. */
  93300. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  93301. }
  93302. /**
  93303. * Represents a Depth Sorted Particle in the solid particle system.
  93304. */
  93305. export class DepthSortedParticle {
  93306. /**
  93307. * Index of the particle in the "indices" array
  93308. */
  93309. ind: number;
  93310. /**
  93311. * Length of the particle shape in the "indices" array
  93312. */
  93313. indicesLength: number;
  93314. /**
  93315. * Squared distance from the particle to the camera
  93316. */
  93317. sqDistance: number;
  93318. }
  93319. }
  93320. declare module BABYLON {
  93321. /**
  93322. * @hidden
  93323. */
  93324. export class _MeshCollisionData {
  93325. _checkCollisions: boolean;
  93326. _collisionMask: number;
  93327. _collisionGroup: number;
  93328. _collider: Nullable<Collider>;
  93329. _oldPositionForCollisions: Vector3;
  93330. _diffPositionForCollisions: Vector3;
  93331. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93332. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93333. }
  93334. }
  93335. declare module BABYLON {
  93336. /** @hidden */
  93337. class _FacetDataStorage {
  93338. facetPositions: Vector3[];
  93339. facetNormals: Vector3[];
  93340. facetPartitioning: number[][];
  93341. facetNb: number;
  93342. partitioningSubdivisions: number;
  93343. partitioningBBoxRatio: number;
  93344. facetDataEnabled: boolean;
  93345. facetParameters: any;
  93346. bbSize: Vector3;
  93347. subDiv: {
  93348. max: number;
  93349. X: number;
  93350. Y: number;
  93351. Z: number;
  93352. };
  93353. facetDepthSort: boolean;
  93354. facetDepthSortEnabled: boolean;
  93355. depthSortedIndices: IndicesArray;
  93356. depthSortedFacets: {
  93357. ind: number;
  93358. sqDistance: number;
  93359. }[];
  93360. facetDepthSortFunction: (f1: {
  93361. ind: number;
  93362. sqDistance: number;
  93363. }, f2: {
  93364. ind: number;
  93365. sqDistance: number;
  93366. }) => number;
  93367. facetDepthSortFrom: Vector3;
  93368. facetDepthSortOrigin: Vector3;
  93369. invertedMatrix: Matrix;
  93370. }
  93371. /**
  93372. * @hidden
  93373. **/
  93374. class _InternalAbstractMeshDataInfo {
  93375. _hasVertexAlpha: boolean;
  93376. _useVertexColors: boolean;
  93377. _numBoneInfluencers: number;
  93378. _applyFog: boolean;
  93379. _receiveShadows: boolean;
  93380. _facetData: _FacetDataStorage;
  93381. _visibility: number;
  93382. _skeleton: Nullable<Skeleton>;
  93383. _layerMask: number;
  93384. _computeBonesUsingShaders: boolean;
  93385. _isActive: boolean;
  93386. _onlyForInstances: boolean;
  93387. _isActiveIntermediate: boolean;
  93388. _onlyForInstancesIntermediate: boolean;
  93389. _actAsRegularMesh: boolean;
  93390. }
  93391. /**
  93392. * Class used to store all common mesh properties
  93393. */
  93394. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93395. /** No occlusion */
  93396. static OCCLUSION_TYPE_NONE: number;
  93397. /** Occlusion set to optimisitic */
  93398. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93399. /** Occlusion set to strict */
  93400. static OCCLUSION_TYPE_STRICT: number;
  93401. /** Use an accurante occlusion algorithm */
  93402. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93403. /** Use a conservative occlusion algorithm */
  93404. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93405. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93406. * Test order :
  93407. * Is the bounding sphere outside the frustum ?
  93408. * If not, are the bounding box vertices outside the frustum ?
  93409. * It not, then the cullable object is in the frustum.
  93410. */
  93411. static readonly CULLINGSTRATEGY_STANDARD: number;
  93412. /** Culling strategy : Bounding Sphere Only.
  93413. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93414. * It's also less accurate than the standard because some not visible objects can still be selected.
  93415. * Test : is the bounding sphere outside the frustum ?
  93416. * If not, then the cullable object is in the frustum.
  93417. */
  93418. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93419. /** Culling strategy : Optimistic Inclusion.
  93420. * This in an inclusion test first, then the standard exclusion test.
  93421. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93422. * 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.
  93423. * Anyway, it's as accurate as the standard strategy.
  93424. * Test :
  93425. * Is the cullable object bounding sphere center in the frustum ?
  93426. * If not, apply the default culling strategy.
  93427. */
  93428. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93429. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93430. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93431. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93432. * 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.
  93433. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93434. * Test :
  93435. * Is the cullable object bounding sphere center in the frustum ?
  93436. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93437. */
  93438. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93439. /**
  93440. * No billboard
  93441. */
  93442. static readonly BILLBOARDMODE_NONE: number;
  93443. /** Billboard on X axis */
  93444. static readonly BILLBOARDMODE_X: number;
  93445. /** Billboard on Y axis */
  93446. static readonly BILLBOARDMODE_Y: number;
  93447. /** Billboard on Z axis */
  93448. static readonly BILLBOARDMODE_Z: number;
  93449. /** Billboard on all axes */
  93450. static readonly BILLBOARDMODE_ALL: number;
  93451. /** Billboard on using position instead of orientation */
  93452. static readonly BILLBOARDMODE_USE_POSITION: number;
  93453. /** @hidden */
  93454. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93455. /**
  93456. * The culling strategy to use to check whether the mesh must be rendered or not.
  93457. * This value can be changed at any time and will be used on the next render mesh selection.
  93458. * The possible values are :
  93459. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93460. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93461. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93462. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93463. * Please read each static variable documentation to get details about the culling process.
  93464. * */
  93465. cullingStrategy: number;
  93466. /**
  93467. * Gets the number of facets in the mesh
  93468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93469. */
  93470. readonly facetNb: number;
  93471. /**
  93472. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93474. */
  93475. partitioningSubdivisions: number;
  93476. /**
  93477. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93478. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93480. */
  93481. partitioningBBoxRatio: number;
  93482. /**
  93483. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93484. * Works only for updatable meshes.
  93485. * Doesn't work with multi-materials
  93486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93487. */
  93488. mustDepthSortFacets: boolean;
  93489. /**
  93490. * The location (Vector3) where the facet depth sort must be computed from.
  93491. * By default, the active camera position.
  93492. * Used only when facet depth sort is enabled
  93493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93494. */
  93495. facetDepthSortFrom: Vector3;
  93496. /**
  93497. * gets a boolean indicating if facetData is enabled
  93498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93499. */
  93500. readonly isFacetDataEnabled: boolean;
  93501. /** @hidden */
  93502. _updateNonUniformScalingState(value: boolean): boolean;
  93503. /**
  93504. * An event triggered when this mesh collides with another one
  93505. */
  93506. onCollideObservable: Observable<AbstractMesh>;
  93507. /** Set a function to call when this mesh collides with another one */
  93508. onCollide: () => void;
  93509. /**
  93510. * An event triggered when the collision's position changes
  93511. */
  93512. onCollisionPositionChangeObservable: Observable<Vector3>;
  93513. /** Set a function to call when the collision's position changes */
  93514. onCollisionPositionChange: () => void;
  93515. /**
  93516. * An event triggered when material is changed
  93517. */
  93518. onMaterialChangedObservable: Observable<AbstractMesh>;
  93519. /**
  93520. * Gets or sets the orientation for POV movement & rotation
  93521. */
  93522. definedFacingForward: boolean;
  93523. /** @hidden */
  93524. _occlusionQuery: Nullable<WebGLQuery>;
  93525. /** @hidden */
  93526. _renderingGroup: Nullable<RenderingGroup>;
  93527. /**
  93528. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93529. */
  93530. /**
  93531. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93532. */
  93533. visibility: number;
  93534. /** Gets or sets the alpha index used to sort transparent meshes
  93535. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93536. */
  93537. alphaIndex: number;
  93538. /**
  93539. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93540. */
  93541. isVisible: boolean;
  93542. /**
  93543. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93544. */
  93545. isPickable: boolean;
  93546. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93547. showSubMeshesBoundingBox: boolean;
  93548. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93549. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93550. */
  93551. isBlocker: boolean;
  93552. /**
  93553. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93554. */
  93555. enablePointerMoveEvents: boolean;
  93556. /**
  93557. * Specifies the rendering group id for this mesh (0 by default)
  93558. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93559. */
  93560. renderingGroupId: number;
  93561. private _material;
  93562. /** Gets or sets current material */
  93563. material: Nullable<Material>;
  93564. /**
  93565. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93566. * @see http://doc.babylonjs.com/babylon101/shadows
  93567. */
  93568. receiveShadows: boolean;
  93569. /** Defines color to use when rendering outline */
  93570. outlineColor: Color3;
  93571. /** Define width to use when rendering outline */
  93572. outlineWidth: number;
  93573. /** Defines color to use when rendering overlay */
  93574. overlayColor: Color3;
  93575. /** Defines alpha to use when rendering overlay */
  93576. overlayAlpha: number;
  93577. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93578. hasVertexAlpha: boolean;
  93579. /** 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) */
  93580. useVertexColors: boolean;
  93581. /**
  93582. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93583. */
  93584. computeBonesUsingShaders: boolean;
  93585. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93586. numBoneInfluencers: number;
  93587. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93588. applyFog: boolean;
  93589. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93590. useOctreeForRenderingSelection: boolean;
  93591. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93592. useOctreeForPicking: boolean;
  93593. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93594. useOctreeForCollisions: boolean;
  93595. /**
  93596. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93597. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93598. */
  93599. layerMask: number;
  93600. /**
  93601. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93602. */
  93603. alwaysSelectAsActiveMesh: boolean;
  93604. /**
  93605. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93606. */
  93607. doNotSyncBoundingInfo: boolean;
  93608. /**
  93609. * Gets or sets the current action manager
  93610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93611. */
  93612. actionManager: Nullable<AbstractActionManager>;
  93613. private _meshCollisionData;
  93614. /**
  93615. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93616. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93617. */
  93618. ellipsoid: Vector3;
  93619. /**
  93620. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93621. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93622. */
  93623. ellipsoidOffset: Vector3;
  93624. /**
  93625. * Gets or sets a collision mask used to mask collisions (default is -1).
  93626. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93627. */
  93628. collisionMask: number;
  93629. /**
  93630. * Gets or sets the current collision group mask (-1 by default).
  93631. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93632. */
  93633. collisionGroup: number;
  93634. /**
  93635. * Defines edge width used when edgesRenderer is enabled
  93636. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93637. */
  93638. edgesWidth: number;
  93639. /**
  93640. * Defines edge color used when edgesRenderer is enabled
  93641. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93642. */
  93643. edgesColor: Color4;
  93644. /** @hidden */
  93645. _edgesRenderer: Nullable<IEdgesRenderer>;
  93646. /** @hidden */
  93647. _masterMesh: Nullable<AbstractMesh>;
  93648. /** @hidden */
  93649. _boundingInfo: Nullable<BoundingInfo>;
  93650. /** @hidden */
  93651. _renderId: number;
  93652. /**
  93653. * Gets or sets the list of subMeshes
  93654. * @see http://doc.babylonjs.com/how_to/multi_materials
  93655. */
  93656. subMeshes: SubMesh[];
  93657. /** @hidden */
  93658. _intersectionsInProgress: AbstractMesh[];
  93659. /** @hidden */
  93660. _unIndexed: boolean;
  93661. /** @hidden */
  93662. _lightSources: Light[];
  93663. /** Gets the list of lights affecting that mesh */
  93664. readonly lightSources: Light[];
  93665. /** @hidden */
  93666. readonly _positions: Nullable<Vector3[]>;
  93667. /** @hidden */
  93668. _waitingData: {
  93669. lods: Nullable<any>;
  93670. actions: Nullable<any>;
  93671. freezeWorldMatrix: Nullable<boolean>;
  93672. };
  93673. /** @hidden */
  93674. _bonesTransformMatrices: Nullable<Float32Array>;
  93675. /** @hidden */
  93676. _transformMatrixTexture: Nullable<RawTexture>;
  93677. /**
  93678. * Gets or sets a skeleton to apply skining transformations
  93679. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93680. */
  93681. skeleton: Nullable<Skeleton>;
  93682. /**
  93683. * An event triggered when the mesh is rebuilt.
  93684. */
  93685. onRebuildObservable: Observable<AbstractMesh>;
  93686. /**
  93687. * Creates a new AbstractMesh
  93688. * @param name defines the name of the mesh
  93689. * @param scene defines the hosting scene
  93690. */
  93691. constructor(name: string, scene?: Nullable<Scene>);
  93692. /**
  93693. * Returns the string "AbstractMesh"
  93694. * @returns "AbstractMesh"
  93695. */
  93696. getClassName(): string;
  93697. /**
  93698. * Gets a string representation of the current mesh
  93699. * @param fullDetails defines a boolean indicating if full details must be included
  93700. * @returns a string representation of the current mesh
  93701. */
  93702. toString(fullDetails?: boolean): string;
  93703. /**
  93704. * @hidden
  93705. */
  93706. protected _getEffectiveParent(): Nullable<Node>;
  93707. /** @hidden */
  93708. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93709. /** @hidden */
  93710. _rebuild(): void;
  93711. /** @hidden */
  93712. _resyncLightSources(): void;
  93713. /** @hidden */
  93714. _resyncLighSource(light: Light): void;
  93715. /** @hidden */
  93716. _unBindEffect(): void;
  93717. /** @hidden */
  93718. _removeLightSource(light: Light, dispose: boolean): void;
  93719. private _markSubMeshesAsDirty;
  93720. /** @hidden */
  93721. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93722. /** @hidden */
  93723. _markSubMeshesAsAttributesDirty(): void;
  93724. /** @hidden */
  93725. _markSubMeshesAsMiscDirty(): void;
  93726. /**
  93727. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93728. */
  93729. scaling: Vector3;
  93730. /**
  93731. * Returns true if the mesh is blocked. Implemented by child classes
  93732. */
  93733. readonly isBlocked: boolean;
  93734. /**
  93735. * Returns the mesh itself by default. Implemented by child classes
  93736. * @param camera defines the camera to use to pick the right LOD level
  93737. * @returns the currentAbstractMesh
  93738. */
  93739. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93740. /**
  93741. * Returns 0 by default. Implemented by child classes
  93742. * @returns an integer
  93743. */
  93744. getTotalVertices(): number;
  93745. /**
  93746. * Returns a positive integer : the total number of indices in this mesh geometry.
  93747. * @returns the numner of indices or zero if the mesh has no geometry.
  93748. */
  93749. getTotalIndices(): number;
  93750. /**
  93751. * Returns null by default. Implemented by child classes
  93752. * @returns null
  93753. */
  93754. getIndices(): Nullable<IndicesArray>;
  93755. /**
  93756. * Returns the array of the requested vertex data kind. Implemented by child classes
  93757. * @param kind defines the vertex data kind to use
  93758. * @returns null
  93759. */
  93760. getVerticesData(kind: string): Nullable<FloatArray>;
  93761. /**
  93762. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93763. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93764. * Note that a new underlying VertexBuffer object is created each call.
  93765. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93766. * @param kind defines vertex data kind:
  93767. * * VertexBuffer.PositionKind
  93768. * * VertexBuffer.UVKind
  93769. * * VertexBuffer.UV2Kind
  93770. * * VertexBuffer.UV3Kind
  93771. * * VertexBuffer.UV4Kind
  93772. * * VertexBuffer.UV5Kind
  93773. * * VertexBuffer.UV6Kind
  93774. * * VertexBuffer.ColorKind
  93775. * * VertexBuffer.MatricesIndicesKind
  93776. * * VertexBuffer.MatricesIndicesExtraKind
  93777. * * VertexBuffer.MatricesWeightsKind
  93778. * * VertexBuffer.MatricesWeightsExtraKind
  93779. * @param data defines the data source
  93780. * @param updatable defines if the data must be flagged as updatable (or static)
  93781. * @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
  93782. * @returns the current mesh
  93783. */
  93784. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93785. /**
  93786. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93787. * If the mesh has no geometry, it is simply returned as it is.
  93788. * @param kind defines vertex data kind:
  93789. * * VertexBuffer.PositionKind
  93790. * * VertexBuffer.UVKind
  93791. * * VertexBuffer.UV2Kind
  93792. * * VertexBuffer.UV3Kind
  93793. * * VertexBuffer.UV4Kind
  93794. * * VertexBuffer.UV5Kind
  93795. * * VertexBuffer.UV6Kind
  93796. * * VertexBuffer.ColorKind
  93797. * * VertexBuffer.MatricesIndicesKind
  93798. * * VertexBuffer.MatricesIndicesExtraKind
  93799. * * VertexBuffer.MatricesWeightsKind
  93800. * * VertexBuffer.MatricesWeightsExtraKind
  93801. * @param data defines the data source
  93802. * @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
  93803. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93804. * @returns the current mesh
  93805. */
  93806. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93807. /**
  93808. * Sets the mesh indices,
  93809. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93810. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93811. * @param totalVertices Defines the total number of vertices
  93812. * @returns the current mesh
  93813. */
  93814. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93815. /**
  93816. * Gets a boolean indicating if specific vertex data is present
  93817. * @param kind defines the vertex data kind to use
  93818. * @returns true is data kind is present
  93819. */
  93820. isVerticesDataPresent(kind: string): boolean;
  93821. /**
  93822. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93823. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93824. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93825. * @returns a BoundingInfo
  93826. */
  93827. getBoundingInfo(): BoundingInfo;
  93828. /**
  93829. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93830. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93831. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93832. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93833. * @returns the current mesh
  93834. */
  93835. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93836. /**
  93837. * Overwrite the current bounding info
  93838. * @param boundingInfo defines the new bounding info
  93839. * @returns the current mesh
  93840. */
  93841. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93842. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93843. readonly useBones: boolean;
  93844. /** @hidden */
  93845. _preActivate(): void;
  93846. /** @hidden */
  93847. _preActivateForIntermediateRendering(renderId: number): void;
  93848. /** @hidden */
  93849. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93850. /** @hidden */
  93851. _postActivate(): void;
  93852. /** @hidden */
  93853. _freeze(): void;
  93854. /** @hidden */
  93855. _unFreeze(): void;
  93856. /**
  93857. * Gets the current world matrix
  93858. * @returns a Matrix
  93859. */
  93860. getWorldMatrix(): Matrix;
  93861. /** @hidden */
  93862. _getWorldMatrixDeterminant(): number;
  93863. /**
  93864. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93865. */
  93866. readonly isAnInstance: boolean;
  93867. /**
  93868. * Gets a boolean indicating if this mesh has instances
  93869. */
  93870. readonly hasInstances: boolean;
  93871. /**
  93872. * Perform relative position change from the point of view of behind the front of the mesh.
  93873. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93874. * Supports definition of mesh facing forward or backward
  93875. * @param amountRight defines the distance on the right axis
  93876. * @param amountUp defines the distance on the up axis
  93877. * @param amountForward defines the distance on the forward axis
  93878. * @returns the current mesh
  93879. */
  93880. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93881. /**
  93882. * Calculate relative position change from the point of view of behind the front of the mesh.
  93883. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93884. * Supports definition of mesh facing forward or backward
  93885. * @param amountRight defines the distance on the right axis
  93886. * @param amountUp defines the distance on the up axis
  93887. * @param amountForward defines the distance on the forward axis
  93888. * @returns the new displacement vector
  93889. */
  93890. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93891. /**
  93892. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93893. * Supports definition of mesh facing forward or backward
  93894. * @param flipBack defines the flip
  93895. * @param twirlClockwise defines the twirl
  93896. * @param tiltRight defines the tilt
  93897. * @returns the current mesh
  93898. */
  93899. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93900. /**
  93901. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93902. * Supports definition of mesh facing forward or backward.
  93903. * @param flipBack defines the flip
  93904. * @param twirlClockwise defines the twirl
  93905. * @param tiltRight defines the tilt
  93906. * @returns the new rotation vector
  93907. */
  93908. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93909. /**
  93910. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93911. * This means the mesh underlying bounding box and sphere are recomputed.
  93912. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93913. * @returns the current mesh
  93914. */
  93915. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93916. /** @hidden */
  93917. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93918. /** @hidden */
  93919. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93920. /** @hidden */
  93921. _updateBoundingInfo(): AbstractMesh;
  93922. /** @hidden */
  93923. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93924. /** @hidden */
  93925. protected _afterComputeWorldMatrix(): void;
  93926. /** @hidden */
  93927. readonly _effectiveMesh: AbstractMesh;
  93928. /**
  93929. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93930. * A mesh is in the frustum if its bounding box intersects the frustum
  93931. * @param frustumPlanes defines the frustum to test
  93932. * @returns true if the mesh is in the frustum planes
  93933. */
  93934. isInFrustum(frustumPlanes: Plane[]): boolean;
  93935. /**
  93936. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93937. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93938. * @param frustumPlanes defines the frustum to test
  93939. * @returns true if the mesh is completely in the frustum planes
  93940. */
  93941. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93942. /**
  93943. * True if the mesh intersects another mesh or a SolidParticle object
  93944. * @param mesh defines a target mesh or SolidParticle to test
  93945. * @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)
  93946. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93947. * @returns true if there is an intersection
  93948. */
  93949. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93950. /**
  93951. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93952. * @param point defines the point to test
  93953. * @returns true if there is an intersection
  93954. */
  93955. intersectsPoint(point: Vector3): boolean;
  93956. /**
  93957. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93959. */
  93960. checkCollisions: boolean;
  93961. /**
  93962. * Gets Collider object used to compute collisions (not physics)
  93963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93964. */
  93965. readonly collider: Nullable<Collider>;
  93966. /**
  93967. * Move the mesh using collision engine
  93968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93969. * @param displacement defines the requested displacement vector
  93970. * @returns the current mesh
  93971. */
  93972. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93973. private _onCollisionPositionChange;
  93974. /** @hidden */
  93975. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93976. /** @hidden */
  93977. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93978. /** @hidden */
  93979. _checkCollision(collider: Collider): AbstractMesh;
  93980. /** @hidden */
  93981. _generatePointsArray(): boolean;
  93982. /**
  93983. * Checks if the passed Ray intersects with the mesh
  93984. * @param ray defines the ray to use
  93985. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93986. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93987. * @returns the picking info
  93988. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93989. */
  93990. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93991. /**
  93992. * Clones the current mesh
  93993. * @param name defines the mesh name
  93994. * @param newParent defines the new mesh parent
  93995. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93996. * @returns the new mesh
  93997. */
  93998. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93999. /**
  94000. * Disposes all the submeshes of the current meshnp
  94001. * @returns the current mesh
  94002. */
  94003. releaseSubMeshes(): AbstractMesh;
  94004. /**
  94005. * Releases resources associated with this abstract mesh.
  94006. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94007. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94008. */
  94009. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94010. /**
  94011. * Adds the passed mesh as a child to the current mesh
  94012. * @param mesh defines the child mesh
  94013. * @returns the current mesh
  94014. */
  94015. addChild(mesh: AbstractMesh): AbstractMesh;
  94016. /**
  94017. * Removes the passed mesh from the current mesh children list
  94018. * @param mesh defines the child mesh
  94019. * @returns the current mesh
  94020. */
  94021. removeChild(mesh: AbstractMesh): AbstractMesh;
  94022. /** @hidden */
  94023. private _initFacetData;
  94024. /**
  94025. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94026. * This method can be called within the render loop.
  94027. * 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
  94028. * @returns the current mesh
  94029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94030. */
  94031. updateFacetData(): AbstractMesh;
  94032. /**
  94033. * Returns the facetLocalNormals array.
  94034. * The normals are expressed in the mesh local spac
  94035. * @returns an array of Vector3
  94036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94037. */
  94038. getFacetLocalNormals(): Vector3[];
  94039. /**
  94040. * Returns the facetLocalPositions array.
  94041. * The facet positions are expressed in the mesh local space
  94042. * @returns an array of Vector3
  94043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94044. */
  94045. getFacetLocalPositions(): Vector3[];
  94046. /**
  94047. * Returns the facetLocalPartioning array
  94048. * @returns an array of array of numbers
  94049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94050. */
  94051. getFacetLocalPartitioning(): number[][];
  94052. /**
  94053. * Returns the i-th facet position in the world system.
  94054. * This method allocates a new Vector3 per call
  94055. * @param i defines the facet index
  94056. * @returns a new Vector3
  94057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94058. */
  94059. getFacetPosition(i: number): Vector3;
  94060. /**
  94061. * Sets the reference Vector3 with the i-th facet position in the world system
  94062. * @param i defines the facet index
  94063. * @param ref defines the target vector
  94064. * @returns the current mesh
  94065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94066. */
  94067. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94068. /**
  94069. * Returns the i-th facet normal in the world system.
  94070. * This method allocates a new Vector3 per call
  94071. * @param i defines the facet index
  94072. * @returns a new Vector3
  94073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94074. */
  94075. getFacetNormal(i: number): Vector3;
  94076. /**
  94077. * Sets the reference Vector3 with the i-th facet normal in the world system
  94078. * @param i defines the facet index
  94079. * @param ref defines the target vector
  94080. * @returns the current mesh
  94081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94082. */
  94083. getFacetNormalToRef(i: number, ref: Vector3): this;
  94084. /**
  94085. * 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)
  94086. * @param x defines x coordinate
  94087. * @param y defines y coordinate
  94088. * @param z defines z coordinate
  94089. * @returns the array of facet indexes
  94090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94091. */
  94092. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94093. /**
  94094. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94095. * @param projected sets as the (x,y,z) world projection on the facet
  94096. * @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
  94097. * @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
  94098. * @param x defines x coordinate
  94099. * @param y defines y coordinate
  94100. * @param z defines z coordinate
  94101. * @returns the face index if found (or null instead)
  94102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94103. */
  94104. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94105. /**
  94106. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94107. * @param projected sets as the (x,y,z) local projection on the facet
  94108. * @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
  94109. * @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
  94110. * @param x defines x coordinate
  94111. * @param y defines y coordinate
  94112. * @param z defines z coordinate
  94113. * @returns the face index if found (or null instead)
  94114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94115. */
  94116. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94117. /**
  94118. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94119. * @returns the parameters
  94120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94121. */
  94122. getFacetDataParameters(): any;
  94123. /**
  94124. * Disables the feature FacetData and frees the related memory
  94125. * @returns the current mesh
  94126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94127. */
  94128. disableFacetData(): AbstractMesh;
  94129. /**
  94130. * Updates the AbstractMesh indices array
  94131. * @param indices defines the data source
  94132. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94133. * @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)
  94134. * @returns the current mesh
  94135. */
  94136. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94137. /**
  94138. * Creates new normals data for the mesh
  94139. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94140. * @returns the current mesh
  94141. */
  94142. createNormals(updatable: boolean): AbstractMesh;
  94143. /**
  94144. * Align the mesh with a normal
  94145. * @param normal defines the normal to use
  94146. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94147. * @returns the current mesh
  94148. */
  94149. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94150. /** @hidden */
  94151. _checkOcclusionQuery(): boolean;
  94152. /**
  94153. * Disables the mesh edge rendering mode
  94154. * @returns the currentAbstractMesh
  94155. */
  94156. disableEdgesRendering(): AbstractMesh;
  94157. /**
  94158. * Enables the edge rendering mode on the mesh.
  94159. * This mode makes the mesh edges visible
  94160. * @param epsilon defines the maximal distance between two angles to detect a face
  94161. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94162. * @returns the currentAbstractMesh
  94163. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94164. */
  94165. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94166. }
  94167. }
  94168. declare module BABYLON {
  94169. /**
  94170. * Interface used to define ActionEvent
  94171. */
  94172. export interface IActionEvent {
  94173. /** The mesh or sprite that triggered the action */
  94174. source: any;
  94175. /** The X mouse cursor position at the time of the event */
  94176. pointerX: number;
  94177. /** The Y mouse cursor position at the time of the event */
  94178. pointerY: number;
  94179. /** The mesh that is currently pointed at (can be null) */
  94180. meshUnderPointer: Nullable<AbstractMesh>;
  94181. /** the original (browser) event that triggered the ActionEvent */
  94182. sourceEvent?: any;
  94183. /** additional data for the event */
  94184. additionalData?: any;
  94185. }
  94186. /**
  94187. * ActionEvent is the event being sent when an action is triggered.
  94188. */
  94189. export class ActionEvent implements IActionEvent {
  94190. /** The mesh or sprite that triggered the action */
  94191. source: any;
  94192. /** The X mouse cursor position at the time of the event */
  94193. pointerX: number;
  94194. /** The Y mouse cursor position at the time of the event */
  94195. pointerY: number;
  94196. /** The mesh that is currently pointed at (can be null) */
  94197. meshUnderPointer: Nullable<AbstractMesh>;
  94198. /** the original (browser) event that triggered the ActionEvent */
  94199. sourceEvent?: any;
  94200. /** additional data for the event */
  94201. additionalData?: any;
  94202. /**
  94203. * Creates a new ActionEvent
  94204. * @param source The mesh or sprite that triggered the action
  94205. * @param pointerX The X mouse cursor position at the time of the event
  94206. * @param pointerY The Y mouse cursor position at the time of the event
  94207. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94208. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94209. * @param additionalData additional data for the event
  94210. */
  94211. constructor(
  94212. /** The mesh or sprite that triggered the action */
  94213. source: any,
  94214. /** The X mouse cursor position at the time of the event */
  94215. pointerX: number,
  94216. /** The Y mouse cursor position at the time of the event */
  94217. pointerY: number,
  94218. /** The mesh that is currently pointed at (can be null) */
  94219. meshUnderPointer: Nullable<AbstractMesh>,
  94220. /** the original (browser) event that triggered the ActionEvent */
  94221. sourceEvent?: any,
  94222. /** additional data for the event */
  94223. additionalData?: any);
  94224. /**
  94225. * Helper function to auto-create an ActionEvent from a source mesh.
  94226. * @param source The source mesh that triggered the event
  94227. * @param evt The original (browser) event
  94228. * @param additionalData additional data for the event
  94229. * @returns the new ActionEvent
  94230. */
  94231. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94232. /**
  94233. * Helper function to auto-create an ActionEvent from a source sprite
  94234. * @param source The source sprite that triggered the event
  94235. * @param scene Scene associated with the sprite
  94236. * @param evt The original (browser) event
  94237. * @param additionalData additional data for the event
  94238. * @returns the new ActionEvent
  94239. */
  94240. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94241. /**
  94242. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94243. * @param scene the scene where the event occurred
  94244. * @param evt The original (browser) event
  94245. * @returns the new ActionEvent
  94246. */
  94247. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94248. /**
  94249. * Helper function to auto-create an ActionEvent from a primitive
  94250. * @param prim defines the target primitive
  94251. * @param pointerPos defines the pointer position
  94252. * @param evt The original (browser) event
  94253. * @param additionalData additional data for the event
  94254. * @returns the new ActionEvent
  94255. */
  94256. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94257. }
  94258. }
  94259. declare module BABYLON {
  94260. /**
  94261. * Abstract class used to decouple action Manager from scene and meshes.
  94262. * Do not instantiate.
  94263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94264. */
  94265. export abstract class AbstractActionManager implements IDisposable {
  94266. /** Gets the list of active triggers */
  94267. static Triggers: {
  94268. [key: string]: number;
  94269. };
  94270. /** Gets the cursor to use when hovering items */
  94271. hoverCursor: string;
  94272. /** Gets the list of actions */
  94273. actions: IAction[];
  94274. /**
  94275. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94276. */
  94277. isRecursive: boolean;
  94278. /**
  94279. * Releases all associated resources
  94280. */
  94281. abstract dispose(): void;
  94282. /**
  94283. * Does this action manager has pointer triggers
  94284. */
  94285. abstract readonly hasPointerTriggers: boolean;
  94286. /**
  94287. * Does this action manager has pick triggers
  94288. */
  94289. abstract readonly hasPickTriggers: boolean;
  94290. /**
  94291. * Process a specific trigger
  94292. * @param trigger defines the trigger to process
  94293. * @param evt defines the event details to be processed
  94294. */
  94295. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94296. /**
  94297. * Does this action manager handles actions of any of the given triggers
  94298. * @param triggers defines the triggers to be tested
  94299. * @return a boolean indicating whether one (or more) of the triggers is handled
  94300. */
  94301. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94302. /**
  94303. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94304. * speed.
  94305. * @param triggerA defines the trigger to be tested
  94306. * @param triggerB defines the trigger to be tested
  94307. * @return a boolean indicating whether one (or more) of the triggers is handled
  94308. */
  94309. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94310. /**
  94311. * Does this action manager handles actions of a given trigger
  94312. * @param trigger defines the trigger to be tested
  94313. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94314. * @return whether the trigger is handled
  94315. */
  94316. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94317. /**
  94318. * Serialize this manager to a JSON object
  94319. * @param name defines the property name to store this manager
  94320. * @returns a JSON representation of this manager
  94321. */
  94322. abstract serialize(name: string): any;
  94323. /**
  94324. * Registers an action to this action manager
  94325. * @param action defines the action to be registered
  94326. * @return the action amended (prepared) after registration
  94327. */
  94328. abstract registerAction(action: IAction): Nullable<IAction>;
  94329. /**
  94330. * Unregisters an action to this action manager
  94331. * @param action defines the action to be unregistered
  94332. * @return a boolean indicating whether the action has been unregistered
  94333. */
  94334. abstract unregisterAction(action: IAction): Boolean;
  94335. /**
  94336. * Does exist one action manager with at least one trigger
  94337. **/
  94338. static readonly HasTriggers: boolean;
  94339. /**
  94340. * Does exist one action manager with at least one pick trigger
  94341. **/
  94342. static readonly HasPickTriggers: boolean;
  94343. /**
  94344. * Does exist one action manager that handles actions of a given trigger
  94345. * @param trigger defines the trigger to be tested
  94346. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94347. **/
  94348. static HasSpecificTrigger(trigger: number): boolean;
  94349. }
  94350. }
  94351. declare module BABYLON {
  94352. /**
  94353. * Defines how a node can be built from a string name.
  94354. */
  94355. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94356. /**
  94357. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94358. */
  94359. export class Node implements IBehaviorAware<Node> {
  94360. /** @hidden */
  94361. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94362. private static _NodeConstructors;
  94363. /**
  94364. * Add a new node constructor
  94365. * @param type defines the type name of the node to construct
  94366. * @param constructorFunc defines the constructor function
  94367. */
  94368. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94369. /**
  94370. * Returns a node constructor based on type name
  94371. * @param type defines the type name
  94372. * @param name defines the new node name
  94373. * @param scene defines the hosting scene
  94374. * @param options defines optional options to transmit to constructors
  94375. * @returns the new constructor or null
  94376. */
  94377. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94378. /**
  94379. * Gets or sets the name of the node
  94380. */
  94381. name: string;
  94382. /**
  94383. * Gets or sets the id of the node
  94384. */
  94385. id: string;
  94386. /**
  94387. * Gets or sets the unique id of the node
  94388. */
  94389. uniqueId: number;
  94390. /**
  94391. * Gets or sets a string used to store user defined state for the node
  94392. */
  94393. state: string;
  94394. /**
  94395. * Gets or sets an object used to store user defined information for the node
  94396. */
  94397. metadata: any;
  94398. /**
  94399. * For internal use only. Please do not use.
  94400. */
  94401. reservedDataStore: any;
  94402. /**
  94403. * List of inspectable custom properties (used by the Inspector)
  94404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94405. */
  94406. inspectableCustomProperties: IInspectable[];
  94407. private _doNotSerialize;
  94408. /**
  94409. * Gets or sets a boolean used to define if the node must be serialized
  94410. */
  94411. doNotSerialize: boolean;
  94412. /** @hidden */
  94413. _isDisposed: boolean;
  94414. /**
  94415. * Gets a list of Animations associated with the node
  94416. */
  94417. animations: Animation[];
  94418. protected _ranges: {
  94419. [name: string]: Nullable<AnimationRange>;
  94420. };
  94421. /**
  94422. * Callback raised when the node is ready to be used
  94423. */
  94424. onReady: Nullable<(node: Node) => void>;
  94425. private _isEnabled;
  94426. private _isParentEnabled;
  94427. private _isReady;
  94428. /** @hidden */
  94429. _currentRenderId: number;
  94430. private _parentUpdateId;
  94431. /** @hidden */
  94432. _childUpdateId: number;
  94433. /** @hidden */
  94434. _waitingParentId: Nullable<string>;
  94435. /** @hidden */
  94436. _scene: Scene;
  94437. /** @hidden */
  94438. _cache: any;
  94439. private _parentNode;
  94440. private _children;
  94441. /** @hidden */
  94442. _worldMatrix: Matrix;
  94443. /** @hidden */
  94444. _worldMatrixDeterminant: number;
  94445. /** @hidden */
  94446. _worldMatrixDeterminantIsDirty: boolean;
  94447. /** @hidden */
  94448. private _sceneRootNodesIndex;
  94449. /**
  94450. * Gets a boolean indicating if the node has been disposed
  94451. * @returns true if the node was disposed
  94452. */
  94453. isDisposed(): boolean;
  94454. /**
  94455. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94456. * @see https://doc.babylonjs.com/how_to/parenting
  94457. */
  94458. parent: Nullable<Node>;
  94459. private addToSceneRootNodes;
  94460. private removeFromSceneRootNodes;
  94461. private _animationPropertiesOverride;
  94462. /**
  94463. * Gets or sets the animation properties override
  94464. */
  94465. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94466. /**
  94467. * Gets a string idenfifying the name of the class
  94468. * @returns "Node" string
  94469. */
  94470. getClassName(): string;
  94471. /** @hidden */
  94472. readonly _isNode: boolean;
  94473. /**
  94474. * An event triggered when the mesh is disposed
  94475. */
  94476. onDisposeObservable: Observable<Node>;
  94477. private _onDisposeObserver;
  94478. /**
  94479. * Sets a callback that will be raised when the node will be disposed
  94480. */
  94481. onDispose: () => void;
  94482. /**
  94483. * Creates a new Node
  94484. * @param name the name and id to be given to this node
  94485. * @param scene the scene this node will be added to
  94486. * @param addToRootNodes the node will be added to scene.rootNodes
  94487. */
  94488. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94489. /**
  94490. * Gets the scene of the node
  94491. * @returns a scene
  94492. */
  94493. getScene(): Scene;
  94494. /**
  94495. * Gets the engine of the node
  94496. * @returns a Engine
  94497. */
  94498. getEngine(): Engine;
  94499. private _behaviors;
  94500. /**
  94501. * Attach a behavior to the node
  94502. * @see http://doc.babylonjs.com/features/behaviour
  94503. * @param behavior defines the behavior to attach
  94504. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94505. * @returns the current Node
  94506. */
  94507. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94508. /**
  94509. * Remove an attached behavior
  94510. * @see http://doc.babylonjs.com/features/behaviour
  94511. * @param behavior defines the behavior to attach
  94512. * @returns the current Node
  94513. */
  94514. removeBehavior(behavior: Behavior<Node>): Node;
  94515. /**
  94516. * Gets the list of attached behaviors
  94517. * @see http://doc.babylonjs.com/features/behaviour
  94518. */
  94519. readonly behaviors: Behavior<Node>[];
  94520. /**
  94521. * Gets an attached behavior by name
  94522. * @param name defines the name of the behavior to look for
  94523. * @see http://doc.babylonjs.com/features/behaviour
  94524. * @returns null if behavior was not found else the requested behavior
  94525. */
  94526. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94527. /**
  94528. * Returns the latest update of the World matrix
  94529. * @returns a Matrix
  94530. */
  94531. getWorldMatrix(): Matrix;
  94532. /** @hidden */
  94533. _getWorldMatrixDeterminant(): number;
  94534. /**
  94535. * Returns directly the latest state of the mesh World matrix.
  94536. * A Matrix is returned.
  94537. */
  94538. readonly worldMatrixFromCache: Matrix;
  94539. /** @hidden */
  94540. _initCache(): void;
  94541. /** @hidden */
  94542. updateCache(force?: boolean): void;
  94543. /** @hidden */
  94544. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94545. /** @hidden */
  94546. _updateCache(ignoreParentClass?: boolean): void;
  94547. /** @hidden */
  94548. _isSynchronized(): boolean;
  94549. /** @hidden */
  94550. _markSyncedWithParent(): void;
  94551. /** @hidden */
  94552. isSynchronizedWithParent(): boolean;
  94553. /** @hidden */
  94554. isSynchronized(): boolean;
  94555. /**
  94556. * Is this node ready to be used/rendered
  94557. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94558. * @return true if the node is ready
  94559. */
  94560. isReady(completeCheck?: boolean): boolean;
  94561. /**
  94562. * Is this node enabled?
  94563. * 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
  94564. * @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
  94565. * @return whether this node (and its parent) is enabled
  94566. */
  94567. isEnabled(checkAncestors?: boolean): boolean;
  94568. /** @hidden */
  94569. protected _syncParentEnabledState(): void;
  94570. /**
  94571. * Set the enabled state of this node
  94572. * @param value defines the new enabled state
  94573. */
  94574. setEnabled(value: boolean): void;
  94575. /**
  94576. * Is this node a descendant of the given node?
  94577. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94578. * @param ancestor defines the parent node to inspect
  94579. * @returns a boolean indicating if this node is a descendant of the given node
  94580. */
  94581. isDescendantOf(ancestor: Node): boolean;
  94582. /** @hidden */
  94583. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94584. /**
  94585. * Will return all nodes that have this node as ascendant
  94586. * @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
  94587. * @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
  94588. * @return all children nodes of all types
  94589. */
  94590. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94591. /**
  94592. * Get all child-meshes of this node
  94593. * @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)
  94594. * @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
  94595. * @returns an array of AbstractMesh
  94596. */
  94597. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94598. /**
  94599. * Get all direct children of this node
  94600. * @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
  94601. * @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)
  94602. * @returns an array of Node
  94603. */
  94604. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94605. /** @hidden */
  94606. _setReady(state: boolean): void;
  94607. /**
  94608. * Get an animation by name
  94609. * @param name defines the name of the animation to look for
  94610. * @returns null if not found else the requested animation
  94611. */
  94612. getAnimationByName(name: string): Nullable<Animation>;
  94613. /**
  94614. * Creates an animation range for this node
  94615. * @param name defines the name of the range
  94616. * @param from defines the starting key
  94617. * @param to defines the end key
  94618. */
  94619. createAnimationRange(name: string, from: number, to: number): void;
  94620. /**
  94621. * Delete a specific animation range
  94622. * @param name defines the name of the range to delete
  94623. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94624. */
  94625. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94626. /**
  94627. * Get an animation range by name
  94628. * @param name defines the name of the animation range to look for
  94629. * @returns null if not found else the requested animation range
  94630. */
  94631. getAnimationRange(name: string): Nullable<AnimationRange>;
  94632. /**
  94633. * Gets the list of all animation ranges defined on this node
  94634. * @returns an array
  94635. */
  94636. getAnimationRanges(): Nullable<AnimationRange>[];
  94637. /**
  94638. * Will start the animation sequence
  94639. * @param name defines the range frames for animation sequence
  94640. * @param loop defines if the animation should loop (false by default)
  94641. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94642. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94643. * @returns the object created for this animation. If range does not exist, it will return null
  94644. */
  94645. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94646. /**
  94647. * Serialize animation ranges into a JSON compatible object
  94648. * @returns serialization object
  94649. */
  94650. serializeAnimationRanges(): any;
  94651. /**
  94652. * Computes the world matrix of the node
  94653. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94654. * @returns the world matrix
  94655. */
  94656. computeWorldMatrix(force?: boolean): Matrix;
  94657. /**
  94658. * Releases resources associated with this node.
  94659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94661. */
  94662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94663. /**
  94664. * Parse animation range data from a serialization object and store them into a given node
  94665. * @param node defines where to store the animation ranges
  94666. * @param parsedNode defines the serialization object to read data from
  94667. * @param scene defines the hosting scene
  94668. */
  94669. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94670. /**
  94671. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94672. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94673. * @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
  94674. * @returns the new bounding vectors
  94675. */
  94676. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94677. min: Vector3;
  94678. max: Vector3;
  94679. };
  94680. }
  94681. }
  94682. declare module BABYLON {
  94683. /**
  94684. * @hidden
  94685. */
  94686. export class _IAnimationState {
  94687. key: number;
  94688. repeatCount: number;
  94689. workValue?: any;
  94690. loopMode?: number;
  94691. offsetValue?: any;
  94692. highLimitValue?: any;
  94693. }
  94694. /**
  94695. * Class used to store any kind of animation
  94696. */
  94697. export class Animation {
  94698. /**Name of the animation */
  94699. name: string;
  94700. /**Property to animate */
  94701. targetProperty: string;
  94702. /**The frames per second of the animation */
  94703. framePerSecond: number;
  94704. /**The data type of the animation */
  94705. dataType: number;
  94706. /**The loop mode of the animation */
  94707. loopMode?: number | undefined;
  94708. /**Specifies if blending should be enabled */
  94709. enableBlending?: boolean | undefined;
  94710. /**
  94711. * Use matrix interpolation instead of using direct key value when animating matrices
  94712. */
  94713. static AllowMatricesInterpolation: boolean;
  94714. /**
  94715. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94716. */
  94717. static AllowMatrixDecomposeForInterpolation: boolean;
  94718. /**
  94719. * Stores the key frames of the animation
  94720. */
  94721. private _keys;
  94722. /**
  94723. * Stores the easing function of the animation
  94724. */
  94725. private _easingFunction;
  94726. /**
  94727. * @hidden Internal use only
  94728. */
  94729. _runtimeAnimations: RuntimeAnimation[];
  94730. /**
  94731. * The set of event that will be linked to this animation
  94732. */
  94733. private _events;
  94734. /**
  94735. * Stores an array of target property paths
  94736. */
  94737. targetPropertyPath: string[];
  94738. /**
  94739. * Stores the blending speed of the animation
  94740. */
  94741. blendingSpeed: number;
  94742. /**
  94743. * Stores the animation ranges for the animation
  94744. */
  94745. private _ranges;
  94746. /**
  94747. * @hidden Internal use
  94748. */
  94749. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94750. /**
  94751. * Sets up an animation
  94752. * @param property The property to animate
  94753. * @param animationType The animation type to apply
  94754. * @param framePerSecond The frames per second of the animation
  94755. * @param easingFunction The easing function used in the animation
  94756. * @returns The created animation
  94757. */
  94758. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94759. /**
  94760. * Create and start an animation on a node
  94761. * @param name defines the name of the global animation that will be run on all nodes
  94762. * @param node defines the root node where the animation will take place
  94763. * @param targetProperty defines property to animate
  94764. * @param framePerSecond defines the number of frame per second yo use
  94765. * @param totalFrame defines the number of frames in total
  94766. * @param from defines the initial value
  94767. * @param to defines the final value
  94768. * @param loopMode defines which loop mode you want to use (off by default)
  94769. * @param easingFunction defines the easing function to use (linear by default)
  94770. * @param onAnimationEnd defines the callback to call when animation end
  94771. * @returns the animatable created for this animation
  94772. */
  94773. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94774. /**
  94775. * Create and start an animation on a node and its descendants
  94776. * @param name defines the name of the global animation that will be run on all nodes
  94777. * @param node defines the root node where the animation will take place
  94778. * @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
  94779. * @param targetProperty defines property to animate
  94780. * @param framePerSecond defines the number of frame per second to use
  94781. * @param totalFrame defines the number of frames in total
  94782. * @param from defines the initial value
  94783. * @param to defines the final value
  94784. * @param loopMode defines which loop mode you want to use (off by default)
  94785. * @param easingFunction defines the easing function to use (linear by default)
  94786. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94787. * @returns the list of animatables created for all nodes
  94788. * @example https://www.babylonjs-playground.com/#MH0VLI
  94789. */
  94790. 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[]>;
  94791. /**
  94792. * Creates a new animation, merges it with the existing animations and starts it
  94793. * @param name Name of the animation
  94794. * @param node Node which contains the scene that begins the animations
  94795. * @param targetProperty Specifies which property to animate
  94796. * @param framePerSecond The frames per second of the animation
  94797. * @param totalFrame The total number of frames
  94798. * @param from The frame at the beginning of the animation
  94799. * @param to The frame at the end of the animation
  94800. * @param loopMode Specifies the loop mode of the animation
  94801. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94802. * @param onAnimationEnd Callback to run once the animation is complete
  94803. * @returns Nullable animation
  94804. */
  94805. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94806. /**
  94807. * Transition property of an host to the target Value
  94808. * @param property The property to transition
  94809. * @param targetValue The target Value of the property
  94810. * @param host The object where the property to animate belongs
  94811. * @param scene Scene used to run the animation
  94812. * @param frameRate Framerate (in frame/s) to use
  94813. * @param transition The transition type we want to use
  94814. * @param duration The duration of the animation, in milliseconds
  94815. * @param onAnimationEnd Callback trigger at the end of the animation
  94816. * @returns Nullable animation
  94817. */
  94818. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94819. /**
  94820. * Return the array of runtime animations currently using this animation
  94821. */
  94822. readonly runtimeAnimations: RuntimeAnimation[];
  94823. /**
  94824. * Specifies if any of the runtime animations are currently running
  94825. */
  94826. readonly hasRunningRuntimeAnimations: boolean;
  94827. /**
  94828. * Initializes the animation
  94829. * @param name Name of the animation
  94830. * @param targetProperty Property to animate
  94831. * @param framePerSecond The frames per second of the animation
  94832. * @param dataType The data type of the animation
  94833. * @param loopMode The loop mode of the animation
  94834. * @param enableBlending Specifies if blending should be enabled
  94835. */
  94836. constructor(
  94837. /**Name of the animation */
  94838. name: string,
  94839. /**Property to animate */
  94840. targetProperty: string,
  94841. /**The frames per second of the animation */
  94842. framePerSecond: number,
  94843. /**The data type of the animation */
  94844. dataType: number,
  94845. /**The loop mode of the animation */
  94846. loopMode?: number | undefined,
  94847. /**Specifies if blending should be enabled */
  94848. enableBlending?: boolean | undefined);
  94849. /**
  94850. * Converts the animation to a string
  94851. * @param fullDetails support for multiple levels of logging within scene loading
  94852. * @returns String form of the animation
  94853. */
  94854. toString(fullDetails?: boolean): string;
  94855. /**
  94856. * Add an event to this animation
  94857. * @param event Event to add
  94858. */
  94859. addEvent(event: AnimationEvent): void;
  94860. /**
  94861. * Remove all events found at the given frame
  94862. * @param frame The frame to remove events from
  94863. */
  94864. removeEvents(frame: number): void;
  94865. /**
  94866. * Retrieves all the events from the animation
  94867. * @returns Events from the animation
  94868. */
  94869. getEvents(): AnimationEvent[];
  94870. /**
  94871. * Creates an animation range
  94872. * @param name Name of the animation range
  94873. * @param from Starting frame of the animation range
  94874. * @param to Ending frame of the animation
  94875. */
  94876. createRange(name: string, from: number, to: number): void;
  94877. /**
  94878. * Deletes an animation range by name
  94879. * @param name Name of the animation range to delete
  94880. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94881. */
  94882. deleteRange(name: string, deleteFrames?: boolean): void;
  94883. /**
  94884. * Gets the animation range by name, or null if not defined
  94885. * @param name Name of the animation range
  94886. * @returns Nullable animation range
  94887. */
  94888. getRange(name: string): Nullable<AnimationRange>;
  94889. /**
  94890. * Gets the key frames from the animation
  94891. * @returns The key frames of the animation
  94892. */
  94893. getKeys(): Array<IAnimationKey>;
  94894. /**
  94895. * Gets the highest frame rate of the animation
  94896. * @returns Highest frame rate of the animation
  94897. */
  94898. getHighestFrame(): number;
  94899. /**
  94900. * Gets the easing function of the animation
  94901. * @returns Easing function of the animation
  94902. */
  94903. getEasingFunction(): IEasingFunction;
  94904. /**
  94905. * Sets the easing function of the animation
  94906. * @param easingFunction A custom mathematical formula for animation
  94907. */
  94908. setEasingFunction(easingFunction: EasingFunction): void;
  94909. /**
  94910. * Interpolates a scalar linearly
  94911. * @param startValue Start value of the animation curve
  94912. * @param endValue End value of the animation curve
  94913. * @param gradient Scalar amount to interpolate
  94914. * @returns Interpolated scalar value
  94915. */
  94916. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94917. /**
  94918. * Interpolates a scalar cubically
  94919. * @param startValue Start value of the animation curve
  94920. * @param outTangent End tangent of the animation
  94921. * @param endValue End value of the animation curve
  94922. * @param inTangent Start tangent of the animation curve
  94923. * @param gradient Scalar amount to interpolate
  94924. * @returns Interpolated scalar value
  94925. */
  94926. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94927. /**
  94928. * Interpolates a quaternion using a spherical linear interpolation
  94929. * @param startValue Start value of the animation curve
  94930. * @param endValue End value of the animation curve
  94931. * @param gradient Scalar amount to interpolate
  94932. * @returns Interpolated quaternion value
  94933. */
  94934. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94935. /**
  94936. * Interpolates a quaternion cubically
  94937. * @param startValue Start value of the animation curve
  94938. * @param outTangent End tangent of the animation curve
  94939. * @param endValue End value of the animation curve
  94940. * @param inTangent Start tangent of the animation curve
  94941. * @param gradient Scalar amount to interpolate
  94942. * @returns Interpolated quaternion value
  94943. */
  94944. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94945. /**
  94946. * Interpolates a Vector3 linearl
  94947. * @param startValue Start value of the animation curve
  94948. * @param endValue End value of the animation curve
  94949. * @param gradient Scalar amount to interpolate
  94950. * @returns Interpolated scalar value
  94951. */
  94952. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94953. /**
  94954. * Interpolates a Vector3 cubically
  94955. * @param startValue Start value of the animation curve
  94956. * @param outTangent End tangent of the animation
  94957. * @param endValue End value of the animation curve
  94958. * @param inTangent Start tangent of the animation curve
  94959. * @param gradient Scalar amount to interpolate
  94960. * @returns InterpolatedVector3 value
  94961. */
  94962. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94963. /**
  94964. * Interpolates a Vector2 linearly
  94965. * @param startValue Start value of the animation curve
  94966. * @param endValue End value of the animation curve
  94967. * @param gradient Scalar amount to interpolate
  94968. * @returns Interpolated Vector2 value
  94969. */
  94970. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94971. /**
  94972. * Interpolates a Vector2 cubically
  94973. * @param startValue Start value of the animation curve
  94974. * @param outTangent End tangent of the animation
  94975. * @param endValue End value of the animation curve
  94976. * @param inTangent Start tangent of the animation curve
  94977. * @param gradient Scalar amount to interpolate
  94978. * @returns Interpolated Vector2 value
  94979. */
  94980. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94981. /**
  94982. * Interpolates a size linearly
  94983. * @param startValue Start value of the animation curve
  94984. * @param endValue End value of the animation curve
  94985. * @param gradient Scalar amount to interpolate
  94986. * @returns Interpolated Size value
  94987. */
  94988. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94989. /**
  94990. * Interpolates a Color3 linearly
  94991. * @param startValue Start value of the animation curve
  94992. * @param endValue End value of the animation curve
  94993. * @param gradient Scalar amount to interpolate
  94994. * @returns Interpolated Color3 value
  94995. */
  94996. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94997. /**
  94998. * Interpolates a Color4 linearly
  94999. * @param startValue Start value of the animation curve
  95000. * @param endValue End value of the animation curve
  95001. * @param gradient Scalar amount to interpolate
  95002. * @returns Interpolated Color3 value
  95003. */
  95004. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95005. /**
  95006. * @hidden Internal use only
  95007. */
  95008. _getKeyValue(value: any): any;
  95009. /**
  95010. * @hidden Internal use only
  95011. */
  95012. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95013. /**
  95014. * Defines the function to use to interpolate matrices
  95015. * @param startValue defines the start matrix
  95016. * @param endValue defines the end matrix
  95017. * @param gradient defines the gradient between both matrices
  95018. * @param result defines an optional target matrix where to store the interpolation
  95019. * @returns the interpolated matrix
  95020. */
  95021. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95022. /**
  95023. * Makes a copy of the animation
  95024. * @returns Cloned animation
  95025. */
  95026. clone(): Animation;
  95027. /**
  95028. * Sets the key frames of the animation
  95029. * @param values The animation key frames to set
  95030. */
  95031. setKeys(values: Array<IAnimationKey>): void;
  95032. /**
  95033. * Serializes the animation to an object
  95034. * @returns Serialized object
  95035. */
  95036. serialize(): any;
  95037. /**
  95038. * Float animation type
  95039. */
  95040. static readonly ANIMATIONTYPE_FLOAT: number;
  95041. /**
  95042. * Vector3 animation type
  95043. */
  95044. static readonly ANIMATIONTYPE_VECTOR3: number;
  95045. /**
  95046. * Quaternion animation type
  95047. */
  95048. static readonly ANIMATIONTYPE_QUATERNION: number;
  95049. /**
  95050. * Matrix animation type
  95051. */
  95052. static readonly ANIMATIONTYPE_MATRIX: number;
  95053. /**
  95054. * Color3 animation type
  95055. */
  95056. static readonly ANIMATIONTYPE_COLOR3: number;
  95057. /**
  95058. * Color3 animation type
  95059. */
  95060. static readonly ANIMATIONTYPE_COLOR4: number;
  95061. /**
  95062. * Vector2 animation type
  95063. */
  95064. static readonly ANIMATIONTYPE_VECTOR2: number;
  95065. /**
  95066. * Size animation type
  95067. */
  95068. static readonly ANIMATIONTYPE_SIZE: number;
  95069. /**
  95070. * Relative Loop Mode
  95071. */
  95072. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95073. /**
  95074. * Cycle Loop Mode
  95075. */
  95076. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95077. /**
  95078. * Constant Loop Mode
  95079. */
  95080. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95081. /** @hidden */
  95082. static _UniversalLerp(left: any, right: any, amount: number): any;
  95083. /**
  95084. * Parses an animation object and creates an animation
  95085. * @param parsedAnimation Parsed animation object
  95086. * @returns Animation object
  95087. */
  95088. static Parse(parsedAnimation: any): Animation;
  95089. /**
  95090. * Appends the serialized animations from the source animations
  95091. * @param source Source containing the animations
  95092. * @param destination Target to store the animations
  95093. */
  95094. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95095. }
  95096. }
  95097. declare module BABYLON {
  95098. /**
  95099. * Interface containing an array of animations
  95100. */
  95101. export interface IAnimatable {
  95102. /**
  95103. * Array of animations
  95104. */
  95105. animations: Nullable<Array<Animation>>;
  95106. }
  95107. }
  95108. declare module BABYLON {
  95109. /**
  95110. * This represents all the required information to add a fresnel effect on a material:
  95111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95112. */
  95113. export class FresnelParameters {
  95114. private _isEnabled;
  95115. /**
  95116. * Define if the fresnel effect is enable or not.
  95117. */
  95118. isEnabled: boolean;
  95119. /**
  95120. * Define the color used on edges (grazing angle)
  95121. */
  95122. leftColor: Color3;
  95123. /**
  95124. * Define the color used on center
  95125. */
  95126. rightColor: Color3;
  95127. /**
  95128. * Define bias applied to computed fresnel term
  95129. */
  95130. bias: number;
  95131. /**
  95132. * Defined the power exponent applied to fresnel term
  95133. */
  95134. power: number;
  95135. /**
  95136. * Clones the current fresnel and its valuues
  95137. * @returns a clone fresnel configuration
  95138. */
  95139. clone(): FresnelParameters;
  95140. /**
  95141. * Serializes the current fresnel parameters to a JSON representation.
  95142. * @return the JSON serialization
  95143. */
  95144. serialize(): any;
  95145. /**
  95146. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95147. * @param parsedFresnelParameters Define the JSON representation
  95148. * @returns the parsed parameters
  95149. */
  95150. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95151. }
  95152. }
  95153. declare module BABYLON {
  95154. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95155. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95156. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95157. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95158. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95159. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95160. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95161. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95162. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95163. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95164. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95165. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95166. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95167. /**
  95168. * Decorator used to define property that can be serialized as reference to a camera
  95169. * @param sourceName defines the name of the property to decorate
  95170. */
  95171. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95172. /**
  95173. * Class used to help serialization objects
  95174. */
  95175. export class SerializationHelper {
  95176. /** @hidden */
  95177. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95178. /** @hidden */
  95179. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95180. /** @hidden */
  95181. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95182. /** @hidden */
  95183. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95184. /**
  95185. * Appends the serialized animations from the source animations
  95186. * @param source Source containing the animations
  95187. * @param destination Target to store the animations
  95188. */
  95189. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95190. /**
  95191. * Static function used to serialized a specific entity
  95192. * @param entity defines the entity to serialize
  95193. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95194. * @returns a JSON compatible object representing the serialization of the entity
  95195. */
  95196. static Serialize<T>(entity: T, serializationObject?: any): any;
  95197. /**
  95198. * Creates a new entity from a serialization data object
  95199. * @param creationFunction defines a function used to instanciated the new entity
  95200. * @param source defines the source serialization data
  95201. * @param scene defines the hosting scene
  95202. * @param rootUrl defines the root url for resources
  95203. * @returns a new entity
  95204. */
  95205. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95206. /**
  95207. * Clones an object
  95208. * @param creationFunction defines the function used to instanciate the new object
  95209. * @param source defines the source object
  95210. * @returns the cloned object
  95211. */
  95212. static Clone<T>(creationFunction: () => T, source: T): T;
  95213. /**
  95214. * Instanciates a new object based on a source one (some data will be shared between both object)
  95215. * @param creationFunction defines the function used to instanciate the new object
  95216. * @param source defines the source object
  95217. * @returns the new object
  95218. */
  95219. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95220. }
  95221. }
  95222. declare module BABYLON {
  95223. /**
  95224. * Class used to manipulate GUIDs
  95225. */
  95226. export class GUID {
  95227. /**
  95228. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95229. * Be aware Math.random() could cause collisions, but:
  95230. * "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"
  95231. * @returns a pseudo random id
  95232. */
  95233. static RandomId(): string;
  95234. }
  95235. }
  95236. declare module BABYLON {
  95237. /**
  95238. * Base class of all the textures in babylon.
  95239. * It groups all the common properties the materials, post process, lights... might need
  95240. * in order to make a correct use of the texture.
  95241. */
  95242. export class BaseTexture implements IAnimatable {
  95243. /**
  95244. * Default anisotropic filtering level for the application.
  95245. * It is set to 4 as a good tradeoff between perf and quality.
  95246. */
  95247. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95248. /**
  95249. * Gets or sets the unique id of the texture
  95250. */
  95251. uniqueId: number;
  95252. /**
  95253. * Define the name of the texture.
  95254. */
  95255. name: string;
  95256. /**
  95257. * Gets or sets an object used to store user defined information.
  95258. */
  95259. metadata: any;
  95260. /**
  95261. * For internal use only. Please do not use.
  95262. */
  95263. reservedDataStore: any;
  95264. private _hasAlpha;
  95265. /**
  95266. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95267. */
  95268. hasAlpha: boolean;
  95269. /**
  95270. * Defines if the alpha value should be determined via the rgb values.
  95271. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95272. */
  95273. getAlphaFromRGB: boolean;
  95274. /**
  95275. * Intensity or strength of the texture.
  95276. * It is commonly used by materials to fine tune the intensity of the texture
  95277. */
  95278. level: number;
  95279. /**
  95280. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95281. * This is part of the texture as textures usually maps to one uv set.
  95282. */
  95283. coordinatesIndex: number;
  95284. private _coordinatesMode;
  95285. /**
  95286. * How a texture is mapped.
  95287. *
  95288. * | Value | Type | Description |
  95289. * | ----- | ----------------------------------- | ----------- |
  95290. * | 0 | EXPLICIT_MODE | |
  95291. * | 1 | SPHERICAL_MODE | |
  95292. * | 2 | PLANAR_MODE | |
  95293. * | 3 | CUBIC_MODE | |
  95294. * | 4 | PROJECTION_MODE | |
  95295. * | 5 | SKYBOX_MODE | |
  95296. * | 6 | INVCUBIC_MODE | |
  95297. * | 7 | EQUIRECTANGULAR_MODE | |
  95298. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95299. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95300. */
  95301. coordinatesMode: number;
  95302. /**
  95303. * | Value | Type | Description |
  95304. * | ----- | ------------------ | ----------- |
  95305. * | 0 | CLAMP_ADDRESSMODE | |
  95306. * | 1 | WRAP_ADDRESSMODE | |
  95307. * | 2 | MIRROR_ADDRESSMODE | |
  95308. */
  95309. wrapU: number;
  95310. /**
  95311. * | Value | Type | Description |
  95312. * | ----- | ------------------ | ----------- |
  95313. * | 0 | CLAMP_ADDRESSMODE | |
  95314. * | 1 | WRAP_ADDRESSMODE | |
  95315. * | 2 | MIRROR_ADDRESSMODE | |
  95316. */
  95317. wrapV: number;
  95318. /**
  95319. * | Value | Type | Description |
  95320. * | ----- | ------------------ | ----------- |
  95321. * | 0 | CLAMP_ADDRESSMODE | |
  95322. * | 1 | WRAP_ADDRESSMODE | |
  95323. * | 2 | MIRROR_ADDRESSMODE | |
  95324. */
  95325. wrapR: number;
  95326. /**
  95327. * With compliant hardware and browser (supporting anisotropic filtering)
  95328. * this defines the level of anisotropic filtering in the texture.
  95329. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95330. */
  95331. anisotropicFilteringLevel: number;
  95332. /**
  95333. * Define if the texture is a cube texture or if false a 2d texture.
  95334. */
  95335. isCube: boolean;
  95336. /**
  95337. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95338. */
  95339. is3D: boolean;
  95340. /**
  95341. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95342. * HDR texture are usually stored in linear space.
  95343. * This only impacts the PBR and Background materials
  95344. */
  95345. gammaSpace: boolean;
  95346. /**
  95347. * Gets or sets whether or not the texture contains RGBD data.
  95348. */
  95349. isRGBD: boolean;
  95350. /**
  95351. * Is Z inverted in the texture (useful in a cube texture).
  95352. */
  95353. invertZ: boolean;
  95354. /**
  95355. * Are mip maps generated for this texture or not.
  95356. */
  95357. readonly noMipmap: boolean;
  95358. /**
  95359. * @hidden
  95360. */
  95361. lodLevelInAlpha: boolean;
  95362. /**
  95363. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95364. */
  95365. lodGenerationOffset: number;
  95366. /**
  95367. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95368. */
  95369. lodGenerationScale: number;
  95370. /**
  95371. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95372. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95373. * average roughness values.
  95374. */
  95375. linearSpecularLOD: boolean;
  95376. /**
  95377. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95378. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95379. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95380. */
  95381. irradianceTexture: Nullable<BaseTexture>;
  95382. /**
  95383. * Define if the texture is a render target.
  95384. */
  95385. isRenderTarget: boolean;
  95386. /**
  95387. * Define the unique id of the texture in the scene.
  95388. */
  95389. readonly uid: string;
  95390. /**
  95391. * Return a string representation of the texture.
  95392. * @returns the texture as a string
  95393. */
  95394. toString(): string;
  95395. /**
  95396. * Get the class name of the texture.
  95397. * @returns "BaseTexture"
  95398. */
  95399. getClassName(): string;
  95400. /**
  95401. * Define the list of animation attached to the texture.
  95402. */
  95403. animations: Animation[];
  95404. /**
  95405. * An event triggered when the texture is disposed.
  95406. */
  95407. onDisposeObservable: Observable<BaseTexture>;
  95408. private _onDisposeObserver;
  95409. /**
  95410. * Callback triggered when the texture has been disposed.
  95411. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95412. */
  95413. onDispose: () => void;
  95414. /**
  95415. * Define the current state of the loading sequence when in delayed load mode.
  95416. */
  95417. delayLoadState: number;
  95418. private _scene;
  95419. /** @hidden */
  95420. _texture: Nullable<InternalTexture>;
  95421. private _uid;
  95422. /**
  95423. * Define if the texture is preventinga material to render or not.
  95424. * If not and the texture is not ready, the engine will use a default black texture instead.
  95425. */
  95426. readonly isBlocking: boolean;
  95427. /**
  95428. * Instantiates a new BaseTexture.
  95429. * Base class of all the textures in babylon.
  95430. * It groups all the common properties the materials, post process, lights... might need
  95431. * in order to make a correct use of the texture.
  95432. * @param scene Define the scene the texture blongs to
  95433. */
  95434. constructor(scene: Nullable<Scene>);
  95435. /**
  95436. * Get the scene the texture belongs to.
  95437. * @returns the scene or null if undefined
  95438. */
  95439. getScene(): Nullable<Scene>;
  95440. /**
  95441. * Get the texture transform matrix used to offset tile the texture for istance.
  95442. * @returns the transformation matrix
  95443. */
  95444. getTextureMatrix(): Matrix;
  95445. /**
  95446. * Get the texture reflection matrix used to rotate/transform the reflection.
  95447. * @returns the reflection matrix
  95448. */
  95449. getReflectionTextureMatrix(): Matrix;
  95450. /**
  95451. * Get the underlying lower level texture from Babylon.
  95452. * @returns the insternal texture
  95453. */
  95454. getInternalTexture(): Nullable<InternalTexture>;
  95455. /**
  95456. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95457. * @returns true if ready or not blocking
  95458. */
  95459. isReadyOrNotBlocking(): boolean;
  95460. /**
  95461. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95462. * @returns true if fully ready
  95463. */
  95464. isReady(): boolean;
  95465. private _cachedSize;
  95466. /**
  95467. * Get the size of the texture.
  95468. * @returns the texture size.
  95469. */
  95470. getSize(): ISize;
  95471. /**
  95472. * Get the base size of the texture.
  95473. * It can be different from the size if the texture has been resized for POT for instance
  95474. * @returns the base size
  95475. */
  95476. getBaseSize(): ISize;
  95477. /**
  95478. * Update the sampling mode of the texture.
  95479. * Default is Trilinear mode.
  95480. *
  95481. * | Value | Type | Description |
  95482. * | ----- | ------------------ | ----------- |
  95483. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95484. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95485. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95486. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95487. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95488. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95489. * | 7 | NEAREST_LINEAR | |
  95490. * | 8 | NEAREST_NEAREST | |
  95491. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95492. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95493. * | 11 | LINEAR_LINEAR | |
  95494. * | 12 | LINEAR_NEAREST | |
  95495. *
  95496. * > _mag_: magnification filter (close to the viewer)
  95497. * > _min_: minification filter (far from the viewer)
  95498. * > _mip_: filter used between mip map levels
  95499. *@param samplingMode Define the new sampling mode of the texture
  95500. */
  95501. updateSamplingMode(samplingMode: number): void;
  95502. /**
  95503. * Scales the texture if is `canRescale()`
  95504. * @param ratio the resize factor we want to use to rescale
  95505. */
  95506. scale(ratio: number): void;
  95507. /**
  95508. * Get if the texture can rescale.
  95509. */
  95510. readonly canRescale: boolean;
  95511. /** @hidden */
  95512. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95513. /** @hidden */
  95514. _rebuild(): void;
  95515. /**
  95516. * Triggers the load sequence in delayed load mode.
  95517. */
  95518. delayLoad(): void;
  95519. /**
  95520. * Clones the texture.
  95521. * @returns the cloned texture
  95522. */
  95523. clone(): Nullable<BaseTexture>;
  95524. /**
  95525. * Get the texture underlying type (INT, FLOAT...)
  95526. */
  95527. readonly textureType: number;
  95528. /**
  95529. * Get the texture underlying format (RGB, RGBA...)
  95530. */
  95531. readonly textureFormat: number;
  95532. /**
  95533. * Indicates that textures need to be re-calculated for all materials
  95534. */
  95535. protected _markAllSubMeshesAsTexturesDirty(): void;
  95536. /**
  95537. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95538. * This will returns an RGBA array buffer containing either in values (0-255) or
  95539. * float values (0-1) depending of the underlying buffer type.
  95540. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95541. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95542. * @param buffer defines a user defined buffer to fill with data (can be null)
  95543. * @returns The Array buffer containing the pixels data.
  95544. */
  95545. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95546. /**
  95547. * Release and destroy the underlying lower level texture aka internalTexture.
  95548. */
  95549. releaseInternalTexture(): void;
  95550. /** @hidden */
  95551. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95552. /** @hidden */
  95553. readonly _lodTextureMid: Nullable<BaseTexture>;
  95554. /** @hidden */
  95555. readonly _lodTextureLow: Nullable<BaseTexture>;
  95556. /**
  95557. * Dispose the texture and release its associated resources.
  95558. */
  95559. dispose(): void;
  95560. /**
  95561. * Serialize the texture into a JSON representation that can be parsed later on.
  95562. * @returns the JSON representation of the texture
  95563. */
  95564. serialize(): any;
  95565. /**
  95566. * Helper function to be called back once a list of texture contains only ready textures.
  95567. * @param textures Define the list of textures to wait for
  95568. * @param callback Define the callback triggered once the entire list will be ready
  95569. */
  95570. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95571. }
  95572. }
  95573. declare module BABYLON {
  95574. /**
  95575. * Options to be used when creating an effect.
  95576. */
  95577. export interface IEffectCreationOptions {
  95578. /**
  95579. * Atrributes that will be used in the shader.
  95580. */
  95581. attributes: string[];
  95582. /**
  95583. * Uniform varible names that will be set in the shader.
  95584. */
  95585. uniformsNames: string[];
  95586. /**
  95587. * Uniform buffer varible names that will be set in the shader.
  95588. */
  95589. uniformBuffersNames: string[];
  95590. /**
  95591. * Sampler texture variable names that will be set in the shader.
  95592. */
  95593. samplers: string[];
  95594. /**
  95595. * Define statements that will be set in the shader.
  95596. */
  95597. defines: any;
  95598. /**
  95599. * Possible fallbacks for this effect to improve performance when needed.
  95600. */
  95601. fallbacks: Nullable<IEffectFallbacks>;
  95602. /**
  95603. * Callback that will be called when the shader is compiled.
  95604. */
  95605. onCompiled: Nullable<(effect: Effect) => void>;
  95606. /**
  95607. * Callback that will be called if an error occurs during shader compilation.
  95608. */
  95609. onError: Nullable<(effect: Effect, errors: string) => void>;
  95610. /**
  95611. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95612. */
  95613. indexParameters?: any;
  95614. /**
  95615. * Max number of lights that can be used in the shader.
  95616. */
  95617. maxSimultaneousLights?: number;
  95618. /**
  95619. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95620. */
  95621. transformFeedbackVaryings?: Nullable<string[]>;
  95622. }
  95623. /**
  95624. * Effect containing vertex and fragment shader that can be executed on an object.
  95625. */
  95626. export class Effect implements IDisposable {
  95627. /**
  95628. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95629. */
  95630. static ShadersRepository: string;
  95631. /**
  95632. * Name of the effect.
  95633. */
  95634. name: any;
  95635. /**
  95636. * String container all the define statements that should be set on the shader.
  95637. */
  95638. defines: string;
  95639. /**
  95640. * Callback that will be called when the shader is compiled.
  95641. */
  95642. onCompiled: Nullable<(effect: Effect) => void>;
  95643. /**
  95644. * Callback that will be called if an error occurs during shader compilation.
  95645. */
  95646. onError: Nullable<(effect: Effect, errors: string) => void>;
  95647. /**
  95648. * Callback that will be called when effect is bound.
  95649. */
  95650. onBind: Nullable<(effect: Effect) => void>;
  95651. /**
  95652. * Unique ID of the effect.
  95653. */
  95654. uniqueId: number;
  95655. /**
  95656. * Observable that will be called when the shader is compiled.
  95657. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95658. */
  95659. onCompileObservable: Observable<Effect>;
  95660. /**
  95661. * Observable that will be called if an error occurs during shader compilation.
  95662. */
  95663. onErrorObservable: Observable<Effect>;
  95664. /** @hidden */
  95665. _onBindObservable: Nullable<Observable<Effect>>;
  95666. /**
  95667. * Observable that will be called when effect is bound.
  95668. */
  95669. readonly onBindObservable: Observable<Effect>;
  95670. /** @hidden */
  95671. _bonesComputationForcedToCPU: boolean;
  95672. private static _uniqueIdSeed;
  95673. private _engine;
  95674. private _uniformBuffersNames;
  95675. private _uniformsNames;
  95676. private _samplerList;
  95677. private _samplers;
  95678. private _isReady;
  95679. private _compilationError;
  95680. private _allFallbacksProcessed;
  95681. private _attributesNames;
  95682. private _attributes;
  95683. private _uniforms;
  95684. /**
  95685. * Key for the effect.
  95686. * @hidden
  95687. */
  95688. _key: string;
  95689. private _indexParameters;
  95690. private _fallbacks;
  95691. private _vertexSourceCode;
  95692. private _fragmentSourceCode;
  95693. private _vertexSourceCodeOverride;
  95694. private _fragmentSourceCodeOverride;
  95695. private _transformFeedbackVaryings;
  95696. /**
  95697. * Compiled shader to webGL program.
  95698. * @hidden
  95699. */
  95700. _pipelineContext: Nullable<IPipelineContext>;
  95701. private _valueCache;
  95702. private static _baseCache;
  95703. /**
  95704. * Instantiates an effect.
  95705. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95706. * @param baseName Name of the effect.
  95707. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95708. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95709. * @param samplers List of sampler variables that will be passed to the shader.
  95710. * @param engine Engine to be used to render the effect
  95711. * @param defines Define statements to be added to the shader.
  95712. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95713. * @param onCompiled Callback that will be called when the shader is compiled.
  95714. * @param onError Callback that will be called if an error occurs during shader compilation.
  95715. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95716. */
  95717. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  95718. private _useFinalCode;
  95719. /**
  95720. * Unique key for this effect
  95721. */
  95722. readonly key: string;
  95723. /**
  95724. * If the effect has been compiled and prepared.
  95725. * @returns if the effect is compiled and prepared.
  95726. */
  95727. isReady(): boolean;
  95728. private _isReadyInternal;
  95729. /**
  95730. * The engine the effect was initialized with.
  95731. * @returns the engine.
  95732. */
  95733. getEngine(): Engine;
  95734. /**
  95735. * The pipeline context for this effect
  95736. * @returns the associated pipeline context
  95737. */
  95738. getPipelineContext(): Nullable<IPipelineContext>;
  95739. /**
  95740. * The set of names of attribute variables for the shader.
  95741. * @returns An array of attribute names.
  95742. */
  95743. getAttributesNames(): string[];
  95744. /**
  95745. * Returns the attribute at the given index.
  95746. * @param index The index of the attribute.
  95747. * @returns The location of the attribute.
  95748. */
  95749. getAttributeLocation(index: number): number;
  95750. /**
  95751. * Returns the attribute based on the name of the variable.
  95752. * @param name of the attribute to look up.
  95753. * @returns the attribute location.
  95754. */
  95755. getAttributeLocationByName(name: string): number;
  95756. /**
  95757. * The number of attributes.
  95758. * @returns the numnber of attributes.
  95759. */
  95760. getAttributesCount(): number;
  95761. /**
  95762. * Gets the index of a uniform variable.
  95763. * @param uniformName of the uniform to look up.
  95764. * @returns the index.
  95765. */
  95766. getUniformIndex(uniformName: string): number;
  95767. /**
  95768. * Returns the attribute based on the name of the variable.
  95769. * @param uniformName of the uniform to look up.
  95770. * @returns the location of the uniform.
  95771. */
  95772. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95773. /**
  95774. * Returns an array of sampler variable names
  95775. * @returns The array of sampler variable neames.
  95776. */
  95777. getSamplers(): string[];
  95778. /**
  95779. * The error from the last compilation.
  95780. * @returns the error string.
  95781. */
  95782. getCompilationError(): string;
  95783. /**
  95784. * Gets a boolean indicating that all fallbacks were used during compilation
  95785. * @returns true if all fallbacks were used
  95786. */
  95787. allFallbacksProcessed(): boolean;
  95788. /**
  95789. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95790. * @param func The callback to be used.
  95791. */
  95792. executeWhenCompiled(func: (effect: Effect) => void): void;
  95793. private _checkIsReady;
  95794. private _loadShader;
  95795. /**
  95796. * Recompiles the webGL program
  95797. * @param vertexSourceCode The source code for the vertex shader.
  95798. * @param fragmentSourceCode The source code for the fragment shader.
  95799. * @param onCompiled Callback called when completed.
  95800. * @param onError Callback called on error.
  95801. * @hidden
  95802. */
  95803. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95804. /**
  95805. * Prepares the effect
  95806. * @hidden
  95807. */
  95808. _prepareEffect(): void;
  95809. private _processCompilationErrors;
  95810. /**
  95811. * Checks if the effect is supported. (Must be called after compilation)
  95812. */
  95813. readonly isSupported: boolean;
  95814. /**
  95815. * Binds a texture to the engine to be used as output of the shader.
  95816. * @param channel Name of the output variable.
  95817. * @param texture Texture to bind.
  95818. * @hidden
  95819. */
  95820. _bindTexture(channel: string, texture: InternalTexture): void;
  95821. /**
  95822. * Sets a texture on the engine to be used in the shader.
  95823. * @param channel Name of the sampler variable.
  95824. * @param texture Texture to set.
  95825. */
  95826. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95827. /**
  95828. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95829. * @param channel Name of the sampler variable.
  95830. * @param texture Texture to set.
  95831. */
  95832. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95833. /**
  95834. * Sets an array of textures on the engine to be used in the shader.
  95835. * @param channel Name of the variable.
  95836. * @param textures Textures to set.
  95837. */
  95838. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95839. /**
  95840. * 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)
  95841. * @param channel Name of the sampler variable.
  95842. * @param postProcess Post process to get the input texture from.
  95843. */
  95844. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95845. /**
  95846. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95847. * 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)
  95848. * @param channel Name of the sampler variable.
  95849. * @param postProcess Post process to get the output texture from.
  95850. */
  95851. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95852. /** @hidden */
  95853. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95854. /** @hidden */
  95855. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95856. /** @hidden */
  95857. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95858. /** @hidden */
  95859. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95860. /**
  95861. * Binds a buffer to a uniform.
  95862. * @param buffer Buffer to bind.
  95863. * @param name Name of the uniform variable to bind to.
  95864. */
  95865. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95866. /**
  95867. * Binds block to a uniform.
  95868. * @param blockName Name of the block to bind.
  95869. * @param index Index to bind.
  95870. */
  95871. bindUniformBlock(blockName: string, index: number): void;
  95872. /**
  95873. * Sets an interger value on a uniform variable.
  95874. * @param uniformName Name of the variable.
  95875. * @param value Value to be set.
  95876. * @returns this effect.
  95877. */
  95878. setInt(uniformName: string, value: number): Effect;
  95879. /**
  95880. * Sets an int array on a uniform variable.
  95881. * @param uniformName Name of the variable.
  95882. * @param array array to be set.
  95883. * @returns this effect.
  95884. */
  95885. setIntArray(uniformName: string, array: Int32Array): Effect;
  95886. /**
  95887. * 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)
  95888. * @param uniformName Name of the variable.
  95889. * @param array array to be set.
  95890. * @returns this effect.
  95891. */
  95892. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95893. /**
  95894. * 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)
  95895. * @param uniformName Name of the variable.
  95896. * @param array array to be set.
  95897. * @returns this effect.
  95898. */
  95899. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95900. /**
  95901. * 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)
  95902. * @param uniformName Name of the variable.
  95903. * @param array array to be set.
  95904. * @returns this effect.
  95905. */
  95906. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95907. /**
  95908. * Sets an float array on a uniform variable.
  95909. * @param uniformName Name of the variable.
  95910. * @param array array to be set.
  95911. * @returns this effect.
  95912. */
  95913. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95914. /**
  95915. * 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)
  95916. * @param uniformName Name of the variable.
  95917. * @param array array to be set.
  95918. * @returns this effect.
  95919. */
  95920. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95921. /**
  95922. * 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)
  95923. * @param uniformName Name of the variable.
  95924. * @param array array to be set.
  95925. * @returns this effect.
  95926. */
  95927. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95928. /**
  95929. * 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)
  95930. * @param uniformName Name of the variable.
  95931. * @param array array to be set.
  95932. * @returns this effect.
  95933. */
  95934. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95935. /**
  95936. * Sets an array on a uniform variable.
  95937. * @param uniformName Name of the variable.
  95938. * @param array array to be set.
  95939. * @returns this effect.
  95940. */
  95941. setArray(uniformName: string, array: number[]): Effect;
  95942. /**
  95943. * 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)
  95944. * @param uniformName Name of the variable.
  95945. * @param array array to be set.
  95946. * @returns this effect.
  95947. */
  95948. setArray2(uniformName: string, array: number[]): Effect;
  95949. /**
  95950. * 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)
  95951. * @param uniformName Name of the variable.
  95952. * @param array array to be set.
  95953. * @returns this effect.
  95954. */
  95955. setArray3(uniformName: string, array: number[]): Effect;
  95956. /**
  95957. * 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)
  95958. * @param uniformName Name of the variable.
  95959. * @param array array to be set.
  95960. * @returns this effect.
  95961. */
  95962. setArray4(uniformName: string, array: number[]): Effect;
  95963. /**
  95964. * Sets matrices on a uniform variable.
  95965. * @param uniformName Name of the variable.
  95966. * @param matrices matrices to be set.
  95967. * @returns this effect.
  95968. */
  95969. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95970. /**
  95971. * Sets matrix on a uniform variable.
  95972. * @param uniformName Name of the variable.
  95973. * @param matrix matrix to be set.
  95974. * @returns this effect.
  95975. */
  95976. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95977. /**
  95978. * 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)
  95979. * @param uniformName Name of the variable.
  95980. * @param matrix matrix to be set.
  95981. * @returns this effect.
  95982. */
  95983. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95984. /**
  95985. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95986. * @param uniformName Name of the variable.
  95987. * @param matrix matrix to be set.
  95988. * @returns this effect.
  95989. */
  95990. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95991. /**
  95992. * Sets a float on a uniform variable.
  95993. * @param uniformName Name of the variable.
  95994. * @param value value to be set.
  95995. * @returns this effect.
  95996. */
  95997. setFloat(uniformName: string, value: number): Effect;
  95998. /**
  95999. * Sets a boolean on a uniform variable.
  96000. * @param uniformName Name of the variable.
  96001. * @param bool value to be set.
  96002. * @returns this effect.
  96003. */
  96004. setBool(uniformName: string, bool: boolean): Effect;
  96005. /**
  96006. * Sets a Vector2 on a uniform variable.
  96007. * @param uniformName Name of the variable.
  96008. * @param vector2 vector2 to be set.
  96009. * @returns this effect.
  96010. */
  96011. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96012. /**
  96013. * Sets a float2 on a uniform variable.
  96014. * @param uniformName Name of the variable.
  96015. * @param x First float in float2.
  96016. * @param y Second float in float2.
  96017. * @returns this effect.
  96018. */
  96019. setFloat2(uniformName: string, x: number, y: number): Effect;
  96020. /**
  96021. * Sets a Vector3 on a uniform variable.
  96022. * @param uniformName Name of the variable.
  96023. * @param vector3 Value to be set.
  96024. * @returns this effect.
  96025. */
  96026. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96027. /**
  96028. * Sets a float3 on a uniform variable.
  96029. * @param uniformName Name of the variable.
  96030. * @param x First float in float3.
  96031. * @param y Second float in float3.
  96032. * @param z Third float in float3.
  96033. * @returns this effect.
  96034. */
  96035. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96036. /**
  96037. * Sets a Vector4 on a uniform variable.
  96038. * @param uniformName Name of the variable.
  96039. * @param vector4 Value to be set.
  96040. * @returns this effect.
  96041. */
  96042. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96043. /**
  96044. * Sets a float4 on a uniform variable.
  96045. * @param uniformName Name of the variable.
  96046. * @param x First float in float4.
  96047. * @param y Second float in float4.
  96048. * @param z Third float in float4.
  96049. * @param w Fourth float in float4.
  96050. * @returns this effect.
  96051. */
  96052. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96053. /**
  96054. * Sets a Color3 on a uniform variable.
  96055. * @param uniformName Name of the variable.
  96056. * @param color3 Value to be set.
  96057. * @returns this effect.
  96058. */
  96059. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96060. /**
  96061. * Sets a Color4 on a uniform variable.
  96062. * @param uniformName Name of the variable.
  96063. * @param color3 Value to be set.
  96064. * @param alpha Alpha value to be set.
  96065. * @returns this effect.
  96066. */
  96067. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96068. /**
  96069. * Sets a Color4 on a uniform variable
  96070. * @param uniformName defines the name of the variable
  96071. * @param color4 defines the value to be set
  96072. * @returns this effect.
  96073. */
  96074. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96075. /** Release all associated resources */
  96076. dispose(): void;
  96077. /**
  96078. * This function will add a new shader to the shader store
  96079. * @param name the name of the shader
  96080. * @param pixelShader optional pixel shader content
  96081. * @param vertexShader optional vertex shader content
  96082. */
  96083. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96084. /**
  96085. * Store of each shader (The can be looked up using effect.key)
  96086. */
  96087. static ShadersStore: {
  96088. [key: string]: string;
  96089. };
  96090. /**
  96091. * Store of each included file for a shader (The can be looked up using effect.key)
  96092. */
  96093. static IncludesShadersStore: {
  96094. [key: string]: string;
  96095. };
  96096. /**
  96097. * Resets the cache of effects.
  96098. */
  96099. static ResetCache(): void;
  96100. }
  96101. }
  96102. declare module BABYLON {
  96103. /**
  96104. * Interface used to describe the capabilities of the engine relatively to the current browser
  96105. */
  96106. export interface EngineCapabilities {
  96107. /** Maximum textures units per fragment shader */
  96108. maxTexturesImageUnits: number;
  96109. /** Maximum texture units per vertex shader */
  96110. maxVertexTextureImageUnits: number;
  96111. /** Maximum textures units in the entire pipeline */
  96112. maxCombinedTexturesImageUnits: number;
  96113. /** Maximum texture size */
  96114. maxTextureSize: number;
  96115. /** Maximum cube texture size */
  96116. maxCubemapTextureSize: number;
  96117. /** Maximum render texture size */
  96118. maxRenderTextureSize: number;
  96119. /** Maximum number of vertex attributes */
  96120. maxVertexAttribs: number;
  96121. /** Maximum number of varyings */
  96122. maxVaryingVectors: number;
  96123. /** Maximum number of uniforms per vertex shader */
  96124. maxVertexUniformVectors: number;
  96125. /** Maximum number of uniforms per fragment shader */
  96126. maxFragmentUniformVectors: number;
  96127. /** Defines if standard derivates (dx/dy) are supported */
  96128. standardDerivatives: boolean;
  96129. /** Defines if s3tc texture compression is supported */
  96130. s3tc?: WEBGL_compressed_texture_s3tc;
  96131. /** Defines if pvrtc texture compression is supported */
  96132. pvrtc: any;
  96133. /** Defines if etc1 texture compression is supported */
  96134. etc1: any;
  96135. /** Defines if etc2 texture compression is supported */
  96136. etc2: any;
  96137. /** Defines if astc texture compression is supported */
  96138. astc: any;
  96139. /** Defines if float textures are supported */
  96140. textureFloat: boolean;
  96141. /** Defines if vertex array objects are supported */
  96142. vertexArrayObject: boolean;
  96143. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96144. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96145. /** Gets the maximum level of anisotropy supported */
  96146. maxAnisotropy: number;
  96147. /** Defines if instancing is supported */
  96148. instancedArrays: boolean;
  96149. /** Defines if 32 bits indices are supported */
  96150. uintIndices: boolean;
  96151. /** Defines if high precision shaders are supported */
  96152. highPrecisionShaderSupported: boolean;
  96153. /** Defines if depth reading in the fragment shader is supported */
  96154. fragmentDepthSupported: boolean;
  96155. /** Defines if float texture linear filtering is supported*/
  96156. textureFloatLinearFiltering: boolean;
  96157. /** Defines if rendering to float textures is supported */
  96158. textureFloatRender: boolean;
  96159. /** Defines if half float textures are supported*/
  96160. textureHalfFloat: boolean;
  96161. /** Defines if half float texture linear filtering is supported*/
  96162. textureHalfFloatLinearFiltering: boolean;
  96163. /** Defines if rendering to half float textures is supported */
  96164. textureHalfFloatRender: boolean;
  96165. /** Defines if textureLOD shader command is supported */
  96166. textureLOD: boolean;
  96167. /** Defines if draw buffers extension is supported */
  96168. drawBuffersExtension: boolean;
  96169. /** Defines if depth textures are supported */
  96170. depthTextureExtension: boolean;
  96171. /** Defines if float color buffer are supported */
  96172. colorBufferFloat: boolean;
  96173. /** Gets disjoint timer query extension (null if not supported) */
  96174. timerQuery?: EXT_disjoint_timer_query;
  96175. /** Defines if timestamp can be used with timer query */
  96176. canUseTimestampForTimerQuery: boolean;
  96177. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96178. multiview?: any;
  96179. /** Function used to let the system compiles shaders in background */
  96180. parallelShaderCompile?: {
  96181. COMPLETION_STATUS_KHR: number;
  96182. };
  96183. /** Max number of texture samples for MSAA */
  96184. maxMSAASamples: number;
  96185. /** Defines if the blend min max extension is supported */
  96186. blendMinMax: boolean;
  96187. }
  96188. }
  96189. declare module BABYLON {
  96190. /**
  96191. * @hidden
  96192. **/
  96193. export class DepthCullingState {
  96194. private _isDepthTestDirty;
  96195. private _isDepthMaskDirty;
  96196. private _isDepthFuncDirty;
  96197. private _isCullFaceDirty;
  96198. private _isCullDirty;
  96199. private _isZOffsetDirty;
  96200. private _isFrontFaceDirty;
  96201. private _depthTest;
  96202. private _depthMask;
  96203. private _depthFunc;
  96204. private _cull;
  96205. private _cullFace;
  96206. private _zOffset;
  96207. private _frontFace;
  96208. /**
  96209. * Initializes the state.
  96210. */
  96211. constructor();
  96212. readonly isDirty: boolean;
  96213. zOffset: number;
  96214. cullFace: Nullable<number>;
  96215. cull: Nullable<boolean>;
  96216. depthFunc: Nullable<number>;
  96217. depthMask: boolean;
  96218. depthTest: boolean;
  96219. frontFace: Nullable<number>;
  96220. reset(): void;
  96221. apply(gl: WebGLRenderingContext): void;
  96222. }
  96223. }
  96224. declare module BABYLON {
  96225. /**
  96226. * @hidden
  96227. **/
  96228. export class StencilState {
  96229. /** 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 */
  96230. static readonly ALWAYS: number;
  96231. /** Passed to stencilOperation to specify that stencil value must be kept */
  96232. static readonly KEEP: number;
  96233. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96234. static readonly REPLACE: number;
  96235. private _isStencilTestDirty;
  96236. private _isStencilMaskDirty;
  96237. private _isStencilFuncDirty;
  96238. private _isStencilOpDirty;
  96239. private _stencilTest;
  96240. private _stencilMask;
  96241. private _stencilFunc;
  96242. private _stencilFuncRef;
  96243. private _stencilFuncMask;
  96244. private _stencilOpStencilFail;
  96245. private _stencilOpDepthFail;
  96246. private _stencilOpStencilDepthPass;
  96247. readonly isDirty: boolean;
  96248. stencilFunc: number;
  96249. stencilFuncRef: number;
  96250. stencilFuncMask: number;
  96251. stencilOpStencilFail: number;
  96252. stencilOpDepthFail: number;
  96253. stencilOpStencilDepthPass: number;
  96254. stencilMask: number;
  96255. stencilTest: boolean;
  96256. constructor();
  96257. reset(): void;
  96258. apply(gl: WebGLRenderingContext): void;
  96259. }
  96260. }
  96261. declare module BABYLON {
  96262. /**
  96263. * @hidden
  96264. **/
  96265. export class AlphaState {
  96266. private _isAlphaBlendDirty;
  96267. private _isBlendFunctionParametersDirty;
  96268. private _isBlendEquationParametersDirty;
  96269. private _isBlendConstantsDirty;
  96270. private _alphaBlend;
  96271. private _blendFunctionParameters;
  96272. private _blendEquationParameters;
  96273. private _blendConstants;
  96274. /**
  96275. * Initializes the state.
  96276. */
  96277. constructor();
  96278. readonly isDirty: boolean;
  96279. alphaBlend: boolean;
  96280. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96281. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96282. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96283. reset(): void;
  96284. apply(gl: WebGLRenderingContext): void;
  96285. }
  96286. }
  96287. declare module BABYLON {
  96288. /** @hidden */
  96289. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96290. attributeProcessor(attribute: string): string;
  96291. varyingProcessor(varying: string, isFragment: boolean): string;
  96292. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96293. }
  96294. }
  96295. declare module BABYLON {
  96296. /**
  96297. * Interface for attribute information associated with buffer instanciation
  96298. */
  96299. export interface InstancingAttributeInfo {
  96300. /**
  96301. * Index/offset of the attribute in the vertex shader
  96302. */
  96303. index: number;
  96304. /**
  96305. * size of the attribute, 1, 2, 3 or 4
  96306. */
  96307. attributeSize: number;
  96308. /**
  96309. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96310. * default is FLOAT
  96311. */
  96312. attributeType: number;
  96313. /**
  96314. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96315. */
  96316. normalized: boolean;
  96317. /**
  96318. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96319. */
  96320. offset: number;
  96321. /**
  96322. * Name of the GLSL attribute, for debugging purpose only
  96323. */
  96324. attributeName: string;
  96325. }
  96326. }
  96327. declare module BABYLON {
  96328. interface ThinEngine {
  96329. /**
  96330. * Update a video texture
  96331. * @param texture defines the texture to update
  96332. * @param video defines the video element to use
  96333. * @param invertY defines if data must be stored with Y axis inverted
  96334. */
  96335. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96336. }
  96337. }
  96338. declare module BABYLON {
  96339. /**
  96340. * Settings for finer control over video usage
  96341. */
  96342. export interface VideoTextureSettings {
  96343. /**
  96344. * Applies `autoplay` to video, if specified
  96345. */
  96346. autoPlay?: boolean;
  96347. /**
  96348. * Applies `loop` to video, if specified
  96349. */
  96350. loop?: boolean;
  96351. /**
  96352. * Automatically updates internal texture from video at every frame in the render loop
  96353. */
  96354. autoUpdateTexture: boolean;
  96355. /**
  96356. * Image src displayed during the video loading or until the user interacts with the video.
  96357. */
  96358. poster?: string;
  96359. }
  96360. /**
  96361. * If you want to display a video in your scene, this is the special texture for that.
  96362. * This special texture works similar to other textures, with the exception of a few parameters.
  96363. * @see https://doc.babylonjs.com/how_to/video_texture
  96364. */
  96365. export class VideoTexture extends Texture {
  96366. /**
  96367. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96368. */
  96369. readonly autoUpdateTexture: boolean;
  96370. /**
  96371. * The video instance used by the texture internally
  96372. */
  96373. readonly video: HTMLVideoElement;
  96374. private _onUserActionRequestedObservable;
  96375. /**
  96376. * Event triggerd when a dom action is required by the user to play the video.
  96377. * This happens due to recent changes in browser policies preventing video to auto start.
  96378. */
  96379. readonly onUserActionRequestedObservable: Observable<Texture>;
  96380. private _generateMipMaps;
  96381. private _engine;
  96382. private _stillImageCaptured;
  96383. private _displayingPosterTexture;
  96384. private _settings;
  96385. private _createInternalTextureOnEvent;
  96386. private _frameId;
  96387. /**
  96388. * Creates a video texture.
  96389. * If you want to display a video in your scene, this is the special texture for that.
  96390. * This special texture works similar to other textures, with the exception of a few parameters.
  96391. * @see https://doc.babylonjs.com/how_to/video_texture
  96392. * @param name optional name, will detect from video source, if not defined
  96393. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96394. * @param scene is obviously the current scene.
  96395. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96396. * @param invertY is false by default but can be used to invert video on Y axis
  96397. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96398. * @param settings allows finer control over video usage
  96399. */
  96400. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96401. private _getName;
  96402. private _getVideo;
  96403. private _createInternalTexture;
  96404. private reset;
  96405. /**
  96406. * @hidden Internal method to initiate `update`.
  96407. */
  96408. _rebuild(): void;
  96409. /**
  96410. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96411. */
  96412. update(): void;
  96413. /**
  96414. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96415. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96416. */
  96417. updateTexture(isVisible: boolean): void;
  96418. protected _updateInternalTexture: () => void;
  96419. /**
  96420. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96421. * @param url New url.
  96422. */
  96423. updateURL(url: string): void;
  96424. /**
  96425. * Dispose the texture and release its associated resources.
  96426. */
  96427. dispose(): void;
  96428. /**
  96429. * Creates a video texture straight from a stream.
  96430. * @param scene Define the scene the texture should be created in
  96431. * @param stream Define the stream the texture should be created from
  96432. * @returns The created video texture as a promise
  96433. */
  96434. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96435. /**
  96436. * Creates a video texture straight from your WebCam video feed.
  96437. * @param scene Define the scene the texture should be created in
  96438. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96439. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96440. * @returns The created video texture as a promise
  96441. */
  96442. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96443. minWidth: number;
  96444. maxWidth: number;
  96445. minHeight: number;
  96446. maxHeight: number;
  96447. deviceId: string;
  96448. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96449. /**
  96450. * Creates a video texture straight from your WebCam video feed.
  96451. * @param scene Define the scene the texture should be created in
  96452. * @param onReady Define a callback to triggered once the texture will be ready
  96453. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96454. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96455. */
  96456. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96457. minWidth: number;
  96458. maxWidth: number;
  96459. minHeight: number;
  96460. maxHeight: number;
  96461. deviceId: string;
  96462. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96463. }
  96464. }
  96465. declare module BABYLON {
  96466. /**
  96467. * Defines the interface used by objects working like Scene
  96468. * @hidden
  96469. */
  96470. interface ISceneLike {
  96471. _addPendingData(data: any): void;
  96472. _removePendingData(data: any): void;
  96473. offlineProvider: IOfflineProvider;
  96474. }
  96475. /** Interface defining initialization parameters for Engine class */
  96476. export interface EngineOptions extends WebGLContextAttributes {
  96477. /**
  96478. * Defines if the engine should no exceed a specified device ratio
  96479. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96480. */
  96481. limitDeviceRatio?: number;
  96482. /**
  96483. * Defines if webvr should be enabled automatically
  96484. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96485. */
  96486. autoEnableWebVR?: boolean;
  96487. /**
  96488. * Defines if webgl2 should be turned off even if supported
  96489. * @see http://doc.babylonjs.com/features/webgl2
  96490. */
  96491. disableWebGL2Support?: boolean;
  96492. /**
  96493. * Defines if webaudio should be initialized as well
  96494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96495. */
  96496. audioEngine?: boolean;
  96497. /**
  96498. * Defines if animations should run using a deterministic lock step
  96499. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96500. */
  96501. deterministicLockstep?: boolean;
  96502. /** Defines the maximum steps to use with deterministic lock step mode */
  96503. lockstepMaxSteps?: number;
  96504. /**
  96505. * Defines that engine should ignore context lost events
  96506. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96507. */
  96508. doNotHandleContextLost?: boolean;
  96509. /**
  96510. * Defines that engine should ignore modifying touch action attribute and style
  96511. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96512. */
  96513. doNotHandleTouchAction?: boolean;
  96514. /**
  96515. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96516. */
  96517. useHighPrecisionFloats?: boolean;
  96518. }
  96519. /**
  96520. * The base engine class (root of all engines)
  96521. */
  96522. export class ThinEngine {
  96523. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96524. static ExceptionList: ({
  96525. key: string;
  96526. capture: string;
  96527. captureConstraint: number;
  96528. targets: string[];
  96529. } | {
  96530. key: string;
  96531. capture: null;
  96532. captureConstraint: null;
  96533. targets: string[];
  96534. })[];
  96535. /** @hidden */
  96536. static _TextureLoaders: IInternalTextureLoader[];
  96537. /**
  96538. * Returns the current npm package of the sdk
  96539. */
  96540. static readonly NpmPackage: string;
  96541. /**
  96542. * Returns the current version of the framework
  96543. */
  96544. static readonly Version: string;
  96545. /**
  96546. * Returns a string describing the current engine
  96547. */
  96548. readonly description: string;
  96549. /**
  96550. * Gets or sets the epsilon value used by collision engine
  96551. */
  96552. static CollisionsEpsilon: number;
  96553. /**
  96554. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96555. */
  96556. static ShadersRepository: string;
  96557. /** @hidden */
  96558. _shaderProcessor: IShaderProcessor;
  96559. /**
  96560. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96561. */
  96562. forcePOTTextures: boolean;
  96563. /**
  96564. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96565. */
  96566. isFullscreen: boolean;
  96567. /**
  96568. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96569. */
  96570. cullBackFaces: boolean;
  96571. /**
  96572. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96573. */
  96574. renderEvenInBackground: boolean;
  96575. /**
  96576. * Gets or sets a boolean indicating that cache can be kept between frames
  96577. */
  96578. preventCacheWipeBetweenFrames: boolean;
  96579. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96580. validateShaderPrograms: boolean;
  96581. /**
  96582. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96583. */
  96584. disableUniformBuffers: boolean;
  96585. /** @hidden */
  96586. _uniformBuffers: UniformBuffer[];
  96587. /**
  96588. * Gets a boolean indicating that the engine supports uniform buffers
  96589. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96590. */
  96591. readonly supportsUniformBuffers: boolean;
  96592. /** @hidden */
  96593. _gl: WebGLRenderingContext;
  96594. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96595. protected _windowIsBackground: boolean;
  96596. protected _webGLVersion: number;
  96597. protected _highPrecisionShadersAllowed: boolean;
  96598. /** @hidden */
  96599. readonly _shouldUseHighPrecisionShader: boolean;
  96600. /**
  96601. * Gets a boolean indicating that only power of 2 textures are supported
  96602. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96603. */
  96604. readonly needPOTTextures: boolean;
  96605. /** @hidden */
  96606. _badOS: boolean;
  96607. /** @hidden */
  96608. _badDesktopOS: boolean;
  96609. private _hardwareScalingLevel;
  96610. /** @hidden */
  96611. _caps: EngineCapabilities;
  96612. private _isStencilEnable;
  96613. protected _colorWrite: boolean;
  96614. private _glVersion;
  96615. private _glRenderer;
  96616. private _glVendor;
  96617. /** @hidden */
  96618. _videoTextureSupported: boolean;
  96619. protected _renderingQueueLaunched: boolean;
  96620. protected _activeRenderLoops: (() => void)[];
  96621. /**
  96622. * Observable signaled when a context lost event is raised
  96623. */
  96624. onContextLostObservable: Observable<ThinEngine>;
  96625. /**
  96626. * Observable signaled when a context restored event is raised
  96627. */
  96628. onContextRestoredObservable: Observable<ThinEngine>;
  96629. private _onContextLost;
  96630. private _onContextRestored;
  96631. protected _contextWasLost: boolean;
  96632. /** @hidden */
  96633. _doNotHandleContextLost: boolean;
  96634. /**
  96635. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96637. */
  96638. doNotHandleContextLost: boolean;
  96639. /**
  96640. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96641. */
  96642. disableVertexArrayObjects: boolean;
  96643. /** @hidden */
  96644. protected _depthCullingState: DepthCullingState;
  96645. /** @hidden */
  96646. protected _stencilState: StencilState;
  96647. /** @hidden */
  96648. protected _alphaState: AlphaState;
  96649. /** @hidden */
  96650. _internalTexturesCache: InternalTexture[];
  96651. /** @hidden */
  96652. protected _activeChannel: number;
  96653. private _currentTextureChannel;
  96654. /** @hidden */
  96655. protected _boundTexturesCache: {
  96656. [key: string]: Nullable<InternalTexture>;
  96657. };
  96658. /** @hidden */
  96659. protected _currentEffect: Nullable<Effect>;
  96660. /** @hidden */
  96661. protected _currentProgram: Nullable<WebGLProgram>;
  96662. private _compiledEffects;
  96663. private _vertexAttribArraysEnabled;
  96664. /** @hidden */
  96665. protected _cachedViewport: Nullable<IViewportLike>;
  96666. private _cachedVertexArrayObject;
  96667. /** @hidden */
  96668. protected _cachedVertexBuffers: any;
  96669. /** @hidden */
  96670. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96671. /** @hidden */
  96672. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96673. /** @hidden */
  96674. _currentRenderTarget: Nullable<InternalTexture>;
  96675. private _uintIndicesCurrentlySet;
  96676. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96677. /** @hidden */
  96678. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96679. private _currentBufferPointers;
  96680. private _currentInstanceLocations;
  96681. private _currentInstanceBuffers;
  96682. private _textureUnits;
  96683. /** @hidden */
  96684. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  96685. /** @hidden */
  96686. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  96687. /** @hidden */
  96688. _bindedRenderFunction: any;
  96689. private _vaoRecordInProgress;
  96690. private _mustWipeVertexAttributes;
  96691. private _emptyTexture;
  96692. private _emptyCubeTexture;
  96693. private _emptyTexture3D;
  96694. /** @hidden */
  96695. _frameHandler: number;
  96696. private _nextFreeTextureSlots;
  96697. private _maxSimultaneousTextures;
  96698. private _activeRequests;
  96699. protected _texturesSupported: string[];
  96700. /** @hidden */
  96701. _textureFormatInUse: Nullable<string>;
  96702. protected readonly _supportsHardwareTextureRescaling: boolean;
  96703. /**
  96704. * Gets the list of texture formats supported
  96705. */
  96706. readonly texturesSupported: Array<string>;
  96707. /**
  96708. * Gets the list of texture formats in use
  96709. */
  96710. readonly textureFormatInUse: Nullable<string>;
  96711. /**
  96712. * Gets the current viewport
  96713. */
  96714. readonly currentViewport: Nullable<IViewportLike>;
  96715. /**
  96716. * Gets the default empty texture
  96717. */
  96718. readonly emptyTexture: InternalTexture;
  96719. /**
  96720. * Gets the default empty 3D texture
  96721. */
  96722. readonly emptyTexture3D: InternalTexture;
  96723. /**
  96724. * Gets the default empty cube texture
  96725. */
  96726. readonly emptyCubeTexture: InternalTexture;
  96727. /**
  96728. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96729. */
  96730. readonly premultipliedAlpha: boolean;
  96731. /**
  96732. * Observable event triggered before each texture is initialized
  96733. */
  96734. onBeforeTextureInitObservable: Observable<Texture>;
  96735. /**
  96736. * Creates a new engine
  96737. * @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
  96738. * @param antialias defines enable antialiasing (default: false)
  96739. * @param options defines further options to be sent to the getContext() function
  96740. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96741. */
  96742. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96743. private _rebuildInternalTextures;
  96744. private _rebuildEffects;
  96745. /**
  96746. * Gets a boolean indicating if all created effects are ready
  96747. * @returns true if all effects are ready
  96748. */
  96749. areAllEffectsReady(): boolean;
  96750. protected _rebuildBuffers(): void;
  96751. private _initGLContext;
  96752. /**
  96753. * Gets version of the current webGL context
  96754. */
  96755. readonly webGLVersion: number;
  96756. /**
  96757. * Gets a string idenfifying the name of the class
  96758. * @returns "Engine" string
  96759. */
  96760. getClassName(): string;
  96761. /**
  96762. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96763. */
  96764. readonly isStencilEnable: boolean;
  96765. /** @hidden */
  96766. _prepareWorkingCanvas(): void;
  96767. /**
  96768. * Reset the texture cache to empty state
  96769. */
  96770. resetTextureCache(): void;
  96771. /**
  96772. * Gets an object containing information about the current webGL context
  96773. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96774. */
  96775. getGlInfo(): {
  96776. vendor: string;
  96777. renderer: string;
  96778. version: string;
  96779. };
  96780. /**
  96781. * Defines the hardware scaling level.
  96782. * By default the hardware scaling level is computed from the window device ratio.
  96783. * 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.
  96784. * @param level defines the level to use
  96785. */
  96786. setHardwareScalingLevel(level: number): void;
  96787. /**
  96788. * Gets the current hardware scaling level.
  96789. * By default the hardware scaling level is computed from the window device ratio.
  96790. * 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.
  96791. * @returns a number indicating the current hardware scaling level
  96792. */
  96793. getHardwareScalingLevel(): number;
  96794. /**
  96795. * Gets the list of loaded textures
  96796. * @returns an array containing all loaded textures
  96797. */
  96798. getLoadedTexturesCache(): InternalTexture[];
  96799. /**
  96800. * Gets the object containing all engine capabilities
  96801. * @returns the EngineCapabilities object
  96802. */
  96803. getCaps(): EngineCapabilities;
  96804. /**
  96805. * stop executing a render loop function and remove it from the execution array
  96806. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96807. */
  96808. stopRenderLoop(renderFunction?: () => void): void;
  96809. /** @hidden */
  96810. _renderLoop(): void;
  96811. /**
  96812. * Gets the HTML canvas attached with the current webGL context
  96813. * @returns a HTML canvas
  96814. */
  96815. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96816. /**
  96817. * Gets host window
  96818. * @returns the host window object
  96819. */
  96820. getHostWindow(): Nullable<Window>;
  96821. /**
  96822. * Gets the current render width
  96823. * @param useScreen defines if screen size must be used (or the current render target if any)
  96824. * @returns a number defining the current render width
  96825. */
  96826. getRenderWidth(useScreen?: boolean): number;
  96827. /**
  96828. * Gets the current render height
  96829. * @param useScreen defines if screen size must be used (or the current render target if any)
  96830. * @returns a number defining the current render height
  96831. */
  96832. getRenderHeight(useScreen?: boolean): number;
  96833. /**
  96834. * Can be used to override the current requestAnimationFrame requester.
  96835. * @hidden
  96836. */
  96837. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96838. /**
  96839. * Register and execute a render loop. The engine can have more than one render function
  96840. * @param renderFunction defines the function to continuously execute
  96841. */
  96842. runRenderLoop(renderFunction: () => void): void;
  96843. /**
  96844. * Clear the current render buffer or the current render target (if any is set up)
  96845. * @param color defines the color to use
  96846. * @param backBuffer defines if the back buffer must be cleared
  96847. * @param depth defines if the depth buffer must be cleared
  96848. * @param stencil defines if the stencil buffer must be cleared
  96849. */
  96850. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96851. private _viewportCached;
  96852. /** @hidden */
  96853. _viewport(x: number, y: number, width: number, height: number): void;
  96854. /**
  96855. * Set the WebGL's viewport
  96856. * @param viewport defines the viewport element to be used
  96857. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96858. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96859. */
  96860. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96861. /**
  96862. * Begin a new frame
  96863. */
  96864. beginFrame(): void;
  96865. /**
  96866. * Enf the current frame
  96867. */
  96868. endFrame(): void;
  96869. /**
  96870. * Resize the view according to the canvas' size
  96871. */
  96872. resize(): void;
  96873. /**
  96874. * Force a specific size of the canvas
  96875. * @param width defines the new canvas' width
  96876. * @param height defines the new canvas' height
  96877. */
  96878. setSize(width: number, height: number): void;
  96879. /**
  96880. * Binds the frame buffer to the specified texture.
  96881. * @param texture The texture to render to or null for the default canvas
  96882. * @param faceIndex The face of the texture to render to in case of cube texture
  96883. * @param requiredWidth The width of the target to render to
  96884. * @param requiredHeight The height of the target to render to
  96885. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96886. * @param depthStencilTexture The depth stencil texture to use to render
  96887. * @param lodLevel defines le lod level to bind to the frame buffer
  96888. */
  96889. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96890. /** @hidden */
  96891. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96892. /**
  96893. * Unbind the current render target texture from the webGL context
  96894. * @param texture defines the render target texture to unbind
  96895. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96896. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96897. */
  96898. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96899. /**
  96900. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96901. */
  96902. flushFramebuffer(): void;
  96903. /**
  96904. * Unbind the current render target and bind the default framebuffer
  96905. */
  96906. restoreDefaultFramebuffer(): void;
  96907. /** @hidden */
  96908. protected _resetVertexBufferBinding(): void;
  96909. /**
  96910. * Creates a vertex buffer
  96911. * @param data the data for the vertex buffer
  96912. * @returns the new WebGL static buffer
  96913. */
  96914. createVertexBuffer(data: DataArray): DataBuffer;
  96915. private _createVertexBuffer;
  96916. /**
  96917. * Creates a dynamic vertex buffer
  96918. * @param data the data for the dynamic vertex buffer
  96919. * @returns the new WebGL dynamic buffer
  96920. */
  96921. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96922. protected _resetIndexBufferBinding(): void;
  96923. /**
  96924. * Creates a new index buffer
  96925. * @param indices defines the content of the index buffer
  96926. * @param updatable defines if the index buffer must be updatable
  96927. * @returns a new webGL buffer
  96928. */
  96929. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96930. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96931. /**
  96932. * Bind a webGL buffer to the webGL context
  96933. * @param buffer defines the buffer to bind
  96934. */
  96935. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96936. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96937. private bindBuffer;
  96938. /**
  96939. * update the bound buffer with the given data
  96940. * @param data defines the data to update
  96941. */
  96942. updateArrayBuffer(data: Float32Array): void;
  96943. private _vertexAttribPointer;
  96944. private _bindIndexBufferWithCache;
  96945. private _bindVertexBuffersAttributes;
  96946. /**
  96947. * Records a vertex array object
  96948. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96949. * @param vertexBuffers defines the list of vertex buffers to store
  96950. * @param indexBuffer defines the index buffer to store
  96951. * @param effect defines the effect to store
  96952. * @returns the new vertex array object
  96953. */
  96954. recordVertexArrayObject(vertexBuffers: {
  96955. [key: string]: VertexBuffer;
  96956. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96957. /**
  96958. * Bind a specific vertex array object
  96959. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96960. * @param vertexArrayObject defines the vertex array object to bind
  96961. * @param indexBuffer defines the index buffer to bind
  96962. */
  96963. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96964. /**
  96965. * Bind webGl buffers directly to the webGL context
  96966. * @param vertexBuffer defines the vertex buffer to bind
  96967. * @param indexBuffer defines the index buffer to bind
  96968. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96969. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96970. * @param effect defines the effect associated with the vertex buffer
  96971. */
  96972. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96973. private _unbindVertexArrayObject;
  96974. /**
  96975. * Bind a list of vertex buffers to the webGL context
  96976. * @param vertexBuffers defines the list of vertex buffers to bind
  96977. * @param indexBuffer defines the index buffer to bind
  96978. * @param effect defines the effect associated with the vertex buffers
  96979. */
  96980. bindBuffers(vertexBuffers: {
  96981. [key: string]: Nullable<VertexBuffer>;
  96982. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96983. /**
  96984. * Unbind all instance attributes
  96985. */
  96986. unbindInstanceAttributes(): void;
  96987. /**
  96988. * Release and free the memory of a vertex array object
  96989. * @param vao defines the vertex array object to delete
  96990. */
  96991. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96992. /** @hidden */
  96993. _releaseBuffer(buffer: DataBuffer): boolean;
  96994. protected _deleteBuffer(buffer: DataBuffer): void;
  96995. /**
  96996. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96997. * @param instancesBuffer defines the webGL buffer to update and bind
  96998. * @param data defines the data to store in the buffer
  96999. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97000. */
  97001. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97002. /**
  97003. * Apply all cached states (depth, culling, stencil and alpha)
  97004. */
  97005. applyStates(): void;
  97006. /**
  97007. * Send a draw order
  97008. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97009. * @param indexStart defines the starting index
  97010. * @param indexCount defines the number of index to draw
  97011. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97012. */
  97013. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97014. /**
  97015. * Draw a list of points
  97016. * @param verticesStart defines the index of first vertex to draw
  97017. * @param verticesCount defines the count of vertices to draw
  97018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97019. */
  97020. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97021. /**
  97022. * Draw a list of unindexed primitives
  97023. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97024. * @param verticesStart defines the index of first vertex to draw
  97025. * @param verticesCount defines the count of vertices to draw
  97026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97027. */
  97028. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97029. /**
  97030. * Draw a list of indexed primitives
  97031. * @param fillMode defines the primitive to use
  97032. * @param indexStart defines the starting index
  97033. * @param indexCount defines the number of index to draw
  97034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97035. */
  97036. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97037. /**
  97038. * Draw a list of unindexed primitives
  97039. * @param fillMode defines the primitive to use
  97040. * @param verticesStart defines the index of first vertex to draw
  97041. * @param verticesCount defines the count of vertices to draw
  97042. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97043. */
  97044. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97045. private _drawMode;
  97046. /** @hidden */
  97047. protected _reportDrawCall(): void;
  97048. /** @hidden */
  97049. _releaseEffect(effect: Effect): void;
  97050. /** @hidden */
  97051. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97052. /**
  97053. * Create a new effect (used to store vertex/fragment shaders)
  97054. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97055. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97056. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97057. * @param samplers defines an array of string used to represent textures
  97058. * @param defines defines the string containing the defines to use to compile the shaders
  97059. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97060. * @param onCompiled defines a function to call when the effect creation is successful
  97061. * @param onError defines a function to call when the effect creation has failed
  97062. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97063. * @returns the new Effect
  97064. */
  97065. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  97066. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97067. private _compileShader;
  97068. private _compileRawShader;
  97069. /**
  97070. * Directly creates a webGL program
  97071. * @param pipelineContext defines the pipeline context to attach to
  97072. * @param vertexCode defines the vertex shader code to use
  97073. * @param fragmentCode defines the fragment shader code to use
  97074. * @param context defines the webGL context to use (if not set, the current one will be used)
  97075. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97076. * @returns the new webGL program
  97077. */
  97078. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97079. /**
  97080. * Creates a webGL program
  97081. * @param pipelineContext defines the pipeline context to attach to
  97082. * @param vertexCode defines the vertex shader code to use
  97083. * @param fragmentCode defines the fragment shader code to use
  97084. * @param defines defines the string containing the defines to use to compile the shaders
  97085. * @param context defines the webGL context to use (if not set, the current one will be used)
  97086. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97087. * @returns the new webGL program
  97088. */
  97089. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97090. /**
  97091. * Creates a new pipeline context
  97092. * @returns the new pipeline
  97093. */
  97094. createPipelineContext(): IPipelineContext;
  97095. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97096. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97097. /** @hidden */
  97098. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97099. /** @hidden */
  97100. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97101. /** @hidden */
  97102. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97103. /**
  97104. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97105. * @param pipelineContext defines the pipeline context to use
  97106. * @param uniformsNames defines the list of uniform names
  97107. * @returns an array of webGL uniform locations
  97108. */
  97109. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97110. /**
  97111. * Gets the lsit of active attributes for a given webGL program
  97112. * @param pipelineContext defines the pipeline context to use
  97113. * @param attributesNames defines the list of attribute names to get
  97114. * @returns an array of indices indicating the offset of each attribute
  97115. */
  97116. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97117. /**
  97118. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97119. * @param effect defines the effect to activate
  97120. */
  97121. enableEffect(effect: Nullable<Effect>): void;
  97122. /**
  97123. * Set the value of an uniform to a number (int)
  97124. * @param uniform defines the webGL uniform location where to store the value
  97125. * @param value defines the int number to store
  97126. */
  97127. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97128. /**
  97129. * Set the value of an uniform to an array of int32
  97130. * @param uniform defines the webGL uniform location where to store the value
  97131. * @param array defines the array of int32 to store
  97132. */
  97133. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97134. /**
  97135. * Set the value of an uniform to an array of int32 (stored as vec2)
  97136. * @param uniform defines the webGL uniform location where to store the value
  97137. * @param array defines the array of int32 to store
  97138. */
  97139. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97140. /**
  97141. * Set the value of an uniform to an array of int32 (stored as vec3)
  97142. * @param uniform defines the webGL uniform location where to store the value
  97143. * @param array defines the array of int32 to store
  97144. */
  97145. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97146. /**
  97147. * Set the value of an uniform to an array of int32 (stored as vec4)
  97148. * @param uniform defines the webGL uniform location where to store the value
  97149. * @param array defines the array of int32 to store
  97150. */
  97151. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97152. /**
  97153. * Set the value of an uniform to an array of number
  97154. * @param uniform defines the webGL uniform location where to store the value
  97155. * @param array defines the array of number to store
  97156. */
  97157. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97158. /**
  97159. * Set the value of an uniform to an array of number (stored as vec2)
  97160. * @param uniform defines the webGL uniform location where to store the value
  97161. * @param array defines the array of number to store
  97162. */
  97163. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97164. /**
  97165. * Set the value of an uniform to an array of number (stored as vec3)
  97166. * @param uniform defines the webGL uniform location where to store the value
  97167. * @param array defines the array of number to store
  97168. */
  97169. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97170. /**
  97171. * Set the value of an uniform to an array of number (stored as vec4)
  97172. * @param uniform defines the webGL uniform location where to store the value
  97173. * @param array defines the array of number to store
  97174. */
  97175. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97176. /**
  97177. * Set the value of an uniform to an array of float32 (stored as matrices)
  97178. * @param uniform defines the webGL uniform location where to store the value
  97179. * @param matrices defines the array of float32 to store
  97180. */
  97181. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97182. /**
  97183. * Set the value of an uniform to a matrix (3x3)
  97184. * @param uniform defines the webGL uniform location where to store the value
  97185. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97186. */
  97187. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97188. /**
  97189. * Set the value of an uniform to a matrix (2x2)
  97190. * @param uniform defines the webGL uniform location where to store the value
  97191. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97192. */
  97193. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97194. /**
  97195. * Set the value of an uniform to a number (float)
  97196. * @param uniform defines the webGL uniform location where to store the value
  97197. * @param value defines the float number to store
  97198. */
  97199. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97200. /**
  97201. * Set the value of an uniform to a vec2
  97202. * @param uniform defines the webGL uniform location where to store the value
  97203. * @param x defines the 1st component of the value
  97204. * @param y defines the 2nd component of the value
  97205. */
  97206. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97207. /**
  97208. * Set the value of an uniform to a vec3
  97209. * @param uniform defines the webGL uniform location where to store the value
  97210. * @param x defines the 1st component of the value
  97211. * @param y defines the 2nd component of the value
  97212. * @param z defines the 3rd component of the value
  97213. */
  97214. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97215. /**
  97216. * Set the value of an uniform to a vec4
  97217. * @param uniform defines the webGL uniform location where to store the value
  97218. * @param x defines the 1st component of the value
  97219. * @param y defines the 2nd component of the value
  97220. * @param z defines the 3rd component of the value
  97221. * @param w defines the 4th component of the value
  97222. */
  97223. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97224. /**
  97225. * Gets the depth culling state manager
  97226. */
  97227. readonly depthCullingState: DepthCullingState;
  97228. /**
  97229. * Gets the alpha state manager
  97230. */
  97231. readonly alphaState: AlphaState;
  97232. /**
  97233. * Gets the stencil state manager
  97234. */
  97235. readonly stencilState: StencilState;
  97236. /**
  97237. * Clears the list of texture accessible through engine.
  97238. * This can help preventing texture load conflict due to name collision.
  97239. */
  97240. clearInternalTexturesCache(): void;
  97241. /**
  97242. * Force the entire cache to be cleared
  97243. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97244. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97245. */
  97246. wipeCaches(bruteForce?: boolean): void;
  97247. /** @hidden */
  97248. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97249. min: number;
  97250. mag: number;
  97251. };
  97252. /** @hidden */
  97253. _createTexture(): WebGLTexture;
  97254. /**
  97255. * Usually called from Texture.ts.
  97256. * Passed information to create a WebGLTexture
  97257. * @param urlArg defines a value which contains one of the following:
  97258. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97259. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97260. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97261. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97262. * @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)
  97263. * @param scene needed for loading to the correct scene
  97264. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97265. * @param onLoad optional callback to be called upon successful completion
  97266. * @param onError optional callback to be called upon failure
  97267. * @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
  97268. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97269. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97270. * @param forcedExtension defines the extension to use to pick the right loader
  97271. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97272. * @param mimeType defines an optional mime type
  97273. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97274. */
  97275. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  97276. /**
  97277. * @hidden
  97278. */
  97279. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97280. /**
  97281. * Creates a raw texture
  97282. * @param data defines the data to store in the texture
  97283. * @param width defines the width of the texture
  97284. * @param height defines the height of the texture
  97285. * @param format defines the format of the data
  97286. * @param generateMipMaps defines if the engine should generate the mip levels
  97287. * @param invertY defines if data must be stored with Y axis inverted
  97288. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97289. * @param compression defines the compression used (null by default)
  97290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97291. * @returns the raw texture inside an InternalTexture
  97292. */
  97293. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97294. /**
  97295. * Creates a new raw cube texture
  97296. * @param data defines the array of data to use to create each face
  97297. * @param size defines the size of the textures
  97298. * @param format defines the format of the data
  97299. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97300. * @param generateMipMaps defines if the engine should generate the mip levels
  97301. * @param invertY defines if data must be stored with Y axis inverted
  97302. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97303. * @param compression defines the compression used (null by default)
  97304. * @returns the cube texture as an InternalTexture
  97305. */
  97306. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97307. /**
  97308. * Creates a new raw 3D texture
  97309. * @param data defines the data used to create the texture
  97310. * @param width defines the width of the texture
  97311. * @param height defines the height of the texture
  97312. * @param depth defines the depth of the texture
  97313. * @param format defines the format of the texture
  97314. * @param generateMipMaps defines if the engine must generate mip levels
  97315. * @param invertY defines if data must be stored with Y axis inverted
  97316. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97317. * @param compression defines the compressed used (can be null)
  97318. * @param textureType defines the compressed used (can be null)
  97319. * @returns a new raw 3D texture (stored in an InternalTexture)
  97320. */
  97321. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97322. private _unpackFlipYCached;
  97323. /**
  97324. * In case you are sharing the context with other applications, it might
  97325. * be interested to not cache the unpack flip y state to ensure a consistent
  97326. * value would be set.
  97327. */
  97328. enableUnpackFlipYCached: boolean;
  97329. /** @hidden */
  97330. _unpackFlipY(value: boolean): void;
  97331. /** @hidden */
  97332. _getUnpackAlignement(): number;
  97333. /**
  97334. * Update the sampling mode of a given texture
  97335. * @param samplingMode defines the required sampling mode
  97336. * @param texture defines the texture to update
  97337. */
  97338. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97339. /** @hidden */
  97340. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97341. width: number;
  97342. height: number;
  97343. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97344. /** @hidden */
  97345. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97346. /** @hidden */
  97347. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97348. /** @hidden */
  97349. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97350. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97351. private _prepareWebGLTexture;
  97352. /** @hidden */
  97353. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97354. /** @hidden */
  97355. _releaseFramebufferObjects(texture: InternalTexture): void;
  97356. /** @hidden */
  97357. _releaseTexture(texture: InternalTexture): void;
  97358. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97359. protected _setProgram(program: WebGLProgram): void;
  97360. protected _boundUniforms: {
  97361. [key: number]: WebGLUniformLocation;
  97362. };
  97363. /**
  97364. * Binds an effect to the webGL context
  97365. * @param effect defines the effect to bind
  97366. */
  97367. bindSamplers(effect: Effect): void;
  97368. private _activateCurrentTexture;
  97369. /** @hidden */
  97370. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97371. /** @hidden */
  97372. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97373. /**
  97374. * Unbind all textures from the webGL context
  97375. */
  97376. unbindAllTextures(): void;
  97377. /**
  97378. * Sets a texture to the according uniform.
  97379. * @param channel The texture channel
  97380. * @param uniform The uniform to set
  97381. * @param texture The texture to apply
  97382. */
  97383. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97384. private _bindSamplerUniformToChannel;
  97385. private _getTextureWrapMode;
  97386. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97387. /**
  97388. * Sets an array of texture to the webGL context
  97389. * @param channel defines the channel where the texture array must be set
  97390. * @param uniform defines the associated uniform location
  97391. * @param textures defines the array of textures to bind
  97392. */
  97393. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97394. /** @hidden */
  97395. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97396. private _setTextureParameterFloat;
  97397. private _setTextureParameterInteger;
  97398. /**
  97399. * Unbind all vertex attributes from the webGL context
  97400. */
  97401. unbindAllAttributes(): void;
  97402. /**
  97403. * 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
  97404. */
  97405. releaseEffects(): void;
  97406. /**
  97407. * Dispose and release all associated resources
  97408. */
  97409. dispose(): void;
  97410. /**
  97411. * Attach a new callback raised when context lost event is fired
  97412. * @param callback defines the callback to call
  97413. */
  97414. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97415. /**
  97416. * Attach a new callback raised when context restored event is fired
  97417. * @param callback defines the callback to call
  97418. */
  97419. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97420. /**
  97421. * Get the current error code of the webGL context
  97422. * @returns the error code
  97423. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97424. */
  97425. getError(): number;
  97426. private _canRenderToFloatFramebuffer;
  97427. private _canRenderToHalfFloatFramebuffer;
  97428. private _canRenderToFramebuffer;
  97429. /** @hidden */
  97430. _getWebGLTextureType(type: number): number;
  97431. /** @hidden */
  97432. _getInternalFormat(format: number): number;
  97433. /** @hidden */
  97434. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97435. /** @hidden */
  97436. _getRGBAMultiSampleBufferFormat(type: number): number;
  97437. /** @hidden */
  97438. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  97439. /**
  97440. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97441. * @returns true if the engine can be created
  97442. * @ignorenaming
  97443. */
  97444. static isSupported(): boolean;
  97445. /**
  97446. * Find the next highest power of two.
  97447. * @param x Number to start search from.
  97448. * @return Next highest power of two.
  97449. */
  97450. static CeilingPOT(x: number): number;
  97451. /**
  97452. * Find the next lowest power of two.
  97453. * @param x Number to start search from.
  97454. * @return Next lowest power of two.
  97455. */
  97456. static FloorPOT(x: number): number;
  97457. /**
  97458. * Find the nearest power of two.
  97459. * @param x Number to start search from.
  97460. * @return Next nearest power of two.
  97461. */
  97462. static NearestPOT(x: number): number;
  97463. /**
  97464. * Get the closest exponent of two
  97465. * @param value defines the value to approximate
  97466. * @param max defines the maximum value to return
  97467. * @param mode defines how to define the closest value
  97468. * @returns closest exponent of two of the given value
  97469. */
  97470. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97471. /**
  97472. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97473. * @param func - the function to be called
  97474. * @param requester - the object that will request the next frame. Falls back to window.
  97475. * @returns frame number
  97476. */
  97477. static QueueNewFrame(func: () => void, requester?: any): number;
  97478. }
  97479. }
  97480. declare module BABYLON {
  97481. /**
  97482. * Class representing spherical harmonics coefficients to the 3rd degree
  97483. */
  97484. export class SphericalHarmonics {
  97485. /**
  97486. * Defines whether or not the harmonics have been prescaled for rendering.
  97487. */
  97488. preScaled: boolean;
  97489. /**
  97490. * The l0,0 coefficients of the spherical harmonics
  97491. */
  97492. l00: Vector3;
  97493. /**
  97494. * The l1,-1 coefficients of the spherical harmonics
  97495. */
  97496. l1_1: Vector3;
  97497. /**
  97498. * The l1,0 coefficients of the spherical harmonics
  97499. */
  97500. l10: Vector3;
  97501. /**
  97502. * The l1,1 coefficients of the spherical harmonics
  97503. */
  97504. l11: Vector3;
  97505. /**
  97506. * The l2,-2 coefficients of the spherical harmonics
  97507. */
  97508. l2_2: Vector3;
  97509. /**
  97510. * The l2,-1 coefficients of the spherical harmonics
  97511. */
  97512. l2_1: Vector3;
  97513. /**
  97514. * The l2,0 coefficients of the spherical harmonics
  97515. */
  97516. l20: Vector3;
  97517. /**
  97518. * The l2,1 coefficients of the spherical harmonics
  97519. */
  97520. l21: Vector3;
  97521. /**
  97522. * The l2,2 coefficients of the spherical harmonics
  97523. */
  97524. l22: Vector3;
  97525. /**
  97526. * Adds a light to the spherical harmonics
  97527. * @param direction the direction of the light
  97528. * @param color the color of the light
  97529. * @param deltaSolidAngle the delta solid angle of the light
  97530. */
  97531. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97532. /**
  97533. * Scales the spherical harmonics by the given amount
  97534. * @param scale the amount to scale
  97535. */
  97536. scaleInPlace(scale: number): void;
  97537. /**
  97538. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97539. *
  97540. * ```
  97541. * E_lm = A_l * L_lm
  97542. * ```
  97543. *
  97544. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97545. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97546. * the scaling factors are given in equation 9.
  97547. */
  97548. convertIncidentRadianceToIrradiance(): void;
  97549. /**
  97550. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97551. *
  97552. * ```
  97553. * L = (1/pi) * E * rho
  97554. * ```
  97555. *
  97556. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97557. */
  97558. convertIrradianceToLambertianRadiance(): void;
  97559. /**
  97560. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97561. * required operations at run time.
  97562. *
  97563. * This is simply done by scaling back the SH with Ylm constants parameter.
  97564. * The trigonometric part being applied by the shader at run time.
  97565. */
  97566. preScaleForRendering(): void;
  97567. /**
  97568. * Constructs a spherical harmonics from an array.
  97569. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97570. * @returns the spherical harmonics
  97571. */
  97572. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97573. /**
  97574. * Gets the spherical harmonics from polynomial
  97575. * @param polynomial the spherical polynomial
  97576. * @returns the spherical harmonics
  97577. */
  97578. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97579. }
  97580. /**
  97581. * Class representing spherical polynomial coefficients to the 3rd degree
  97582. */
  97583. export class SphericalPolynomial {
  97584. private _harmonics;
  97585. /**
  97586. * The spherical harmonics used to create the polynomials.
  97587. */
  97588. readonly preScaledHarmonics: SphericalHarmonics;
  97589. /**
  97590. * The x coefficients of the spherical polynomial
  97591. */
  97592. x: Vector3;
  97593. /**
  97594. * The y coefficients of the spherical polynomial
  97595. */
  97596. y: Vector3;
  97597. /**
  97598. * The z coefficients of the spherical polynomial
  97599. */
  97600. z: Vector3;
  97601. /**
  97602. * The xx coefficients of the spherical polynomial
  97603. */
  97604. xx: Vector3;
  97605. /**
  97606. * The yy coefficients of the spherical polynomial
  97607. */
  97608. yy: Vector3;
  97609. /**
  97610. * The zz coefficients of the spherical polynomial
  97611. */
  97612. zz: Vector3;
  97613. /**
  97614. * The xy coefficients of the spherical polynomial
  97615. */
  97616. xy: Vector3;
  97617. /**
  97618. * The yz coefficients of the spherical polynomial
  97619. */
  97620. yz: Vector3;
  97621. /**
  97622. * The zx coefficients of the spherical polynomial
  97623. */
  97624. zx: Vector3;
  97625. /**
  97626. * Adds an ambient color to the spherical polynomial
  97627. * @param color the color to add
  97628. */
  97629. addAmbient(color: Color3): void;
  97630. /**
  97631. * Scales the spherical polynomial by the given amount
  97632. * @param scale the amount to scale
  97633. */
  97634. scaleInPlace(scale: number): void;
  97635. /**
  97636. * Gets the spherical polynomial from harmonics
  97637. * @param harmonics the spherical harmonics
  97638. * @returns the spherical polynomial
  97639. */
  97640. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97641. /**
  97642. * Constructs a spherical polynomial from an array.
  97643. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97644. * @returns the spherical polynomial
  97645. */
  97646. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97647. }
  97648. }
  97649. declare module BABYLON {
  97650. /**
  97651. * Defines the source of the internal texture
  97652. */
  97653. export enum InternalTextureSource {
  97654. /**
  97655. * The source of the texture data is unknown
  97656. */
  97657. Unknown = 0,
  97658. /**
  97659. * Texture data comes from an URL
  97660. */
  97661. Url = 1,
  97662. /**
  97663. * Texture data is only used for temporary storage
  97664. */
  97665. Temp = 2,
  97666. /**
  97667. * Texture data comes from raw data (ArrayBuffer)
  97668. */
  97669. Raw = 3,
  97670. /**
  97671. * Texture content is dynamic (video or dynamic texture)
  97672. */
  97673. Dynamic = 4,
  97674. /**
  97675. * Texture content is generated by rendering to it
  97676. */
  97677. RenderTarget = 5,
  97678. /**
  97679. * Texture content is part of a multi render target process
  97680. */
  97681. MultiRenderTarget = 6,
  97682. /**
  97683. * Texture data comes from a cube data file
  97684. */
  97685. Cube = 7,
  97686. /**
  97687. * Texture data comes from a raw cube data
  97688. */
  97689. CubeRaw = 8,
  97690. /**
  97691. * Texture data come from a prefiltered cube data file
  97692. */
  97693. CubePrefiltered = 9,
  97694. /**
  97695. * Texture content is raw 3D data
  97696. */
  97697. Raw3D = 10,
  97698. /**
  97699. * Texture content is a depth texture
  97700. */
  97701. Depth = 11,
  97702. /**
  97703. * Texture data comes from a raw cube data encoded with RGBD
  97704. */
  97705. CubeRawRGBD = 12
  97706. }
  97707. /**
  97708. * Class used to store data associated with WebGL texture data for the engine
  97709. * This class should not be used directly
  97710. */
  97711. export class InternalTexture {
  97712. /** @hidden */
  97713. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97714. /**
  97715. * Defines if the texture is ready
  97716. */
  97717. isReady: boolean;
  97718. /**
  97719. * Defines if the texture is a cube texture
  97720. */
  97721. isCube: boolean;
  97722. /**
  97723. * Defines if the texture contains 3D data
  97724. */
  97725. is3D: boolean;
  97726. /**
  97727. * Defines if the texture contains multiview data
  97728. */
  97729. isMultiview: boolean;
  97730. /**
  97731. * Gets the URL used to load this texture
  97732. */
  97733. url: string;
  97734. /**
  97735. * Gets the sampling mode of the texture
  97736. */
  97737. samplingMode: number;
  97738. /**
  97739. * Gets a boolean indicating if the texture needs mipmaps generation
  97740. */
  97741. generateMipMaps: boolean;
  97742. /**
  97743. * Gets the number of samples used by the texture (WebGL2+ only)
  97744. */
  97745. samples: number;
  97746. /**
  97747. * Gets the type of the texture (int, float...)
  97748. */
  97749. type: number;
  97750. /**
  97751. * Gets the format of the texture (RGB, RGBA...)
  97752. */
  97753. format: number;
  97754. /**
  97755. * Observable called when the texture is loaded
  97756. */
  97757. onLoadedObservable: Observable<InternalTexture>;
  97758. /**
  97759. * Gets the width of the texture
  97760. */
  97761. width: number;
  97762. /**
  97763. * Gets the height of the texture
  97764. */
  97765. height: number;
  97766. /**
  97767. * Gets the depth of the texture
  97768. */
  97769. depth: number;
  97770. /**
  97771. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97772. */
  97773. baseWidth: number;
  97774. /**
  97775. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97776. */
  97777. baseHeight: number;
  97778. /**
  97779. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97780. */
  97781. baseDepth: number;
  97782. /**
  97783. * Gets a boolean indicating if the texture is inverted on Y axis
  97784. */
  97785. invertY: boolean;
  97786. /** @hidden */
  97787. _invertVScale: boolean;
  97788. /** @hidden */
  97789. _associatedChannel: number;
  97790. /** @hidden */
  97791. _source: InternalTextureSource;
  97792. /** @hidden */
  97793. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  97794. /** @hidden */
  97795. _bufferView: Nullable<ArrayBufferView>;
  97796. /** @hidden */
  97797. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97798. /** @hidden */
  97799. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97800. /** @hidden */
  97801. _size: number;
  97802. /** @hidden */
  97803. _extension: string;
  97804. /** @hidden */
  97805. _files: Nullable<string[]>;
  97806. /** @hidden */
  97807. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97808. /** @hidden */
  97809. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97810. /** @hidden */
  97811. _framebuffer: Nullable<WebGLFramebuffer>;
  97812. /** @hidden */
  97813. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97814. /** @hidden */
  97815. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97816. /** @hidden */
  97817. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97818. /** @hidden */
  97819. _attachments: Nullable<number[]>;
  97820. /** @hidden */
  97821. _cachedCoordinatesMode: Nullable<number>;
  97822. /** @hidden */
  97823. _cachedWrapU: Nullable<number>;
  97824. /** @hidden */
  97825. _cachedWrapV: Nullable<number>;
  97826. /** @hidden */
  97827. _cachedWrapR: Nullable<number>;
  97828. /** @hidden */
  97829. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97830. /** @hidden */
  97831. _isDisabled: boolean;
  97832. /** @hidden */
  97833. _compression: Nullable<string>;
  97834. /** @hidden */
  97835. _generateStencilBuffer: boolean;
  97836. /** @hidden */
  97837. _generateDepthBuffer: boolean;
  97838. /** @hidden */
  97839. _comparisonFunction: number;
  97840. /** @hidden */
  97841. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97842. /** @hidden */
  97843. _lodGenerationScale: number;
  97844. /** @hidden */
  97845. _lodGenerationOffset: number;
  97846. /** @hidden */
  97847. _colorTextureArray: Nullable<WebGLTexture>;
  97848. /** @hidden */
  97849. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97850. /** @hidden */
  97851. _lodTextureHigh: Nullable<BaseTexture>;
  97852. /** @hidden */
  97853. _lodTextureMid: Nullable<BaseTexture>;
  97854. /** @hidden */
  97855. _lodTextureLow: Nullable<BaseTexture>;
  97856. /** @hidden */
  97857. _isRGBD: boolean;
  97858. /** @hidden */
  97859. _linearSpecularLOD: boolean;
  97860. /** @hidden */
  97861. _irradianceTexture: Nullable<BaseTexture>;
  97862. /** @hidden */
  97863. _webGLTexture: Nullable<WebGLTexture>;
  97864. /** @hidden */
  97865. _references: number;
  97866. private _engine;
  97867. /**
  97868. * Gets the Engine the texture belongs to.
  97869. * @returns The babylon engine
  97870. */
  97871. getEngine(): ThinEngine;
  97872. /**
  97873. * Gets the data source type of the texture
  97874. */
  97875. readonly source: InternalTextureSource;
  97876. /**
  97877. * Creates a new InternalTexture
  97878. * @param engine defines the engine to use
  97879. * @param source defines the type of data that will be used
  97880. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97881. */
  97882. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97883. /**
  97884. * Increments the number of references (ie. the number of Texture that point to it)
  97885. */
  97886. incrementReferences(): void;
  97887. /**
  97888. * Change the size of the texture (not the size of the content)
  97889. * @param width defines the new width
  97890. * @param height defines the new height
  97891. * @param depth defines the new depth (1 by default)
  97892. */
  97893. updateSize(width: int, height: int, depth?: int): void;
  97894. /** @hidden */
  97895. _rebuild(): void;
  97896. /** @hidden */
  97897. _swapAndDie(target: InternalTexture): void;
  97898. /**
  97899. * Dispose the current allocated resources
  97900. */
  97901. dispose(): void;
  97902. }
  97903. }
  97904. declare module BABYLON {
  97905. /**
  97906. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97908. */
  97909. export class Analyser {
  97910. /**
  97911. * Gets or sets the smoothing
  97912. * @ignorenaming
  97913. */
  97914. SMOOTHING: number;
  97915. /**
  97916. * Gets or sets the FFT table size
  97917. * @ignorenaming
  97918. */
  97919. FFT_SIZE: number;
  97920. /**
  97921. * Gets or sets the bar graph amplitude
  97922. * @ignorenaming
  97923. */
  97924. BARGRAPHAMPLITUDE: number;
  97925. /**
  97926. * Gets or sets the position of the debug canvas
  97927. * @ignorenaming
  97928. */
  97929. DEBUGCANVASPOS: {
  97930. x: number;
  97931. y: number;
  97932. };
  97933. /**
  97934. * Gets or sets the debug canvas size
  97935. * @ignorenaming
  97936. */
  97937. DEBUGCANVASSIZE: {
  97938. width: number;
  97939. height: number;
  97940. };
  97941. private _byteFreqs;
  97942. private _byteTime;
  97943. private _floatFreqs;
  97944. private _webAudioAnalyser;
  97945. private _debugCanvas;
  97946. private _debugCanvasContext;
  97947. private _scene;
  97948. private _registerFunc;
  97949. private _audioEngine;
  97950. /**
  97951. * Creates a new analyser
  97952. * @param scene defines hosting scene
  97953. */
  97954. constructor(scene: Scene);
  97955. /**
  97956. * Get the number of data values you will have to play with for the visualization
  97957. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97958. * @returns a number
  97959. */
  97960. getFrequencyBinCount(): number;
  97961. /**
  97962. * Gets the current frequency data as a byte array
  97963. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97964. * @returns a Uint8Array
  97965. */
  97966. getByteFrequencyData(): Uint8Array;
  97967. /**
  97968. * Gets the current waveform as a byte array
  97969. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97970. * @returns a Uint8Array
  97971. */
  97972. getByteTimeDomainData(): Uint8Array;
  97973. /**
  97974. * Gets the current frequency data as a float array
  97975. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97976. * @returns a Float32Array
  97977. */
  97978. getFloatFrequencyData(): Float32Array;
  97979. /**
  97980. * Renders the debug canvas
  97981. */
  97982. drawDebugCanvas(): void;
  97983. /**
  97984. * Stops rendering the debug canvas and removes it
  97985. */
  97986. stopDebugCanvas(): void;
  97987. /**
  97988. * Connects two audio nodes
  97989. * @param inputAudioNode defines first node to connect
  97990. * @param outputAudioNode defines second node to connect
  97991. */
  97992. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97993. /**
  97994. * Releases all associated resources
  97995. */
  97996. dispose(): void;
  97997. }
  97998. }
  97999. declare module BABYLON {
  98000. /**
  98001. * This represents an audio engine and it is responsible
  98002. * to play, synchronize and analyse sounds throughout the application.
  98003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98004. */
  98005. export interface IAudioEngine extends IDisposable {
  98006. /**
  98007. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98008. */
  98009. readonly canUseWebAudio: boolean;
  98010. /**
  98011. * Gets the current AudioContext if available.
  98012. */
  98013. readonly audioContext: Nullable<AudioContext>;
  98014. /**
  98015. * The master gain node defines the global audio volume of your audio engine.
  98016. */
  98017. readonly masterGain: GainNode;
  98018. /**
  98019. * Gets whether or not mp3 are supported by your browser.
  98020. */
  98021. readonly isMP3supported: boolean;
  98022. /**
  98023. * Gets whether or not ogg are supported by your browser.
  98024. */
  98025. readonly isOGGsupported: boolean;
  98026. /**
  98027. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98028. * @ignoreNaming
  98029. */
  98030. WarnedWebAudioUnsupported: boolean;
  98031. /**
  98032. * Defines if the audio engine relies on a custom unlocked button.
  98033. * In this case, the embedded button will not be displayed.
  98034. */
  98035. useCustomUnlockedButton: boolean;
  98036. /**
  98037. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98038. */
  98039. readonly unlocked: boolean;
  98040. /**
  98041. * Event raised when audio has been unlocked on the browser.
  98042. */
  98043. onAudioUnlockedObservable: Observable<AudioEngine>;
  98044. /**
  98045. * Event raised when audio has been locked on the browser.
  98046. */
  98047. onAudioLockedObservable: Observable<AudioEngine>;
  98048. /**
  98049. * Flags the audio engine in Locked state.
  98050. * This happens due to new browser policies preventing audio to autoplay.
  98051. */
  98052. lock(): void;
  98053. /**
  98054. * Unlocks the audio engine once a user action has been done on the dom.
  98055. * This is helpful to resume play once browser policies have been satisfied.
  98056. */
  98057. unlock(): void;
  98058. }
  98059. /**
  98060. * This represents the default audio engine used in babylon.
  98061. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98063. */
  98064. export class AudioEngine implements IAudioEngine {
  98065. private _audioContext;
  98066. private _audioContextInitialized;
  98067. private _muteButton;
  98068. private _hostElement;
  98069. /**
  98070. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98071. */
  98072. canUseWebAudio: boolean;
  98073. /**
  98074. * The master gain node defines the global audio volume of your audio engine.
  98075. */
  98076. masterGain: GainNode;
  98077. /**
  98078. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98079. * @ignoreNaming
  98080. */
  98081. WarnedWebAudioUnsupported: boolean;
  98082. /**
  98083. * Gets whether or not mp3 are supported by your browser.
  98084. */
  98085. isMP3supported: boolean;
  98086. /**
  98087. * Gets whether or not ogg are supported by your browser.
  98088. */
  98089. isOGGsupported: boolean;
  98090. /**
  98091. * Gets whether audio has been unlocked on the device.
  98092. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98093. * a user interaction has happened.
  98094. */
  98095. unlocked: boolean;
  98096. /**
  98097. * Defines if the audio engine relies on a custom unlocked button.
  98098. * In this case, the embedded button will not be displayed.
  98099. */
  98100. useCustomUnlockedButton: boolean;
  98101. /**
  98102. * Event raised when audio has been unlocked on the browser.
  98103. */
  98104. onAudioUnlockedObservable: Observable<AudioEngine>;
  98105. /**
  98106. * Event raised when audio has been locked on the browser.
  98107. */
  98108. onAudioLockedObservable: Observable<AudioEngine>;
  98109. /**
  98110. * Gets the current AudioContext if available.
  98111. */
  98112. readonly audioContext: Nullable<AudioContext>;
  98113. private _connectedAnalyser;
  98114. /**
  98115. * Instantiates a new audio engine.
  98116. *
  98117. * There should be only one per page as some browsers restrict the number
  98118. * of audio contexts you can create.
  98119. * @param hostElement defines the host element where to display the mute icon if necessary
  98120. */
  98121. constructor(hostElement?: Nullable<HTMLElement>);
  98122. /**
  98123. * Flags the audio engine in Locked state.
  98124. * This happens due to new browser policies preventing audio to autoplay.
  98125. */
  98126. lock(): void;
  98127. /**
  98128. * Unlocks the audio engine once a user action has been done on the dom.
  98129. * This is helpful to resume play once browser policies have been satisfied.
  98130. */
  98131. unlock(): void;
  98132. private _resumeAudioContext;
  98133. private _initializeAudioContext;
  98134. private _tryToRun;
  98135. private _triggerRunningState;
  98136. private _triggerSuspendedState;
  98137. private _displayMuteButton;
  98138. private _moveButtonToTopLeft;
  98139. private _onResize;
  98140. private _hideMuteButton;
  98141. /**
  98142. * Destroy and release the resources associated with the audio ccontext.
  98143. */
  98144. dispose(): void;
  98145. /**
  98146. * Gets the global volume sets on the master gain.
  98147. * @returns the global volume if set or -1 otherwise
  98148. */
  98149. getGlobalVolume(): number;
  98150. /**
  98151. * Sets the global volume of your experience (sets on the master gain).
  98152. * @param newVolume Defines the new global volume of the application
  98153. */
  98154. setGlobalVolume(newVolume: number): void;
  98155. /**
  98156. * Connect the audio engine to an audio analyser allowing some amazing
  98157. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98159. * @param analyser The analyser to connect to the engine
  98160. */
  98161. connectToAnalyser(analyser: Analyser): void;
  98162. }
  98163. }
  98164. declare module BABYLON {
  98165. /**
  98166. * Interface used to present a loading screen while loading a scene
  98167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98168. */
  98169. export interface ILoadingScreen {
  98170. /**
  98171. * Function called to display the loading screen
  98172. */
  98173. displayLoadingUI: () => void;
  98174. /**
  98175. * Function called to hide the loading screen
  98176. */
  98177. hideLoadingUI: () => void;
  98178. /**
  98179. * Gets or sets the color to use for the background
  98180. */
  98181. loadingUIBackgroundColor: string;
  98182. /**
  98183. * Gets or sets the text to display while loading
  98184. */
  98185. loadingUIText: string;
  98186. }
  98187. /**
  98188. * Class used for the default loading screen
  98189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98190. */
  98191. export class DefaultLoadingScreen implements ILoadingScreen {
  98192. private _renderingCanvas;
  98193. private _loadingText;
  98194. private _loadingDivBackgroundColor;
  98195. private _loadingDiv;
  98196. private _loadingTextDiv;
  98197. /** Gets or sets the logo url to use for the default loading screen */
  98198. static DefaultLogoUrl: string;
  98199. /** Gets or sets the spinner url to use for the default loading screen */
  98200. static DefaultSpinnerUrl: string;
  98201. /**
  98202. * Creates a new default loading screen
  98203. * @param _renderingCanvas defines the canvas used to render the scene
  98204. * @param _loadingText defines the default text to display
  98205. * @param _loadingDivBackgroundColor defines the default background color
  98206. */
  98207. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98208. /**
  98209. * Function called to display the loading screen
  98210. */
  98211. displayLoadingUI(): void;
  98212. /**
  98213. * Function called to hide the loading screen
  98214. */
  98215. hideLoadingUI(): void;
  98216. /**
  98217. * Gets or sets the text to display while loading
  98218. */
  98219. loadingUIText: string;
  98220. /**
  98221. * Gets or sets the color to use for the background
  98222. */
  98223. loadingUIBackgroundColor: string;
  98224. private _resizeLoadingUI;
  98225. }
  98226. }
  98227. declare module BABYLON {
  98228. /**
  98229. * Interface for any object that can request an animation frame
  98230. */
  98231. export interface ICustomAnimationFrameRequester {
  98232. /**
  98233. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98234. */
  98235. renderFunction?: Function;
  98236. /**
  98237. * Called to request the next frame to render to
  98238. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98239. */
  98240. requestAnimationFrame: Function;
  98241. /**
  98242. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98243. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98244. */
  98245. requestID?: number;
  98246. }
  98247. }
  98248. declare module BABYLON {
  98249. /**
  98250. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98251. */
  98252. export class PerformanceMonitor {
  98253. private _enabled;
  98254. private _rollingFrameTime;
  98255. private _lastFrameTimeMs;
  98256. /**
  98257. * constructor
  98258. * @param frameSampleSize The number of samples required to saturate the sliding window
  98259. */
  98260. constructor(frameSampleSize?: number);
  98261. /**
  98262. * Samples current frame
  98263. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98264. */
  98265. sampleFrame(timeMs?: number): void;
  98266. /**
  98267. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98268. */
  98269. readonly averageFrameTime: number;
  98270. /**
  98271. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98272. */
  98273. readonly averageFrameTimeVariance: number;
  98274. /**
  98275. * Returns the frame time of the most recent frame
  98276. */
  98277. readonly instantaneousFrameTime: number;
  98278. /**
  98279. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98280. */
  98281. readonly averageFPS: number;
  98282. /**
  98283. * Returns the average framerate in frames per second using the most recent frame time
  98284. */
  98285. readonly instantaneousFPS: number;
  98286. /**
  98287. * Returns true if enough samples have been taken to completely fill the sliding window
  98288. */
  98289. readonly isSaturated: boolean;
  98290. /**
  98291. * Enables contributions to the sliding window sample set
  98292. */
  98293. enable(): void;
  98294. /**
  98295. * Disables contributions to the sliding window sample set
  98296. * Samples will not be interpolated over the disabled period
  98297. */
  98298. disable(): void;
  98299. /**
  98300. * Returns true if sampling is enabled
  98301. */
  98302. readonly isEnabled: boolean;
  98303. /**
  98304. * Resets performance monitor
  98305. */
  98306. reset(): void;
  98307. }
  98308. /**
  98309. * RollingAverage
  98310. *
  98311. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98312. */
  98313. export class RollingAverage {
  98314. /**
  98315. * Current average
  98316. */
  98317. average: number;
  98318. /**
  98319. * Current variance
  98320. */
  98321. variance: number;
  98322. protected _samples: Array<number>;
  98323. protected _sampleCount: number;
  98324. protected _pos: number;
  98325. protected _m2: number;
  98326. /**
  98327. * constructor
  98328. * @param length The number of samples required to saturate the sliding window
  98329. */
  98330. constructor(length: number);
  98331. /**
  98332. * Adds a sample to the sample set
  98333. * @param v The sample value
  98334. */
  98335. add(v: number): void;
  98336. /**
  98337. * Returns previously added values or null if outside of history or outside the sliding window domain
  98338. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98339. * @return Value previously recorded with add() or null if outside of range
  98340. */
  98341. history(i: number): number;
  98342. /**
  98343. * Returns true if enough samples have been taken to completely fill the sliding window
  98344. * @return true if sample-set saturated
  98345. */
  98346. isSaturated(): boolean;
  98347. /**
  98348. * Resets the rolling average (equivalent to 0 samples taken so far)
  98349. */
  98350. reset(): void;
  98351. /**
  98352. * Wraps a value around the sample range boundaries
  98353. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98354. * @return Wrapped position in sample range
  98355. */
  98356. protected _wrapPosition(i: number): number;
  98357. }
  98358. }
  98359. declare module BABYLON {
  98360. /**
  98361. * This class is used to track a performance counter which is number based.
  98362. * The user has access to many properties which give statistics of different nature.
  98363. *
  98364. * The implementer can track two kinds of Performance Counter: time and count.
  98365. * 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.
  98366. * 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.
  98367. */
  98368. export class PerfCounter {
  98369. /**
  98370. * Gets or sets a global boolean to turn on and off all the counters
  98371. */
  98372. static Enabled: boolean;
  98373. /**
  98374. * Returns the smallest value ever
  98375. */
  98376. readonly min: number;
  98377. /**
  98378. * Returns the biggest value ever
  98379. */
  98380. readonly max: number;
  98381. /**
  98382. * Returns the average value since the performance counter is running
  98383. */
  98384. readonly average: number;
  98385. /**
  98386. * Returns the average value of the last second the counter was monitored
  98387. */
  98388. readonly lastSecAverage: number;
  98389. /**
  98390. * Returns the current value
  98391. */
  98392. readonly current: number;
  98393. /**
  98394. * Gets the accumulated total
  98395. */
  98396. readonly total: number;
  98397. /**
  98398. * Gets the total value count
  98399. */
  98400. readonly count: number;
  98401. /**
  98402. * Creates a new counter
  98403. */
  98404. constructor();
  98405. /**
  98406. * Call this method to start monitoring a new frame.
  98407. * 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.
  98408. */
  98409. fetchNewFrame(): void;
  98410. /**
  98411. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98412. * @param newCount the count value to add to the monitored count
  98413. * @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.
  98414. */
  98415. addCount(newCount: number, fetchResult: boolean): void;
  98416. /**
  98417. * Start monitoring this performance counter
  98418. */
  98419. beginMonitoring(): void;
  98420. /**
  98421. * Compute the time lapsed since the previous beginMonitoring() call.
  98422. * @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
  98423. */
  98424. endMonitoring(newFrame?: boolean): void;
  98425. private _fetchResult;
  98426. private _startMonitoringTime;
  98427. private _min;
  98428. private _max;
  98429. private _average;
  98430. private _current;
  98431. private _totalValueCount;
  98432. private _totalAccumulated;
  98433. private _lastSecAverage;
  98434. private _lastSecAccumulated;
  98435. private _lastSecTime;
  98436. private _lastSecValueCount;
  98437. }
  98438. }
  98439. declare module BABYLON {
  98440. /**
  98441. * Defines the interface used by display changed events
  98442. */
  98443. export interface IDisplayChangedEventArgs {
  98444. /** Gets the vrDisplay object (if any) */
  98445. vrDisplay: Nullable<any>;
  98446. /** Gets a boolean indicating if webVR is supported */
  98447. vrSupported: boolean;
  98448. }
  98449. /**
  98450. * Defines the interface used by objects containing a viewport (like a camera)
  98451. */
  98452. interface IViewportOwnerLike {
  98453. /**
  98454. * Gets or sets the viewport
  98455. */
  98456. viewport: IViewportLike;
  98457. }
  98458. /**
  98459. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98460. */
  98461. export class Engine extends ThinEngine {
  98462. /** Defines that alpha blending is disabled */
  98463. static readonly ALPHA_DISABLE: number;
  98464. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98465. static readonly ALPHA_ADD: number;
  98466. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98467. static readonly ALPHA_COMBINE: number;
  98468. /** Defines that alpha blending to DEST - SRC * DEST */
  98469. static readonly ALPHA_SUBTRACT: number;
  98470. /** Defines that alpha blending to SRC * DEST */
  98471. static readonly ALPHA_MULTIPLY: number;
  98472. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98473. static readonly ALPHA_MAXIMIZED: number;
  98474. /** Defines that alpha blending to SRC + DEST */
  98475. static readonly ALPHA_ONEONE: number;
  98476. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98477. static readonly ALPHA_PREMULTIPLIED: number;
  98478. /**
  98479. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98480. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98481. */
  98482. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98483. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98484. static readonly ALPHA_INTERPOLATE: number;
  98485. /**
  98486. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98487. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98488. */
  98489. static readonly ALPHA_SCREENMODE: number;
  98490. /** Defines that the ressource is not delayed*/
  98491. static readonly DELAYLOADSTATE_NONE: number;
  98492. /** Defines that the ressource was successfully delay loaded */
  98493. static readonly DELAYLOADSTATE_LOADED: number;
  98494. /** Defines that the ressource is currently delay loading */
  98495. static readonly DELAYLOADSTATE_LOADING: number;
  98496. /** Defines that the ressource is delayed and has not started loading */
  98497. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98498. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98499. static readonly NEVER: number;
  98500. /** 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 */
  98501. static readonly ALWAYS: number;
  98502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98503. static readonly LESS: number;
  98504. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98505. static readonly EQUAL: number;
  98506. /** 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 */
  98507. static readonly LEQUAL: number;
  98508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98509. static readonly GREATER: number;
  98510. /** 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 */
  98511. static readonly GEQUAL: number;
  98512. /** 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 */
  98513. static readonly NOTEQUAL: number;
  98514. /** Passed to stencilOperation to specify that stencil value must be kept */
  98515. static readonly KEEP: number;
  98516. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98517. static readonly REPLACE: number;
  98518. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98519. static readonly INCR: number;
  98520. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98521. static readonly DECR: number;
  98522. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98523. static readonly INVERT: number;
  98524. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98525. static readonly INCR_WRAP: number;
  98526. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98527. static readonly DECR_WRAP: number;
  98528. /** Texture is not repeating outside of 0..1 UVs */
  98529. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98530. /** Texture is repeating outside of 0..1 UVs */
  98531. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98532. /** Texture is repeating and mirrored */
  98533. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98534. /** ALPHA */
  98535. static readonly TEXTUREFORMAT_ALPHA: number;
  98536. /** LUMINANCE */
  98537. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98538. /** LUMINANCE_ALPHA */
  98539. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98540. /** RGB */
  98541. static readonly TEXTUREFORMAT_RGB: number;
  98542. /** RGBA */
  98543. static readonly TEXTUREFORMAT_RGBA: number;
  98544. /** RED */
  98545. static readonly TEXTUREFORMAT_RED: number;
  98546. /** RED (2nd reference) */
  98547. static readonly TEXTUREFORMAT_R: number;
  98548. /** RG */
  98549. static readonly TEXTUREFORMAT_RG: number;
  98550. /** RED_INTEGER */
  98551. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98552. /** RED_INTEGER (2nd reference) */
  98553. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98554. /** RG_INTEGER */
  98555. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98556. /** RGB_INTEGER */
  98557. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98558. /** RGBA_INTEGER */
  98559. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98560. /** UNSIGNED_BYTE */
  98561. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98562. /** UNSIGNED_BYTE (2nd reference) */
  98563. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98564. /** FLOAT */
  98565. static readonly TEXTURETYPE_FLOAT: number;
  98566. /** HALF_FLOAT */
  98567. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98568. /** BYTE */
  98569. static readonly TEXTURETYPE_BYTE: number;
  98570. /** SHORT */
  98571. static readonly TEXTURETYPE_SHORT: number;
  98572. /** UNSIGNED_SHORT */
  98573. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98574. /** INT */
  98575. static readonly TEXTURETYPE_INT: number;
  98576. /** UNSIGNED_INT */
  98577. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98578. /** UNSIGNED_SHORT_4_4_4_4 */
  98579. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98580. /** UNSIGNED_SHORT_5_5_5_1 */
  98581. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98582. /** UNSIGNED_SHORT_5_6_5 */
  98583. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98584. /** UNSIGNED_INT_2_10_10_10_REV */
  98585. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98586. /** UNSIGNED_INT_24_8 */
  98587. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98588. /** UNSIGNED_INT_10F_11F_11F_REV */
  98589. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98590. /** UNSIGNED_INT_5_9_9_9_REV */
  98591. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98592. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98593. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98594. /** nearest is mag = nearest and min = nearest and mip = linear */
  98595. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98596. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98597. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98598. /** Trilinear is mag = linear and min = linear and mip = linear */
  98599. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98600. /** nearest is mag = nearest and min = nearest and mip = linear */
  98601. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98602. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98603. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98604. /** Trilinear is mag = linear and min = linear and mip = linear */
  98605. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98606. /** mag = nearest and min = nearest and mip = nearest */
  98607. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98608. /** mag = nearest and min = linear and mip = nearest */
  98609. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98610. /** mag = nearest and min = linear and mip = linear */
  98611. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98612. /** mag = nearest and min = linear and mip = none */
  98613. static readonly TEXTURE_NEAREST_LINEAR: number;
  98614. /** mag = nearest and min = nearest and mip = none */
  98615. static readonly TEXTURE_NEAREST_NEAREST: number;
  98616. /** mag = linear and min = nearest and mip = nearest */
  98617. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98618. /** mag = linear and min = nearest and mip = linear */
  98619. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98620. /** mag = linear and min = linear and mip = none */
  98621. static readonly TEXTURE_LINEAR_LINEAR: number;
  98622. /** mag = linear and min = nearest and mip = none */
  98623. static readonly TEXTURE_LINEAR_NEAREST: number;
  98624. /** Explicit coordinates mode */
  98625. static readonly TEXTURE_EXPLICIT_MODE: number;
  98626. /** Spherical coordinates mode */
  98627. static readonly TEXTURE_SPHERICAL_MODE: number;
  98628. /** Planar coordinates mode */
  98629. static readonly TEXTURE_PLANAR_MODE: number;
  98630. /** Cubic coordinates mode */
  98631. static readonly TEXTURE_CUBIC_MODE: number;
  98632. /** Projection coordinates mode */
  98633. static readonly TEXTURE_PROJECTION_MODE: number;
  98634. /** Skybox coordinates mode */
  98635. static readonly TEXTURE_SKYBOX_MODE: number;
  98636. /** Inverse Cubic coordinates mode */
  98637. static readonly TEXTURE_INVCUBIC_MODE: number;
  98638. /** Equirectangular coordinates mode */
  98639. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98640. /** Equirectangular Fixed coordinates mode */
  98641. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98642. /** Equirectangular Fixed Mirrored coordinates mode */
  98643. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98644. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98645. static readonly SCALEMODE_FLOOR: number;
  98646. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98647. static readonly SCALEMODE_NEAREST: number;
  98648. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98649. static readonly SCALEMODE_CEILING: number;
  98650. /**
  98651. * Returns the current npm package of the sdk
  98652. */
  98653. static readonly NpmPackage: string;
  98654. /**
  98655. * Returns the current version of the framework
  98656. */
  98657. static readonly Version: string;
  98658. /** Gets the list of created engines */
  98659. static readonly Instances: Engine[];
  98660. /**
  98661. * Gets the latest created engine
  98662. */
  98663. static readonly LastCreatedEngine: Nullable<Engine>;
  98664. /**
  98665. * Gets the latest created scene
  98666. */
  98667. static readonly LastCreatedScene: Nullable<Scene>;
  98668. /**
  98669. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98670. * @param flag defines which part of the materials must be marked as dirty
  98671. * @param predicate defines a predicate used to filter which materials should be affected
  98672. */
  98673. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98674. /**
  98675. * Method called to create the default loading screen.
  98676. * This can be overriden in your own app.
  98677. * @param canvas The rendering canvas element
  98678. * @returns The loading screen
  98679. */
  98680. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98681. /**
  98682. * Method called to create the default rescale post process on each engine.
  98683. */
  98684. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98685. /**
  98686. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98687. **/
  98688. enableOfflineSupport: boolean;
  98689. /**
  98690. * 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)
  98691. **/
  98692. disableManifestCheck: boolean;
  98693. /**
  98694. * Gets the list of created scenes
  98695. */
  98696. scenes: Scene[];
  98697. /**
  98698. * Event raised when a new scene is created
  98699. */
  98700. onNewSceneAddedObservable: Observable<Scene>;
  98701. /**
  98702. * Gets the list of created postprocesses
  98703. */
  98704. postProcesses: PostProcess[];
  98705. /**
  98706. * Gets a boolean indicating if the pointer is currently locked
  98707. */
  98708. isPointerLock: boolean;
  98709. /**
  98710. * Observable event triggered each time the rendering canvas is resized
  98711. */
  98712. onResizeObservable: Observable<Engine>;
  98713. /**
  98714. * Observable event triggered each time the canvas loses focus
  98715. */
  98716. onCanvasBlurObservable: Observable<Engine>;
  98717. /**
  98718. * Observable event triggered each time the canvas gains focus
  98719. */
  98720. onCanvasFocusObservable: Observable<Engine>;
  98721. /**
  98722. * Observable event triggered each time the canvas receives pointerout event
  98723. */
  98724. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98725. /**
  98726. * Observable raised when the engine begins a new frame
  98727. */
  98728. onBeginFrameObservable: Observable<Engine>;
  98729. /**
  98730. * If set, will be used to request the next animation frame for the render loop
  98731. */
  98732. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98733. /**
  98734. * Observable raised when the engine ends the current frame
  98735. */
  98736. onEndFrameObservable: Observable<Engine>;
  98737. /**
  98738. * Observable raised when the engine is about to compile a shader
  98739. */
  98740. onBeforeShaderCompilationObservable: Observable<Engine>;
  98741. /**
  98742. * Observable raised when the engine has jsut compiled a shader
  98743. */
  98744. onAfterShaderCompilationObservable: Observable<Engine>;
  98745. /**
  98746. * Gets the audio engine
  98747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98748. * @ignorenaming
  98749. */
  98750. static audioEngine: IAudioEngine;
  98751. /**
  98752. * Default AudioEngine factory responsible of creating the Audio Engine.
  98753. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98754. */
  98755. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98756. /**
  98757. * Default offline support factory responsible of creating a tool used to store data locally.
  98758. * By default, this will create a Database object if the workload has been embedded.
  98759. */
  98760. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98761. private _loadingScreen;
  98762. private _pointerLockRequested;
  98763. private _dummyFramebuffer;
  98764. private _rescalePostProcess;
  98765. /** @hidden */
  98766. protected _alphaMode: number;
  98767. /** @hidden */
  98768. protected _alphaEquation: number;
  98769. private _deterministicLockstep;
  98770. private _lockstepMaxSteps;
  98771. protected readonly _supportsHardwareTextureRescaling: boolean;
  98772. private _fps;
  98773. private _deltaTime;
  98774. /** @hidden */
  98775. _drawCalls: PerfCounter;
  98776. /**
  98777. * Turn this value on if you want to pause FPS computation when in background
  98778. */
  98779. disablePerformanceMonitorInBackground: boolean;
  98780. private _performanceMonitor;
  98781. /**
  98782. * Gets the performance monitor attached to this engine
  98783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98784. */
  98785. readonly performanceMonitor: PerformanceMonitor;
  98786. private _onFocus;
  98787. private _onBlur;
  98788. private _onCanvasPointerOut;
  98789. private _onCanvasBlur;
  98790. private _onCanvasFocus;
  98791. private _onFullscreenChange;
  98792. private _onPointerLockChange;
  98793. /**
  98794. * Creates a new engine
  98795. * @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
  98796. * @param antialias defines enable antialiasing (default: false)
  98797. * @param options defines further options to be sent to the getContext() function
  98798. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98799. */
  98800. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98801. /**
  98802. * Gets current aspect ratio
  98803. * @param viewportOwner defines the camera to use to get the aspect ratio
  98804. * @param useScreen defines if screen size must be used (or the current render target if any)
  98805. * @returns a number defining the aspect ratio
  98806. */
  98807. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98808. /**
  98809. * Gets current screen aspect ratio
  98810. * @returns a number defining the aspect ratio
  98811. */
  98812. getScreenAspectRatio(): number;
  98813. /**
  98814. * Gets host document
  98815. * @returns the host document object
  98816. */
  98817. getHostDocument(): Document;
  98818. /**
  98819. * Gets the client rect of the HTML canvas attached with the current webGL context
  98820. * @returns a client rectanglee
  98821. */
  98822. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98823. /**
  98824. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98825. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98826. * @returns true if engine is in deterministic lock step mode
  98827. */
  98828. isDeterministicLockStep(): boolean;
  98829. /**
  98830. * Gets the max steps when engine is running in deterministic lock step
  98831. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98832. * @returns the max steps
  98833. */
  98834. getLockstepMaxSteps(): number;
  98835. /**
  98836. * Force the mipmap generation for the given render target texture
  98837. * @param texture defines the render target texture to use
  98838. */
  98839. generateMipMapsForCubemap(texture: InternalTexture): void;
  98840. /** States */
  98841. /**
  98842. * Set various states to the webGL context
  98843. * @param culling defines backface culling state
  98844. * @param zOffset defines the value to apply to zOffset (0 by default)
  98845. * @param force defines if states must be applied even if cache is up to date
  98846. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98847. */
  98848. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98849. /**
  98850. * Set the z offset to apply to current rendering
  98851. * @param value defines the offset to apply
  98852. */
  98853. setZOffset(value: number): void;
  98854. /**
  98855. * Gets the current value of the zOffset
  98856. * @returns the current zOffset state
  98857. */
  98858. getZOffset(): number;
  98859. /**
  98860. * Enable or disable depth buffering
  98861. * @param enable defines the state to set
  98862. */
  98863. setDepthBuffer(enable: boolean): void;
  98864. /**
  98865. * Gets a boolean indicating if depth writing is enabled
  98866. * @returns the current depth writing state
  98867. */
  98868. getDepthWrite(): boolean;
  98869. /**
  98870. * Enable or disable depth writing
  98871. * @param enable defines the state to set
  98872. */
  98873. setDepthWrite(enable: boolean): void;
  98874. /**
  98875. * Enable or disable color writing
  98876. * @param enable defines the state to set
  98877. */
  98878. setColorWrite(enable: boolean): void;
  98879. /**
  98880. * Gets a boolean indicating if color writing is enabled
  98881. * @returns the current color writing state
  98882. */
  98883. getColorWrite(): boolean;
  98884. /**
  98885. * Sets alpha constants used by some alpha blending modes
  98886. * @param r defines the red component
  98887. * @param g defines the green component
  98888. * @param b defines the blue component
  98889. * @param a defines the alpha component
  98890. */
  98891. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98892. /**
  98893. * Sets the current alpha mode
  98894. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98895. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98896. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98897. */
  98898. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98899. /**
  98900. * Gets the current alpha mode
  98901. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98902. * @returns the current alpha mode
  98903. */
  98904. getAlphaMode(): number;
  98905. /**
  98906. * Sets the current alpha equation
  98907. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98908. */
  98909. setAlphaEquation(equation: number): void;
  98910. /**
  98911. * Gets the current alpha equation.
  98912. * @returns the current alpha equation
  98913. */
  98914. getAlphaEquation(): number;
  98915. /**
  98916. * Gets a boolean indicating if stencil buffer is enabled
  98917. * @returns the current stencil buffer state
  98918. */
  98919. getStencilBuffer(): boolean;
  98920. /**
  98921. * Enable or disable the stencil buffer
  98922. * @param enable defines if the stencil buffer must be enabled or disabled
  98923. */
  98924. setStencilBuffer(enable: boolean): void;
  98925. /**
  98926. * Gets the current stencil mask
  98927. * @returns a number defining the new stencil mask to use
  98928. */
  98929. getStencilMask(): number;
  98930. /**
  98931. * Sets the current stencil mask
  98932. * @param mask defines the new stencil mask to use
  98933. */
  98934. setStencilMask(mask: number): void;
  98935. /**
  98936. * Gets the current stencil function
  98937. * @returns a number defining the stencil function to use
  98938. */
  98939. getStencilFunction(): number;
  98940. /**
  98941. * Gets the current stencil reference value
  98942. * @returns a number defining the stencil reference value to use
  98943. */
  98944. getStencilFunctionReference(): number;
  98945. /**
  98946. * Gets the current stencil mask
  98947. * @returns a number defining the stencil mask to use
  98948. */
  98949. getStencilFunctionMask(): number;
  98950. /**
  98951. * Sets the current stencil function
  98952. * @param stencilFunc defines the new stencil function to use
  98953. */
  98954. setStencilFunction(stencilFunc: number): void;
  98955. /**
  98956. * Sets the current stencil reference
  98957. * @param reference defines the new stencil reference to use
  98958. */
  98959. setStencilFunctionReference(reference: number): void;
  98960. /**
  98961. * Sets the current stencil mask
  98962. * @param mask defines the new stencil mask to use
  98963. */
  98964. setStencilFunctionMask(mask: number): void;
  98965. /**
  98966. * Gets the current stencil operation when stencil fails
  98967. * @returns a number defining stencil operation to use when stencil fails
  98968. */
  98969. getStencilOperationFail(): number;
  98970. /**
  98971. * Gets the current stencil operation when depth fails
  98972. * @returns a number defining stencil operation to use when depth fails
  98973. */
  98974. getStencilOperationDepthFail(): number;
  98975. /**
  98976. * Gets the current stencil operation when stencil passes
  98977. * @returns a number defining stencil operation to use when stencil passes
  98978. */
  98979. getStencilOperationPass(): number;
  98980. /**
  98981. * Sets the stencil operation to use when stencil fails
  98982. * @param operation defines the stencil operation to use when stencil fails
  98983. */
  98984. setStencilOperationFail(operation: number): void;
  98985. /**
  98986. * Sets the stencil operation to use when depth fails
  98987. * @param operation defines the stencil operation to use when depth fails
  98988. */
  98989. setStencilOperationDepthFail(operation: number): void;
  98990. /**
  98991. * Sets the stencil operation to use when stencil passes
  98992. * @param operation defines the stencil operation to use when stencil passes
  98993. */
  98994. setStencilOperationPass(operation: number): void;
  98995. /**
  98996. * Sets a boolean indicating if the dithering state is enabled or disabled
  98997. * @param value defines the dithering state
  98998. */
  98999. setDitheringState(value: boolean): void;
  99000. /**
  99001. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99002. * @param value defines the rasterizer state
  99003. */
  99004. setRasterizerState(value: boolean): void;
  99005. /**
  99006. * Gets the current depth function
  99007. * @returns a number defining the depth function
  99008. */
  99009. getDepthFunction(): Nullable<number>;
  99010. /**
  99011. * Sets the current depth function
  99012. * @param depthFunc defines the function to use
  99013. */
  99014. setDepthFunction(depthFunc: number): void;
  99015. /**
  99016. * Sets the current depth function to GREATER
  99017. */
  99018. setDepthFunctionToGreater(): void;
  99019. /**
  99020. * Sets the current depth function to GEQUAL
  99021. */
  99022. setDepthFunctionToGreaterOrEqual(): void;
  99023. /**
  99024. * Sets the current depth function to LESS
  99025. */
  99026. setDepthFunctionToLess(): void;
  99027. /**
  99028. * Sets the current depth function to LEQUAL
  99029. */
  99030. setDepthFunctionToLessOrEqual(): void;
  99031. private _cachedStencilBuffer;
  99032. private _cachedStencilFunction;
  99033. private _cachedStencilMask;
  99034. private _cachedStencilOperationPass;
  99035. private _cachedStencilOperationFail;
  99036. private _cachedStencilOperationDepthFail;
  99037. private _cachedStencilReference;
  99038. /**
  99039. * Caches the the state of the stencil buffer
  99040. */
  99041. cacheStencilState(): void;
  99042. /**
  99043. * Restores the state of the stencil buffer
  99044. */
  99045. restoreStencilState(): void;
  99046. /**
  99047. * Directly set the WebGL Viewport
  99048. * @param x defines the x coordinate of the viewport (in screen space)
  99049. * @param y defines the y coordinate of the viewport (in screen space)
  99050. * @param width defines the width of the viewport (in screen space)
  99051. * @param height defines the height of the viewport (in screen space)
  99052. * @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
  99053. */
  99054. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99055. /**
  99056. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99057. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99058. * @param y defines the y-coordinate of the corner of the clear rectangle
  99059. * @param width defines the width of the clear rectangle
  99060. * @param height defines the height of the clear rectangle
  99061. * @param clearColor defines the clear color
  99062. */
  99063. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99064. /**
  99065. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99066. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99067. * @param y defines the y-coordinate of the corner of the clear rectangle
  99068. * @param width defines the width of the clear rectangle
  99069. * @param height defines the height of the clear rectangle
  99070. */
  99071. enableScissor(x: number, y: number, width: number, height: number): void;
  99072. /**
  99073. * Disable previously set scissor test rectangle
  99074. */
  99075. disableScissor(): void;
  99076. protected _reportDrawCall(): void;
  99077. /**
  99078. * Initializes a webVR display and starts listening to display change events
  99079. * The onVRDisplayChangedObservable will be notified upon these changes
  99080. * @returns The onVRDisplayChangedObservable
  99081. */
  99082. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99083. /** @hidden */
  99084. _prepareVRComponent(): void;
  99085. /** @hidden */
  99086. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99087. /** @hidden */
  99088. _submitVRFrame(): void;
  99089. /**
  99090. * Call this function to leave webVR mode
  99091. * Will do nothing if webVR is not supported or if there is no webVR device
  99092. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99093. */
  99094. disableVR(): void;
  99095. /**
  99096. * Gets a boolean indicating that the system is in VR mode and is presenting
  99097. * @returns true if VR mode is engaged
  99098. */
  99099. isVRPresenting(): boolean;
  99100. /** @hidden */
  99101. _requestVRFrame(): void;
  99102. /** @hidden */
  99103. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99104. /**
  99105. * Gets the source code of the vertex shader associated with a specific webGL program
  99106. * @param program defines the program to use
  99107. * @returns a string containing the source code of the vertex shader associated with the program
  99108. */
  99109. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99110. /**
  99111. * Gets the source code of the fragment shader associated with a specific webGL program
  99112. * @param program defines the program to use
  99113. * @returns a string containing the source code of the fragment shader associated with the program
  99114. */
  99115. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99116. /**
  99117. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99118. * @param x defines the x coordinate of the rectangle where pixels must be read
  99119. * @param y defines the y coordinate of the rectangle where pixels must be read
  99120. * @param width defines the width of the rectangle where pixels must be read
  99121. * @param height defines the height of the rectangle where pixels must be read
  99122. * @returns a Uint8Array containing RGBA colors
  99123. */
  99124. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99125. /**
  99126. * Sets a depth stencil texture from a render target to the according uniform.
  99127. * @param channel The texture channel
  99128. * @param uniform The uniform to set
  99129. * @param texture The render target texture containing the depth stencil texture to apply
  99130. */
  99131. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99132. /**
  99133. * Sets a texture to the webGL context from a postprocess
  99134. * @param channel defines the channel to use
  99135. * @param postProcess defines the source postprocess
  99136. */
  99137. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99138. /**
  99139. * Binds the output of the passed in post process to the texture channel specified
  99140. * @param channel The channel the texture should be bound to
  99141. * @param postProcess The post process which's output should be bound
  99142. */
  99143. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99144. /** @hidden */
  99145. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99146. protected _rebuildBuffers(): void;
  99147. _renderLoop(): void;
  99148. /**
  99149. * Toggle full screen mode
  99150. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99151. */
  99152. switchFullscreen(requestPointerLock: boolean): void;
  99153. /**
  99154. * Enters full screen mode
  99155. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99156. */
  99157. enterFullscreen(requestPointerLock: boolean): void;
  99158. /**
  99159. * Exits full screen mode
  99160. */
  99161. exitFullscreen(): void;
  99162. /**
  99163. * Enters Pointerlock mode
  99164. */
  99165. enterPointerlock(): void;
  99166. /**
  99167. * Exits Pointerlock mode
  99168. */
  99169. exitPointerlock(): void;
  99170. /**
  99171. * Begin a new frame
  99172. */
  99173. beginFrame(): void;
  99174. /**
  99175. * Enf the current frame
  99176. */
  99177. endFrame(): void;
  99178. resize(): void;
  99179. /**
  99180. * Set the compressed texture format to use, based on the formats you have, and the formats
  99181. * supported by the hardware / browser.
  99182. *
  99183. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99184. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99185. * to API arguments needed to compressed textures. This puts the burden on the container
  99186. * generator to house the arcane code for determining these for current & future formats.
  99187. *
  99188. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99189. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99190. *
  99191. * Note: The result of this call is not taken into account when a texture is base64.
  99192. *
  99193. * @param formatsAvailable defines the list of those format families you have created
  99194. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99195. *
  99196. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99197. * @returns The extension selected.
  99198. */
  99199. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99200. /**
  99201. * Force a specific size of the canvas
  99202. * @param width defines the new canvas' width
  99203. * @param height defines the new canvas' height
  99204. */
  99205. setSize(width: number, height: number): void;
  99206. /**
  99207. * Updates a dynamic vertex buffer.
  99208. * @param vertexBuffer the vertex buffer to update
  99209. * @param data the data used to update the vertex buffer
  99210. * @param byteOffset the byte offset of the data
  99211. * @param byteLength the byte length of the data
  99212. */
  99213. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99214. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99215. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99216. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99217. _releaseTexture(texture: InternalTexture): void;
  99218. /**
  99219. * @hidden
  99220. * Rescales a texture
  99221. * @param source input texutre
  99222. * @param destination destination texture
  99223. * @param scene scene to use to render the resize
  99224. * @param internalFormat format to use when resizing
  99225. * @param onComplete callback to be called when resize has completed
  99226. */
  99227. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99228. /**
  99229. * Gets the current framerate
  99230. * @returns a number representing the framerate
  99231. */
  99232. getFps(): number;
  99233. /**
  99234. * Gets the time spent between current and previous frame
  99235. * @returns a number representing the delta time in ms
  99236. */
  99237. getDeltaTime(): number;
  99238. private _measureFps;
  99239. /** @hidden */
  99240. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  99241. /**
  99242. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99243. * @param renderTarget The render target to set the frame buffer for
  99244. */
  99245. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99246. /**
  99247. * Update a dynamic index buffer
  99248. * @param indexBuffer defines the target index buffer
  99249. * @param indices defines the data to update
  99250. * @param offset defines the offset in the target index buffer where update should start
  99251. */
  99252. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99253. /**
  99254. * Updates the sample count of a render target texture
  99255. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99256. * @param texture defines the texture to update
  99257. * @param samples defines the sample count to set
  99258. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99259. */
  99260. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99261. /**
  99262. * Updates a depth texture Comparison Mode and Function.
  99263. * If the comparison Function is equal to 0, the mode will be set to none.
  99264. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  99265. * @param texture The texture to set the comparison function for
  99266. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  99267. */
  99268. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  99269. /**
  99270. * Creates a webGL buffer to use with instanciation
  99271. * @param capacity defines the size of the buffer
  99272. * @returns the webGL buffer
  99273. */
  99274. createInstancesBuffer(capacity: number): DataBuffer;
  99275. /**
  99276. * Delete a webGL buffer used with instanciation
  99277. * @param buffer defines the webGL buffer to delete
  99278. */
  99279. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  99280. /** @hidden */
  99281. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99282. dispose(): void;
  99283. private _disableTouchAction;
  99284. /**
  99285. * Display the loading screen
  99286. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99287. */
  99288. displayLoadingUI(): void;
  99289. /**
  99290. * Hide the loading screen
  99291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99292. */
  99293. hideLoadingUI(): void;
  99294. /**
  99295. * Gets the current loading screen object
  99296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99297. */
  99298. /**
  99299. * Sets the current loading screen object
  99300. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99301. */
  99302. loadingScreen: ILoadingScreen;
  99303. /**
  99304. * Sets the current loading screen text
  99305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99306. */
  99307. loadingUIText: string;
  99308. /**
  99309. * Sets the current loading screen background color
  99310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99311. */
  99312. loadingUIBackgroundColor: string;
  99313. /** Pointerlock and fullscreen */
  99314. /**
  99315. * Ask the browser to promote the current element to pointerlock mode
  99316. * @param element defines the DOM element to promote
  99317. */
  99318. static _RequestPointerlock(element: HTMLElement): void;
  99319. /**
  99320. * Asks the browser to exit pointerlock mode
  99321. */
  99322. static _ExitPointerlock(): void;
  99323. /**
  99324. * Ask the browser to promote the current element to fullscreen rendering mode
  99325. * @param element defines the DOM element to promote
  99326. */
  99327. static _RequestFullscreen(element: HTMLElement): void;
  99328. /**
  99329. * Asks the browser to exit fullscreen mode
  99330. */
  99331. static _ExitFullscreen(): void;
  99332. }
  99333. }
  99334. declare module BABYLON {
  99335. /**
  99336. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99337. * during the life time of the application.
  99338. */
  99339. export class EngineStore {
  99340. /** Gets the list of created engines */
  99341. static Instances: Engine[];
  99342. /** @hidden */
  99343. static _LastCreatedScene: Nullable<Scene>;
  99344. /**
  99345. * Gets the latest created engine
  99346. */
  99347. static readonly LastCreatedEngine: Nullable<Engine>;
  99348. /**
  99349. * Gets the latest created scene
  99350. */
  99351. static readonly LastCreatedScene: Nullable<Scene>;
  99352. /**
  99353. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99354. * @ignorenaming
  99355. */
  99356. static UseFallbackTexture: boolean;
  99357. /**
  99358. * Texture content used if a texture cannot loaded
  99359. * @ignorenaming
  99360. */
  99361. static FallbackTexture: string;
  99362. }
  99363. }
  99364. declare module BABYLON {
  99365. /**
  99366. * Helper class that provides a small promise polyfill
  99367. */
  99368. export class PromisePolyfill {
  99369. /**
  99370. * Static function used to check if the polyfill is required
  99371. * If this is the case then the function will inject the polyfill to window.Promise
  99372. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99373. */
  99374. static Apply(force?: boolean): void;
  99375. }
  99376. }
  99377. declare module BABYLON {
  99378. /**
  99379. * Interface for screenshot methods with describe argument called `size` as object with options
  99380. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99381. */
  99382. export interface IScreenshotSize {
  99383. /**
  99384. * number in pixels for canvas height
  99385. */
  99386. height?: number;
  99387. /**
  99388. * multiplier allowing render at a higher or lower resolution
  99389. * If value is defined then height and width will be ignored and taken from camera
  99390. */
  99391. precision?: number;
  99392. /**
  99393. * number in pixels for canvas width
  99394. */
  99395. width?: number;
  99396. }
  99397. }
  99398. declare module BABYLON {
  99399. interface IColor4Like {
  99400. r: float;
  99401. g: float;
  99402. b: float;
  99403. a: float;
  99404. }
  99405. /**
  99406. * Class containing a set of static utilities functions
  99407. */
  99408. export class Tools {
  99409. /**
  99410. * Gets or sets the base URL to use to load assets
  99411. */
  99412. static BaseUrl: string;
  99413. /**
  99414. * Enable/Disable Custom HTTP Request Headers globally.
  99415. * default = false
  99416. * @see CustomRequestHeaders
  99417. */
  99418. static UseCustomRequestHeaders: boolean;
  99419. /**
  99420. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99421. * i.e. when loading files, where the server/service expects an Authorization header
  99422. */
  99423. static CustomRequestHeaders: {
  99424. [key: string]: string;
  99425. };
  99426. /**
  99427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99428. */
  99429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99430. /**
  99431. * Default behaviour for cors in the application.
  99432. * It can be a string if the expected behavior is identical in the entire app.
  99433. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99434. */
  99435. static CorsBehavior: string | ((url: string | string[]) => string);
  99436. /**
  99437. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99438. * @ignorenaming
  99439. */
  99440. static UseFallbackTexture: boolean;
  99441. /**
  99442. * Use this object to register external classes like custom textures or material
  99443. * to allow the laoders to instantiate them
  99444. */
  99445. static RegisteredExternalClasses: {
  99446. [key: string]: Object;
  99447. };
  99448. /**
  99449. * Texture content used if a texture cannot loaded
  99450. * @ignorenaming
  99451. */
  99452. static fallbackTexture: string;
  99453. /**
  99454. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99455. * @param u defines the coordinate on X axis
  99456. * @param v defines the coordinate on Y axis
  99457. * @param width defines the width of the source data
  99458. * @param height defines the height of the source data
  99459. * @param pixels defines the source byte array
  99460. * @param color defines the output color
  99461. */
  99462. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99463. /**
  99464. * Interpolates between a and b via alpha
  99465. * @param a The lower value (returned when alpha = 0)
  99466. * @param b The upper value (returned when alpha = 1)
  99467. * @param alpha The interpolation-factor
  99468. * @return The mixed value
  99469. */
  99470. static Mix(a: number, b: number, alpha: number): number;
  99471. /**
  99472. * Tries to instantiate a new object from a given class name
  99473. * @param className defines the class name to instantiate
  99474. * @returns the new object or null if the system was not able to do the instantiation
  99475. */
  99476. static Instantiate(className: string): any;
  99477. /**
  99478. * Provides a slice function that will work even on IE
  99479. * @param data defines the array to slice
  99480. * @param start defines the start of the data (optional)
  99481. * @param end defines the end of the data (optional)
  99482. * @returns the new sliced array
  99483. */
  99484. static Slice<T>(data: T, start?: number, end?: number): T;
  99485. /**
  99486. * Polyfill for setImmediate
  99487. * @param action defines the action to execute after the current execution block
  99488. */
  99489. static SetImmediate(action: () => void): void;
  99490. /**
  99491. * Function indicating if a number is an exponent of 2
  99492. * @param value defines the value to test
  99493. * @returns true if the value is an exponent of 2
  99494. */
  99495. static IsExponentOfTwo(value: number): boolean;
  99496. private static _tmpFloatArray;
  99497. /**
  99498. * Returns the nearest 32-bit single precision float representation of a Number
  99499. * @param value A Number. If the parameter is of a different type, it will get converted
  99500. * to a number or to NaN if it cannot be converted
  99501. * @returns number
  99502. */
  99503. static FloatRound(value: number): number;
  99504. /**
  99505. * Extracts the filename from a path
  99506. * @param path defines the path to use
  99507. * @returns the filename
  99508. */
  99509. static GetFilename(path: string): string;
  99510. /**
  99511. * Extracts the "folder" part of a path (everything before the filename).
  99512. * @param uri The URI to extract the info from
  99513. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99514. * @returns The "folder" part of the path
  99515. */
  99516. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99517. /**
  99518. * Extracts text content from a DOM element hierarchy
  99519. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99520. */
  99521. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99522. /**
  99523. * Convert an angle in radians to degrees
  99524. * @param angle defines the angle to convert
  99525. * @returns the angle in degrees
  99526. */
  99527. static ToDegrees(angle: number): number;
  99528. /**
  99529. * Convert an angle in degrees to radians
  99530. * @param angle defines the angle to convert
  99531. * @returns the angle in radians
  99532. */
  99533. static ToRadians(angle: number): number;
  99534. /**
  99535. * Returns an array if obj is not an array
  99536. * @param obj defines the object to evaluate as an array
  99537. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99538. * @returns either obj directly if obj is an array or a new array containing obj
  99539. */
  99540. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99541. /**
  99542. * Gets the pointer prefix to use
  99543. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99544. */
  99545. static GetPointerPrefix(): string;
  99546. /**
  99547. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99548. * @param url define the url we are trying
  99549. * @param element define the dom element where to configure the cors policy
  99550. */
  99551. static SetCorsBehavior(url: string | string[], element: {
  99552. crossOrigin: string | null;
  99553. }): void;
  99554. /**
  99555. * Removes unwanted characters from an url
  99556. * @param url defines the url to clean
  99557. * @returns the cleaned url
  99558. */
  99559. static CleanUrl(url: string): string;
  99560. /**
  99561. * Gets or sets a function used to pre-process url before using them to load assets
  99562. */
  99563. static PreprocessUrl: (url: string) => string;
  99564. /**
  99565. * Loads an image as an HTMLImageElement.
  99566. * @param input url string, ArrayBuffer, or Blob to load
  99567. * @param onLoad callback called when the image successfully loads
  99568. * @param onError callback called when the image fails to load
  99569. * @param offlineProvider offline provider for caching
  99570. * @param mimeType optional mime type
  99571. * @returns the HTMLImageElement of the loaded image
  99572. */
  99573. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99574. /**
  99575. * Loads a file from a url
  99576. * @param url url string, ArrayBuffer, or Blob to load
  99577. * @param onSuccess callback called when the file successfully loads
  99578. * @param onProgress callback called while file is loading (if the server supports this mode)
  99579. * @param offlineProvider defines the offline provider for caching
  99580. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99581. * @param onError callback called when the file fails to load
  99582. * @returns a file request object
  99583. */
  99584. 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;
  99585. /**
  99586. * Loads a file from a url
  99587. * @param url the file url to load
  99588. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99589. */
  99590. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99591. /**
  99592. * Load a script (identified by an url). When the url returns, the
  99593. * content of this file is added into a new script element, attached to the DOM (body element)
  99594. * @param scriptUrl defines the url of the script to laod
  99595. * @param onSuccess defines the callback called when the script is loaded
  99596. * @param onError defines the callback to call if an error occurs
  99597. * @param scriptId defines the id of the script element
  99598. */
  99599. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99600. /**
  99601. * Load an asynchronous script (identified by an url). When the url returns, the
  99602. * content of this file is added into a new script element, attached to the DOM (body element)
  99603. * @param scriptUrl defines the url of the script to laod
  99604. * @param scriptId defines the id of the script element
  99605. * @returns a promise request object
  99606. */
  99607. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99608. /**
  99609. * Loads a file from a blob
  99610. * @param fileToLoad defines the blob to use
  99611. * @param callback defines the callback to call when data is loaded
  99612. * @param progressCallback defines the callback to call during loading process
  99613. * @returns a file request object
  99614. */
  99615. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99616. /**
  99617. * Reads a file from a File object
  99618. * @param file defines the file to load
  99619. * @param onSuccess defines the callback to call when data is loaded
  99620. * @param onProgress defines the callback to call during loading process
  99621. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99622. * @param onError defines the callback to call when an error occurs
  99623. * @returns a file request object
  99624. */
  99625. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  99626. /**
  99627. * Creates a data url from a given string content
  99628. * @param content defines the content to convert
  99629. * @returns the new data url link
  99630. */
  99631. static FileAsURL(content: string): string;
  99632. /**
  99633. * Format the given number to a specific decimal format
  99634. * @param value defines the number to format
  99635. * @param decimals defines the number of decimals to use
  99636. * @returns the formatted string
  99637. */
  99638. static Format(value: number, decimals?: number): string;
  99639. /**
  99640. * Tries to copy an object by duplicating every property
  99641. * @param source defines the source object
  99642. * @param destination defines the target object
  99643. * @param doNotCopyList defines a list of properties to avoid
  99644. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99645. */
  99646. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99647. /**
  99648. * Gets a boolean indicating if the given object has no own property
  99649. * @param obj defines the object to test
  99650. * @returns true if object has no own property
  99651. */
  99652. static IsEmpty(obj: any): boolean;
  99653. /**
  99654. * Function used to register events at window level
  99655. * @param windowElement defines the Window object to use
  99656. * @param events defines the events to register
  99657. */
  99658. static RegisterTopRootEvents(windowElement: Window, events: {
  99659. name: string;
  99660. handler: Nullable<(e: FocusEvent) => any>;
  99661. }[]): void;
  99662. /**
  99663. * Function used to unregister events from window level
  99664. * @param windowElement defines the Window object to use
  99665. * @param events defines the events to unregister
  99666. */
  99667. static UnregisterTopRootEvents(windowElement: Window, events: {
  99668. name: string;
  99669. handler: Nullable<(e: FocusEvent) => any>;
  99670. }[]): void;
  99671. /**
  99672. * @ignore
  99673. */
  99674. static _ScreenshotCanvas: HTMLCanvasElement;
  99675. /**
  99676. * Dumps the current bound framebuffer
  99677. * @param width defines the rendering width
  99678. * @param height defines the rendering height
  99679. * @param engine defines the hosting engine
  99680. * @param successCallback defines the callback triggered once the data are available
  99681. * @param mimeType defines the mime type of the result
  99682. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99683. */
  99684. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99685. /**
  99686. * Converts the canvas data to blob.
  99687. * This acts as a polyfill for browsers not supporting the to blob function.
  99688. * @param canvas Defines the canvas to extract the data from
  99689. * @param successCallback Defines the callback triggered once the data are available
  99690. * @param mimeType Defines the mime type of the result
  99691. */
  99692. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99693. /**
  99694. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99695. * @param successCallback defines the callback triggered once the data are available
  99696. * @param mimeType defines the mime type of the result
  99697. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99698. */
  99699. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99700. /**
  99701. * Downloads a blob in the browser
  99702. * @param blob defines the blob to download
  99703. * @param fileName defines the name of the downloaded file
  99704. */
  99705. static Download(blob: Blob, fileName: string): void;
  99706. /**
  99707. * Captures a screenshot of the current rendering
  99708. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99709. * @param engine defines the rendering engine
  99710. * @param camera defines the source camera
  99711. * @param size This parameter can be set to a single number or to an object with the
  99712. * following (optional) properties: precision, width, height. If a single number is passed,
  99713. * it will be used for both width and height. If an object is passed, the screenshot size
  99714. * will be derived from the parameters. The precision property is a multiplier allowing
  99715. * rendering at a higher or lower resolution
  99716. * @param successCallback defines the callback receives a single parameter which contains the
  99717. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99718. * src parameter of an <img> to display it
  99719. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99720. * Check your browser for supported MIME types
  99721. */
  99722. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99723. /**
  99724. * Captures a screenshot of the current rendering
  99725. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99726. * @param engine defines the rendering engine
  99727. * @param camera defines the source camera
  99728. * @param size This parameter can be set to a single number or to an object with the
  99729. * following (optional) properties: precision, width, height. If a single number is passed,
  99730. * it will be used for both width and height. If an object is passed, the screenshot size
  99731. * will be derived from the parameters. The precision property is a multiplier allowing
  99732. * rendering at a higher or lower resolution
  99733. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99734. * Check your browser for supported MIME types
  99735. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99736. * to the src parameter of an <img> to display it
  99737. */
  99738. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99739. /**
  99740. * Generates an image screenshot from the specified camera.
  99741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99742. * @param engine The engine to use for rendering
  99743. * @param camera The camera to use for rendering
  99744. * @param size This parameter can be set to a single number or to an object with the
  99745. * following (optional) properties: precision, width, height. If a single number is passed,
  99746. * it will be used for both width and height. If an object is passed, the screenshot size
  99747. * will be derived from the parameters. The precision property is a multiplier allowing
  99748. * rendering at a higher or lower resolution
  99749. * @param successCallback The callback receives a single parameter which contains the
  99750. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99751. * src parameter of an <img> to display it
  99752. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99753. * Check your browser for supported MIME types
  99754. * @param samples Texture samples (default: 1)
  99755. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99756. * @param fileName A name for for the downloaded file.
  99757. */
  99758. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99759. /**
  99760. * Generates an image screenshot from the specified camera.
  99761. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99762. * @param engine The engine to use for rendering
  99763. * @param camera The camera to use for rendering
  99764. * @param size This parameter can be set to a single number or to an object with the
  99765. * following (optional) properties: precision, width, height. If a single number is passed,
  99766. * it will be used for both width and height. If an object is passed, the screenshot size
  99767. * will be derived from the parameters. The precision property is a multiplier allowing
  99768. * rendering at a higher or lower resolution
  99769. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99770. * Check your browser for supported MIME types
  99771. * @param samples Texture samples (default: 1)
  99772. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99773. * @param fileName A name for for the downloaded file.
  99774. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99775. * to the src parameter of an <img> to display it
  99776. */
  99777. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99778. /**
  99779. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99780. * Be aware Math.random() could cause collisions, but:
  99781. * "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"
  99782. * @returns a pseudo random id
  99783. */
  99784. static RandomId(): string;
  99785. /**
  99786. * Test if the given uri is a base64 string
  99787. * @param uri The uri to test
  99788. * @return True if the uri is a base64 string or false otherwise
  99789. */
  99790. static IsBase64(uri: string): boolean;
  99791. /**
  99792. * Decode the given base64 uri.
  99793. * @param uri The uri to decode
  99794. * @return The decoded base64 data.
  99795. */
  99796. static DecodeBase64(uri: string): ArrayBuffer;
  99797. /**
  99798. * Gets the absolute url.
  99799. * @param url the input url
  99800. * @return the absolute url
  99801. */
  99802. static GetAbsoluteUrl(url: string): string;
  99803. /**
  99804. * No log
  99805. */
  99806. static readonly NoneLogLevel: number;
  99807. /**
  99808. * Only message logs
  99809. */
  99810. static readonly MessageLogLevel: number;
  99811. /**
  99812. * Only warning logs
  99813. */
  99814. static readonly WarningLogLevel: number;
  99815. /**
  99816. * Only error logs
  99817. */
  99818. static readonly ErrorLogLevel: number;
  99819. /**
  99820. * All logs
  99821. */
  99822. static readonly AllLogLevel: number;
  99823. /**
  99824. * Gets a value indicating the number of loading errors
  99825. * @ignorenaming
  99826. */
  99827. static readonly errorsCount: number;
  99828. /**
  99829. * Callback called when a new log is added
  99830. */
  99831. static OnNewCacheEntry: (entry: string) => void;
  99832. /**
  99833. * Log a message to the console
  99834. * @param message defines the message to log
  99835. */
  99836. static Log(message: string): void;
  99837. /**
  99838. * Write a warning message to the console
  99839. * @param message defines the message to log
  99840. */
  99841. static Warn(message: string): void;
  99842. /**
  99843. * Write an error message to the console
  99844. * @param message defines the message to log
  99845. */
  99846. static Error(message: string): void;
  99847. /**
  99848. * Gets current log cache (list of logs)
  99849. */
  99850. static readonly LogCache: string;
  99851. /**
  99852. * Clears the log cache
  99853. */
  99854. static ClearLogCache(): void;
  99855. /**
  99856. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99857. */
  99858. static LogLevels: number;
  99859. /**
  99860. * Checks if the window object exists
  99861. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99862. */
  99863. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99864. /**
  99865. * No performance log
  99866. */
  99867. static readonly PerformanceNoneLogLevel: number;
  99868. /**
  99869. * Use user marks to log performance
  99870. */
  99871. static readonly PerformanceUserMarkLogLevel: number;
  99872. /**
  99873. * Log performance to the console
  99874. */
  99875. static readonly PerformanceConsoleLogLevel: number;
  99876. private static _performance;
  99877. /**
  99878. * Sets the current performance log level
  99879. */
  99880. static PerformanceLogLevel: number;
  99881. private static _StartPerformanceCounterDisabled;
  99882. private static _EndPerformanceCounterDisabled;
  99883. private static _StartUserMark;
  99884. private static _EndUserMark;
  99885. private static _StartPerformanceConsole;
  99886. private static _EndPerformanceConsole;
  99887. /**
  99888. * Starts a performance counter
  99889. */
  99890. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99891. /**
  99892. * Ends a specific performance coutner
  99893. */
  99894. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99895. /**
  99896. * Gets either window.performance.now() if supported or Date.now() else
  99897. */
  99898. static readonly Now: number;
  99899. /**
  99900. * This method will return the name of the class used to create the instance of the given object.
  99901. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99902. * @param object the object to get the class name from
  99903. * @param isType defines if the object is actually a type
  99904. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99905. */
  99906. static GetClassName(object: any, isType?: boolean): string;
  99907. /**
  99908. * Gets the first element of an array satisfying a given predicate
  99909. * @param array defines the array to browse
  99910. * @param predicate defines the predicate to use
  99911. * @returns null if not found or the element
  99912. */
  99913. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99914. /**
  99915. * This method will return the name of the full name of the class, including its owning module (if any).
  99916. * 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).
  99917. * @param object the object to get the class name from
  99918. * @param isType defines if the object is actually a type
  99919. * @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.
  99920. * @ignorenaming
  99921. */
  99922. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99923. /**
  99924. * Returns a promise that resolves after the given amount of time.
  99925. * @param delay Number of milliseconds to delay
  99926. * @returns Promise that resolves after the given amount of time
  99927. */
  99928. static DelayAsync(delay: number): Promise<void>;
  99929. }
  99930. /**
  99931. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99932. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99933. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99934. * @param name The name of the class, case should be preserved
  99935. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99936. */
  99937. export function className(name: string, module?: string): (target: Object) => void;
  99938. /**
  99939. * An implementation of a loop for asynchronous functions.
  99940. */
  99941. export class AsyncLoop {
  99942. /**
  99943. * Defines the number of iterations for the loop
  99944. */
  99945. iterations: number;
  99946. /**
  99947. * Defines the current index of the loop.
  99948. */
  99949. index: number;
  99950. private _done;
  99951. private _fn;
  99952. private _successCallback;
  99953. /**
  99954. * Constructor.
  99955. * @param iterations the number of iterations.
  99956. * @param func the function to run each iteration
  99957. * @param successCallback the callback that will be called upon succesful execution
  99958. * @param offset starting offset.
  99959. */
  99960. constructor(
  99961. /**
  99962. * Defines the number of iterations for the loop
  99963. */
  99964. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99965. /**
  99966. * Execute the next iteration. Must be called after the last iteration was finished.
  99967. */
  99968. executeNext(): void;
  99969. /**
  99970. * Break the loop and run the success callback.
  99971. */
  99972. breakLoop(): void;
  99973. /**
  99974. * Create and run an async loop.
  99975. * @param iterations the number of iterations.
  99976. * @param fn the function to run each iteration
  99977. * @param successCallback the callback that will be called upon succesful execution
  99978. * @param offset starting offset.
  99979. * @returns the created async loop object
  99980. */
  99981. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99982. /**
  99983. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99984. * @param iterations total number of iterations
  99985. * @param syncedIterations number of synchronous iterations in each async iteration.
  99986. * @param fn the function to call each iteration.
  99987. * @param callback a success call back that will be called when iterating stops.
  99988. * @param breakFunction a break condition (optional)
  99989. * @param timeout timeout settings for the setTimeout function. default - 0.
  99990. * @returns the created async loop object
  99991. */
  99992. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99993. }
  99994. }
  99995. declare module BABYLON {
  99996. /**
  99997. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99998. * The underlying implementation relies on an associative array to ensure the best performances.
  99999. * The value can be anything including 'null' but except 'undefined'
  100000. */
  100001. export class StringDictionary<T> {
  100002. /**
  100003. * This will clear this dictionary and copy the content from the 'source' one.
  100004. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100005. * @param source the dictionary to take the content from and copy to this dictionary
  100006. */
  100007. copyFrom(source: StringDictionary<T>): void;
  100008. /**
  100009. * Get a value based from its key
  100010. * @param key the given key to get the matching value from
  100011. * @return the value if found, otherwise undefined is returned
  100012. */
  100013. get(key: string): T | undefined;
  100014. /**
  100015. * Get a value from its key or add it if it doesn't exist.
  100016. * This method will ensure you that a given key/data will be present in the dictionary.
  100017. * @param key the given key to get the matching value from
  100018. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100019. * The factory will only be invoked if there's no data for the given key.
  100020. * @return the value corresponding to the key.
  100021. */
  100022. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100023. /**
  100024. * Get a value from its key if present in the dictionary otherwise add it
  100025. * @param key the key to get the value from
  100026. * @param val if there's no such key/value pair in the dictionary add it with this value
  100027. * @return the value corresponding to the key
  100028. */
  100029. getOrAdd(key: string, val: T): T;
  100030. /**
  100031. * Check if there's a given key in the dictionary
  100032. * @param key the key to check for
  100033. * @return true if the key is present, false otherwise
  100034. */
  100035. contains(key: string): boolean;
  100036. /**
  100037. * Add a new key and its corresponding value
  100038. * @param key the key to add
  100039. * @param value the value corresponding to the key
  100040. * @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
  100041. */
  100042. add(key: string, value: T): boolean;
  100043. /**
  100044. * Update a specific value associated to a key
  100045. * @param key defines the key to use
  100046. * @param value defines the value to store
  100047. * @returns true if the value was updated (or false if the key was not found)
  100048. */
  100049. set(key: string, value: T): boolean;
  100050. /**
  100051. * Get the element of the given key and remove it from the dictionary
  100052. * @param key defines the key to search
  100053. * @returns the value associated with the key or null if not found
  100054. */
  100055. getAndRemove(key: string): Nullable<T>;
  100056. /**
  100057. * Remove a key/value from the dictionary.
  100058. * @param key the key to remove
  100059. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100060. */
  100061. remove(key: string): boolean;
  100062. /**
  100063. * Clear the whole content of the dictionary
  100064. */
  100065. clear(): void;
  100066. /**
  100067. * Gets the current count
  100068. */
  100069. readonly count: number;
  100070. /**
  100071. * Execute a callback on each key/val of the dictionary.
  100072. * Note that you can remove any element in this dictionary in the callback implementation
  100073. * @param callback the callback to execute on a given key/value pair
  100074. */
  100075. forEach(callback: (key: string, val: T) => void): void;
  100076. /**
  100077. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100078. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100079. * Note that you can remove any element in this dictionary in the callback implementation
  100080. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100081. * @returns the first item
  100082. */
  100083. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100084. private _count;
  100085. private _data;
  100086. }
  100087. }
  100088. declare module BABYLON {
  100089. /** @hidden */
  100090. export interface ICollisionCoordinator {
  100091. createCollider(): Collider;
  100092. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100093. init(scene: Scene): void;
  100094. }
  100095. /** @hidden */
  100096. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100097. private _scene;
  100098. private _scaledPosition;
  100099. private _scaledVelocity;
  100100. private _finalPosition;
  100101. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100102. createCollider(): Collider;
  100103. init(scene: Scene): void;
  100104. private _collideWithWorld;
  100105. }
  100106. }
  100107. declare module BABYLON {
  100108. /**
  100109. * Class used to manage all inputs for the scene.
  100110. */
  100111. export class InputManager {
  100112. /** The distance in pixel that you have to move to prevent some events */
  100113. static DragMovementThreshold: number;
  100114. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100115. static LongPressDelay: number;
  100116. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100117. static DoubleClickDelay: number;
  100118. /** If you need to check double click without raising a single click at first click, enable this flag */
  100119. static ExclusiveDoubleClickMode: boolean;
  100120. private _wheelEventName;
  100121. private _onPointerMove;
  100122. private _onPointerDown;
  100123. private _onPointerUp;
  100124. private _initClickEvent;
  100125. private _initActionManager;
  100126. private _delayedSimpleClick;
  100127. private _delayedSimpleClickTimeout;
  100128. private _previousDelayedSimpleClickTimeout;
  100129. private _meshPickProceed;
  100130. private _previousButtonPressed;
  100131. private _currentPickResult;
  100132. private _previousPickResult;
  100133. private _totalPointersPressed;
  100134. private _doubleClickOccured;
  100135. private _pointerOverMesh;
  100136. private _pickedDownMesh;
  100137. private _pickedUpMesh;
  100138. private _pointerX;
  100139. private _pointerY;
  100140. private _unTranslatedPointerX;
  100141. private _unTranslatedPointerY;
  100142. private _startingPointerPosition;
  100143. private _previousStartingPointerPosition;
  100144. private _startingPointerTime;
  100145. private _previousStartingPointerTime;
  100146. private _pointerCaptures;
  100147. private _onKeyDown;
  100148. private _onKeyUp;
  100149. private _onCanvasFocusObserver;
  100150. private _onCanvasBlurObserver;
  100151. private _scene;
  100152. /**
  100153. * Creates a new InputManager
  100154. * @param scene defines the hosting scene
  100155. */
  100156. constructor(scene: Scene);
  100157. /**
  100158. * Gets the mesh that is currently under the pointer
  100159. */
  100160. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100161. /**
  100162. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100163. */
  100164. readonly unTranslatedPointer: Vector2;
  100165. /**
  100166. * Gets or sets the current on-screen X position of the pointer
  100167. */
  100168. pointerX: number;
  100169. /**
  100170. * Gets or sets the current on-screen Y position of the pointer
  100171. */
  100172. pointerY: number;
  100173. private _updatePointerPosition;
  100174. private _processPointerMove;
  100175. private _setRayOnPointerInfo;
  100176. private _checkPrePointerObservable;
  100177. /**
  100178. * Use this method to simulate a pointer move on a mesh
  100179. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100180. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100181. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100182. */
  100183. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100184. /**
  100185. * Use this method to simulate a pointer down on a mesh
  100186. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100187. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100188. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100189. */
  100190. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100191. private _processPointerDown;
  100192. /** @hidden */
  100193. _isPointerSwiping(): boolean;
  100194. /**
  100195. * Use this method to simulate a pointer up on a mesh
  100196. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100197. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100198. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100199. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100200. */
  100201. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100202. private _processPointerUp;
  100203. /**
  100204. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100205. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100206. * @returns true if the pointer was captured
  100207. */
  100208. isPointerCaptured(pointerId?: number): boolean;
  100209. /**
  100210. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100211. * @param attachUp defines if you want to attach events to pointerup
  100212. * @param attachDown defines if you want to attach events to pointerdown
  100213. * @param attachMove defines if you want to attach events to pointermove
  100214. */
  100215. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100216. /**
  100217. * Detaches all event handlers
  100218. */
  100219. detachControl(): void;
  100220. /**
  100221. * Force the value of meshUnderPointer
  100222. * @param mesh defines the mesh to use
  100223. */
  100224. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100225. /**
  100226. * Gets the mesh under the pointer
  100227. * @returns a Mesh or null if no mesh is under the pointer
  100228. */
  100229. getPointerOverMesh(): Nullable<AbstractMesh>;
  100230. }
  100231. }
  100232. declare module BABYLON {
  100233. /**
  100234. * Helper class used to generate session unique ID
  100235. */
  100236. export class UniqueIdGenerator {
  100237. private static _UniqueIdCounter;
  100238. /**
  100239. * Gets an unique (relatively to the current scene) Id
  100240. */
  100241. static readonly UniqueId: number;
  100242. }
  100243. }
  100244. declare module BABYLON {
  100245. /**
  100246. * This class defines the direct association between an animation and a target
  100247. */
  100248. export class TargetedAnimation {
  100249. /**
  100250. * Animation to perform
  100251. */
  100252. animation: Animation;
  100253. /**
  100254. * Target to animate
  100255. */
  100256. target: any;
  100257. /**
  100258. * Serialize the object
  100259. * @returns the JSON object representing the current entity
  100260. */
  100261. serialize(): any;
  100262. }
  100263. /**
  100264. * Use this class to create coordinated animations on multiple targets
  100265. */
  100266. export class AnimationGroup implements IDisposable {
  100267. /** The name of the animation group */
  100268. name: string;
  100269. private _scene;
  100270. private _targetedAnimations;
  100271. private _animatables;
  100272. private _from;
  100273. private _to;
  100274. private _isStarted;
  100275. private _isPaused;
  100276. private _speedRatio;
  100277. private _loopAnimation;
  100278. /**
  100279. * Gets or sets the unique id of the node
  100280. */
  100281. uniqueId: number;
  100282. /**
  100283. * This observable will notify when one animation have ended
  100284. */
  100285. onAnimationEndObservable: Observable<TargetedAnimation>;
  100286. /**
  100287. * Observer raised when one animation loops
  100288. */
  100289. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100290. /**
  100291. * This observable will notify when all animations have ended.
  100292. */
  100293. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100294. /**
  100295. * This observable will notify when all animations have paused.
  100296. */
  100297. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100298. /**
  100299. * This observable will notify when all animations are playing.
  100300. */
  100301. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100302. /**
  100303. * Gets the first frame
  100304. */
  100305. readonly from: number;
  100306. /**
  100307. * Gets the last frame
  100308. */
  100309. readonly to: number;
  100310. /**
  100311. * Define if the animations are started
  100312. */
  100313. readonly isStarted: boolean;
  100314. /**
  100315. * Gets a value indicating that the current group is playing
  100316. */
  100317. readonly isPlaying: boolean;
  100318. /**
  100319. * Gets or sets the speed ratio to use for all animations
  100320. */
  100321. /**
  100322. * Gets or sets the speed ratio to use for all animations
  100323. */
  100324. speedRatio: number;
  100325. /**
  100326. * Gets or sets if all animations should loop or not
  100327. */
  100328. loopAnimation: boolean;
  100329. /**
  100330. * Gets the targeted animations for this animation group
  100331. */
  100332. readonly targetedAnimations: Array<TargetedAnimation>;
  100333. /**
  100334. * returning the list of animatables controlled by this animation group.
  100335. */
  100336. readonly animatables: Array<Animatable>;
  100337. /**
  100338. * Instantiates a new Animation Group.
  100339. * This helps managing several animations at once.
  100340. * @see http://doc.babylonjs.com/how_to/group
  100341. * @param name Defines the name of the group
  100342. * @param scene Defines the scene the group belongs to
  100343. */
  100344. constructor(
  100345. /** The name of the animation group */
  100346. name: string, scene?: Nullable<Scene>);
  100347. /**
  100348. * Add an animation (with its target) in the group
  100349. * @param animation defines the animation we want to add
  100350. * @param target defines the target of the animation
  100351. * @returns the TargetedAnimation object
  100352. */
  100353. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100354. /**
  100355. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100356. * It can add constant keys at begin or end
  100357. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100358. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100359. * @returns the animation group
  100360. */
  100361. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100362. /**
  100363. * Start all animations on given targets
  100364. * @param loop defines if animations must loop
  100365. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100366. * @param from defines the from key (optional)
  100367. * @param to defines the to key (optional)
  100368. * @returns the current animation group
  100369. */
  100370. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100371. /**
  100372. * Pause all animations
  100373. * @returns the animation group
  100374. */
  100375. pause(): AnimationGroup;
  100376. /**
  100377. * Play all animations to initial state
  100378. * This function will start() the animations if they were not started or will restart() them if they were paused
  100379. * @param loop defines if animations must loop
  100380. * @returns the animation group
  100381. */
  100382. play(loop?: boolean): AnimationGroup;
  100383. /**
  100384. * Reset all animations to initial state
  100385. * @returns the animation group
  100386. */
  100387. reset(): AnimationGroup;
  100388. /**
  100389. * Restart animations from key 0
  100390. * @returns the animation group
  100391. */
  100392. restart(): AnimationGroup;
  100393. /**
  100394. * Stop all animations
  100395. * @returns the animation group
  100396. */
  100397. stop(): AnimationGroup;
  100398. /**
  100399. * Set animation weight for all animatables
  100400. * @param weight defines the weight to use
  100401. * @return the animationGroup
  100402. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100403. */
  100404. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100405. /**
  100406. * Synchronize and normalize all animatables with a source animatable
  100407. * @param root defines the root animatable to synchronize with
  100408. * @return the animationGroup
  100409. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100410. */
  100411. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100412. /**
  100413. * Goes to a specific frame in this animation group
  100414. * @param frame the frame number to go to
  100415. * @return the animationGroup
  100416. */
  100417. goToFrame(frame: number): AnimationGroup;
  100418. /**
  100419. * Dispose all associated resources
  100420. */
  100421. dispose(): void;
  100422. private _checkAnimationGroupEnded;
  100423. /**
  100424. * Clone the current animation group and returns a copy
  100425. * @param newName defines the name of the new group
  100426. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100427. * @returns the new aniamtion group
  100428. */
  100429. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100430. /**
  100431. * Serializes the animationGroup to an object
  100432. * @returns Serialized object
  100433. */
  100434. serialize(): any;
  100435. /**
  100436. * Returns a new AnimationGroup object parsed from the source provided.
  100437. * @param parsedAnimationGroup defines the source
  100438. * @param scene defines the scene that will receive the animationGroup
  100439. * @returns a new AnimationGroup
  100440. */
  100441. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100442. /**
  100443. * Returns the string "AnimationGroup"
  100444. * @returns "AnimationGroup"
  100445. */
  100446. getClassName(): string;
  100447. /**
  100448. * Creates a detailled string about the object
  100449. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100450. * @returns a string representing the object
  100451. */
  100452. toString(fullDetails?: boolean): string;
  100453. }
  100454. }
  100455. declare module BABYLON {
  100456. /**
  100457. * Define an interface for all classes that will hold resources
  100458. */
  100459. export interface IDisposable {
  100460. /**
  100461. * Releases all held resources
  100462. */
  100463. dispose(): void;
  100464. }
  100465. /** Interface defining initialization parameters for Scene class */
  100466. export interface SceneOptions {
  100467. /**
  100468. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100469. * It will improve performance when the number of geometries becomes important.
  100470. */
  100471. useGeometryUniqueIdsMap?: boolean;
  100472. /**
  100473. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100474. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100475. */
  100476. useMaterialMeshMap?: boolean;
  100477. /**
  100478. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100479. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100480. */
  100481. useClonedMeshhMap?: boolean;
  100482. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100483. virtual?: boolean;
  100484. }
  100485. /**
  100486. * Represents a scene to be rendered by the engine.
  100487. * @see http://doc.babylonjs.com/features/scene
  100488. */
  100489. export class Scene extends AbstractScene implements IAnimatable {
  100490. /** The fog is deactivated */
  100491. static readonly FOGMODE_NONE: number;
  100492. /** The fog density is following an exponential function */
  100493. static readonly FOGMODE_EXP: number;
  100494. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100495. static readonly FOGMODE_EXP2: number;
  100496. /** The fog density is following a linear function. */
  100497. static readonly FOGMODE_LINEAR: number;
  100498. /**
  100499. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100500. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100501. */
  100502. static MinDeltaTime: number;
  100503. /**
  100504. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100506. */
  100507. static MaxDeltaTime: number;
  100508. /**
  100509. * Factory used to create the default material.
  100510. * @param name The name of the material to create
  100511. * @param scene The scene to create the material for
  100512. * @returns The default material
  100513. */
  100514. static DefaultMaterialFactory(scene: Scene): Material;
  100515. /**
  100516. * Factory used to create the a collision coordinator.
  100517. * @returns The collision coordinator
  100518. */
  100519. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100520. /** @hidden */
  100521. _inputManager: InputManager;
  100522. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100523. cameraToUseForPointers: Nullable<Camera>;
  100524. /** @hidden */
  100525. readonly _isScene: boolean;
  100526. /**
  100527. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100528. */
  100529. autoClear: boolean;
  100530. /**
  100531. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100532. */
  100533. autoClearDepthAndStencil: boolean;
  100534. /**
  100535. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100536. */
  100537. clearColor: Color4;
  100538. /**
  100539. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100540. */
  100541. ambientColor: Color3;
  100542. /**
  100543. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100544. * It should only be one of the following (if not the default embedded one):
  100545. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100546. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100547. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100548. * The material properties need to be setup according to the type of texture in use.
  100549. */
  100550. environmentBRDFTexture: BaseTexture;
  100551. /** @hidden */
  100552. protected _environmentTexture: Nullable<BaseTexture>;
  100553. /**
  100554. * Texture used in all pbr material as the reflection texture.
  100555. * As in the majority of the scene they are the same (exception for multi room and so on),
  100556. * this is easier to reference from here than from all the materials.
  100557. */
  100558. /**
  100559. * Texture used in all pbr material as the reflection texture.
  100560. * As in the majority of the scene they are the same (exception for multi room and so on),
  100561. * this is easier to set here than in all the materials.
  100562. */
  100563. environmentTexture: Nullable<BaseTexture>;
  100564. /** @hidden */
  100565. protected _environmentIntensity: number;
  100566. /**
  100567. * Intensity of the environment in all pbr material.
  100568. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100569. * As in the majority of the scene they are the same (exception for multi room and so on),
  100570. * this is easier to reference from here than from all the materials.
  100571. */
  100572. /**
  100573. * Intensity of the environment in all pbr material.
  100574. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100575. * As in the majority of the scene they are the same (exception for multi room and so on),
  100576. * this is easier to set here than in all the materials.
  100577. */
  100578. environmentIntensity: number;
  100579. /** @hidden */
  100580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100581. /**
  100582. * Default image processing configuration used either in the rendering
  100583. * Forward main pass or through the imageProcessingPostProcess if present.
  100584. * As in the majority of the scene they are the same (exception for multi camera),
  100585. * this is easier to reference from here than from all the materials and post process.
  100586. *
  100587. * No setter as we it is a shared configuration, you can set the values instead.
  100588. */
  100589. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100590. private _forceWireframe;
  100591. /**
  100592. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100593. */
  100594. forceWireframe: boolean;
  100595. private _forcePointsCloud;
  100596. /**
  100597. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100598. */
  100599. forcePointsCloud: boolean;
  100600. /**
  100601. * Gets or sets the active clipplane 1
  100602. */
  100603. clipPlane: Nullable<Plane>;
  100604. /**
  100605. * Gets or sets the active clipplane 2
  100606. */
  100607. clipPlane2: Nullable<Plane>;
  100608. /**
  100609. * Gets or sets the active clipplane 3
  100610. */
  100611. clipPlane3: Nullable<Plane>;
  100612. /**
  100613. * Gets or sets the active clipplane 4
  100614. */
  100615. clipPlane4: Nullable<Plane>;
  100616. /**
  100617. * Gets or sets a boolean indicating if animations are enabled
  100618. */
  100619. animationsEnabled: boolean;
  100620. private _animationPropertiesOverride;
  100621. /**
  100622. * Gets or sets the animation properties override
  100623. */
  100624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100625. /**
  100626. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100627. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100628. */
  100629. useConstantAnimationDeltaTime: boolean;
  100630. /**
  100631. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100632. * Please note that it requires to run a ray cast through the scene on every frame
  100633. */
  100634. constantlyUpdateMeshUnderPointer: boolean;
  100635. /**
  100636. * Defines the HTML cursor to use when hovering over interactive elements
  100637. */
  100638. hoverCursor: string;
  100639. /**
  100640. * Defines the HTML default cursor to use (empty by default)
  100641. */
  100642. defaultCursor: string;
  100643. /**
  100644. * Defines wether cursors are handled by the scene.
  100645. */
  100646. doNotHandleCursors: boolean;
  100647. /**
  100648. * This is used to call preventDefault() on pointer down
  100649. * in order to block unwanted artifacts like system double clicks
  100650. */
  100651. preventDefaultOnPointerDown: boolean;
  100652. /**
  100653. * This is used to call preventDefault() on pointer up
  100654. * in order to block unwanted artifacts like system double clicks
  100655. */
  100656. preventDefaultOnPointerUp: boolean;
  100657. /**
  100658. * Gets or sets user defined metadata
  100659. */
  100660. metadata: any;
  100661. /**
  100662. * For internal use only. Please do not use.
  100663. */
  100664. reservedDataStore: any;
  100665. /**
  100666. * Gets the name of the plugin used to load this scene (null by default)
  100667. */
  100668. loadingPluginName: string;
  100669. /**
  100670. * Use this array to add regular expressions used to disable offline support for specific urls
  100671. */
  100672. disableOfflineSupportExceptionRules: RegExp[];
  100673. /**
  100674. * An event triggered when the scene is disposed.
  100675. */
  100676. onDisposeObservable: Observable<Scene>;
  100677. private _onDisposeObserver;
  100678. /** Sets a function to be executed when this scene is disposed. */
  100679. onDispose: () => void;
  100680. /**
  100681. * An event triggered before rendering the scene (right after animations and physics)
  100682. */
  100683. onBeforeRenderObservable: Observable<Scene>;
  100684. private _onBeforeRenderObserver;
  100685. /** Sets a function to be executed before rendering this scene */
  100686. beforeRender: Nullable<() => void>;
  100687. /**
  100688. * An event triggered after rendering the scene
  100689. */
  100690. onAfterRenderObservable: Observable<Scene>;
  100691. /**
  100692. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100693. */
  100694. onAfterRenderCameraObservable: Observable<Camera>;
  100695. private _onAfterRenderObserver;
  100696. /** Sets a function to be executed after rendering this scene */
  100697. afterRender: Nullable<() => void>;
  100698. /**
  100699. * An event triggered before animating the scene
  100700. */
  100701. onBeforeAnimationsObservable: Observable<Scene>;
  100702. /**
  100703. * An event triggered after animations processing
  100704. */
  100705. onAfterAnimationsObservable: Observable<Scene>;
  100706. /**
  100707. * An event triggered before draw calls are ready to be sent
  100708. */
  100709. onBeforeDrawPhaseObservable: Observable<Scene>;
  100710. /**
  100711. * An event triggered after draw calls have been sent
  100712. */
  100713. onAfterDrawPhaseObservable: Observable<Scene>;
  100714. /**
  100715. * An event triggered when the scene is ready
  100716. */
  100717. onReadyObservable: Observable<Scene>;
  100718. /**
  100719. * An event triggered before rendering a camera
  100720. */
  100721. onBeforeCameraRenderObservable: Observable<Camera>;
  100722. private _onBeforeCameraRenderObserver;
  100723. /** Sets a function to be executed before rendering a camera*/
  100724. beforeCameraRender: () => void;
  100725. /**
  100726. * An event triggered after rendering a camera
  100727. */
  100728. onAfterCameraRenderObservable: Observable<Camera>;
  100729. private _onAfterCameraRenderObserver;
  100730. /** Sets a function to be executed after rendering a camera*/
  100731. afterCameraRender: () => void;
  100732. /**
  100733. * An event triggered when active meshes evaluation is about to start
  100734. */
  100735. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100736. /**
  100737. * An event triggered when active meshes evaluation is done
  100738. */
  100739. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100740. /**
  100741. * An event triggered when particles rendering is about to start
  100742. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100743. */
  100744. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100745. /**
  100746. * An event triggered when particles rendering is done
  100747. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100748. */
  100749. onAfterParticlesRenderingObservable: Observable<Scene>;
  100750. /**
  100751. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100752. */
  100753. onDataLoadedObservable: Observable<Scene>;
  100754. /**
  100755. * An event triggered when a camera is created
  100756. */
  100757. onNewCameraAddedObservable: Observable<Camera>;
  100758. /**
  100759. * An event triggered when a camera is removed
  100760. */
  100761. onCameraRemovedObservable: Observable<Camera>;
  100762. /**
  100763. * An event triggered when a light is created
  100764. */
  100765. onNewLightAddedObservable: Observable<Light>;
  100766. /**
  100767. * An event triggered when a light is removed
  100768. */
  100769. onLightRemovedObservable: Observable<Light>;
  100770. /**
  100771. * An event triggered when a geometry is created
  100772. */
  100773. onNewGeometryAddedObservable: Observable<Geometry>;
  100774. /**
  100775. * An event triggered when a geometry is removed
  100776. */
  100777. onGeometryRemovedObservable: Observable<Geometry>;
  100778. /**
  100779. * An event triggered when a transform node is created
  100780. */
  100781. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100782. /**
  100783. * An event triggered when a transform node is removed
  100784. */
  100785. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100786. /**
  100787. * An event triggered when a mesh is created
  100788. */
  100789. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100790. /**
  100791. * An event triggered when a mesh is removed
  100792. */
  100793. onMeshRemovedObservable: Observable<AbstractMesh>;
  100794. /**
  100795. * An event triggered when a skeleton is created
  100796. */
  100797. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100798. /**
  100799. * An event triggered when a skeleton is removed
  100800. */
  100801. onSkeletonRemovedObservable: Observable<Skeleton>;
  100802. /**
  100803. * An event triggered when a material is created
  100804. */
  100805. onNewMaterialAddedObservable: Observable<Material>;
  100806. /**
  100807. * An event triggered when a material is removed
  100808. */
  100809. onMaterialRemovedObservable: Observable<Material>;
  100810. /**
  100811. * An event triggered when a texture is created
  100812. */
  100813. onNewTextureAddedObservable: Observable<BaseTexture>;
  100814. /**
  100815. * An event triggered when a texture is removed
  100816. */
  100817. onTextureRemovedObservable: Observable<BaseTexture>;
  100818. /**
  100819. * An event triggered when render targets are about to be rendered
  100820. * Can happen multiple times per frame.
  100821. */
  100822. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100823. /**
  100824. * An event triggered when render targets were rendered.
  100825. * Can happen multiple times per frame.
  100826. */
  100827. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100828. /**
  100829. * An event triggered before calculating deterministic simulation step
  100830. */
  100831. onBeforeStepObservable: Observable<Scene>;
  100832. /**
  100833. * An event triggered after calculating deterministic simulation step
  100834. */
  100835. onAfterStepObservable: Observable<Scene>;
  100836. /**
  100837. * An event triggered when the activeCamera property is updated
  100838. */
  100839. onActiveCameraChanged: Observable<Scene>;
  100840. /**
  100841. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100842. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100843. * 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)
  100844. */
  100845. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100846. /**
  100847. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100848. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100849. * 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)
  100850. */
  100851. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100852. /**
  100853. * This Observable will when a mesh has been imported into the scene.
  100854. */
  100855. onMeshImportedObservable: Observable<AbstractMesh>;
  100856. /**
  100857. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100858. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100859. */
  100860. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100861. /** @hidden */
  100862. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100863. /**
  100864. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100865. */
  100866. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100867. /**
  100868. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100869. */
  100870. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100871. /**
  100872. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100873. */
  100874. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100875. /** Callback called when a pointer move is detected */
  100876. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100877. /** Callback called when a pointer down is detected */
  100878. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100879. /** Callback called when a pointer up is detected */
  100880. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100881. /** Callback called when a pointer pick is detected */
  100882. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100883. /**
  100884. * 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).
  100885. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100886. */
  100887. onPrePointerObservable: Observable<PointerInfoPre>;
  100888. /**
  100889. * Observable event triggered each time an input event is received from the rendering canvas
  100890. */
  100891. onPointerObservable: Observable<PointerInfo>;
  100892. /**
  100893. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100894. */
  100895. readonly unTranslatedPointer: Vector2;
  100896. /**
  100897. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100898. */
  100899. static DragMovementThreshold: number;
  100900. /**
  100901. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100902. */
  100903. static LongPressDelay: number;
  100904. /**
  100905. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100906. */
  100907. static DoubleClickDelay: number;
  100908. /** If you need to check double click without raising a single click at first click, enable this flag */
  100909. static ExclusiveDoubleClickMode: boolean;
  100910. /** @hidden */
  100911. _mirroredCameraPosition: Nullable<Vector3>;
  100912. /**
  100913. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100914. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100915. */
  100916. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100917. /**
  100918. * Observable event triggered each time an keyboard event is received from the hosting window
  100919. */
  100920. onKeyboardObservable: Observable<KeyboardInfo>;
  100921. private _useRightHandedSystem;
  100922. /**
  100923. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100924. */
  100925. useRightHandedSystem: boolean;
  100926. private _timeAccumulator;
  100927. private _currentStepId;
  100928. private _currentInternalStep;
  100929. /**
  100930. * Sets the step Id used by deterministic lock step
  100931. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100932. * @param newStepId defines the step Id
  100933. */
  100934. setStepId(newStepId: number): void;
  100935. /**
  100936. * Gets the step Id used by deterministic lock step
  100937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100938. * @returns the step Id
  100939. */
  100940. getStepId(): number;
  100941. /**
  100942. * Gets the internal step used by deterministic lock step
  100943. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100944. * @returns the internal step
  100945. */
  100946. getInternalStep(): number;
  100947. private _fogEnabled;
  100948. /**
  100949. * Gets or sets a boolean indicating if fog is enabled on this scene
  100950. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100951. * (Default is true)
  100952. */
  100953. fogEnabled: boolean;
  100954. private _fogMode;
  100955. /**
  100956. * Gets or sets the fog mode to use
  100957. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100958. * | mode | value |
  100959. * | --- | --- |
  100960. * | FOGMODE_NONE | 0 |
  100961. * | FOGMODE_EXP | 1 |
  100962. * | FOGMODE_EXP2 | 2 |
  100963. * | FOGMODE_LINEAR | 3 |
  100964. */
  100965. fogMode: number;
  100966. /**
  100967. * Gets or sets the fog color to use
  100968. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100969. * (Default is Color3(0.2, 0.2, 0.3))
  100970. */
  100971. fogColor: Color3;
  100972. /**
  100973. * Gets or sets the fog density to use
  100974. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100975. * (Default is 0.1)
  100976. */
  100977. fogDensity: number;
  100978. /**
  100979. * Gets or sets the fog start distance to use
  100980. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100981. * (Default is 0)
  100982. */
  100983. fogStart: number;
  100984. /**
  100985. * Gets or sets the fog end distance to use
  100986. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100987. * (Default is 1000)
  100988. */
  100989. fogEnd: number;
  100990. private _shadowsEnabled;
  100991. /**
  100992. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100993. */
  100994. shadowsEnabled: boolean;
  100995. private _lightsEnabled;
  100996. /**
  100997. * Gets or sets a boolean indicating if lights are enabled on this scene
  100998. */
  100999. lightsEnabled: boolean;
  101000. /** All of the active cameras added to this scene. */
  101001. activeCameras: Camera[];
  101002. /** @hidden */
  101003. _activeCamera: Nullable<Camera>;
  101004. /** Gets or sets the current active camera */
  101005. activeCamera: Nullable<Camera>;
  101006. private _defaultMaterial;
  101007. /** The default material used on meshes when no material is affected */
  101008. /** The default material used on meshes when no material is affected */
  101009. defaultMaterial: Material;
  101010. private _texturesEnabled;
  101011. /**
  101012. * Gets or sets a boolean indicating if textures are enabled on this scene
  101013. */
  101014. texturesEnabled: boolean;
  101015. /**
  101016. * Gets or sets a boolean indicating if particles are enabled on this scene
  101017. */
  101018. particlesEnabled: boolean;
  101019. /**
  101020. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101021. */
  101022. spritesEnabled: boolean;
  101023. private _skeletonsEnabled;
  101024. /**
  101025. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101026. */
  101027. skeletonsEnabled: boolean;
  101028. /**
  101029. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101030. */
  101031. lensFlaresEnabled: boolean;
  101032. /**
  101033. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101034. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101035. */
  101036. collisionsEnabled: boolean;
  101037. private _collisionCoordinator;
  101038. /** @hidden */
  101039. readonly collisionCoordinator: ICollisionCoordinator;
  101040. /**
  101041. * Defines the gravity applied to this scene (used only for collisions)
  101042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101043. */
  101044. gravity: Vector3;
  101045. /**
  101046. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101047. */
  101048. postProcessesEnabled: boolean;
  101049. /**
  101050. * The list of postprocesses added to the scene
  101051. */
  101052. postProcesses: PostProcess[];
  101053. /**
  101054. * Gets the current postprocess manager
  101055. */
  101056. postProcessManager: PostProcessManager;
  101057. /**
  101058. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101059. */
  101060. renderTargetsEnabled: boolean;
  101061. /**
  101062. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101063. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101064. */
  101065. dumpNextRenderTargets: boolean;
  101066. /**
  101067. * The list of user defined render targets added to the scene
  101068. */
  101069. customRenderTargets: RenderTargetTexture[];
  101070. /**
  101071. * Defines if texture loading must be delayed
  101072. * If true, textures will only be loaded when they need to be rendered
  101073. */
  101074. useDelayedTextureLoading: boolean;
  101075. /**
  101076. * Gets the list of meshes imported to the scene through SceneLoader
  101077. */
  101078. importedMeshesFiles: String[];
  101079. /**
  101080. * Gets or sets a boolean indicating if probes are enabled on this scene
  101081. */
  101082. probesEnabled: boolean;
  101083. /**
  101084. * Gets or sets the current offline provider to use to store scene data
  101085. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101086. */
  101087. offlineProvider: IOfflineProvider;
  101088. /**
  101089. * Gets or sets the action manager associated with the scene
  101090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101091. */
  101092. actionManager: AbstractActionManager;
  101093. private _meshesForIntersections;
  101094. /**
  101095. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101096. */
  101097. proceduralTexturesEnabled: boolean;
  101098. private _engine;
  101099. private _totalVertices;
  101100. /** @hidden */
  101101. _activeIndices: PerfCounter;
  101102. /** @hidden */
  101103. _activeParticles: PerfCounter;
  101104. /** @hidden */
  101105. _activeBones: PerfCounter;
  101106. private _animationRatio;
  101107. /** @hidden */
  101108. _animationTimeLast: number;
  101109. /** @hidden */
  101110. _animationTime: number;
  101111. /**
  101112. * Gets or sets a general scale for animation speed
  101113. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101114. */
  101115. animationTimeScale: number;
  101116. /** @hidden */
  101117. _cachedMaterial: Nullable<Material>;
  101118. /** @hidden */
  101119. _cachedEffect: Nullable<Effect>;
  101120. /** @hidden */
  101121. _cachedVisibility: Nullable<number>;
  101122. private _renderId;
  101123. private _frameId;
  101124. private _executeWhenReadyTimeoutId;
  101125. private _intermediateRendering;
  101126. private _viewUpdateFlag;
  101127. private _projectionUpdateFlag;
  101128. /** @hidden */
  101129. _toBeDisposed: Nullable<IDisposable>[];
  101130. private _activeRequests;
  101131. /** @hidden */
  101132. _pendingData: any[];
  101133. private _isDisposed;
  101134. /**
  101135. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101136. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101137. */
  101138. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101139. private _activeMeshes;
  101140. private _processedMaterials;
  101141. private _renderTargets;
  101142. /** @hidden */
  101143. _activeParticleSystems: SmartArray<IParticleSystem>;
  101144. private _activeSkeletons;
  101145. private _softwareSkinnedMeshes;
  101146. private _renderingManager;
  101147. /** @hidden */
  101148. _activeAnimatables: Animatable[];
  101149. private _transformMatrix;
  101150. private _sceneUbo;
  101151. /** @hidden */
  101152. _viewMatrix: Matrix;
  101153. private _projectionMatrix;
  101154. /** @hidden */
  101155. _forcedViewPosition: Nullable<Vector3>;
  101156. /** @hidden */
  101157. _frustumPlanes: Plane[];
  101158. /**
  101159. * Gets the list of frustum planes (built from the active camera)
  101160. */
  101161. readonly frustumPlanes: Plane[];
  101162. /**
  101163. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101164. * This is useful if there are more lights that the maximum simulteanous authorized
  101165. */
  101166. requireLightSorting: boolean;
  101167. /** @hidden */
  101168. readonly useMaterialMeshMap: boolean;
  101169. /** @hidden */
  101170. readonly useClonedMeshhMap: boolean;
  101171. private _externalData;
  101172. private _uid;
  101173. /**
  101174. * @hidden
  101175. * Backing store of defined scene components.
  101176. */
  101177. _components: ISceneComponent[];
  101178. /**
  101179. * @hidden
  101180. * Backing store of defined scene components.
  101181. */
  101182. _serializableComponents: ISceneSerializableComponent[];
  101183. /**
  101184. * List of components to register on the next registration step.
  101185. */
  101186. private _transientComponents;
  101187. /**
  101188. * Registers the transient components if needed.
  101189. */
  101190. private _registerTransientComponents;
  101191. /**
  101192. * @hidden
  101193. * Add a component to the scene.
  101194. * Note that the ccomponent could be registered on th next frame if this is called after
  101195. * the register component stage.
  101196. * @param component Defines the component to add to the scene
  101197. */
  101198. _addComponent(component: ISceneComponent): void;
  101199. /**
  101200. * @hidden
  101201. * Gets a component from the scene.
  101202. * @param name defines the name of the component to retrieve
  101203. * @returns the component or null if not present
  101204. */
  101205. _getComponent(name: string): Nullable<ISceneComponent>;
  101206. /**
  101207. * @hidden
  101208. * Defines the actions happening before camera updates.
  101209. */
  101210. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101211. /**
  101212. * @hidden
  101213. * Defines the actions happening before clear the canvas.
  101214. */
  101215. _beforeClearStage: Stage<SimpleStageAction>;
  101216. /**
  101217. * @hidden
  101218. * Defines the actions when collecting render targets for the frame.
  101219. */
  101220. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101221. /**
  101222. * @hidden
  101223. * Defines the actions happening for one camera in the frame.
  101224. */
  101225. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101226. /**
  101227. * @hidden
  101228. * Defines the actions happening during the per mesh ready checks.
  101229. */
  101230. _isReadyForMeshStage: Stage<MeshStageAction>;
  101231. /**
  101232. * @hidden
  101233. * Defines the actions happening before evaluate active mesh checks.
  101234. */
  101235. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101236. /**
  101237. * @hidden
  101238. * Defines the actions happening during the evaluate sub mesh checks.
  101239. */
  101240. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101241. /**
  101242. * @hidden
  101243. * Defines the actions happening during the active mesh stage.
  101244. */
  101245. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101246. /**
  101247. * @hidden
  101248. * Defines the actions happening during the per camera render target step.
  101249. */
  101250. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101251. /**
  101252. * @hidden
  101253. * Defines the actions happening just before the active camera is drawing.
  101254. */
  101255. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101256. /**
  101257. * @hidden
  101258. * Defines the actions happening just before a render target is drawing.
  101259. */
  101260. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101261. /**
  101262. * @hidden
  101263. * Defines the actions happening just before a rendering group is drawing.
  101264. */
  101265. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101266. /**
  101267. * @hidden
  101268. * Defines the actions happening just before a mesh is drawing.
  101269. */
  101270. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101271. /**
  101272. * @hidden
  101273. * Defines the actions happening just after a mesh has been drawn.
  101274. */
  101275. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101276. /**
  101277. * @hidden
  101278. * Defines the actions happening just after a rendering group has been drawn.
  101279. */
  101280. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101281. /**
  101282. * @hidden
  101283. * Defines the actions happening just after the active camera has been drawn.
  101284. */
  101285. _afterCameraDrawStage: Stage<CameraStageAction>;
  101286. /**
  101287. * @hidden
  101288. * Defines the actions happening just after a render target has been drawn.
  101289. */
  101290. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101291. /**
  101292. * @hidden
  101293. * Defines the actions happening just after rendering all cameras and computing intersections.
  101294. */
  101295. _afterRenderStage: Stage<SimpleStageAction>;
  101296. /**
  101297. * @hidden
  101298. * Defines the actions happening when a pointer move event happens.
  101299. */
  101300. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101301. /**
  101302. * @hidden
  101303. * Defines the actions happening when a pointer down event happens.
  101304. */
  101305. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101306. /**
  101307. * @hidden
  101308. * Defines the actions happening when a pointer up event happens.
  101309. */
  101310. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101311. /**
  101312. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101313. */
  101314. private geometriesByUniqueId;
  101315. /**
  101316. * Creates a new Scene
  101317. * @param engine defines the engine to use to render this scene
  101318. * @param options defines the scene options
  101319. */
  101320. constructor(engine: Engine, options?: SceneOptions);
  101321. /**
  101322. * Gets a string idenfifying the name of the class
  101323. * @returns "Scene" string
  101324. */
  101325. getClassName(): string;
  101326. private _defaultMeshCandidates;
  101327. /**
  101328. * @hidden
  101329. */
  101330. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101331. private _defaultSubMeshCandidates;
  101332. /**
  101333. * @hidden
  101334. */
  101335. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101336. /**
  101337. * Sets the default candidate providers for the scene.
  101338. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101339. * and getCollidingSubMeshCandidates to their default function
  101340. */
  101341. setDefaultCandidateProviders(): void;
  101342. /**
  101343. * Gets the mesh that is currently under the pointer
  101344. */
  101345. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101346. /**
  101347. * Gets or sets the current on-screen X position of the pointer
  101348. */
  101349. pointerX: number;
  101350. /**
  101351. * Gets or sets the current on-screen Y position of the pointer
  101352. */
  101353. pointerY: number;
  101354. /**
  101355. * Gets the cached material (ie. the latest rendered one)
  101356. * @returns the cached material
  101357. */
  101358. getCachedMaterial(): Nullable<Material>;
  101359. /**
  101360. * Gets the cached effect (ie. the latest rendered one)
  101361. * @returns the cached effect
  101362. */
  101363. getCachedEffect(): Nullable<Effect>;
  101364. /**
  101365. * Gets the cached visibility state (ie. the latest rendered one)
  101366. * @returns the cached visibility state
  101367. */
  101368. getCachedVisibility(): Nullable<number>;
  101369. /**
  101370. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101371. * @param material defines the current material
  101372. * @param effect defines the current effect
  101373. * @param visibility defines the current visibility state
  101374. * @returns true if one parameter is not cached
  101375. */
  101376. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101377. /**
  101378. * Gets the engine associated with the scene
  101379. * @returns an Engine
  101380. */
  101381. getEngine(): Engine;
  101382. /**
  101383. * Gets the total number of vertices rendered per frame
  101384. * @returns the total number of vertices rendered per frame
  101385. */
  101386. getTotalVertices(): number;
  101387. /**
  101388. * Gets the performance counter for total vertices
  101389. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101390. */
  101391. readonly totalVerticesPerfCounter: PerfCounter;
  101392. /**
  101393. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101394. * @returns the total number of active indices rendered per frame
  101395. */
  101396. getActiveIndices(): number;
  101397. /**
  101398. * Gets the performance counter for active indices
  101399. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101400. */
  101401. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101402. /**
  101403. * Gets the total number of active particles rendered per frame
  101404. * @returns the total number of active particles rendered per frame
  101405. */
  101406. getActiveParticles(): number;
  101407. /**
  101408. * Gets the performance counter for active particles
  101409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101410. */
  101411. readonly activeParticlesPerfCounter: PerfCounter;
  101412. /**
  101413. * Gets the total number of active bones rendered per frame
  101414. * @returns the total number of active bones rendered per frame
  101415. */
  101416. getActiveBones(): number;
  101417. /**
  101418. * Gets the performance counter for active bones
  101419. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101420. */
  101421. readonly activeBonesPerfCounter: PerfCounter;
  101422. /**
  101423. * Gets the array of active meshes
  101424. * @returns an array of AbstractMesh
  101425. */
  101426. getActiveMeshes(): SmartArray<AbstractMesh>;
  101427. /**
  101428. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101429. * @returns a number
  101430. */
  101431. getAnimationRatio(): number;
  101432. /**
  101433. * Gets an unique Id for the current render phase
  101434. * @returns a number
  101435. */
  101436. getRenderId(): number;
  101437. /**
  101438. * Gets an unique Id for the current frame
  101439. * @returns a number
  101440. */
  101441. getFrameId(): number;
  101442. /** Call this function if you want to manually increment the render Id*/
  101443. incrementRenderId(): void;
  101444. private _createUbo;
  101445. /**
  101446. * Use this method to simulate a pointer move on a mesh
  101447. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101448. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101449. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101450. * @returns the current scene
  101451. */
  101452. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101453. /**
  101454. * Use this method to simulate a pointer down on a mesh
  101455. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101456. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101457. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101458. * @returns the current scene
  101459. */
  101460. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101461. /**
  101462. * Use this method to simulate a pointer up on a mesh
  101463. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101464. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101465. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101466. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101467. * @returns the current scene
  101468. */
  101469. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101470. /**
  101471. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101472. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101473. * @returns true if the pointer was captured
  101474. */
  101475. isPointerCaptured(pointerId?: number): boolean;
  101476. /**
  101477. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101478. * @param attachUp defines if you want to attach events to pointerup
  101479. * @param attachDown defines if you want to attach events to pointerdown
  101480. * @param attachMove defines if you want to attach events to pointermove
  101481. */
  101482. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101483. /** Detaches all event handlers*/
  101484. detachControl(): void;
  101485. /**
  101486. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101487. * Delay loaded resources are not taking in account
  101488. * @return true if all required resources are ready
  101489. */
  101490. isReady(): boolean;
  101491. /** Resets all cached information relative to material (including effect and visibility) */
  101492. resetCachedMaterial(): void;
  101493. /**
  101494. * Registers a function to be called before every frame render
  101495. * @param func defines the function to register
  101496. */
  101497. registerBeforeRender(func: () => void): void;
  101498. /**
  101499. * Unregisters a function called before every frame render
  101500. * @param func defines the function to unregister
  101501. */
  101502. unregisterBeforeRender(func: () => void): void;
  101503. /**
  101504. * Registers a function to be called after every frame render
  101505. * @param func defines the function to register
  101506. */
  101507. registerAfterRender(func: () => void): void;
  101508. /**
  101509. * Unregisters a function called after every frame render
  101510. * @param func defines the function to unregister
  101511. */
  101512. unregisterAfterRender(func: () => void): void;
  101513. private _executeOnceBeforeRender;
  101514. /**
  101515. * The provided function will run before render once and will be disposed afterwards.
  101516. * A timeout delay can be provided so that the function will be executed in N ms.
  101517. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101518. * @param func The function to be executed.
  101519. * @param timeout optional delay in ms
  101520. */
  101521. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101522. /** @hidden */
  101523. _addPendingData(data: any): void;
  101524. /** @hidden */
  101525. _removePendingData(data: any): void;
  101526. /**
  101527. * Returns the number of items waiting to be loaded
  101528. * @returns the number of items waiting to be loaded
  101529. */
  101530. getWaitingItemsCount(): number;
  101531. /**
  101532. * Returns a boolean indicating if the scene is still loading data
  101533. */
  101534. readonly isLoading: boolean;
  101535. /**
  101536. * Registers a function to be executed when the scene is ready
  101537. * @param {Function} func - the function to be executed
  101538. */
  101539. executeWhenReady(func: () => void): void;
  101540. /**
  101541. * Returns a promise that resolves when the scene is ready
  101542. * @returns A promise that resolves when the scene is ready
  101543. */
  101544. whenReadyAsync(): Promise<void>;
  101545. /** @hidden */
  101546. _checkIsReady(): void;
  101547. /**
  101548. * Gets all animatable attached to the scene
  101549. */
  101550. readonly animatables: Animatable[];
  101551. /**
  101552. * Resets the last animation time frame.
  101553. * Useful to override when animations start running when loading a scene for the first time.
  101554. */
  101555. resetLastAnimationTimeFrame(): void;
  101556. /**
  101557. * Gets the current view matrix
  101558. * @returns a Matrix
  101559. */
  101560. getViewMatrix(): Matrix;
  101561. /**
  101562. * Gets the current projection matrix
  101563. * @returns a Matrix
  101564. */
  101565. getProjectionMatrix(): Matrix;
  101566. /**
  101567. * Gets the current transform matrix
  101568. * @returns a Matrix made of View * Projection
  101569. */
  101570. getTransformMatrix(): Matrix;
  101571. /**
  101572. * Sets the current transform matrix
  101573. * @param viewL defines the View matrix to use
  101574. * @param projectionL defines the Projection matrix to use
  101575. * @param viewR defines the right View matrix to use (if provided)
  101576. * @param projectionR defines the right Projection matrix to use (if provided)
  101577. */
  101578. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101579. /**
  101580. * Gets the uniform buffer used to store scene data
  101581. * @returns a UniformBuffer
  101582. */
  101583. getSceneUniformBuffer(): UniformBuffer;
  101584. /**
  101585. * Gets an unique (relatively to the current scene) Id
  101586. * @returns an unique number for the scene
  101587. */
  101588. getUniqueId(): number;
  101589. /**
  101590. * Add a mesh to the list of scene's meshes
  101591. * @param newMesh defines the mesh to add
  101592. * @param recursive if all child meshes should also be added to the scene
  101593. */
  101594. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101595. /**
  101596. * Remove a mesh for the list of scene's meshes
  101597. * @param toRemove defines the mesh to remove
  101598. * @param recursive if all child meshes should also be removed from the scene
  101599. * @returns the index where the mesh was in the mesh list
  101600. */
  101601. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101602. /**
  101603. * Add a transform node to the list of scene's transform nodes
  101604. * @param newTransformNode defines the transform node to add
  101605. */
  101606. addTransformNode(newTransformNode: TransformNode): void;
  101607. /**
  101608. * Remove a transform node for the list of scene's transform nodes
  101609. * @param toRemove defines the transform node to remove
  101610. * @returns the index where the transform node was in the transform node list
  101611. */
  101612. removeTransformNode(toRemove: TransformNode): number;
  101613. /**
  101614. * Remove a skeleton for the list of scene's skeletons
  101615. * @param toRemove defines the skeleton to remove
  101616. * @returns the index where the skeleton was in the skeleton list
  101617. */
  101618. removeSkeleton(toRemove: Skeleton): number;
  101619. /**
  101620. * Remove a morph target for the list of scene's morph targets
  101621. * @param toRemove defines the morph target to remove
  101622. * @returns the index where the morph target was in the morph target list
  101623. */
  101624. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101625. /**
  101626. * Remove a light for the list of scene's lights
  101627. * @param toRemove defines the light to remove
  101628. * @returns the index where the light was in the light list
  101629. */
  101630. removeLight(toRemove: Light): number;
  101631. /**
  101632. * Remove a camera for the list of scene's cameras
  101633. * @param toRemove defines the camera to remove
  101634. * @returns the index where the camera was in the camera list
  101635. */
  101636. removeCamera(toRemove: Camera): number;
  101637. /**
  101638. * Remove a particle system for the list of scene's particle systems
  101639. * @param toRemove defines the particle system to remove
  101640. * @returns the index where the particle system was in the particle system list
  101641. */
  101642. removeParticleSystem(toRemove: IParticleSystem): number;
  101643. /**
  101644. * Remove a animation for the list of scene's animations
  101645. * @param toRemove defines the animation to remove
  101646. * @returns the index where the animation was in the animation list
  101647. */
  101648. removeAnimation(toRemove: Animation): number;
  101649. /**
  101650. * Will stop the animation of the given target
  101651. * @param target - the target
  101652. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101653. * @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)
  101654. */
  101655. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101656. /**
  101657. * Removes the given animation group from this scene.
  101658. * @param toRemove The animation group to remove
  101659. * @returns The index of the removed animation group
  101660. */
  101661. removeAnimationGroup(toRemove: AnimationGroup): number;
  101662. /**
  101663. * Removes the given multi-material from this scene.
  101664. * @param toRemove The multi-material to remove
  101665. * @returns The index of the removed multi-material
  101666. */
  101667. removeMultiMaterial(toRemove: MultiMaterial): number;
  101668. /**
  101669. * Removes the given material from this scene.
  101670. * @param toRemove The material to remove
  101671. * @returns The index of the removed material
  101672. */
  101673. removeMaterial(toRemove: Material): number;
  101674. /**
  101675. * Removes the given action manager from this scene.
  101676. * @param toRemove The action manager to remove
  101677. * @returns The index of the removed action manager
  101678. */
  101679. removeActionManager(toRemove: AbstractActionManager): number;
  101680. /**
  101681. * Removes the given texture from this scene.
  101682. * @param toRemove The texture to remove
  101683. * @returns The index of the removed texture
  101684. */
  101685. removeTexture(toRemove: BaseTexture): number;
  101686. /**
  101687. * Adds the given light to this scene
  101688. * @param newLight The light to add
  101689. */
  101690. addLight(newLight: Light): void;
  101691. /**
  101692. * Sorts the list list based on light priorities
  101693. */
  101694. sortLightsByPriority(): void;
  101695. /**
  101696. * Adds the given camera to this scene
  101697. * @param newCamera The camera to add
  101698. */
  101699. addCamera(newCamera: Camera): void;
  101700. /**
  101701. * Adds the given skeleton to this scene
  101702. * @param newSkeleton The skeleton to add
  101703. */
  101704. addSkeleton(newSkeleton: Skeleton): void;
  101705. /**
  101706. * Adds the given particle system to this scene
  101707. * @param newParticleSystem The particle system to add
  101708. */
  101709. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101710. /**
  101711. * Adds the given animation to this scene
  101712. * @param newAnimation The animation to add
  101713. */
  101714. addAnimation(newAnimation: Animation): void;
  101715. /**
  101716. * Adds the given animation group to this scene.
  101717. * @param newAnimationGroup The animation group to add
  101718. */
  101719. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101720. /**
  101721. * Adds the given multi-material to this scene
  101722. * @param newMultiMaterial The multi-material to add
  101723. */
  101724. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101725. /**
  101726. * Adds the given material to this scene
  101727. * @param newMaterial The material to add
  101728. */
  101729. addMaterial(newMaterial: Material): void;
  101730. /**
  101731. * Adds the given morph target to this scene
  101732. * @param newMorphTargetManager The morph target to add
  101733. */
  101734. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101735. /**
  101736. * Adds the given geometry to this scene
  101737. * @param newGeometry The geometry to add
  101738. */
  101739. addGeometry(newGeometry: Geometry): void;
  101740. /**
  101741. * Adds the given action manager to this scene
  101742. * @param newActionManager The action manager to add
  101743. */
  101744. addActionManager(newActionManager: AbstractActionManager): void;
  101745. /**
  101746. * Adds the given texture to this scene.
  101747. * @param newTexture The texture to add
  101748. */
  101749. addTexture(newTexture: BaseTexture): void;
  101750. /**
  101751. * Switch active camera
  101752. * @param newCamera defines the new active camera
  101753. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101754. */
  101755. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101756. /**
  101757. * sets the active camera of the scene using its ID
  101758. * @param id defines the camera's ID
  101759. * @return the new active camera or null if none found.
  101760. */
  101761. setActiveCameraByID(id: string): Nullable<Camera>;
  101762. /**
  101763. * sets the active camera of the scene using its name
  101764. * @param name defines the camera's name
  101765. * @returns the new active camera or null if none found.
  101766. */
  101767. setActiveCameraByName(name: string): Nullable<Camera>;
  101768. /**
  101769. * get an animation group using its name
  101770. * @param name defines the material's name
  101771. * @return the animation group or null if none found.
  101772. */
  101773. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101774. /**
  101775. * Get a material using its unique id
  101776. * @param uniqueId defines the material's unique id
  101777. * @return the material or null if none found.
  101778. */
  101779. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101780. /**
  101781. * get a material using its id
  101782. * @param id defines the material's ID
  101783. * @return the material or null if none found.
  101784. */
  101785. getMaterialByID(id: string): Nullable<Material>;
  101786. /**
  101787. * Gets a the last added material using a given id
  101788. * @param id defines the material's ID
  101789. * @return the last material with the given id or null if none found.
  101790. */
  101791. getLastMaterialByID(id: string): Nullable<Material>;
  101792. /**
  101793. * Gets a material using its name
  101794. * @param name defines the material's name
  101795. * @return the material or null if none found.
  101796. */
  101797. getMaterialByName(name: string): Nullable<Material>;
  101798. /**
  101799. * Get a texture using its unique id
  101800. * @param uniqueId defines the texture's unique id
  101801. * @return the texture or null if none found.
  101802. */
  101803. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101804. /**
  101805. * Gets a camera using its id
  101806. * @param id defines the id to look for
  101807. * @returns the camera or null if not found
  101808. */
  101809. getCameraByID(id: string): Nullable<Camera>;
  101810. /**
  101811. * Gets a camera using its unique id
  101812. * @param uniqueId defines the unique id to look for
  101813. * @returns the camera or null if not found
  101814. */
  101815. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101816. /**
  101817. * Gets a camera using its name
  101818. * @param name defines the camera's name
  101819. * @return the camera or null if none found.
  101820. */
  101821. getCameraByName(name: string): Nullable<Camera>;
  101822. /**
  101823. * Gets a bone using its id
  101824. * @param id defines the bone's id
  101825. * @return the bone or null if not found
  101826. */
  101827. getBoneByID(id: string): Nullable<Bone>;
  101828. /**
  101829. * Gets a bone using its id
  101830. * @param name defines the bone's name
  101831. * @return the bone or null if not found
  101832. */
  101833. getBoneByName(name: string): Nullable<Bone>;
  101834. /**
  101835. * Gets a light node using its name
  101836. * @param name defines the the light's name
  101837. * @return the light or null if none found.
  101838. */
  101839. getLightByName(name: string): Nullable<Light>;
  101840. /**
  101841. * Gets a light node using its id
  101842. * @param id defines the light's id
  101843. * @return the light or null if none found.
  101844. */
  101845. getLightByID(id: string): Nullable<Light>;
  101846. /**
  101847. * Gets a light node using its scene-generated unique ID
  101848. * @param uniqueId defines the light's unique id
  101849. * @return the light or null if none found.
  101850. */
  101851. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101852. /**
  101853. * Gets a particle system by id
  101854. * @param id defines the particle system id
  101855. * @return the corresponding system or null if none found
  101856. */
  101857. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101858. /**
  101859. * Gets a geometry using its ID
  101860. * @param id defines the geometry's id
  101861. * @return the geometry or null if none found.
  101862. */
  101863. getGeometryByID(id: string): Nullable<Geometry>;
  101864. private _getGeometryByUniqueID;
  101865. /**
  101866. * Add a new geometry to this scene
  101867. * @param geometry defines the geometry to be added to the scene.
  101868. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101869. * @return a boolean defining if the geometry was added or not
  101870. */
  101871. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101872. /**
  101873. * Removes an existing geometry
  101874. * @param geometry defines the geometry to be removed from the scene
  101875. * @return a boolean defining if the geometry was removed or not
  101876. */
  101877. removeGeometry(geometry: Geometry): boolean;
  101878. /**
  101879. * Gets the list of geometries attached to the scene
  101880. * @returns an array of Geometry
  101881. */
  101882. getGeometries(): Geometry[];
  101883. /**
  101884. * Gets the first added mesh found of a given ID
  101885. * @param id defines the id to search for
  101886. * @return the mesh found or null if not found at all
  101887. */
  101888. getMeshByID(id: string): Nullable<AbstractMesh>;
  101889. /**
  101890. * Gets a list of meshes using their id
  101891. * @param id defines the id to search for
  101892. * @returns a list of meshes
  101893. */
  101894. getMeshesByID(id: string): Array<AbstractMesh>;
  101895. /**
  101896. * Gets the first added transform node found of a given ID
  101897. * @param id defines the id to search for
  101898. * @return the found transform node or null if not found at all.
  101899. */
  101900. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101901. /**
  101902. * Gets a transform node with its auto-generated unique id
  101903. * @param uniqueId efines the unique id to search for
  101904. * @return the found transform node or null if not found at all.
  101905. */
  101906. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101907. /**
  101908. * Gets a list of transform nodes using their id
  101909. * @param id defines the id to search for
  101910. * @returns a list of transform nodes
  101911. */
  101912. getTransformNodesByID(id: string): Array<TransformNode>;
  101913. /**
  101914. * Gets a mesh with its auto-generated unique id
  101915. * @param uniqueId defines the unique id to search for
  101916. * @return the found mesh or null if not found at all.
  101917. */
  101918. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101919. /**
  101920. * Gets a the last added mesh using a given id
  101921. * @param id defines the id to search for
  101922. * @return the found mesh or null if not found at all.
  101923. */
  101924. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101925. /**
  101926. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101927. * @param id defines the id to search for
  101928. * @return the found node or null if not found at all
  101929. */
  101930. getLastEntryByID(id: string): Nullable<Node>;
  101931. /**
  101932. * Gets a node (Mesh, Camera, Light) using a given id
  101933. * @param id defines the id to search for
  101934. * @return the found node or null if not found at all
  101935. */
  101936. getNodeByID(id: string): Nullable<Node>;
  101937. /**
  101938. * Gets a node (Mesh, Camera, Light) using a given name
  101939. * @param name defines the name to search for
  101940. * @return the found node or null if not found at all.
  101941. */
  101942. getNodeByName(name: string): Nullable<Node>;
  101943. /**
  101944. * Gets a mesh using a given name
  101945. * @param name defines the name to search for
  101946. * @return the found mesh or null if not found at all.
  101947. */
  101948. getMeshByName(name: string): Nullable<AbstractMesh>;
  101949. /**
  101950. * Gets a transform node using a given name
  101951. * @param name defines the name to search for
  101952. * @return the found transform node or null if not found at all.
  101953. */
  101954. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101955. /**
  101956. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101957. * @param id defines the id to search for
  101958. * @return the found skeleton or null if not found at all.
  101959. */
  101960. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101961. /**
  101962. * Gets a skeleton using a given auto generated unique id
  101963. * @param uniqueId defines the unique id to search for
  101964. * @return the found skeleton or null if not found at all.
  101965. */
  101966. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101967. /**
  101968. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101969. * @param id defines the id to search for
  101970. * @return the found skeleton or null if not found at all.
  101971. */
  101972. getSkeletonById(id: string): Nullable<Skeleton>;
  101973. /**
  101974. * Gets a skeleton using a given name
  101975. * @param name defines the name to search for
  101976. * @return the found skeleton or null if not found at all.
  101977. */
  101978. getSkeletonByName(name: string): Nullable<Skeleton>;
  101979. /**
  101980. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101981. * @param id defines the id to search for
  101982. * @return the found morph target manager or null if not found at all.
  101983. */
  101984. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101985. /**
  101986. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101987. * @param id defines the id to search for
  101988. * @return the found morph target or null if not found at all.
  101989. */
  101990. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101991. /**
  101992. * Gets a boolean indicating if the given mesh is active
  101993. * @param mesh defines the mesh to look for
  101994. * @returns true if the mesh is in the active list
  101995. */
  101996. isActiveMesh(mesh: AbstractMesh): boolean;
  101997. /**
  101998. * Return a unique id as a string which can serve as an identifier for the scene
  101999. */
  102000. readonly uid: string;
  102001. /**
  102002. * Add an externaly attached data from its key.
  102003. * This method call will fail and return false, if such key already exists.
  102004. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102005. * @param key the unique key that identifies the data
  102006. * @param data the data object to associate to the key for this Engine instance
  102007. * @return true if no such key were already present and the data was added successfully, false otherwise
  102008. */
  102009. addExternalData<T>(key: string, data: T): boolean;
  102010. /**
  102011. * Get an externaly attached data from its key
  102012. * @param key the unique key that identifies the data
  102013. * @return the associated data, if present (can be null), or undefined if not present
  102014. */
  102015. getExternalData<T>(key: string): Nullable<T>;
  102016. /**
  102017. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102018. * @param key the unique key that identifies the data
  102019. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102020. * @return the associated data, can be null if the factory returned null.
  102021. */
  102022. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102023. /**
  102024. * Remove an externaly attached data from the Engine instance
  102025. * @param key the unique key that identifies the data
  102026. * @return true if the data was successfully removed, false if it doesn't exist
  102027. */
  102028. removeExternalData(key: string): boolean;
  102029. private _evaluateSubMesh;
  102030. /**
  102031. * Clear the processed materials smart array preventing retention point in material dispose.
  102032. */
  102033. freeProcessedMaterials(): void;
  102034. private _preventFreeActiveMeshesAndRenderingGroups;
  102035. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102036. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102037. * when disposing several meshes in a row or a hierarchy of meshes.
  102038. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102039. */
  102040. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102041. /**
  102042. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102043. */
  102044. freeActiveMeshes(): void;
  102045. /**
  102046. * Clear the info related to rendering groups preventing retention points during dispose.
  102047. */
  102048. freeRenderingGroups(): void;
  102049. /** @hidden */
  102050. _isInIntermediateRendering(): boolean;
  102051. /**
  102052. * Lambda returning the list of potentially active meshes.
  102053. */
  102054. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102055. /**
  102056. * Lambda returning the list of potentially active sub meshes.
  102057. */
  102058. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102059. /**
  102060. * Lambda returning the list of potentially intersecting sub meshes.
  102061. */
  102062. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102063. /**
  102064. * Lambda returning the list of potentially colliding sub meshes.
  102065. */
  102066. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102067. private _activeMeshesFrozen;
  102068. /**
  102069. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102070. * @returns the current scene
  102071. */
  102072. freezeActiveMeshes(): Scene;
  102073. /**
  102074. * Use this function to restart evaluating active meshes on every frame
  102075. * @returns the current scene
  102076. */
  102077. unfreezeActiveMeshes(): Scene;
  102078. private _evaluateActiveMeshes;
  102079. private _activeMesh;
  102080. /**
  102081. * Update the transform matrix to update from the current active camera
  102082. * @param force defines a boolean used to force the update even if cache is up to date
  102083. */
  102084. updateTransformMatrix(force?: boolean): void;
  102085. private _bindFrameBuffer;
  102086. /** @hidden */
  102087. _allowPostProcessClearColor: boolean;
  102088. /** @hidden */
  102089. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102090. private _processSubCameras;
  102091. private _checkIntersections;
  102092. /** @hidden */
  102093. _advancePhysicsEngineStep(step: number): void;
  102094. /**
  102095. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102096. */
  102097. getDeterministicFrameTime: () => number;
  102098. /** @hidden */
  102099. _animate(): void;
  102100. /** Execute all animations (for a frame) */
  102101. animate(): void;
  102102. /**
  102103. * Render the scene
  102104. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102105. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102106. */
  102107. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102108. /**
  102109. * Freeze all materials
  102110. * A frozen material will not be updatable but should be faster to render
  102111. */
  102112. freezeMaterials(): void;
  102113. /**
  102114. * Unfreeze all materials
  102115. * A frozen material will not be updatable but should be faster to render
  102116. */
  102117. unfreezeMaterials(): void;
  102118. /**
  102119. * Releases all held ressources
  102120. */
  102121. dispose(): void;
  102122. /**
  102123. * Gets if the scene is already disposed
  102124. */
  102125. readonly isDisposed: boolean;
  102126. /**
  102127. * Call this function to reduce memory footprint of the scene.
  102128. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102129. */
  102130. clearCachedVertexData(): void;
  102131. /**
  102132. * This function will remove the local cached buffer data from texture.
  102133. * It will save memory but will prevent the texture from being rebuilt
  102134. */
  102135. cleanCachedTextureBuffer(): void;
  102136. /**
  102137. * Get the world extend vectors with an optional filter
  102138. *
  102139. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102140. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102141. */
  102142. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102143. min: Vector3;
  102144. max: Vector3;
  102145. };
  102146. /**
  102147. * Creates a ray that can be used to pick in the scene
  102148. * @param x defines the x coordinate of the origin (on-screen)
  102149. * @param y defines the y coordinate of the origin (on-screen)
  102150. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102151. * @param camera defines the camera to use for the picking
  102152. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102153. * @returns a Ray
  102154. */
  102155. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102156. /**
  102157. * Creates a ray that can be used to pick in the scene
  102158. * @param x defines the x coordinate of the origin (on-screen)
  102159. * @param y defines the y coordinate of the origin (on-screen)
  102160. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102161. * @param result defines the ray where to store the picking ray
  102162. * @param camera defines the camera to use for the picking
  102163. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102164. * @returns the current scene
  102165. */
  102166. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102167. /**
  102168. * Creates a ray that can be used to pick in the scene
  102169. * @param x defines the x coordinate of the origin (on-screen)
  102170. * @param y defines the y coordinate of the origin (on-screen)
  102171. * @param camera defines the camera to use for the picking
  102172. * @returns a Ray
  102173. */
  102174. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102175. /**
  102176. * Creates a ray that can be used to pick in the scene
  102177. * @param x defines the x coordinate of the origin (on-screen)
  102178. * @param y defines the y coordinate of the origin (on-screen)
  102179. * @param result defines the ray where to store the picking ray
  102180. * @param camera defines the camera to use for the picking
  102181. * @returns the current scene
  102182. */
  102183. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102184. /** Launch a ray to try to pick a mesh in the scene
  102185. * @param x position on screen
  102186. * @param y position on screen
  102187. * @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
  102188. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102189. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102190. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102191. * @returns a PickingInfo
  102192. */
  102193. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102194. /** Use the given ray to pick a mesh in the scene
  102195. * @param ray The ray to use to pick meshes
  102196. * @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
  102197. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102198. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102199. * @returns a PickingInfo
  102200. */
  102201. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102202. /**
  102203. * Launch a ray to try to pick a mesh in the scene
  102204. * @param x X position on screen
  102205. * @param y Y position on screen
  102206. * @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
  102207. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102208. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102209. * @returns an array of PickingInfo
  102210. */
  102211. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102212. /**
  102213. * Launch a ray to try to pick a mesh in the scene
  102214. * @param ray Ray to use
  102215. * @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
  102216. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102217. * @returns an array of PickingInfo
  102218. */
  102219. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102220. /**
  102221. * Force the value of meshUnderPointer
  102222. * @param mesh defines the mesh to use
  102223. */
  102224. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102225. /**
  102226. * Gets the mesh under the pointer
  102227. * @returns a Mesh or null if no mesh is under the pointer
  102228. */
  102229. getPointerOverMesh(): Nullable<AbstractMesh>;
  102230. /** @hidden */
  102231. _rebuildGeometries(): void;
  102232. /** @hidden */
  102233. _rebuildTextures(): void;
  102234. private _getByTags;
  102235. /**
  102236. * Get a list of meshes by tags
  102237. * @param tagsQuery defines the tags query to use
  102238. * @param forEach defines a predicate used to filter results
  102239. * @returns an array of Mesh
  102240. */
  102241. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102242. /**
  102243. * Get a list of cameras by tags
  102244. * @param tagsQuery defines the tags query to use
  102245. * @param forEach defines a predicate used to filter results
  102246. * @returns an array of Camera
  102247. */
  102248. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102249. /**
  102250. * Get a list of lights by tags
  102251. * @param tagsQuery defines the tags query to use
  102252. * @param forEach defines a predicate used to filter results
  102253. * @returns an array of Light
  102254. */
  102255. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102256. /**
  102257. * Get a list of materials by tags
  102258. * @param tagsQuery defines the tags query to use
  102259. * @param forEach defines a predicate used to filter results
  102260. * @returns an array of Material
  102261. */
  102262. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102263. /**
  102264. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102265. * This allowed control for front to back rendering or reversly depending of the special needs.
  102266. *
  102267. * @param renderingGroupId The rendering group id corresponding to its index
  102268. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102269. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102270. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102271. */
  102272. 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;
  102273. /**
  102274. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102275. *
  102276. * @param renderingGroupId The rendering group id corresponding to its index
  102277. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102278. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102279. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102280. */
  102281. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102282. /**
  102283. * Gets the current auto clear configuration for one rendering group of the rendering
  102284. * manager.
  102285. * @param index the rendering group index to get the information for
  102286. * @returns The auto clear setup for the requested rendering group
  102287. */
  102288. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102289. private _blockMaterialDirtyMechanism;
  102290. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102291. blockMaterialDirtyMechanism: boolean;
  102292. /**
  102293. * Will flag all materials as dirty to trigger new shader compilation
  102294. * @param flag defines the flag used to specify which material part must be marked as dirty
  102295. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102296. */
  102297. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102298. /** @hidden */
  102299. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  102300. /** @hidden */
  102301. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102302. /** @hidden */
  102303. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  102304. /** @hidden */
  102305. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  102306. /** @hidden */
  102307. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102308. /** @hidden */
  102309. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102310. }
  102311. }
  102312. declare module BABYLON {
  102313. /**
  102314. * Set of assets to keep when moving a scene into an asset container.
  102315. */
  102316. export class KeepAssets extends AbstractScene {
  102317. }
  102318. /**
  102319. * Container with a set of assets that can be added or removed from a scene.
  102320. */
  102321. export class AssetContainer extends AbstractScene {
  102322. /**
  102323. * The scene the AssetContainer belongs to.
  102324. */
  102325. scene: Scene;
  102326. /**
  102327. * Instantiates an AssetContainer.
  102328. * @param scene The scene the AssetContainer belongs to.
  102329. */
  102330. constructor(scene: Scene);
  102331. /**
  102332. * Adds all the assets from the container to the scene.
  102333. */
  102334. addAllToScene(): void;
  102335. /**
  102336. * Removes all the assets in the container from the scene
  102337. */
  102338. removeAllFromScene(): void;
  102339. /**
  102340. * Disposes all the assets in the container
  102341. */
  102342. dispose(): void;
  102343. private _moveAssets;
  102344. /**
  102345. * Removes all the assets contained in the scene and adds them to the container.
  102346. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102347. */
  102348. moveAllFromScene(keepAssets?: KeepAssets): void;
  102349. /**
  102350. * 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.
  102351. * @returns the root mesh
  102352. */
  102353. createRootMesh(): Mesh;
  102354. }
  102355. }
  102356. declare module BABYLON {
  102357. /**
  102358. * Defines how the parser contract is defined.
  102359. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102360. */
  102361. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102362. /**
  102363. * Defines how the individual parser contract is defined.
  102364. * These parser can parse an individual asset
  102365. */
  102366. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102367. /**
  102368. * Base class of the scene acting as a container for the different elements composing a scene.
  102369. * This class is dynamically extended by the different components of the scene increasing
  102370. * flexibility and reducing coupling
  102371. */
  102372. export abstract class AbstractScene {
  102373. /**
  102374. * Stores the list of available parsers in the application.
  102375. */
  102376. private static _BabylonFileParsers;
  102377. /**
  102378. * Stores the list of available individual parsers in the application.
  102379. */
  102380. private static _IndividualBabylonFileParsers;
  102381. /**
  102382. * Adds a parser in the list of available ones
  102383. * @param name Defines the name of the parser
  102384. * @param parser Defines the parser to add
  102385. */
  102386. static AddParser(name: string, parser: BabylonFileParser): void;
  102387. /**
  102388. * Gets a general parser from the list of avaialble ones
  102389. * @param name Defines the name of the parser
  102390. * @returns the requested parser or null
  102391. */
  102392. static GetParser(name: string): Nullable<BabylonFileParser>;
  102393. /**
  102394. * Adds n individual parser in the list of available ones
  102395. * @param name Defines the name of the parser
  102396. * @param parser Defines the parser to add
  102397. */
  102398. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102399. /**
  102400. * Gets an individual parser from the list of avaialble ones
  102401. * @param name Defines the name of the parser
  102402. * @returns the requested parser or null
  102403. */
  102404. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102405. /**
  102406. * Parser json data and populate both a scene and its associated container object
  102407. * @param jsonData Defines the data to parse
  102408. * @param scene Defines the scene to parse the data for
  102409. * @param container Defines the container attached to the parsing sequence
  102410. * @param rootUrl Defines the root url of the data
  102411. */
  102412. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102413. /**
  102414. * Gets the list of root nodes (ie. nodes with no parent)
  102415. */
  102416. rootNodes: Node[];
  102417. /** All of the cameras added to this scene
  102418. * @see http://doc.babylonjs.com/babylon101/cameras
  102419. */
  102420. cameras: Camera[];
  102421. /**
  102422. * All of the lights added to this scene
  102423. * @see http://doc.babylonjs.com/babylon101/lights
  102424. */
  102425. lights: Light[];
  102426. /**
  102427. * All of the (abstract) meshes added to this scene
  102428. */
  102429. meshes: AbstractMesh[];
  102430. /**
  102431. * The list of skeletons added to the scene
  102432. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102433. */
  102434. skeletons: Skeleton[];
  102435. /**
  102436. * All of the particle systems added to this scene
  102437. * @see http://doc.babylonjs.com/babylon101/particles
  102438. */
  102439. particleSystems: IParticleSystem[];
  102440. /**
  102441. * Gets a list of Animations associated with the scene
  102442. */
  102443. animations: Animation[];
  102444. /**
  102445. * All of the animation groups added to this scene
  102446. * @see http://doc.babylonjs.com/how_to/group
  102447. */
  102448. animationGroups: AnimationGroup[];
  102449. /**
  102450. * All of the multi-materials added to this scene
  102451. * @see http://doc.babylonjs.com/how_to/multi_materials
  102452. */
  102453. multiMaterials: MultiMaterial[];
  102454. /**
  102455. * All of the materials added to this scene
  102456. * In the context of a Scene, it is not supposed to be modified manually.
  102457. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  102458. * Note also that the order of the Material wihin the array is not significant and might change.
  102459. * @see http://doc.babylonjs.com/babylon101/materials
  102460. */
  102461. materials: Material[];
  102462. /**
  102463. * The list of morph target managers added to the scene
  102464. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102465. */
  102466. morphTargetManagers: MorphTargetManager[];
  102467. /**
  102468. * The list of geometries used in the scene.
  102469. */
  102470. geometries: Geometry[];
  102471. /**
  102472. * All of the tranform nodes added to this scene
  102473. * In the context of a Scene, it is not supposed to be modified manually.
  102474. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102475. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102476. * @see http://doc.babylonjs.com/how_to/transformnode
  102477. */
  102478. transformNodes: TransformNode[];
  102479. /**
  102480. * ActionManagers available on the scene.
  102481. */
  102482. actionManagers: AbstractActionManager[];
  102483. /**
  102484. * Textures to keep.
  102485. */
  102486. textures: BaseTexture[];
  102487. /**
  102488. * Environment texture for the scene
  102489. */
  102490. environmentTexture: Nullable<BaseTexture>;
  102491. }
  102492. }
  102493. declare module BABYLON {
  102494. /**
  102495. * Interface used to define options for Sound class
  102496. */
  102497. export interface ISoundOptions {
  102498. /**
  102499. * Does the sound autoplay once loaded.
  102500. */
  102501. autoplay?: boolean;
  102502. /**
  102503. * Does the sound loop after it finishes playing once.
  102504. */
  102505. loop?: boolean;
  102506. /**
  102507. * Sound's volume
  102508. */
  102509. volume?: number;
  102510. /**
  102511. * Is it a spatial sound?
  102512. */
  102513. spatialSound?: boolean;
  102514. /**
  102515. * Maximum distance to hear that sound
  102516. */
  102517. maxDistance?: number;
  102518. /**
  102519. * Uses user defined attenuation function
  102520. */
  102521. useCustomAttenuation?: boolean;
  102522. /**
  102523. * Define the roll off factor of spatial sounds.
  102524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102525. */
  102526. rolloffFactor?: number;
  102527. /**
  102528. * Define the reference distance the sound should be heard perfectly.
  102529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102530. */
  102531. refDistance?: number;
  102532. /**
  102533. * Define the distance attenuation model the sound will follow.
  102534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102535. */
  102536. distanceModel?: string;
  102537. /**
  102538. * Defines the playback speed (1 by default)
  102539. */
  102540. playbackRate?: number;
  102541. /**
  102542. * Defines if the sound is from a streaming source
  102543. */
  102544. streaming?: boolean;
  102545. /**
  102546. * Defines an optional length (in seconds) inside the sound file
  102547. */
  102548. length?: number;
  102549. /**
  102550. * Defines an optional offset (in seconds) inside the sound file
  102551. */
  102552. offset?: number;
  102553. /**
  102554. * If true, URLs will not be required to state the audio file codec to use.
  102555. */
  102556. skipCodecCheck?: boolean;
  102557. }
  102558. /**
  102559. * Defines a sound that can be played in the application.
  102560. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102562. */
  102563. export class Sound {
  102564. /**
  102565. * The name of the sound in the scene.
  102566. */
  102567. name: string;
  102568. /**
  102569. * Does the sound autoplay once loaded.
  102570. */
  102571. autoplay: boolean;
  102572. /**
  102573. * Does the sound loop after it finishes playing once.
  102574. */
  102575. loop: boolean;
  102576. /**
  102577. * Does the sound use a custom attenuation curve to simulate the falloff
  102578. * happening when the source gets further away from the camera.
  102579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102580. */
  102581. useCustomAttenuation: boolean;
  102582. /**
  102583. * The sound track id this sound belongs to.
  102584. */
  102585. soundTrackId: number;
  102586. /**
  102587. * Is this sound currently played.
  102588. */
  102589. isPlaying: boolean;
  102590. /**
  102591. * Is this sound currently paused.
  102592. */
  102593. isPaused: boolean;
  102594. /**
  102595. * Does this sound enables spatial sound.
  102596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102597. */
  102598. spatialSound: boolean;
  102599. /**
  102600. * Define the reference distance the sound should be heard perfectly.
  102601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102602. */
  102603. refDistance: number;
  102604. /**
  102605. * Define the roll off factor of spatial sounds.
  102606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102607. */
  102608. rolloffFactor: number;
  102609. /**
  102610. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102612. */
  102613. maxDistance: number;
  102614. /**
  102615. * Define the distance attenuation model the sound will follow.
  102616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102617. */
  102618. distanceModel: string;
  102619. /**
  102620. * @hidden
  102621. * Back Compat
  102622. **/
  102623. onended: () => any;
  102624. /**
  102625. * Observable event when the current playing sound finishes.
  102626. */
  102627. onEndedObservable: Observable<Sound>;
  102628. private _panningModel;
  102629. private _playbackRate;
  102630. private _streaming;
  102631. private _startTime;
  102632. private _startOffset;
  102633. private _position;
  102634. /** @hidden */
  102635. _positionInEmitterSpace: boolean;
  102636. private _localDirection;
  102637. private _volume;
  102638. private _isReadyToPlay;
  102639. private _isDirectional;
  102640. private _readyToPlayCallback;
  102641. private _audioBuffer;
  102642. private _soundSource;
  102643. private _streamingSource;
  102644. private _soundPanner;
  102645. private _soundGain;
  102646. private _inputAudioNode;
  102647. private _outputAudioNode;
  102648. private _coneInnerAngle;
  102649. private _coneOuterAngle;
  102650. private _coneOuterGain;
  102651. private _scene;
  102652. private _connectedTransformNode;
  102653. private _customAttenuationFunction;
  102654. private _registerFunc;
  102655. private _isOutputConnected;
  102656. private _htmlAudioElement;
  102657. private _urlType;
  102658. private _length?;
  102659. private _offset?;
  102660. /** @hidden */
  102661. static _SceneComponentInitialization: (scene: Scene) => void;
  102662. /**
  102663. * Create a sound and attach it to a scene
  102664. * @param name Name of your sound
  102665. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102666. * @param scene defines the scene the sound belongs to
  102667. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102668. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102669. */
  102670. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102671. /**
  102672. * Release the sound and its associated resources
  102673. */
  102674. dispose(): void;
  102675. /**
  102676. * Gets if the sounds is ready to be played or not.
  102677. * @returns true if ready, otherwise false
  102678. */
  102679. isReady(): boolean;
  102680. private _soundLoaded;
  102681. /**
  102682. * Sets the data of the sound from an audiobuffer
  102683. * @param audioBuffer The audioBuffer containing the data
  102684. */
  102685. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102686. /**
  102687. * Updates the current sounds options such as maxdistance, loop...
  102688. * @param options A JSON object containing values named as the object properties
  102689. */
  102690. updateOptions(options: ISoundOptions): void;
  102691. private _createSpatialParameters;
  102692. private _updateSpatialParameters;
  102693. /**
  102694. * Switch the panning model to HRTF:
  102695. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102697. */
  102698. switchPanningModelToHRTF(): void;
  102699. /**
  102700. * Switch the panning model to Equal Power:
  102701. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102703. */
  102704. switchPanningModelToEqualPower(): void;
  102705. private _switchPanningModel;
  102706. /**
  102707. * Connect this sound to a sound track audio node like gain...
  102708. * @param soundTrackAudioNode the sound track audio node to connect to
  102709. */
  102710. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102711. /**
  102712. * Transform this sound into a directional source
  102713. * @param coneInnerAngle Size of the inner cone in degree
  102714. * @param coneOuterAngle Size of the outer cone in degree
  102715. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102716. */
  102717. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102718. /**
  102719. * Gets or sets the inner angle for the directional cone.
  102720. */
  102721. /**
  102722. * Gets or sets the inner angle for the directional cone.
  102723. */
  102724. directionalConeInnerAngle: number;
  102725. /**
  102726. * Gets or sets the outer angle for the directional cone.
  102727. */
  102728. /**
  102729. * Gets or sets the outer angle for the directional cone.
  102730. */
  102731. directionalConeOuterAngle: number;
  102732. /**
  102733. * Sets the position of the emitter if spatial sound is enabled
  102734. * @param newPosition Defines the new posisiton
  102735. */
  102736. setPosition(newPosition: Vector3): void;
  102737. /**
  102738. * Sets the local direction of the emitter if spatial sound is enabled
  102739. * @param newLocalDirection Defines the new local direction
  102740. */
  102741. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102742. private _updateDirection;
  102743. /** @hidden */
  102744. updateDistanceFromListener(): void;
  102745. /**
  102746. * Sets a new custom attenuation function for the sound.
  102747. * @param callback Defines the function used for the attenuation
  102748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102749. */
  102750. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102751. /**
  102752. * Play the sound
  102753. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102754. * @param offset (optional) Start the sound at a specific time in seconds
  102755. * @param length (optional) Sound duration (in seconds)
  102756. */
  102757. play(time?: number, offset?: number, length?: number): void;
  102758. private _onended;
  102759. /**
  102760. * Stop the sound
  102761. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102762. */
  102763. stop(time?: number): void;
  102764. /**
  102765. * Put the sound in pause
  102766. */
  102767. pause(): void;
  102768. /**
  102769. * Sets a dedicated volume for this sounds
  102770. * @param newVolume Define the new volume of the sound
  102771. * @param time Define time for gradual change to new volume
  102772. */
  102773. setVolume(newVolume: number, time?: number): void;
  102774. /**
  102775. * Set the sound play back rate
  102776. * @param newPlaybackRate Define the playback rate the sound should be played at
  102777. */
  102778. setPlaybackRate(newPlaybackRate: number): void;
  102779. /**
  102780. * Gets the volume of the sound.
  102781. * @returns the volume of the sound
  102782. */
  102783. getVolume(): number;
  102784. /**
  102785. * Attach the sound to a dedicated mesh
  102786. * @param transformNode The transform node to connect the sound with
  102787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102788. */
  102789. attachToMesh(transformNode: TransformNode): void;
  102790. /**
  102791. * Detach the sound from the previously attached mesh
  102792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102793. */
  102794. detachFromMesh(): void;
  102795. private _onRegisterAfterWorldMatrixUpdate;
  102796. /**
  102797. * Clone the current sound in the scene.
  102798. * @returns the new sound clone
  102799. */
  102800. clone(): Nullable<Sound>;
  102801. /**
  102802. * Gets the current underlying audio buffer containing the data
  102803. * @returns the audio buffer
  102804. */
  102805. getAudioBuffer(): Nullable<AudioBuffer>;
  102806. /**
  102807. * Serializes the Sound in a JSON representation
  102808. * @returns the JSON representation of the sound
  102809. */
  102810. serialize(): any;
  102811. /**
  102812. * Parse a JSON representation of a sound to innstantiate in a given scene
  102813. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102814. * @param scene Define the scene the new parsed sound should be created in
  102815. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102816. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102817. * @returns the newly parsed sound
  102818. */
  102819. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102820. }
  102821. }
  102822. declare module BABYLON {
  102823. /**
  102824. * This defines an action helpful to play a defined sound on a triggered action.
  102825. */
  102826. export class PlaySoundAction extends Action {
  102827. private _sound;
  102828. /**
  102829. * Instantiate the action
  102830. * @param triggerOptions defines the trigger options
  102831. * @param sound defines the sound to play
  102832. * @param condition defines the trigger related conditions
  102833. */
  102834. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102835. /** @hidden */
  102836. _prepare(): void;
  102837. /**
  102838. * Execute the action and play the sound.
  102839. */
  102840. execute(): void;
  102841. /**
  102842. * Serializes the actions and its related information.
  102843. * @param parent defines the object to serialize in
  102844. * @returns the serialized object
  102845. */
  102846. serialize(parent: any): any;
  102847. }
  102848. /**
  102849. * This defines an action helpful to stop a defined sound on a triggered action.
  102850. */
  102851. export class StopSoundAction extends Action {
  102852. private _sound;
  102853. /**
  102854. * Instantiate the action
  102855. * @param triggerOptions defines the trigger options
  102856. * @param sound defines the sound to stop
  102857. * @param condition defines the trigger related conditions
  102858. */
  102859. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102860. /** @hidden */
  102861. _prepare(): void;
  102862. /**
  102863. * Execute the action and stop the sound.
  102864. */
  102865. execute(): void;
  102866. /**
  102867. * Serializes the actions and its related information.
  102868. * @param parent defines the object to serialize in
  102869. * @returns the serialized object
  102870. */
  102871. serialize(parent: any): any;
  102872. }
  102873. }
  102874. declare module BABYLON {
  102875. /**
  102876. * This defines an action responsible to change the value of a property
  102877. * by interpolating between its current value and the newly set one once triggered.
  102878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102879. */
  102880. export class InterpolateValueAction extends Action {
  102881. /**
  102882. * Defines the path of the property where the value should be interpolated
  102883. */
  102884. propertyPath: string;
  102885. /**
  102886. * Defines the target value at the end of the interpolation.
  102887. */
  102888. value: any;
  102889. /**
  102890. * Defines the time it will take for the property to interpolate to the value.
  102891. */
  102892. duration: number;
  102893. /**
  102894. * Defines if the other scene animations should be stopped when the action has been triggered
  102895. */
  102896. stopOtherAnimations?: boolean;
  102897. /**
  102898. * Defines a callback raised once the interpolation animation has been done.
  102899. */
  102900. onInterpolationDone?: () => void;
  102901. /**
  102902. * Observable triggered once the interpolation animation has been done.
  102903. */
  102904. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102905. private _target;
  102906. private _effectiveTarget;
  102907. private _property;
  102908. /**
  102909. * Instantiate the action
  102910. * @param triggerOptions defines the trigger options
  102911. * @param target defines the object containing the value to interpolate
  102912. * @param propertyPath defines the path to the property in the target object
  102913. * @param value defines the target value at the end of the interpolation
  102914. * @param duration deines the time it will take for the property to interpolate to the value.
  102915. * @param condition defines the trigger related conditions
  102916. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102917. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102918. */
  102919. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102920. /** @hidden */
  102921. _prepare(): void;
  102922. /**
  102923. * Execute the action starts the value interpolation.
  102924. */
  102925. execute(): void;
  102926. /**
  102927. * Serializes the actions and its related information.
  102928. * @param parent defines the object to serialize in
  102929. * @returns the serialized object
  102930. */
  102931. serialize(parent: any): any;
  102932. }
  102933. }
  102934. declare module BABYLON {
  102935. /**
  102936. * Options allowed during the creation of a sound track.
  102937. */
  102938. export interface ISoundTrackOptions {
  102939. /**
  102940. * The volume the sound track should take during creation
  102941. */
  102942. volume?: number;
  102943. /**
  102944. * Define if the sound track is the main sound track of the scene
  102945. */
  102946. mainTrack?: boolean;
  102947. }
  102948. /**
  102949. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102950. * It will be also used in a future release to apply effects on a specific track.
  102951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102952. */
  102953. export class SoundTrack {
  102954. /**
  102955. * The unique identifier of the sound track in the scene.
  102956. */
  102957. id: number;
  102958. /**
  102959. * The list of sounds included in the sound track.
  102960. */
  102961. soundCollection: Array<Sound>;
  102962. private _outputAudioNode;
  102963. private _scene;
  102964. private _isMainTrack;
  102965. private _connectedAnalyser;
  102966. private _options;
  102967. private _isInitialized;
  102968. /**
  102969. * Creates a new sound track.
  102970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102971. * @param scene Define the scene the sound track belongs to
  102972. * @param options
  102973. */
  102974. constructor(scene: Scene, options?: ISoundTrackOptions);
  102975. private _initializeSoundTrackAudioGraph;
  102976. /**
  102977. * Release the sound track and its associated resources
  102978. */
  102979. dispose(): void;
  102980. /**
  102981. * Adds a sound to this sound track
  102982. * @param sound define the cound to add
  102983. * @ignoreNaming
  102984. */
  102985. AddSound(sound: Sound): void;
  102986. /**
  102987. * Removes a sound to this sound track
  102988. * @param sound define the cound to remove
  102989. * @ignoreNaming
  102990. */
  102991. RemoveSound(sound: Sound): void;
  102992. /**
  102993. * Set a global volume for the full sound track.
  102994. * @param newVolume Define the new volume of the sound track
  102995. */
  102996. setVolume(newVolume: number): void;
  102997. /**
  102998. * Switch the panning model to HRTF:
  102999. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103001. */
  103002. switchPanningModelToHRTF(): void;
  103003. /**
  103004. * Switch the panning model to Equal Power:
  103005. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103007. */
  103008. switchPanningModelToEqualPower(): void;
  103009. /**
  103010. * Connect the sound track to an audio analyser allowing some amazing
  103011. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103013. * @param analyser The analyser to connect to the engine
  103014. */
  103015. connectToAnalyser(analyser: Analyser): void;
  103016. }
  103017. }
  103018. declare module BABYLON {
  103019. interface AbstractScene {
  103020. /**
  103021. * The list of sounds used in the scene.
  103022. */
  103023. sounds: Nullable<Array<Sound>>;
  103024. }
  103025. interface Scene {
  103026. /**
  103027. * @hidden
  103028. * Backing field
  103029. */
  103030. _mainSoundTrack: SoundTrack;
  103031. /**
  103032. * The main sound track played by the scene.
  103033. * It cotains your primary collection of sounds.
  103034. */
  103035. mainSoundTrack: SoundTrack;
  103036. /**
  103037. * The list of sound tracks added to the scene
  103038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103039. */
  103040. soundTracks: Nullable<Array<SoundTrack>>;
  103041. /**
  103042. * Gets a sound using a given name
  103043. * @param name defines the name to search for
  103044. * @return the found sound or null if not found at all.
  103045. */
  103046. getSoundByName(name: string): Nullable<Sound>;
  103047. /**
  103048. * Gets or sets if audio support is enabled
  103049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103050. */
  103051. audioEnabled: boolean;
  103052. /**
  103053. * Gets or sets if audio will be output to headphones
  103054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103055. */
  103056. headphone: boolean;
  103057. /**
  103058. * Gets or sets custom audio listener position provider
  103059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103060. */
  103061. audioListenerPositionProvider: Nullable<() => Vector3>;
  103062. /**
  103063. * Gets or sets a refresh rate when using 3D audio positioning
  103064. */
  103065. audioPositioningRefreshRate: number;
  103066. }
  103067. /**
  103068. * Defines the sound scene component responsible to manage any sounds
  103069. * in a given scene.
  103070. */
  103071. export class AudioSceneComponent implements ISceneSerializableComponent {
  103072. /**
  103073. * The component name helpfull to identify the component in the list of scene components.
  103074. */
  103075. readonly name: string;
  103076. /**
  103077. * The scene the component belongs to.
  103078. */
  103079. scene: Scene;
  103080. private _audioEnabled;
  103081. /**
  103082. * Gets whether audio is enabled or not.
  103083. * Please use related enable/disable method to switch state.
  103084. */
  103085. readonly audioEnabled: boolean;
  103086. private _headphone;
  103087. /**
  103088. * Gets whether audio is outputing to headphone or not.
  103089. * Please use the according Switch methods to change output.
  103090. */
  103091. readonly headphone: boolean;
  103092. /**
  103093. * Gets or sets a refresh rate when using 3D audio positioning
  103094. */
  103095. audioPositioningRefreshRate: number;
  103096. private _audioListenerPositionProvider;
  103097. /**
  103098. * Gets the current audio listener position provider
  103099. */
  103100. /**
  103101. * Sets a custom listener position for all sounds in the scene
  103102. * By default, this is the position of the first active camera
  103103. */
  103104. audioListenerPositionProvider: Nullable<() => Vector3>;
  103105. /**
  103106. * Creates a new instance of the component for the given scene
  103107. * @param scene Defines the scene to register the component in
  103108. */
  103109. constructor(scene: Scene);
  103110. /**
  103111. * Registers the component in a given scene
  103112. */
  103113. register(): void;
  103114. /**
  103115. * Rebuilds the elements related to this component in case of
  103116. * context lost for instance.
  103117. */
  103118. rebuild(): void;
  103119. /**
  103120. * Serializes the component data to the specified json object
  103121. * @param serializationObject The object to serialize to
  103122. */
  103123. serialize(serializationObject: any): void;
  103124. /**
  103125. * Adds all the elements from the container to the scene
  103126. * @param container the container holding the elements
  103127. */
  103128. addFromContainer(container: AbstractScene): void;
  103129. /**
  103130. * Removes all the elements in the container from the scene
  103131. * @param container contains the elements to remove
  103132. * @param dispose if the removed element should be disposed (default: false)
  103133. */
  103134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103135. /**
  103136. * Disposes the component and the associated ressources.
  103137. */
  103138. dispose(): void;
  103139. /**
  103140. * Disables audio in the associated scene.
  103141. */
  103142. disableAudio(): void;
  103143. /**
  103144. * Enables audio in the associated scene.
  103145. */
  103146. enableAudio(): void;
  103147. /**
  103148. * Switch audio to headphone output.
  103149. */
  103150. switchAudioModeForHeadphones(): void;
  103151. /**
  103152. * Switch audio to normal speakers.
  103153. */
  103154. switchAudioModeForNormalSpeakers(): void;
  103155. private _cachedCameraDirection;
  103156. private _cachedCameraPosition;
  103157. private _lastCheck;
  103158. private _afterRender;
  103159. }
  103160. }
  103161. declare module BABYLON {
  103162. /**
  103163. * Wraps one or more Sound objects and selects one with random weight for playback.
  103164. */
  103165. export class WeightedSound {
  103166. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103167. loop: boolean;
  103168. private _coneInnerAngle;
  103169. private _coneOuterAngle;
  103170. private _volume;
  103171. /** A Sound is currently playing. */
  103172. isPlaying: boolean;
  103173. /** A Sound is currently paused. */
  103174. isPaused: boolean;
  103175. private _sounds;
  103176. private _weights;
  103177. private _currentIndex?;
  103178. /**
  103179. * Creates a new WeightedSound from the list of sounds given.
  103180. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103181. * @param sounds Array of Sounds that will be selected from.
  103182. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103183. */
  103184. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103185. /**
  103186. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103187. */
  103188. /**
  103189. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103190. */
  103191. directionalConeInnerAngle: number;
  103192. /**
  103193. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103194. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103195. */
  103196. /**
  103197. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103198. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103199. */
  103200. directionalConeOuterAngle: number;
  103201. /**
  103202. * Playback volume.
  103203. */
  103204. /**
  103205. * Playback volume.
  103206. */
  103207. volume: number;
  103208. private _onended;
  103209. /**
  103210. * Suspend playback
  103211. */
  103212. pause(): void;
  103213. /**
  103214. * Stop playback
  103215. */
  103216. stop(): void;
  103217. /**
  103218. * Start playback.
  103219. * @param startOffset Position the clip head at a specific time in seconds.
  103220. */
  103221. play(startOffset?: number): void;
  103222. }
  103223. }
  103224. declare module BABYLON {
  103225. /**
  103226. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103228. */
  103229. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103230. /**
  103231. * Gets the name of the behavior.
  103232. */
  103233. readonly name: string;
  103234. /**
  103235. * The easing function used by animations
  103236. */
  103237. static EasingFunction: BackEase;
  103238. /**
  103239. * The easing mode used by animations
  103240. */
  103241. static EasingMode: number;
  103242. /**
  103243. * The duration of the animation, in milliseconds
  103244. */
  103245. transitionDuration: number;
  103246. /**
  103247. * Length of the distance animated by the transition when lower radius is reached
  103248. */
  103249. lowerRadiusTransitionRange: number;
  103250. /**
  103251. * Length of the distance animated by the transition when upper radius is reached
  103252. */
  103253. upperRadiusTransitionRange: number;
  103254. private _autoTransitionRange;
  103255. /**
  103256. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103257. */
  103258. /**
  103259. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103260. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103261. */
  103262. autoTransitionRange: boolean;
  103263. private _attachedCamera;
  103264. private _onAfterCheckInputsObserver;
  103265. private _onMeshTargetChangedObserver;
  103266. /**
  103267. * Initializes the behavior.
  103268. */
  103269. init(): void;
  103270. /**
  103271. * Attaches the behavior to its arc rotate camera.
  103272. * @param camera Defines the camera to attach the behavior to
  103273. */
  103274. attach(camera: ArcRotateCamera): void;
  103275. /**
  103276. * Detaches the behavior from its current arc rotate camera.
  103277. */
  103278. detach(): void;
  103279. private _radiusIsAnimating;
  103280. private _radiusBounceTransition;
  103281. private _animatables;
  103282. private _cachedWheelPrecision;
  103283. /**
  103284. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103285. * @param radiusLimit The limit to check against.
  103286. * @return Bool to indicate if at limit.
  103287. */
  103288. private _isRadiusAtLimit;
  103289. /**
  103290. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103291. * @param radiusDelta The delta by which to animate to. Can be negative.
  103292. */
  103293. private _applyBoundRadiusAnimation;
  103294. /**
  103295. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103296. */
  103297. protected _clearAnimationLocks(): void;
  103298. /**
  103299. * Stops and removes all animations that have been applied to the camera
  103300. */
  103301. stopAllAnimations(): void;
  103302. }
  103303. }
  103304. declare module BABYLON {
  103305. /**
  103306. * 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.
  103307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103308. */
  103309. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103310. /**
  103311. * Gets the name of the behavior.
  103312. */
  103313. readonly name: string;
  103314. private _mode;
  103315. private _radiusScale;
  103316. private _positionScale;
  103317. private _defaultElevation;
  103318. private _elevationReturnTime;
  103319. private _elevationReturnWaitTime;
  103320. private _zoomStopsAnimation;
  103321. private _framingTime;
  103322. /**
  103323. * The easing function used by animations
  103324. */
  103325. static EasingFunction: ExponentialEase;
  103326. /**
  103327. * The easing mode used by animations
  103328. */
  103329. static EasingMode: number;
  103330. /**
  103331. * Sets the current mode used by the behavior
  103332. */
  103333. /**
  103334. * Gets current mode used by the behavior.
  103335. */
  103336. mode: number;
  103337. /**
  103338. * Sets the scale applied to the radius (1 by default)
  103339. */
  103340. /**
  103341. * Gets the scale applied to the radius
  103342. */
  103343. radiusScale: number;
  103344. /**
  103345. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103346. */
  103347. /**
  103348. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103349. */
  103350. positionScale: number;
  103351. /**
  103352. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103353. * behaviour is triggered, in radians.
  103354. */
  103355. /**
  103356. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103357. * behaviour is triggered, in radians.
  103358. */
  103359. defaultElevation: number;
  103360. /**
  103361. * Sets the time (in milliseconds) taken to return to the default beta position.
  103362. * Negative value indicates camera should not return to default.
  103363. */
  103364. /**
  103365. * Gets the time (in milliseconds) taken to return to the default beta position.
  103366. * Negative value indicates camera should not return to default.
  103367. */
  103368. elevationReturnTime: number;
  103369. /**
  103370. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103371. */
  103372. /**
  103373. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103374. */
  103375. elevationReturnWaitTime: number;
  103376. /**
  103377. * Sets the flag that indicates if user zooming should stop animation.
  103378. */
  103379. /**
  103380. * Gets the flag that indicates if user zooming should stop animation.
  103381. */
  103382. zoomStopsAnimation: boolean;
  103383. /**
  103384. * Sets the transition time when framing the mesh, in milliseconds
  103385. */
  103386. /**
  103387. * Gets the transition time when framing the mesh, in milliseconds
  103388. */
  103389. framingTime: number;
  103390. /**
  103391. * Define if the behavior should automatically change the configured
  103392. * camera limits and sensibilities.
  103393. */
  103394. autoCorrectCameraLimitsAndSensibility: boolean;
  103395. private _onPrePointerObservableObserver;
  103396. private _onAfterCheckInputsObserver;
  103397. private _onMeshTargetChangedObserver;
  103398. private _attachedCamera;
  103399. private _isPointerDown;
  103400. private _lastInteractionTime;
  103401. /**
  103402. * Initializes the behavior.
  103403. */
  103404. init(): void;
  103405. /**
  103406. * Attaches the behavior to its arc rotate camera.
  103407. * @param camera Defines the camera to attach the behavior to
  103408. */
  103409. attach(camera: ArcRotateCamera): void;
  103410. /**
  103411. * Detaches the behavior from its current arc rotate camera.
  103412. */
  103413. detach(): void;
  103414. private _animatables;
  103415. private _betaIsAnimating;
  103416. private _betaTransition;
  103417. private _radiusTransition;
  103418. private _vectorTransition;
  103419. /**
  103420. * Targets the given mesh and updates zoom level accordingly.
  103421. * @param mesh The mesh to target.
  103422. * @param radius Optional. If a cached radius position already exists, overrides default.
  103423. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103424. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103425. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103426. */
  103427. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103428. /**
  103429. * Targets the given mesh with its children and updates zoom level accordingly.
  103430. * @param mesh The mesh to target.
  103431. * @param radius Optional. If a cached radius position already exists, overrides default.
  103432. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103435. */
  103436. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103437. /**
  103438. * Targets the given meshes with their children and updates zoom level accordingly.
  103439. * @param meshes The mesh to target.
  103440. * @param radius Optional. If a cached radius position already exists, overrides default.
  103441. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103442. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103443. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103444. */
  103445. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103446. /**
  103447. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103448. * @param minimumWorld Determines the smaller position of the bounding box extend
  103449. * @param maximumWorld Determines the bigger position of the bounding box extend
  103450. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103451. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103452. */
  103453. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103454. /**
  103455. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103456. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103457. * frustum width.
  103458. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103459. * to fully enclose the mesh in the viewing frustum.
  103460. */
  103461. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103462. /**
  103463. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103464. * is automatically returned to its default position (expected to be above ground plane).
  103465. */
  103466. private _maintainCameraAboveGround;
  103467. /**
  103468. * Returns the frustum slope based on the canvas ratio and camera FOV
  103469. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103470. */
  103471. private _getFrustumSlope;
  103472. /**
  103473. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103474. */
  103475. private _clearAnimationLocks;
  103476. /**
  103477. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103478. */
  103479. private _applyUserInteraction;
  103480. /**
  103481. * Stops and removes all animations that have been applied to the camera
  103482. */
  103483. stopAllAnimations(): void;
  103484. /**
  103485. * Gets a value indicating if the user is moving the camera
  103486. */
  103487. readonly isUserIsMoving: boolean;
  103488. /**
  103489. * The camera can move all the way towards the mesh.
  103490. */
  103491. static IgnoreBoundsSizeMode: number;
  103492. /**
  103493. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103494. */
  103495. static FitFrustumSidesMode: number;
  103496. }
  103497. }
  103498. declare module BABYLON {
  103499. /**
  103500. * Base class for Camera Pointer Inputs.
  103501. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103502. * for example usage.
  103503. */
  103504. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103505. /**
  103506. * Defines the camera the input is attached to.
  103507. */
  103508. abstract camera: Camera;
  103509. /**
  103510. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103511. */
  103512. protected _altKey: boolean;
  103513. protected _ctrlKey: boolean;
  103514. protected _metaKey: boolean;
  103515. protected _shiftKey: boolean;
  103516. /**
  103517. * Which mouse buttons were pressed at time of last mouse event.
  103518. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103519. */
  103520. protected _buttonsPressed: number;
  103521. /**
  103522. * Defines the buttons associated with the input to handle camera move.
  103523. */
  103524. buttons: number[];
  103525. /**
  103526. * Attach the input controls to a specific dom element to get the input from.
  103527. * @param element Defines the element the controls should be listened from
  103528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103529. */
  103530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103531. /**
  103532. * Detach the current controls from the specified dom element.
  103533. * @param element Defines the element to stop listening the inputs from
  103534. */
  103535. detachControl(element: Nullable<HTMLElement>): void;
  103536. /**
  103537. * Gets the class name of the current input.
  103538. * @returns the class name
  103539. */
  103540. getClassName(): string;
  103541. /**
  103542. * Get the friendly name associated with the input class.
  103543. * @returns the input friendly name
  103544. */
  103545. getSimpleName(): string;
  103546. /**
  103547. * Called on pointer POINTERDOUBLETAP event.
  103548. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103549. */
  103550. protected onDoubleTap(type: string): void;
  103551. /**
  103552. * Called on pointer POINTERMOVE event if only a single touch is active.
  103553. * Override this method to provide functionality.
  103554. */
  103555. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103556. /**
  103557. * Called on pointer POINTERMOVE event if multiple touches are active.
  103558. * Override this method to provide functionality.
  103559. */
  103560. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103561. /**
  103562. * Called on JS contextmenu event.
  103563. * Override this method to provide functionality.
  103564. */
  103565. protected onContextMenu(evt: PointerEvent): void;
  103566. /**
  103567. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103568. * press.
  103569. * Override this method to provide functionality.
  103570. */
  103571. protected onButtonDown(evt: PointerEvent): void;
  103572. /**
  103573. * Called each time a new POINTERUP event occurs. Ie, for each button
  103574. * release.
  103575. * Override this method to provide functionality.
  103576. */
  103577. protected onButtonUp(evt: PointerEvent): void;
  103578. /**
  103579. * Called when window becomes inactive.
  103580. * Override this method to provide functionality.
  103581. */
  103582. protected onLostFocus(): void;
  103583. private _pointerInput;
  103584. private _observer;
  103585. private _onLostFocus;
  103586. private pointA;
  103587. private pointB;
  103588. }
  103589. }
  103590. declare module BABYLON {
  103591. /**
  103592. * Manage the pointers inputs to control an arc rotate camera.
  103593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103594. */
  103595. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103596. /**
  103597. * Defines the camera the input is attached to.
  103598. */
  103599. camera: ArcRotateCamera;
  103600. /**
  103601. * Gets the class name of the current input.
  103602. * @returns the class name
  103603. */
  103604. getClassName(): string;
  103605. /**
  103606. * Defines the buttons associated with the input to handle camera move.
  103607. */
  103608. buttons: number[];
  103609. /**
  103610. * Defines the pointer angular sensibility along the X axis or how fast is
  103611. * the camera rotating.
  103612. */
  103613. angularSensibilityX: number;
  103614. /**
  103615. * Defines the pointer angular sensibility along the Y axis or how fast is
  103616. * the camera rotating.
  103617. */
  103618. angularSensibilityY: number;
  103619. /**
  103620. * Defines the pointer pinch precision or how fast is the camera zooming.
  103621. */
  103622. pinchPrecision: number;
  103623. /**
  103624. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103625. * from 0.
  103626. * It defines the percentage of current camera.radius to use as delta when
  103627. * pinch zoom is used.
  103628. */
  103629. pinchDeltaPercentage: number;
  103630. /**
  103631. * Defines the pointer panning sensibility or how fast is the camera moving.
  103632. */
  103633. panningSensibility: number;
  103634. /**
  103635. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103636. */
  103637. multiTouchPanning: boolean;
  103638. /**
  103639. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103640. * zoom (pinch) through multitouch.
  103641. */
  103642. multiTouchPanAndZoom: boolean;
  103643. /**
  103644. * Revers pinch action direction.
  103645. */
  103646. pinchInwards: boolean;
  103647. private _isPanClick;
  103648. private _twoFingerActivityCount;
  103649. private _isPinching;
  103650. /**
  103651. * Called on pointer POINTERMOVE event if only a single touch is active.
  103652. */
  103653. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103654. /**
  103655. * Called on pointer POINTERDOUBLETAP event.
  103656. */
  103657. protected onDoubleTap(type: string): void;
  103658. /**
  103659. * Called on pointer POINTERMOVE event if multiple touches are active.
  103660. */
  103661. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103662. /**
  103663. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103664. * press.
  103665. */
  103666. protected onButtonDown(evt: PointerEvent): void;
  103667. /**
  103668. * Called each time a new POINTERUP event occurs. Ie, for each button
  103669. * release.
  103670. */
  103671. protected onButtonUp(evt: PointerEvent): void;
  103672. /**
  103673. * Called when window becomes inactive.
  103674. */
  103675. protected onLostFocus(): void;
  103676. }
  103677. }
  103678. declare module BABYLON {
  103679. /**
  103680. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103682. */
  103683. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103684. /**
  103685. * Defines the camera the input is attached to.
  103686. */
  103687. camera: ArcRotateCamera;
  103688. /**
  103689. * Defines the list of key codes associated with the up action (increase alpha)
  103690. */
  103691. keysUp: number[];
  103692. /**
  103693. * Defines the list of key codes associated with the down action (decrease alpha)
  103694. */
  103695. keysDown: number[];
  103696. /**
  103697. * Defines the list of key codes associated with the left action (increase beta)
  103698. */
  103699. keysLeft: number[];
  103700. /**
  103701. * Defines the list of key codes associated with the right action (decrease beta)
  103702. */
  103703. keysRight: number[];
  103704. /**
  103705. * Defines the list of key codes associated with the reset action.
  103706. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103707. */
  103708. keysReset: number[];
  103709. /**
  103710. * Defines the panning sensibility of the inputs.
  103711. * (How fast is the camera paning)
  103712. */
  103713. panningSensibility: number;
  103714. /**
  103715. * Defines the zooming sensibility of the inputs.
  103716. * (How fast is the camera zooming)
  103717. */
  103718. zoomingSensibility: number;
  103719. /**
  103720. * Defines wether maintaining the alt key down switch the movement mode from
  103721. * orientation to zoom.
  103722. */
  103723. useAltToZoom: boolean;
  103724. /**
  103725. * Rotation speed of the camera
  103726. */
  103727. angularSpeed: number;
  103728. private _keys;
  103729. private _ctrlPressed;
  103730. private _altPressed;
  103731. private _onCanvasBlurObserver;
  103732. private _onKeyboardObserver;
  103733. private _engine;
  103734. private _scene;
  103735. /**
  103736. * Attach the input controls to a specific dom element to get the input from.
  103737. * @param element Defines the element the controls should be listened from
  103738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103739. */
  103740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103741. /**
  103742. * Detach the current controls from the specified dom element.
  103743. * @param element Defines the element to stop listening the inputs from
  103744. */
  103745. detachControl(element: Nullable<HTMLElement>): void;
  103746. /**
  103747. * Update the current camera state depending on the inputs that have been used this frame.
  103748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103749. */
  103750. checkInputs(): void;
  103751. /**
  103752. * Gets the class name of the current intput.
  103753. * @returns the class name
  103754. */
  103755. getClassName(): string;
  103756. /**
  103757. * Get the friendly name associated with the input class.
  103758. * @returns the input friendly name
  103759. */
  103760. getSimpleName(): string;
  103761. }
  103762. }
  103763. declare module BABYLON {
  103764. /**
  103765. * Manage the mouse wheel inputs to control an arc rotate camera.
  103766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103767. */
  103768. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103769. /**
  103770. * Defines the camera the input is attached to.
  103771. */
  103772. camera: ArcRotateCamera;
  103773. /**
  103774. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103775. */
  103776. wheelPrecision: number;
  103777. /**
  103778. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103779. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103780. */
  103781. wheelDeltaPercentage: number;
  103782. private _wheel;
  103783. private _observer;
  103784. private computeDeltaFromMouseWheelLegacyEvent;
  103785. /**
  103786. * Attach the input controls to a specific dom element to get the input from.
  103787. * @param element Defines the element the controls should be listened from
  103788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103789. */
  103790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103791. /**
  103792. * Detach the current controls from the specified dom element.
  103793. * @param element Defines the element to stop listening the inputs from
  103794. */
  103795. detachControl(element: Nullable<HTMLElement>): void;
  103796. /**
  103797. * Gets the class name of the current intput.
  103798. * @returns the class name
  103799. */
  103800. getClassName(): string;
  103801. /**
  103802. * Get the friendly name associated with the input class.
  103803. * @returns the input friendly name
  103804. */
  103805. getSimpleName(): string;
  103806. }
  103807. }
  103808. declare module BABYLON {
  103809. /**
  103810. * Default Inputs manager for the ArcRotateCamera.
  103811. * It groups all the default supported inputs for ease of use.
  103812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103813. */
  103814. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103815. /**
  103816. * Instantiates a new ArcRotateCameraInputsManager.
  103817. * @param camera Defines the camera the inputs belong to
  103818. */
  103819. constructor(camera: ArcRotateCamera);
  103820. /**
  103821. * Add mouse wheel input support to the input manager.
  103822. * @returns the current input manager
  103823. */
  103824. addMouseWheel(): ArcRotateCameraInputsManager;
  103825. /**
  103826. * Add pointers input support to the input manager.
  103827. * @returns the current input manager
  103828. */
  103829. addPointers(): ArcRotateCameraInputsManager;
  103830. /**
  103831. * Add keyboard input support to the input manager.
  103832. * @returns the current input manager
  103833. */
  103834. addKeyboard(): ArcRotateCameraInputsManager;
  103835. }
  103836. }
  103837. declare module BABYLON {
  103838. /**
  103839. * This represents an orbital type of camera.
  103840. *
  103841. * 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.
  103842. * 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.
  103843. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103844. */
  103845. export class ArcRotateCamera extends TargetCamera {
  103846. /**
  103847. * Defines the rotation angle of the camera along the longitudinal axis.
  103848. */
  103849. alpha: number;
  103850. /**
  103851. * Defines the rotation angle of the camera along the latitudinal axis.
  103852. */
  103853. beta: number;
  103854. /**
  103855. * Defines the radius of the camera from it s target point.
  103856. */
  103857. radius: number;
  103858. protected _target: Vector3;
  103859. protected _targetHost: Nullable<AbstractMesh>;
  103860. /**
  103861. * Defines the target point of the camera.
  103862. * The camera looks towards it form the radius distance.
  103863. */
  103864. target: Vector3;
  103865. /**
  103866. * Define the current local position of the camera in the scene
  103867. */
  103868. position: Vector3;
  103869. protected _upVector: Vector3;
  103870. protected _upToYMatrix: Matrix;
  103871. protected _YToUpMatrix: Matrix;
  103872. /**
  103873. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103874. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103875. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103876. */
  103877. upVector: Vector3;
  103878. /**
  103879. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103880. */
  103881. setMatUp(): void;
  103882. /**
  103883. * Current inertia value on the longitudinal axis.
  103884. * The bigger this number the longer it will take for the camera to stop.
  103885. */
  103886. inertialAlphaOffset: number;
  103887. /**
  103888. * Current inertia value on the latitudinal axis.
  103889. * The bigger this number the longer it will take for the camera to stop.
  103890. */
  103891. inertialBetaOffset: number;
  103892. /**
  103893. * Current inertia value on the radius axis.
  103894. * The bigger this number the longer it will take for the camera to stop.
  103895. */
  103896. inertialRadiusOffset: number;
  103897. /**
  103898. * Minimum allowed angle on the longitudinal axis.
  103899. * This can help limiting how the Camera is able to move in the scene.
  103900. */
  103901. lowerAlphaLimit: Nullable<number>;
  103902. /**
  103903. * Maximum allowed angle on the longitudinal axis.
  103904. * This can help limiting how the Camera is able to move in the scene.
  103905. */
  103906. upperAlphaLimit: Nullable<number>;
  103907. /**
  103908. * Minimum allowed angle on the latitudinal axis.
  103909. * This can help limiting how the Camera is able to move in the scene.
  103910. */
  103911. lowerBetaLimit: number;
  103912. /**
  103913. * Maximum allowed angle on the latitudinal axis.
  103914. * This can help limiting how the Camera is able to move in the scene.
  103915. */
  103916. upperBetaLimit: number;
  103917. /**
  103918. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103919. * This can help limiting how the Camera is able to move in the scene.
  103920. */
  103921. lowerRadiusLimit: Nullable<number>;
  103922. /**
  103923. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103924. * This can help limiting how the Camera is able to move in the scene.
  103925. */
  103926. upperRadiusLimit: Nullable<number>;
  103927. /**
  103928. * Defines the current inertia value used during panning of the camera along the X axis.
  103929. */
  103930. inertialPanningX: number;
  103931. /**
  103932. * Defines the current inertia value used during panning of the camera along the Y axis.
  103933. */
  103934. inertialPanningY: number;
  103935. /**
  103936. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103937. * Basically if your fingers moves away from more than this distance you will be considered
  103938. * in pinch mode.
  103939. */
  103940. pinchToPanMaxDistance: number;
  103941. /**
  103942. * Defines the maximum distance the camera can pan.
  103943. * This could help keeping the cammera always in your scene.
  103944. */
  103945. panningDistanceLimit: Nullable<number>;
  103946. /**
  103947. * Defines the target of the camera before paning.
  103948. */
  103949. panningOriginTarget: Vector3;
  103950. /**
  103951. * Defines the value of the inertia used during panning.
  103952. * 0 would mean stop inertia and one would mean no decelleration at all.
  103953. */
  103954. panningInertia: number;
  103955. /**
  103956. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103957. */
  103958. angularSensibilityX: number;
  103959. /**
  103960. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103961. */
  103962. angularSensibilityY: number;
  103963. /**
  103964. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103965. */
  103966. pinchPrecision: number;
  103967. /**
  103968. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103969. * It will be used instead of pinchDeltaPrecision if different from 0.
  103970. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103971. */
  103972. pinchDeltaPercentage: number;
  103973. /**
  103974. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103975. */
  103976. panningSensibility: number;
  103977. /**
  103978. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103979. */
  103980. keysUp: number[];
  103981. /**
  103982. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103983. */
  103984. keysDown: number[];
  103985. /**
  103986. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103987. */
  103988. keysLeft: number[];
  103989. /**
  103990. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103991. */
  103992. keysRight: number[];
  103993. /**
  103994. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103995. */
  103996. wheelPrecision: number;
  103997. /**
  103998. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103999. * It will be used instead of pinchDeltaPrecision if different from 0.
  104000. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104001. */
  104002. wheelDeltaPercentage: number;
  104003. /**
  104004. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104005. */
  104006. zoomOnFactor: number;
  104007. /**
  104008. * Defines a screen offset for the camera position.
  104009. */
  104010. targetScreenOffset: Vector2;
  104011. /**
  104012. * Allows the camera to be completely reversed.
  104013. * If false the camera can not arrive upside down.
  104014. */
  104015. allowUpsideDown: boolean;
  104016. /**
  104017. * Define if double tap/click is used to restore the previously saved state of the camera.
  104018. */
  104019. useInputToRestoreState: boolean;
  104020. /** @hidden */
  104021. _viewMatrix: Matrix;
  104022. /** @hidden */
  104023. _useCtrlForPanning: boolean;
  104024. /** @hidden */
  104025. _panningMouseButton: number;
  104026. /**
  104027. * Defines the input associated to the camera.
  104028. */
  104029. inputs: ArcRotateCameraInputsManager;
  104030. /** @hidden */
  104031. _reset: () => void;
  104032. /**
  104033. * Defines the allowed panning axis.
  104034. */
  104035. panningAxis: Vector3;
  104036. protected _localDirection: Vector3;
  104037. protected _transformedDirection: Vector3;
  104038. private _bouncingBehavior;
  104039. /**
  104040. * Gets the bouncing behavior of the camera if it has been enabled.
  104041. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104042. */
  104043. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104044. /**
  104045. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104046. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104047. */
  104048. useBouncingBehavior: boolean;
  104049. private _framingBehavior;
  104050. /**
  104051. * Gets the framing behavior of the camera if it has been enabled.
  104052. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104053. */
  104054. readonly framingBehavior: Nullable<FramingBehavior>;
  104055. /**
  104056. * Defines if the framing behavior of the camera is enabled on the camera.
  104057. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104058. */
  104059. useFramingBehavior: boolean;
  104060. private _autoRotationBehavior;
  104061. /**
  104062. * Gets the auto rotation behavior of the camera if it has been enabled.
  104063. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104064. */
  104065. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104066. /**
  104067. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104068. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104069. */
  104070. useAutoRotationBehavior: boolean;
  104071. /**
  104072. * Observable triggered when the mesh target has been changed on the camera.
  104073. */
  104074. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104075. /**
  104076. * Event raised when the camera is colliding with a mesh.
  104077. */
  104078. onCollide: (collidedMesh: AbstractMesh) => void;
  104079. /**
  104080. * Defines whether the camera should check collision with the objects oh the scene.
  104081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104082. */
  104083. checkCollisions: boolean;
  104084. /**
  104085. * Defines the collision radius of the camera.
  104086. * This simulates a sphere around the camera.
  104087. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104088. */
  104089. collisionRadius: Vector3;
  104090. protected _collider: Collider;
  104091. protected _previousPosition: Vector3;
  104092. protected _collisionVelocity: Vector3;
  104093. protected _newPosition: Vector3;
  104094. protected _previousAlpha: number;
  104095. protected _previousBeta: number;
  104096. protected _previousRadius: number;
  104097. protected _collisionTriggered: boolean;
  104098. protected _targetBoundingCenter: Nullable<Vector3>;
  104099. private _computationVector;
  104100. /**
  104101. * Instantiates a new ArcRotateCamera in a given scene
  104102. * @param name Defines the name of the camera
  104103. * @param alpha Defines the camera rotation along the logitudinal axis
  104104. * @param beta Defines the camera rotation along the latitudinal axis
  104105. * @param radius Defines the camera distance from its target
  104106. * @param target Defines the camera target
  104107. * @param scene Defines the scene the camera belongs to
  104108. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104109. */
  104110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104111. /** @hidden */
  104112. _initCache(): void;
  104113. /** @hidden */
  104114. _updateCache(ignoreParentClass?: boolean): void;
  104115. protected _getTargetPosition(): Vector3;
  104116. private _storedAlpha;
  104117. private _storedBeta;
  104118. private _storedRadius;
  104119. private _storedTarget;
  104120. private _storedTargetScreenOffset;
  104121. /**
  104122. * Stores the current state of the camera (alpha, beta, radius and target)
  104123. * @returns the camera itself
  104124. */
  104125. storeState(): Camera;
  104126. /**
  104127. * @hidden
  104128. * Restored camera state. You must call storeState() first
  104129. */
  104130. _restoreStateValues(): boolean;
  104131. /** @hidden */
  104132. _isSynchronizedViewMatrix(): boolean;
  104133. /**
  104134. * Attached controls to the current camera.
  104135. * @param element Defines the element the controls should be listened from
  104136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104137. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104138. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104139. */
  104140. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104141. /**
  104142. * Detach the current controls from the camera.
  104143. * The camera will stop reacting to inputs.
  104144. * @param element Defines the element to stop listening the inputs from
  104145. */
  104146. detachControl(element: HTMLElement): void;
  104147. /** @hidden */
  104148. _checkInputs(): void;
  104149. protected _checkLimits(): void;
  104150. /**
  104151. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104152. */
  104153. rebuildAnglesAndRadius(): void;
  104154. /**
  104155. * Use a position to define the current camera related information like alpha, beta and radius
  104156. * @param position Defines the position to set the camera at
  104157. */
  104158. setPosition(position: Vector3): void;
  104159. /**
  104160. * Defines the target the camera should look at.
  104161. * This will automatically adapt alpha beta and radius to fit within the new target.
  104162. * @param target Defines the new target as a Vector or a mesh
  104163. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104164. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104165. */
  104166. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104167. /** @hidden */
  104168. _getViewMatrix(): Matrix;
  104169. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104170. /**
  104171. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104172. * @param meshes Defines the mesh to zoom on
  104173. * @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)
  104174. */
  104175. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104176. /**
  104177. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104178. * The target will be changed but the radius
  104179. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104180. * @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)
  104181. */
  104182. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104183. min: Vector3;
  104184. max: Vector3;
  104185. distance: number;
  104186. }, doNotUpdateMaxZ?: boolean): void;
  104187. /**
  104188. * @override
  104189. * Override Camera.createRigCamera
  104190. */
  104191. createRigCamera(name: string, cameraIndex: number): Camera;
  104192. /**
  104193. * @hidden
  104194. * @override
  104195. * Override Camera._updateRigCameras
  104196. */
  104197. _updateRigCameras(): void;
  104198. /**
  104199. * Destroy the camera and release the current resources hold by it.
  104200. */
  104201. dispose(): void;
  104202. /**
  104203. * Gets the current object class name.
  104204. * @return the class name
  104205. */
  104206. getClassName(): string;
  104207. }
  104208. }
  104209. declare module BABYLON {
  104210. /**
  104211. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104212. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104213. */
  104214. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104215. /**
  104216. * Gets the name of the behavior.
  104217. */
  104218. readonly name: string;
  104219. private _zoomStopsAnimation;
  104220. private _idleRotationSpeed;
  104221. private _idleRotationWaitTime;
  104222. private _idleRotationSpinupTime;
  104223. /**
  104224. * Sets the flag that indicates if user zooming should stop animation.
  104225. */
  104226. /**
  104227. * Gets the flag that indicates if user zooming should stop animation.
  104228. */
  104229. zoomStopsAnimation: boolean;
  104230. /**
  104231. * Sets the default speed at which the camera rotates around the model.
  104232. */
  104233. /**
  104234. * Gets the default speed at which the camera rotates around the model.
  104235. */
  104236. idleRotationSpeed: number;
  104237. /**
  104238. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104239. */
  104240. /**
  104241. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104242. */
  104243. idleRotationWaitTime: number;
  104244. /**
  104245. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104246. */
  104247. /**
  104248. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104249. */
  104250. idleRotationSpinupTime: number;
  104251. /**
  104252. * Gets a value indicating if the camera is currently rotating because of this behavior
  104253. */
  104254. readonly rotationInProgress: boolean;
  104255. private _onPrePointerObservableObserver;
  104256. private _onAfterCheckInputsObserver;
  104257. private _attachedCamera;
  104258. private _isPointerDown;
  104259. private _lastFrameTime;
  104260. private _lastInteractionTime;
  104261. private _cameraRotationSpeed;
  104262. /**
  104263. * Initializes the behavior.
  104264. */
  104265. init(): void;
  104266. /**
  104267. * Attaches the behavior to its arc rotate camera.
  104268. * @param camera Defines the camera to attach the behavior to
  104269. */
  104270. attach(camera: ArcRotateCamera): void;
  104271. /**
  104272. * Detaches the behavior from its current arc rotate camera.
  104273. */
  104274. detach(): void;
  104275. /**
  104276. * Returns true if user is scrolling.
  104277. * @return true if user is scrolling.
  104278. */
  104279. private _userIsZooming;
  104280. private _lastFrameRadius;
  104281. private _shouldAnimationStopForInteraction;
  104282. /**
  104283. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104284. */
  104285. private _applyUserInteraction;
  104286. private _userIsMoving;
  104287. }
  104288. }
  104289. declare module BABYLON {
  104290. /**
  104291. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104292. */
  104293. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104294. private ui;
  104295. /**
  104296. * The name of the behavior
  104297. */
  104298. name: string;
  104299. /**
  104300. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104301. */
  104302. distanceAwayFromFace: number;
  104303. /**
  104304. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104305. */
  104306. distanceAwayFromBottomOfFace: number;
  104307. private _faceVectors;
  104308. private _target;
  104309. private _scene;
  104310. private _onRenderObserver;
  104311. private _tmpMatrix;
  104312. private _tmpVector;
  104313. /**
  104314. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104315. * @param ui The transform node that should be attched to the mesh
  104316. */
  104317. constructor(ui: TransformNode);
  104318. /**
  104319. * Initializes the behavior
  104320. */
  104321. init(): void;
  104322. private _closestFace;
  104323. private _zeroVector;
  104324. private _lookAtTmpMatrix;
  104325. private _lookAtToRef;
  104326. /**
  104327. * Attaches the AttachToBoxBehavior to the passed in mesh
  104328. * @param target The mesh that the specified node will be attached to
  104329. */
  104330. attach(target: Mesh): void;
  104331. /**
  104332. * Detaches the behavior from the mesh
  104333. */
  104334. detach(): void;
  104335. }
  104336. }
  104337. declare module BABYLON {
  104338. /**
  104339. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104340. */
  104341. export class FadeInOutBehavior implements Behavior<Mesh> {
  104342. /**
  104343. * Time in milliseconds to delay before fading in (Default: 0)
  104344. */
  104345. delay: number;
  104346. /**
  104347. * Time in milliseconds for the mesh to fade in (Default: 300)
  104348. */
  104349. fadeInTime: number;
  104350. private _millisecondsPerFrame;
  104351. private _hovered;
  104352. private _hoverValue;
  104353. private _ownerNode;
  104354. /**
  104355. * Instatiates the FadeInOutBehavior
  104356. */
  104357. constructor();
  104358. /**
  104359. * The name of the behavior
  104360. */
  104361. readonly name: string;
  104362. /**
  104363. * Initializes the behavior
  104364. */
  104365. init(): void;
  104366. /**
  104367. * Attaches the fade behavior on the passed in mesh
  104368. * @param ownerNode The mesh that will be faded in/out once attached
  104369. */
  104370. attach(ownerNode: Mesh): void;
  104371. /**
  104372. * Detaches the behavior from the mesh
  104373. */
  104374. detach(): void;
  104375. /**
  104376. * Triggers the mesh to begin fading in or out
  104377. * @param value if the object should fade in or out (true to fade in)
  104378. */
  104379. fadeIn(value: boolean): void;
  104380. private _update;
  104381. private _setAllVisibility;
  104382. }
  104383. }
  104384. declare module BABYLON {
  104385. /**
  104386. * Class containing a set of static utilities functions for managing Pivots
  104387. * @hidden
  104388. */
  104389. export class PivotTools {
  104390. private static _PivotCached;
  104391. private static _OldPivotPoint;
  104392. private static _PivotTranslation;
  104393. private static _PivotTmpVector;
  104394. /** @hidden */
  104395. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104396. /** @hidden */
  104397. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104398. }
  104399. }
  104400. declare module BABYLON {
  104401. /**
  104402. * Class containing static functions to help procedurally build meshes
  104403. */
  104404. export class PlaneBuilder {
  104405. /**
  104406. * Creates a plane mesh
  104407. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104408. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104409. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104413. * @param name defines the name of the mesh
  104414. * @param options defines the options used to create the mesh
  104415. * @param scene defines the hosting scene
  104416. * @returns the plane mesh
  104417. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104418. */
  104419. static CreatePlane(name: string, options: {
  104420. size?: number;
  104421. width?: number;
  104422. height?: number;
  104423. sideOrientation?: number;
  104424. frontUVs?: Vector4;
  104425. backUVs?: Vector4;
  104426. updatable?: boolean;
  104427. sourcePlane?: Plane;
  104428. }, scene?: Nullable<Scene>): Mesh;
  104429. }
  104430. }
  104431. declare module BABYLON {
  104432. /**
  104433. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104434. */
  104435. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104436. private static _AnyMouseID;
  104437. /**
  104438. * Abstract mesh the behavior is set on
  104439. */
  104440. attachedNode: AbstractMesh;
  104441. private _dragPlane;
  104442. private _scene;
  104443. private _pointerObserver;
  104444. private _beforeRenderObserver;
  104445. private static _planeScene;
  104446. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104447. /**
  104448. * 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)
  104449. */
  104450. maxDragAngle: number;
  104451. /**
  104452. * @hidden
  104453. */
  104454. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104455. /**
  104456. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104457. */
  104458. currentDraggingPointerID: number;
  104459. /**
  104460. * The last position where the pointer hit the drag plane in world space
  104461. */
  104462. lastDragPosition: Vector3;
  104463. /**
  104464. * If the behavior is currently in a dragging state
  104465. */
  104466. dragging: boolean;
  104467. /**
  104468. * 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)
  104469. */
  104470. dragDeltaRatio: number;
  104471. /**
  104472. * If the drag plane orientation should be updated during the dragging (Default: true)
  104473. */
  104474. updateDragPlane: boolean;
  104475. private _debugMode;
  104476. private _moving;
  104477. /**
  104478. * Fires each time the attached mesh is dragged with the pointer
  104479. * * delta between last drag position and current drag position in world space
  104480. * * dragDistance along the drag axis
  104481. * * dragPlaneNormal normal of the current drag plane used during the drag
  104482. * * dragPlanePoint in world space where the drag intersects the drag plane
  104483. */
  104484. onDragObservable: Observable<{
  104485. delta: Vector3;
  104486. dragPlanePoint: Vector3;
  104487. dragPlaneNormal: Vector3;
  104488. dragDistance: number;
  104489. pointerId: number;
  104490. }>;
  104491. /**
  104492. * Fires each time a drag begins (eg. mouse down on mesh)
  104493. */
  104494. onDragStartObservable: Observable<{
  104495. dragPlanePoint: Vector3;
  104496. pointerId: number;
  104497. }>;
  104498. /**
  104499. * Fires each time a drag ends (eg. mouse release after drag)
  104500. */
  104501. onDragEndObservable: Observable<{
  104502. dragPlanePoint: Vector3;
  104503. pointerId: number;
  104504. }>;
  104505. /**
  104506. * If the attached mesh should be moved when dragged
  104507. */
  104508. moveAttached: boolean;
  104509. /**
  104510. * If the drag behavior will react to drag events (Default: true)
  104511. */
  104512. enabled: boolean;
  104513. /**
  104514. * If pointer events should start and release the drag (Default: true)
  104515. */
  104516. startAndReleaseDragOnPointerEvents: boolean;
  104517. /**
  104518. * If camera controls should be detached during the drag
  104519. */
  104520. detachCameraControls: boolean;
  104521. /**
  104522. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104523. */
  104524. useObjectOrienationForDragging: boolean;
  104525. private _options;
  104526. /**
  104527. * Creates a pointer drag behavior that can be attached to a mesh
  104528. * @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)
  104529. */
  104530. constructor(options?: {
  104531. dragAxis?: Vector3;
  104532. dragPlaneNormal?: Vector3;
  104533. });
  104534. /**
  104535. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104536. */
  104537. validateDrag: (targetPosition: Vector3) => boolean;
  104538. /**
  104539. * The name of the behavior
  104540. */
  104541. readonly name: string;
  104542. /**
  104543. * Initializes the behavior
  104544. */
  104545. init(): void;
  104546. private _tmpVector;
  104547. private _alternatePickedPoint;
  104548. private _worldDragAxis;
  104549. private _targetPosition;
  104550. private _attachedElement;
  104551. /**
  104552. * Attaches the drag behavior the passed in mesh
  104553. * @param ownerNode The mesh that will be dragged around once attached
  104554. * @param predicate Predicate to use for pick filtering
  104555. */
  104556. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104557. /**
  104558. * Force relase the drag action by code.
  104559. */
  104560. releaseDrag(): void;
  104561. private _startDragRay;
  104562. private _lastPointerRay;
  104563. /**
  104564. * Simulates the start of a pointer drag event on the behavior
  104565. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104566. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104567. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104568. */
  104569. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104570. private _startDrag;
  104571. private _dragDelta;
  104572. private _moveDrag;
  104573. private _pickWithRayOnDragPlane;
  104574. private _pointA;
  104575. private _pointB;
  104576. private _pointC;
  104577. private _lineA;
  104578. private _lineB;
  104579. private _localAxis;
  104580. private _lookAt;
  104581. private _updateDragPlanePosition;
  104582. /**
  104583. * Detaches the behavior from the mesh
  104584. */
  104585. detach(): void;
  104586. }
  104587. }
  104588. declare module BABYLON {
  104589. /**
  104590. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104591. */
  104592. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104593. private _dragBehaviorA;
  104594. private _dragBehaviorB;
  104595. private _startDistance;
  104596. private _initialScale;
  104597. private _targetScale;
  104598. private _ownerNode;
  104599. private _sceneRenderObserver;
  104600. /**
  104601. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104602. */
  104603. constructor();
  104604. /**
  104605. * The name of the behavior
  104606. */
  104607. readonly name: string;
  104608. /**
  104609. * Initializes the behavior
  104610. */
  104611. init(): void;
  104612. private _getCurrentDistance;
  104613. /**
  104614. * Attaches the scale behavior the passed in mesh
  104615. * @param ownerNode The mesh that will be scaled around once attached
  104616. */
  104617. attach(ownerNode: Mesh): void;
  104618. /**
  104619. * Detaches the behavior from the mesh
  104620. */
  104621. detach(): void;
  104622. }
  104623. }
  104624. declare module BABYLON {
  104625. /**
  104626. * 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
  104627. */
  104628. export class SixDofDragBehavior implements Behavior<Mesh> {
  104629. private static _virtualScene;
  104630. private _ownerNode;
  104631. private _sceneRenderObserver;
  104632. private _scene;
  104633. private _targetPosition;
  104634. private _virtualOriginMesh;
  104635. private _virtualDragMesh;
  104636. private _pointerObserver;
  104637. private _moving;
  104638. private _startingOrientation;
  104639. /**
  104640. * 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)
  104641. */
  104642. private zDragFactor;
  104643. /**
  104644. * If the object should rotate to face the drag origin
  104645. */
  104646. rotateDraggedObject: boolean;
  104647. /**
  104648. * If the behavior is currently in a dragging state
  104649. */
  104650. dragging: boolean;
  104651. /**
  104652. * 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)
  104653. */
  104654. dragDeltaRatio: number;
  104655. /**
  104656. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104657. */
  104658. currentDraggingPointerID: number;
  104659. /**
  104660. * If camera controls should be detached during the drag
  104661. */
  104662. detachCameraControls: boolean;
  104663. /**
  104664. * Fires each time a drag starts
  104665. */
  104666. onDragStartObservable: Observable<{}>;
  104667. /**
  104668. * Fires each time a drag ends (eg. mouse release after drag)
  104669. */
  104670. onDragEndObservable: Observable<{}>;
  104671. /**
  104672. * 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
  104673. */
  104674. constructor();
  104675. /**
  104676. * The name of the behavior
  104677. */
  104678. readonly name: string;
  104679. /**
  104680. * Initializes the behavior
  104681. */
  104682. init(): void;
  104683. /**
  104684. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104685. */
  104686. private readonly _pointerCamera;
  104687. /**
  104688. * Attaches the scale behavior the passed in mesh
  104689. * @param ownerNode The mesh that will be scaled around once attached
  104690. */
  104691. attach(ownerNode: Mesh): void;
  104692. /**
  104693. * Detaches the behavior from the mesh
  104694. */
  104695. detach(): void;
  104696. }
  104697. }
  104698. declare module BABYLON {
  104699. /**
  104700. * Class used to apply inverse kinematics to bones
  104701. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104702. */
  104703. export class BoneIKController {
  104704. private static _tmpVecs;
  104705. private static _tmpQuat;
  104706. private static _tmpMats;
  104707. /**
  104708. * Gets or sets the target mesh
  104709. */
  104710. targetMesh: AbstractMesh;
  104711. /** Gets or sets the mesh used as pole */
  104712. poleTargetMesh: AbstractMesh;
  104713. /**
  104714. * Gets or sets the bone used as pole
  104715. */
  104716. poleTargetBone: Nullable<Bone>;
  104717. /**
  104718. * Gets or sets the target position
  104719. */
  104720. targetPosition: Vector3;
  104721. /**
  104722. * Gets or sets the pole target position
  104723. */
  104724. poleTargetPosition: Vector3;
  104725. /**
  104726. * Gets or sets the pole target local offset
  104727. */
  104728. poleTargetLocalOffset: Vector3;
  104729. /**
  104730. * Gets or sets the pole angle
  104731. */
  104732. poleAngle: number;
  104733. /**
  104734. * Gets or sets the mesh associated with the controller
  104735. */
  104736. mesh: AbstractMesh;
  104737. /**
  104738. * 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)
  104739. */
  104740. slerpAmount: number;
  104741. private _bone1Quat;
  104742. private _bone1Mat;
  104743. private _bone2Ang;
  104744. private _bone1;
  104745. private _bone2;
  104746. private _bone1Length;
  104747. private _bone2Length;
  104748. private _maxAngle;
  104749. private _maxReach;
  104750. private _rightHandedSystem;
  104751. private _bendAxis;
  104752. private _slerping;
  104753. private _adjustRoll;
  104754. /**
  104755. * Gets or sets maximum allowed angle
  104756. */
  104757. maxAngle: number;
  104758. /**
  104759. * Creates a new BoneIKController
  104760. * @param mesh defines the mesh to control
  104761. * @param bone defines the bone to control
  104762. * @param options defines options to set up the controller
  104763. */
  104764. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104765. targetMesh?: AbstractMesh;
  104766. poleTargetMesh?: AbstractMesh;
  104767. poleTargetBone?: Bone;
  104768. poleTargetLocalOffset?: Vector3;
  104769. poleAngle?: number;
  104770. bendAxis?: Vector3;
  104771. maxAngle?: number;
  104772. slerpAmount?: number;
  104773. });
  104774. private _setMaxAngle;
  104775. /**
  104776. * Force the controller to update the bones
  104777. */
  104778. update(): void;
  104779. }
  104780. }
  104781. declare module BABYLON {
  104782. /**
  104783. * Class used to make a bone look toward a point in space
  104784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104785. */
  104786. export class BoneLookController {
  104787. private static _tmpVecs;
  104788. private static _tmpQuat;
  104789. private static _tmpMats;
  104790. /**
  104791. * The target Vector3 that the bone will look at
  104792. */
  104793. target: Vector3;
  104794. /**
  104795. * The mesh that the bone is attached to
  104796. */
  104797. mesh: AbstractMesh;
  104798. /**
  104799. * The bone that will be looking to the target
  104800. */
  104801. bone: Bone;
  104802. /**
  104803. * The up axis of the coordinate system that is used when the bone is rotated
  104804. */
  104805. upAxis: Vector3;
  104806. /**
  104807. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104808. */
  104809. upAxisSpace: Space;
  104810. /**
  104811. * Used to make an adjustment to the yaw of the bone
  104812. */
  104813. adjustYaw: number;
  104814. /**
  104815. * Used to make an adjustment to the pitch of the bone
  104816. */
  104817. adjustPitch: number;
  104818. /**
  104819. * Used to make an adjustment to the roll of the bone
  104820. */
  104821. adjustRoll: number;
  104822. /**
  104823. * 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)
  104824. */
  104825. slerpAmount: number;
  104826. private _minYaw;
  104827. private _maxYaw;
  104828. private _minPitch;
  104829. private _maxPitch;
  104830. private _minYawSin;
  104831. private _minYawCos;
  104832. private _maxYawSin;
  104833. private _maxYawCos;
  104834. private _midYawConstraint;
  104835. private _minPitchTan;
  104836. private _maxPitchTan;
  104837. private _boneQuat;
  104838. private _slerping;
  104839. private _transformYawPitch;
  104840. private _transformYawPitchInv;
  104841. private _firstFrameSkipped;
  104842. private _yawRange;
  104843. private _fowardAxis;
  104844. /**
  104845. * Gets or sets the minimum yaw angle that the bone can look to
  104846. */
  104847. minYaw: number;
  104848. /**
  104849. * Gets or sets the maximum yaw angle that the bone can look to
  104850. */
  104851. maxYaw: number;
  104852. /**
  104853. * Gets or sets the minimum pitch angle that the bone can look to
  104854. */
  104855. minPitch: number;
  104856. /**
  104857. * Gets or sets the maximum pitch angle that the bone can look to
  104858. */
  104859. maxPitch: number;
  104860. /**
  104861. * Create a BoneLookController
  104862. * @param mesh the mesh that the bone belongs to
  104863. * @param bone the bone that will be looking to the target
  104864. * @param target the target Vector3 to look at
  104865. * @param options optional settings:
  104866. * * maxYaw: the maximum angle the bone will yaw to
  104867. * * minYaw: the minimum angle the bone will yaw to
  104868. * * maxPitch: the maximum angle the bone will pitch to
  104869. * * minPitch: the minimum angle the bone will yaw to
  104870. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104871. * * upAxis: the up axis of the coordinate system
  104872. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104873. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104874. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104875. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104876. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104877. * * adjustRoll: used to make an adjustment to the roll of the bone
  104878. **/
  104879. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104880. maxYaw?: number;
  104881. minYaw?: number;
  104882. maxPitch?: number;
  104883. minPitch?: number;
  104884. slerpAmount?: number;
  104885. upAxis?: Vector3;
  104886. upAxisSpace?: Space;
  104887. yawAxis?: Vector3;
  104888. pitchAxis?: Vector3;
  104889. adjustYaw?: number;
  104890. adjustPitch?: number;
  104891. adjustRoll?: number;
  104892. });
  104893. /**
  104894. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104895. */
  104896. update(): void;
  104897. private _getAngleDiff;
  104898. private _getAngleBetween;
  104899. private _isAngleBetween;
  104900. }
  104901. }
  104902. declare module BABYLON {
  104903. /**
  104904. * Manage the gamepad inputs to control an arc rotate camera.
  104905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104906. */
  104907. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104908. /**
  104909. * Defines the camera the input is attached to.
  104910. */
  104911. camera: ArcRotateCamera;
  104912. /**
  104913. * Defines the gamepad the input is gathering event from.
  104914. */
  104915. gamepad: Nullable<Gamepad>;
  104916. /**
  104917. * Defines the gamepad rotation sensiblity.
  104918. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104919. */
  104920. gamepadRotationSensibility: number;
  104921. /**
  104922. * Defines the gamepad move sensiblity.
  104923. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104924. */
  104925. gamepadMoveSensibility: number;
  104926. private _yAxisScale;
  104927. /**
  104928. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104929. */
  104930. invertYAxis: boolean;
  104931. private _onGamepadConnectedObserver;
  104932. private _onGamepadDisconnectedObserver;
  104933. /**
  104934. * Attach the input controls to a specific dom element to get the input from.
  104935. * @param element Defines the element the controls should be listened from
  104936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104937. */
  104938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104939. /**
  104940. * Detach the current controls from the specified dom element.
  104941. * @param element Defines the element to stop listening the inputs from
  104942. */
  104943. detachControl(element: Nullable<HTMLElement>): void;
  104944. /**
  104945. * Update the current camera state depending on the inputs that have been used this frame.
  104946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104947. */
  104948. checkInputs(): void;
  104949. /**
  104950. * Gets the class name of the current intput.
  104951. * @returns the class name
  104952. */
  104953. getClassName(): string;
  104954. /**
  104955. * Get the friendly name associated with the input class.
  104956. * @returns the input friendly name
  104957. */
  104958. getSimpleName(): string;
  104959. }
  104960. }
  104961. declare module BABYLON {
  104962. interface ArcRotateCameraInputsManager {
  104963. /**
  104964. * Add orientation input support to the input manager.
  104965. * @returns the current input manager
  104966. */
  104967. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104968. }
  104969. /**
  104970. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104972. */
  104973. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104974. /**
  104975. * Defines the camera the input is attached to.
  104976. */
  104977. camera: ArcRotateCamera;
  104978. /**
  104979. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104980. */
  104981. alphaCorrection: number;
  104982. /**
  104983. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104984. */
  104985. gammaCorrection: number;
  104986. private _alpha;
  104987. private _gamma;
  104988. private _dirty;
  104989. private _deviceOrientationHandler;
  104990. /**
  104991. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104992. */
  104993. constructor();
  104994. /**
  104995. * Attach the input controls to a specific dom element to get the input from.
  104996. * @param element Defines the element the controls should be listened from
  104997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104998. */
  104999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105000. /** @hidden */
  105001. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105002. /**
  105003. * Update the current camera state depending on the inputs that have been used this frame.
  105004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105005. */
  105006. checkInputs(): void;
  105007. /**
  105008. * Detach the current controls from the specified dom element.
  105009. * @param element Defines the element to stop listening the inputs from
  105010. */
  105011. detachControl(element: Nullable<HTMLElement>): void;
  105012. /**
  105013. * Gets the class name of the current intput.
  105014. * @returns the class name
  105015. */
  105016. getClassName(): string;
  105017. /**
  105018. * Get the friendly name associated with the input class.
  105019. * @returns the input friendly name
  105020. */
  105021. getSimpleName(): string;
  105022. }
  105023. }
  105024. declare module BABYLON {
  105025. /**
  105026. * Listen to mouse events to control the camera.
  105027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105028. */
  105029. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105030. /**
  105031. * Defines the camera the input is attached to.
  105032. */
  105033. camera: FlyCamera;
  105034. /**
  105035. * Defines if touch is enabled. (Default is true.)
  105036. */
  105037. touchEnabled: boolean;
  105038. /**
  105039. * Defines the buttons associated with the input to handle camera rotation.
  105040. */
  105041. buttons: number[];
  105042. /**
  105043. * Assign buttons for Yaw control.
  105044. */
  105045. buttonsYaw: number[];
  105046. /**
  105047. * Assign buttons for Pitch control.
  105048. */
  105049. buttonsPitch: number[];
  105050. /**
  105051. * Assign buttons for Roll control.
  105052. */
  105053. buttonsRoll: number[];
  105054. /**
  105055. * Detect if any button is being pressed while mouse is moved.
  105056. * -1 = Mouse locked.
  105057. * 0 = Left button.
  105058. * 1 = Middle Button.
  105059. * 2 = Right Button.
  105060. */
  105061. activeButton: number;
  105062. /**
  105063. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105064. * Higher values reduce its sensitivity.
  105065. */
  105066. angularSensibility: number;
  105067. private _mousemoveCallback;
  105068. private _observer;
  105069. private _rollObserver;
  105070. private previousPosition;
  105071. private noPreventDefault;
  105072. private element;
  105073. /**
  105074. * Listen to mouse events to control the camera.
  105075. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105077. */
  105078. constructor(touchEnabled?: boolean);
  105079. /**
  105080. * Attach the mouse control to the HTML DOM element.
  105081. * @param element Defines the element that listens to the input events.
  105082. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105083. */
  105084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105085. /**
  105086. * Detach the current controls from the specified dom element.
  105087. * @param element Defines the element to stop listening the inputs from
  105088. */
  105089. detachControl(element: Nullable<HTMLElement>): void;
  105090. /**
  105091. * Gets the class name of the current input.
  105092. * @returns the class name.
  105093. */
  105094. getClassName(): string;
  105095. /**
  105096. * Get the friendly name associated with the input class.
  105097. * @returns the input's friendly name.
  105098. */
  105099. getSimpleName(): string;
  105100. private _pointerInput;
  105101. private _onMouseMove;
  105102. /**
  105103. * Rotate camera by mouse offset.
  105104. */
  105105. private rotateCamera;
  105106. }
  105107. }
  105108. declare module BABYLON {
  105109. /**
  105110. * Default Inputs manager for the FlyCamera.
  105111. * It groups all the default supported inputs for ease of use.
  105112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105113. */
  105114. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105115. /**
  105116. * Instantiates a new FlyCameraInputsManager.
  105117. * @param camera Defines the camera the inputs belong to.
  105118. */
  105119. constructor(camera: FlyCamera);
  105120. /**
  105121. * Add keyboard input support to the input manager.
  105122. * @returns the new FlyCameraKeyboardMoveInput().
  105123. */
  105124. addKeyboard(): FlyCameraInputsManager;
  105125. /**
  105126. * Add mouse input support to the input manager.
  105127. * @param touchEnabled Enable touch screen support.
  105128. * @returns the new FlyCameraMouseInput().
  105129. */
  105130. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105131. }
  105132. }
  105133. declare module BABYLON {
  105134. /**
  105135. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105136. * such as in a 3D Space Shooter or a Flight Simulator.
  105137. */
  105138. export class FlyCamera extends TargetCamera {
  105139. /**
  105140. * Define the collision ellipsoid of the camera.
  105141. * This is helpful for simulating a camera body, like a player's body.
  105142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105143. */
  105144. ellipsoid: Vector3;
  105145. /**
  105146. * Define an offset for the position of the ellipsoid around the camera.
  105147. * This can be helpful if the camera is attached away from the player's body center,
  105148. * such as at its head.
  105149. */
  105150. ellipsoidOffset: Vector3;
  105151. /**
  105152. * Enable or disable collisions of the camera with the rest of the scene objects.
  105153. */
  105154. checkCollisions: boolean;
  105155. /**
  105156. * Enable or disable gravity on the camera.
  105157. */
  105158. applyGravity: boolean;
  105159. /**
  105160. * Define the current direction the camera is moving to.
  105161. */
  105162. cameraDirection: Vector3;
  105163. /**
  105164. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105165. * This overrides and empties cameraRotation.
  105166. */
  105167. rotationQuaternion: Quaternion;
  105168. /**
  105169. * Track Roll to maintain the wanted Rolling when looking around.
  105170. */
  105171. _trackRoll: number;
  105172. /**
  105173. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105174. */
  105175. rollCorrect: number;
  105176. /**
  105177. * Mimic a banked turn, Rolling the camera when Yawing.
  105178. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105179. */
  105180. bankedTurn: boolean;
  105181. /**
  105182. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105183. */
  105184. bankedTurnLimit: number;
  105185. /**
  105186. * Value of 0 disables the banked Roll.
  105187. * Value of 1 is equal to the Yaw angle in radians.
  105188. */
  105189. bankedTurnMultiplier: number;
  105190. /**
  105191. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105192. */
  105193. inputs: FlyCameraInputsManager;
  105194. /**
  105195. * Gets the input sensibility for mouse input.
  105196. * Higher values reduce sensitivity.
  105197. */
  105198. /**
  105199. * Sets the input sensibility for a mouse input.
  105200. * Higher values reduce sensitivity.
  105201. */
  105202. angularSensibility: number;
  105203. /**
  105204. * Get the keys for camera movement forward.
  105205. */
  105206. /**
  105207. * Set the keys for camera movement forward.
  105208. */
  105209. keysForward: number[];
  105210. /**
  105211. * Get the keys for camera movement backward.
  105212. */
  105213. keysBackward: number[];
  105214. /**
  105215. * Get the keys for camera movement up.
  105216. */
  105217. /**
  105218. * Set the keys for camera movement up.
  105219. */
  105220. keysUp: number[];
  105221. /**
  105222. * Get the keys for camera movement down.
  105223. */
  105224. /**
  105225. * Set the keys for camera movement down.
  105226. */
  105227. keysDown: number[];
  105228. /**
  105229. * Get the keys for camera movement left.
  105230. */
  105231. /**
  105232. * Set the keys for camera movement left.
  105233. */
  105234. keysLeft: number[];
  105235. /**
  105236. * Set the keys for camera movement right.
  105237. */
  105238. /**
  105239. * Set the keys for camera movement right.
  105240. */
  105241. keysRight: number[];
  105242. /**
  105243. * Event raised when the camera collides with a mesh in the scene.
  105244. */
  105245. onCollide: (collidedMesh: AbstractMesh) => void;
  105246. private _collider;
  105247. private _needMoveForGravity;
  105248. private _oldPosition;
  105249. private _diffPosition;
  105250. private _newPosition;
  105251. /** @hidden */
  105252. _localDirection: Vector3;
  105253. /** @hidden */
  105254. _transformedDirection: Vector3;
  105255. /**
  105256. * Instantiates a FlyCamera.
  105257. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105258. * such as in a 3D Space Shooter or a Flight Simulator.
  105259. * @param name Define the name of the camera in the scene.
  105260. * @param position Define the starting position of the camera in the scene.
  105261. * @param scene Define the scene the camera belongs to.
  105262. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105263. */
  105264. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105265. /**
  105266. * Attach a control to the HTML DOM element.
  105267. * @param element Defines the element that listens to the input events.
  105268. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105269. */
  105270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105271. /**
  105272. * Detach a control from the HTML DOM element.
  105273. * The camera will stop reacting to that input.
  105274. * @param element Defines the element that listens to the input events.
  105275. */
  105276. detachControl(element: HTMLElement): void;
  105277. private _collisionMask;
  105278. /**
  105279. * Get the mask that the camera ignores in collision events.
  105280. */
  105281. /**
  105282. * Set the mask that the camera ignores in collision events.
  105283. */
  105284. collisionMask: number;
  105285. /** @hidden */
  105286. _collideWithWorld(displacement: Vector3): void;
  105287. /** @hidden */
  105288. private _onCollisionPositionChange;
  105289. /** @hidden */
  105290. _checkInputs(): void;
  105291. /** @hidden */
  105292. _decideIfNeedsToMove(): boolean;
  105293. /** @hidden */
  105294. _updatePosition(): void;
  105295. /**
  105296. * Restore the Roll to its target value at the rate specified.
  105297. * @param rate - Higher means slower restoring.
  105298. * @hidden
  105299. */
  105300. restoreRoll(rate: number): void;
  105301. /**
  105302. * Destroy the camera and release the current resources held by it.
  105303. */
  105304. dispose(): void;
  105305. /**
  105306. * Get the current object class name.
  105307. * @returns the class name.
  105308. */
  105309. getClassName(): string;
  105310. }
  105311. }
  105312. declare module BABYLON {
  105313. /**
  105314. * Listen to keyboard events to control the camera.
  105315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105316. */
  105317. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105318. /**
  105319. * Defines the camera the input is attached to.
  105320. */
  105321. camera: FlyCamera;
  105322. /**
  105323. * The list of keyboard keys used to control the forward move of the camera.
  105324. */
  105325. keysForward: number[];
  105326. /**
  105327. * The list of keyboard keys used to control the backward move of the camera.
  105328. */
  105329. keysBackward: number[];
  105330. /**
  105331. * The list of keyboard keys used to control the forward move of the camera.
  105332. */
  105333. keysUp: number[];
  105334. /**
  105335. * The list of keyboard keys used to control the backward move of the camera.
  105336. */
  105337. keysDown: number[];
  105338. /**
  105339. * The list of keyboard keys used to control the right strafe move of the camera.
  105340. */
  105341. keysRight: number[];
  105342. /**
  105343. * The list of keyboard keys used to control the left strafe move of the camera.
  105344. */
  105345. keysLeft: number[];
  105346. private _keys;
  105347. private _onCanvasBlurObserver;
  105348. private _onKeyboardObserver;
  105349. private _engine;
  105350. private _scene;
  105351. /**
  105352. * Attach the input controls to a specific dom element to get the input from.
  105353. * @param element Defines the element the controls should be listened from
  105354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105355. */
  105356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105357. /**
  105358. * Detach the current controls from the specified dom element.
  105359. * @param element Defines the element to stop listening the inputs from
  105360. */
  105361. detachControl(element: Nullable<HTMLElement>): void;
  105362. /**
  105363. * Gets the class name of the current intput.
  105364. * @returns the class name
  105365. */
  105366. getClassName(): string;
  105367. /** @hidden */
  105368. _onLostFocus(e: FocusEvent): void;
  105369. /**
  105370. * Get the friendly name associated with the input class.
  105371. * @returns the input friendly name
  105372. */
  105373. getSimpleName(): string;
  105374. /**
  105375. * Update the current camera state depending on the inputs that have been used this frame.
  105376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105377. */
  105378. checkInputs(): void;
  105379. }
  105380. }
  105381. declare module BABYLON {
  105382. /**
  105383. * Manage the mouse wheel inputs to control a follow camera.
  105384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105385. */
  105386. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105387. /**
  105388. * Defines the camera the input is attached to.
  105389. */
  105390. camera: FollowCamera;
  105391. /**
  105392. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105393. */
  105394. axisControlRadius: boolean;
  105395. /**
  105396. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105397. */
  105398. axisControlHeight: boolean;
  105399. /**
  105400. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105401. */
  105402. axisControlRotation: boolean;
  105403. /**
  105404. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105405. * relation to mouseWheel events.
  105406. */
  105407. wheelPrecision: number;
  105408. /**
  105409. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105410. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105411. */
  105412. wheelDeltaPercentage: number;
  105413. private _wheel;
  105414. private _observer;
  105415. /**
  105416. * Attach the input controls to a specific dom element to get the input from.
  105417. * @param element Defines the element the controls should be listened from
  105418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105419. */
  105420. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105421. /**
  105422. * Detach the current controls from the specified dom element.
  105423. * @param element Defines the element to stop listening the inputs from
  105424. */
  105425. detachControl(element: Nullable<HTMLElement>): void;
  105426. /**
  105427. * Gets the class name of the current intput.
  105428. * @returns the class name
  105429. */
  105430. getClassName(): string;
  105431. /**
  105432. * Get the friendly name associated with the input class.
  105433. * @returns the input friendly name
  105434. */
  105435. getSimpleName(): string;
  105436. }
  105437. }
  105438. declare module BABYLON {
  105439. /**
  105440. * Manage the pointers inputs to control an follow camera.
  105441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105442. */
  105443. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105444. /**
  105445. * Defines the camera the input is attached to.
  105446. */
  105447. camera: FollowCamera;
  105448. /**
  105449. * Gets the class name of the current input.
  105450. * @returns the class name
  105451. */
  105452. getClassName(): string;
  105453. /**
  105454. * Defines the pointer angular sensibility along the X axis or how fast is
  105455. * the camera rotating.
  105456. * A negative number will reverse the axis direction.
  105457. */
  105458. angularSensibilityX: number;
  105459. /**
  105460. * Defines the pointer angular sensibility along the Y axis or how fast is
  105461. * the camera rotating.
  105462. * A negative number will reverse the axis direction.
  105463. */
  105464. angularSensibilityY: number;
  105465. /**
  105466. * Defines the pointer pinch precision or how fast is the camera zooming.
  105467. * A negative number will reverse the axis direction.
  105468. */
  105469. pinchPrecision: number;
  105470. /**
  105471. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105472. * from 0.
  105473. * It defines the percentage of current camera.radius to use as delta when
  105474. * pinch zoom is used.
  105475. */
  105476. pinchDeltaPercentage: number;
  105477. /**
  105478. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105479. */
  105480. axisXControlRadius: boolean;
  105481. /**
  105482. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105483. */
  105484. axisXControlHeight: boolean;
  105485. /**
  105486. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105487. */
  105488. axisXControlRotation: boolean;
  105489. /**
  105490. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105491. */
  105492. axisYControlRadius: boolean;
  105493. /**
  105494. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105495. */
  105496. axisYControlHeight: boolean;
  105497. /**
  105498. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105499. */
  105500. axisYControlRotation: boolean;
  105501. /**
  105502. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105503. */
  105504. axisPinchControlRadius: boolean;
  105505. /**
  105506. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105507. */
  105508. axisPinchControlHeight: boolean;
  105509. /**
  105510. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105511. */
  105512. axisPinchControlRotation: boolean;
  105513. /**
  105514. * Log error messages if basic misconfiguration has occurred.
  105515. */
  105516. warningEnable: boolean;
  105517. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105518. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105519. private _warningCounter;
  105520. private _warning;
  105521. }
  105522. }
  105523. declare module BABYLON {
  105524. /**
  105525. * Default Inputs manager for the FollowCamera.
  105526. * It groups all the default supported inputs for ease of use.
  105527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105528. */
  105529. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105530. /**
  105531. * Instantiates a new FollowCameraInputsManager.
  105532. * @param camera Defines the camera the inputs belong to
  105533. */
  105534. constructor(camera: FollowCamera);
  105535. /**
  105536. * Add keyboard input support to the input manager.
  105537. * @returns the current input manager
  105538. */
  105539. addKeyboard(): FollowCameraInputsManager;
  105540. /**
  105541. * Add mouse wheel input support to the input manager.
  105542. * @returns the current input manager
  105543. */
  105544. addMouseWheel(): FollowCameraInputsManager;
  105545. /**
  105546. * Add pointers input support to the input manager.
  105547. * @returns the current input manager
  105548. */
  105549. addPointers(): FollowCameraInputsManager;
  105550. /**
  105551. * Add orientation input support to the input manager.
  105552. * @returns the current input manager
  105553. */
  105554. addVRDeviceOrientation(): FollowCameraInputsManager;
  105555. }
  105556. }
  105557. declare module BABYLON {
  105558. /**
  105559. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105560. * an arc rotate version arcFollowCamera are available.
  105561. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105562. */
  105563. export class FollowCamera extends TargetCamera {
  105564. /**
  105565. * Distance the follow camera should follow an object at
  105566. */
  105567. radius: number;
  105568. /**
  105569. * Minimum allowed distance of the camera to the axis of rotation
  105570. * (The camera can not get closer).
  105571. * This can help limiting how the Camera is able to move in the scene.
  105572. */
  105573. lowerRadiusLimit: Nullable<number>;
  105574. /**
  105575. * Maximum allowed distance of the camera to the axis of rotation
  105576. * (The camera can not get further).
  105577. * This can help limiting how the Camera is able to move in the scene.
  105578. */
  105579. upperRadiusLimit: Nullable<number>;
  105580. /**
  105581. * Define a rotation offset between the camera and the object it follows
  105582. */
  105583. rotationOffset: number;
  105584. /**
  105585. * Minimum allowed angle to camera position relative to target object.
  105586. * This can help limiting how the Camera is able to move in the scene.
  105587. */
  105588. lowerRotationOffsetLimit: Nullable<number>;
  105589. /**
  105590. * Maximum allowed angle to camera position relative to target object.
  105591. * This can help limiting how the Camera is able to move in the scene.
  105592. */
  105593. upperRotationOffsetLimit: Nullable<number>;
  105594. /**
  105595. * Define a height offset between the camera and the object it follows.
  105596. * It can help following an object from the top (like a car chaing a plane)
  105597. */
  105598. heightOffset: number;
  105599. /**
  105600. * Minimum allowed height of camera position relative to target object.
  105601. * This can help limiting how the Camera is able to move in the scene.
  105602. */
  105603. lowerHeightOffsetLimit: Nullable<number>;
  105604. /**
  105605. * Maximum allowed height of camera position relative to target object.
  105606. * This can help limiting how the Camera is able to move in the scene.
  105607. */
  105608. upperHeightOffsetLimit: Nullable<number>;
  105609. /**
  105610. * Define how fast the camera can accelerate to follow it s target.
  105611. */
  105612. cameraAcceleration: number;
  105613. /**
  105614. * Define the speed limit of the camera following an object.
  105615. */
  105616. maxCameraSpeed: number;
  105617. /**
  105618. * Define the target of the camera.
  105619. */
  105620. lockedTarget: Nullable<AbstractMesh>;
  105621. /**
  105622. * Defines the input associated with the camera.
  105623. */
  105624. inputs: FollowCameraInputsManager;
  105625. /**
  105626. * Instantiates the follow camera.
  105627. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105628. * @param name Define the name of the camera in the scene
  105629. * @param position Define the position of the camera
  105630. * @param scene Define the scene the camera belong to
  105631. * @param lockedTarget Define the target of the camera
  105632. */
  105633. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105634. private _follow;
  105635. /**
  105636. * Attached controls to the current camera.
  105637. * @param element Defines the element the controls should be listened from
  105638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105639. */
  105640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105641. /**
  105642. * Detach the current controls from the camera.
  105643. * The camera will stop reacting to inputs.
  105644. * @param element Defines the element to stop listening the inputs from
  105645. */
  105646. detachControl(element: HTMLElement): void;
  105647. /** @hidden */
  105648. _checkInputs(): void;
  105649. private _checkLimits;
  105650. /**
  105651. * Gets the camera class name.
  105652. * @returns the class name
  105653. */
  105654. getClassName(): string;
  105655. }
  105656. /**
  105657. * Arc Rotate version of the follow camera.
  105658. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105660. */
  105661. export class ArcFollowCamera extends TargetCamera {
  105662. /** The longitudinal angle of the camera */
  105663. alpha: number;
  105664. /** The latitudinal angle of the camera */
  105665. beta: number;
  105666. /** The radius of the camera from its target */
  105667. radius: number;
  105668. /** Define the camera target (the messh it should follow) */
  105669. target: Nullable<AbstractMesh>;
  105670. private _cartesianCoordinates;
  105671. /**
  105672. * Instantiates a new ArcFollowCamera
  105673. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105674. * @param name Define the name of the camera
  105675. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105676. * @param beta Define the rotation angle of the camera around the elevation axis
  105677. * @param radius Define the radius of the camera from its target point
  105678. * @param target Define the target of the camera
  105679. * @param scene Define the scene the camera belongs to
  105680. */
  105681. constructor(name: string,
  105682. /** The longitudinal angle of the camera */
  105683. alpha: number,
  105684. /** The latitudinal angle of the camera */
  105685. beta: number,
  105686. /** The radius of the camera from its target */
  105687. radius: number,
  105688. /** Define the camera target (the messh it should follow) */
  105689. target: Nullable<AbstractMesh>, scene: Scene);
  105690. private _follow;
  105691. /** @hidden */
  105692. _checkInputs(): void;
  105693. /**
  105694. * Returns the class name of the object.
  105695. * It is mostly used internally for serialization purposes.
  105696. */
  105697. getClassName(): string;
  105698. }
  105699. }
  105700. declare module BABYLON {
  105701. /**
  105702. * Manage the keyboard inputs to control the movement of a follow camera.
  105703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105704. */
  105705. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105706. /**
  105707. * Defines the camera the input is attached to.
  105708. */
  105709. camera: FollowCamera;
  105710. /**
  105711. * Defines the list of key codes associated with the up action (increase heightOffset)
  105712. */
  105713. keysHeightOffsetIncr: number[];
  105714. /**
  105715. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105716. */
  105717. keysHeightOffsetDecr: number[];
  105718. /**
  105719. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105720. */
  105721. keysHeightOffsetModifierAlt: boolean;
  105722. /**
  105723. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105724. */
  105725. keysHeightOffsetModifierCtrl: boolean;
  105726. /**
  105727. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105728. */
  105729. keysHeightOffsetModifierShift: boolean;
  105730. /**
  105731. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105732. */
  105733. keysRotationOffsetIncr: number[];
  105734. /**
  105735. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105736. */
  105737. keysRotationOffsetDecr: number[];
  105738. /**
  105739. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105740. */
  105741. keysRotationOffsetModifierAlt: boolean;
  105742. /**
  105743. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105744. */
  105745. keysRotationOffsetModifierCtrl: boolean;
  105746. /**
  105747. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105748. */
  105749. keysRotationOffsetModifierShift: boolean;
  105750. /**
  105751. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105752. */
  105753. keysRadiusIncr: number[];
  105754. /**
  105755. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105756. */
  105757. keysRadiusDecr: number[];
  105758. /**
  105759. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105760. */
  105761. keysRadiusModifierAlt: boolean;
  105762. /**
  105763. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105764. */
  105765. keysRadiusModifierCtrl: boolean;
  105766. /**
  105767. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105768. */
  105769. keysRadiusModifierShift: boolean;
  105770. /**
  105771. * Defines the rate of change of heightOffset.
  105772. */
  105773. heightSensibility: number;
  105774. /**
  105775. * Defines the rate of change of rotationOffset.
  105776. */
  105777. rotationSensibility: number;
  105778. /**
  105779. * Defines the rate of change of radius.
  105780. */
  105781. radiusSensibility: number;
  105782. private _keys;
  105783. private _ctrlPressed;
  105784. private _altPressed;
  105785. private _shiftPressed;
  105786. private _onCanvasBlurObserver;
  105787. private _onKeyboardObserver;
  105788. private _engine;
  105789. private _scene;
  105790. /**
  105791. * Attach the input controls to a specific dom element to get the input from.
  105792. * @param element Defines the element the controls should be listened from
  105793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105794. */
  105795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105796. /**
  105797. * Detach the current controls from the specified dom element.
  105798. * @param element Defines the element to stop listening the inputs from
  105799. */
  105800. detachControl(element: Nullable<HTMLElement>): void;
  105801. /**
  105802. * Update the current camera state depending on the inputs that have been used this frame.
  105803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105804. */
  105805. checkInputs(): void;
  105806. /**
  105807. * Gets the class name of the current input.
  105808. * @returns the class name
  105809. */
  105810. getClassName(): string;
  105811. /**
  105812. * Get the friendly name associated with the input class.
  105813. * @returns the input friendly name
  105814. */
  105815. getSimpleName(): string;
  105816. /**
  105817. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105818. * allow modification of the heightOffset value.
  105819. */
  105820. private _modifierHeightOffset;
  105821. /**
  105822. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105823. * allow modification of the rotationOffset value.
  105824. */
  105825. private _modifierRotationOffset;
  105826. /**
  105827. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105828. * allow modification of the radius value.
  105829. */
  105830. private _modifierRadius;
  105831. }
  105832. }
  105833. declare module BABYLON {
  105834. interface FreeCameraInputsManager {
  105835. /**
  105836. * @hidden
  105837. */
  105838. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105839. /**
  105840. * Add orientation input support to the input manager.
  105841. * @returns the current input manager
  105842. */
  105843. addDeviceOrientation(): FreeCameraInputsManager;
  105844. }
  105845. /**
  105846. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105847. * Screen rotation is taken into account.
  105848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105849. */
  105850. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105851. private _camera;
  105852. private _screenOrientationAngle;
  105853. private _constantTranform;
  105854. private _screenQuaternion;
  105855. private _alpha;
  105856. private _beta;
  105857. private _gamma;
  105858. /**
  105859. * Can be used to detect if a device orientation sensor is availible on a device
  105860. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105861. * @returns a promise that will resolve on orientation change
  105862. */
  105863. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105864. /**
  105865. * @hidden
  105866. */
  105867. _onDeviceOrientationChangedObservable: Observable<void>;
  105868. /**
  105869. * Instantiates a new input
  105870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105871. */
  105872. constructor();
  105873. /**
  105874. * Define the camera controlled by the input.
  105875. */
  105876. camera: FreeCamera;
  105877. /**
  105878. * Attach the input controls to a specific dom element to get the input from.
  105879. * @param element Defines the element the controls should be listened from
  105880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105881. */
  105882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105883. private _orientationChanged;
  105884. private _deviceOrientation;
  105885. /**
  105886. * Detach the current controls from the specified dom element.
  105887. * @param element Defines the element to stop listening the inputs from
  105888. */
  105889. detachControl(element: Nullable<HTMLElement>): void;
  105890. /**
  105891. * Update the current camera state depending on the inputs that have been used this frame.
  105892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105893. */
  105894. checkInputs(): void;
  105895. /**
  105896. * Gets the class name of the current intput.
  105897. * @returns the class name
  105898. */
  105899. getClassName(): string;
  105900. /**
  105901. * Get the friendly name associated with the input class.
  105902. * @returns the input friendly name
  105903. */
  105904. getSimpleName(): string;
  105905. }
  105906. }
  105907. declare module BABYLON {
  105908. /**
  105909. * Manage the gamepad inputs to control a free camera.
  105910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105911. */
  105912. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105913. /**
  105914. * Define the camera the input is attached to.
  105915. */
  105916. camera: FreeCamera;
  105917. /**
  105918. * Define the Gamepad controlling the input
  105919. */
  105920. gamepad: Nullable<Gamepad>;
  105921. /**
  105922. * Defines the gamepad rotation sensiblity.
  105923. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105924. */
  105925. gamepadAngularSensibility: number;
  105926. /**
  105927. * Defines the gamepad move sensiblity.
  105928. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105929. */
  105930. gamepadMoveSensibility: number;
  105931. private _yAxisScale;
  105932. /**
  105933. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105934. */
  105935. invertYAxis: boolean;
  105936. private _onGamepadConnectedObserver;
  105937. private _onGamepadDisconnectedObserver;
  105938. private _cameraTransform;
  105939. private _deltaTransform;
  105940. private _vector3;
  105941. private _vector2;
  105942. /**
  105943. * Attach the input controls to a specific dom element to get the input from.
  105944. * @param element Defines the element the controls should be listened from
  105945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105946. */
  105947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105948. /**
  105949. * Detach the current controls from the specified dom element.
  105950. * @param element Defines the element to stop listening the inputs from
  105951. */
  105952. detachControl(element: Nullable<HTMLElement>): void;
  105953. /**
  105954. * Update the current camera state depending on the inputs that have been used this frame.
  105955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105956. */
  105957. checkInputs(): void;
  105958. /**
  105959. * Gets the class name of the current intput.
  105960. * @returns the class name
  105961. */
  105962. getClassName(): string;
  105963. /**
  105964. * Get the friendly name associated with the input class.
  105965. * @returns the input friendly name
  105966. */
  105967. getSimpleName(): string;
  105968. }
  105969. }
  105970. declare module BABYLON {
  105971. /**
  105972. * Defines the potential axis of a Joystick
  105973. */
  105974. export enum JoystickAxis {
  105975. /** X axis */
  105976. X = 0,
  105977. /** Y axis */
  105978. Y = 1,
  105979. /** Z axis */
  105980. Z = 2
  105981. }
  105982. /**
  105983. * Class used to define virtual joystick (used in touch mode)
  105984. */
  105985. export class VirtualJoystick {
  105986. /**
  105987. * Gets or sets a boolean indicating that left and right values must be inverted
  105988. */
  105989. reverseLeftRight: boolean;
  105990. /**
  105991. * Gets or sets a boolean indicating that up and down values must be inverted
  105992. */
  105993. reverseUpDown: boolean;
  105994. /**
  105995. * Gets the offset value for the position (ie. the change of the position value)
  105996. */
  105997. deltaPosition: Vector3;
  105998. /**
  105999. * Gets a boolean indicating if the virtual joystick was pressed
  106000. */
  106001. pressed: boolean;
  106002. /**
  106003. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106004. */
  106005. static Canvas: Nullable<HTMLCanvasElement>;
  106006. private static _globalJoystickIndex;
  106007. private static vjCanvasContext;
  106008. private static vjCanvasWidth;
  106009. private static vjCanvasHeight;
  106010. private static halfWidth;
  106011. private _action;
  106012. private _axisTargetedByLeftAndRight;
  106013. private _axisTargetedByUpAndDown;
  106014. private _joystickSensibility;
  106015. private _inversedSensibility;
  106016. private _joystickPointerID;
  106017. private _joystickColor;
  106018. private _joystickPointerPos;
  106019. private _joystickPreviousPointerPos;
  106020. private _joystickPointerStartPos;
  106021. private _deltaJoystickVector;
  106022. private _leftJoystick;
  106023. private _touches;
  106024. private _onPointerDownHandlerRef;
  106025. private _onPointerMoveHandlerRef;
  106026. private _onPointerUpHandlerRef;
  106027. private _onResize;
  106028. /**
  106029. * Creates a new virtual joystick
  106030. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106031. */
  106032. constructor(leftJoystick?: boolean);
  106033. /**
  106034. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106035. * @param newJoystickSensibility defines the new sensibility
  106036. */
  106037. setJoystickSensibility(newJoystickSensibility: number): void;
  106038. private _onPointerDown;
  106039. private _onPointerMove;
  106040. private _onPointerUp;
  106041. /**
  106042. * Change the color of the virtual joystick
  106043. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106044. */
  106045. setJoystickColor(newColor: string): void;
  106046. /**
  106047. * Defines a callback to call when the joystick is touched
  106048. * @param action defines the callback
  106049. */
  106050. setActionOnTouch(action: () => any): void;
  106051. /**
  106052. * Defines which axis you'd like to control for left & right
  106053. * @param axis defines the axis to use
  106054. */
  106055. setAxisForLeftRight(axis: JoystickAxis): void;
  106056. /**
  106057. * Defines which axis you'd like to control for up & down
  106058. * @param axis defines the axis to use
  106059. */
  106060. setAxisForUpDown(axis: JoystickAxis): void;
  106061. private _drawVirtualJoystick;
  106062. /**
  106063. * Release internal HTML canvas
  106064. */
  106065. releaseCanvas(): void;
  106066. }
  106067. }
  106068. declare module BABYLON {
  106069. interface FreeCameraInputsManager {
  106070. /**
  106071. * Add virtual joystick input support to the input manager.
  106072. * @returns the current input manager
  106073. */
  106074. addVirtualJoystick(): FreeCameraInputsManager;
  106075. }
  106076. /**
  106077. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106079. */
  106080. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106081. /**
  106082. * Defines the camera the input is attached to.
  106083. */
  106084. camera: FreeCamera;
  106085. private _leftjoystick;
  106086. private _rightjoystick;
  106087. /**
  106088. * Gets the left stick of the virtual joystick.
  106089. * @returns The virtual Joystick
  106090. */
  106091. getLeftJoystick(): VirtualJoystick;
  106092. /**
  106093. * Gets the right stick of the virtual joystick.
  106094. * @returns The virtual Joystick
  106095. */
  106096. getRightJoystick(): VirtualJoystick;
  106097. /**
  106098. * Update the current camera state depending on the inputs that have been used this frame.
  106099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106100. */
  106101. checkInputs(): void;
  106102. /**
  106103. * Attach the input controls to a specific dom element to get the input from.
  106104. * @param element Defines the element the controls should be listened from
  106105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106106. */
  106107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106108. /**
  106109. * Detach the current controls from the specified dom element.
  106110. * @param element Defines the element to stop listening the inputs from
  106111. */
  106112. detachControl(element: Nullable<HTMLElement>): void;
  106113. /**
  106114. * Gets the class name of the current intput.
  106115. * @returns the class name
  106116. */
  106117. getClassName(): string;
  106118. /**
  106119. * Get the friendly name associated with the input class.
  106120. * @returns the input friendly name
  106121. */
  106122. getSimpleName(): string;
  106123. }
  106124. }
  106125. declare module BABYLON {
  106126. /**
  106127. * This represents a FPS type of camera controlled by touch.
  106128. * This is like a universal camera minus the Gamepad controls.
  106129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106130. */
  106131. export class TouchCamera extends FreeCamera {
  106132. /**
  106133. * Defines the touch sensibility for rotation.
  106134. * The higher the faster.
  106135. */
  106136. touchAngularSensibility: number;
  106137. /**
  106138. * Defines the touch sensibility for move.
  106139. * The higher the faster.
  106140. */
  106141. touchMoveSensibility: number;
  106142. /**
  106143. * Instantiates a new touch camera.
  106144. * This represents a FPS type of camera controlled by touch.
  106145. * This is like a universal camera minus the Gamepad controls.
  106146. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106147. * @param name Define the name of the camera in the scene
  106148. * @param position Define the start position of the camera in the scene
  106149. * @param scene Define the scene the camera belongs to
  106150. */
  106151. constructor(name: string, position: Vector3, scene: Scene);
  106152. /**
  106153. * Gets the current object class name.
  106154. * @return the class name
  106155. */
  106156. getClassName(): string;
  106157. /** @hidden */
  106158. _setupInputs(): void;
  106159. }
  106160. }
  106161. declare module BABYLON {
  106162. /**
  106163. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106164. * being tilted forward or back and left or right.
  106165. */
  106166. export class DeviceOrientationCamera extends FreeCamera {
  106167. private _initialQuaternion;
  106168. private _quaternionCache;
  106169. private _tmpDragQuaternion;
  106170. private _disablePointerInputWhenUsingDeviceOrientation;
  106171. /**
  106172. * Creates a new device orientation camera
  106173. * @param name The name of the camera
  106174. * @param position The start position camera
  106175. * @param scene The scene the camera belongs to
  106176. */
  106177. constructor(name: string, position: Vector3, scene: Scene);
  106178. /**
  106179. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106180. */
  106181. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106182. private _dragFactor;
  106183. /**
  106184. * Enabled turning on the y axis when the orientation sensor is active
  106185. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106186. */
  106187. enableHorizontalDragging(dragFactor?: number): void;
  106188. /**
  106189. * Gets the current instance class name ("DeviceOrientationCamera").
  106190. * This helps avoiding instanceof at run time.
  106191. * @returns the class name
  106192. */
  106193. getClassName(): string;
  106194. /**
  106195. * @hidden
  106196. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106197. */
  106198. _checkInputs(): void;
  106199. /**
  106200. * Reset the camera to its default orientation on the specified axis only.
  106201. * @param axis The axis to reset
  106202. */
  106203. resetToCurrentRotation(axis?: Axis): void;
  106204. }
  106205. }
  106206. declare module BABYLON {
  106207. /**
  106208. * Defines supported buttons for XBox360 compatible gamepads
  106209. */
  106210. export enum Xbox360Button {
  106211. /** A */
  106212. A = 0,
  106213. /** B */
  106214. B = 1,
  106215. /** X */
  106216. X = 2,
  106217. /** Y */
  106218. Y = 3,
  106219. /** Start */
  106220. Start = 4,
  106221. /** Back */
  106222. Back = 5,
  106223. /** Left button */
  106224. LB = 6,
  106225. /** Right button */
  106226. RB = 7,
  106227. /** Left stick */
  106228. LeftStick = 8,
  106229. /** Right stick */
  106230. RightStick = 9
  106231. }
  106232. /** Defines values for XBox360 DPad */
  106233. export enum Xbox360Dpad {
  106234. /** Up */
  106235. Up = 0,
  106236. /** Down */
  106237. Down = 1,
  106238. /** Left */
  106239. Left = 2,
  106240. /** Right */
  106241. Right = 3
  106242. }
  106243. /**
  106244. * Defines a XBox360 gamepad
  106245. */
  106246. export class Xbox360Pad extends Gamepad {
  106247. private _leftTrigger;
  106248. private _rightTrigger;
  106249. private _onlefttriggerchanged;
  106250. private _onrighttriggerchanged;
  106251. private _onbuttondown;
  106252. private _onbuttonup;
  106253. private _ondpaddown;
  106254. private _ondpadup;
  106255. /** Observable raised when a button is pressed */
  106256. onButtonDownObservable: Observable<Xbox360Button>;
  106257. /** Observable raised when a button is released */
  106258. onButtonUpObservable: Observable<Xbox360Button>;
  106259. /** Observable raised when a pad is pressed */
  106260. onPadDownObservable: Observable<Xbox360Dpad>;
  106261. /** Observable raised when a pad is released */
  106262. onPadUpObservable: Observable<Xbox360Dpad>;
  106263. private _buttonA;
  106264. private _buttonB;
  106265. private _buttonX;
  106266. private _buttonY;
  106267. private _buttonBack;
  106268. private _buttonStart;
  106269. private _buttonLB;
  106270. private _buttonRB;
  106271. private _buttonLeftStick;
  106272. private _buttonRightStick;
  106273. private _dPadUp;
  106274. private _dPadDown;
  106275. private _dPadLeft;
  106276. private _dPadRight;
  106277. private _isXboxOnePad;
  106278. /**
  106279. * Creates a new XBox360 gamepad object
  106280. * @param id defines the id of this gamepad
  106281. * @param index defines its index
  106282. * @param gamepad defines the internal HTML gamepad object
  106283. * @param xboxOne defines if it is a XBox One gamepad
  106284. */
  106285. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106286. /**
  106287. * Defines the callback to call when left trigger is pressed
  106288. * @param callback defines the callback to use
  106289. */
  106290. onlefttriggerchanged(callback: (value: number) => void): void;
  106291. /**
  106292. * Defines the callback to call when right trigger is pressed
  106293. * @param callback defines the callback to use
  106294. */
  106295. onrighttriggerchanged(callback: (value: number) => void): void;
  106296. /**
  106297. * Gets the left trigger value
  106298. */
  106299. /**
  106300. * Sets the left trigger value
  106301. */
  106302. leftTrigger: number;
  106303. /**
  106304. * Gets the right trigger value
  106305. */
  106306. /**
  106307. * Sets the right trigger value
  106308. */
  106309. rightTrigger: number;
  106310. /**
  106311. * Defines the callback to call when a button is pressed
  106312. * @param callback defines the callback to use
  106313. */
  106314. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106315. /**
  106316. * Defines the callback to call when a button is released
  106317. * @param callback defines the callback to use
  106318. */
  106319. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106320. /**
  106321. * Defines the callback to call when a pad is pressed
  106322. * @param callback defines the callback to use
  106323. */
  106324. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106325. /**
  106326. * Defines the callback to call when a pad is released
  106327. * @param callback defines the callback to use
  106328. */
  106329. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106330. private _setButtonValue;
  106331. private _setDPadValue;
  106332. /**
  106333. * Gets the value of the `A` button
  106334. */
  106335. /**
  106336. * Sets the value of the `A` button
  106337. */
  106338. buttonA: number;
  106339. /**
  106340. * Gets the value of the `B` button
  106341. */
  106342. /**
  106343. * Sets the value of the `B` button
  106344. */
  106345. buttonB: number;
  106346. /**
  106347. * Gets the value of the `X` button
  106348. */
  106349. /**
  106350. * Sets the value of the `X` button
  106351. */
  106352. buttonX: number;
  106353. /**
  106354. * Gets the value of the `Y` button
  106355. */
  106356. /**
  106357. * Sets the value of the `Y` button
  106358. */
  106359. buttonY: number;
  106360. /**
  106361. * Gets the value of the `Start` button
  106362. */
  106363. /**
  106364. * Sets the value of the `Start` button
  106365. */
  106366. buttonStart: number;
  106367. /**
  106368. * Gets the value of the `Back` button
  106369. */
  106370. /**
  106371. * Sets the value of the `Back` button
  106372. */
  106373. buttonBack: number;
  106374. /**
  106375. * Gets the value of the `Left` button
  106376. */
  106377. /**
  106378. * Sets the value of the `Left` button
  106379. */
  106380. buttonLB: number;
  106381. /**
  106382. * Gets the value of the `Right` button
  106383. */
  106384. /**
  106385. * Sets the value of the `Right` button
  106386. */
  106387. buttonRB: number;
  106388. /**
  106389. * Gets the value of the Left joystick
  106390. */
  106391. /**
  106392. * Sets the value of the Left joystick
  106393. */
  106394. buttonLeftStick: number;
  106395. /**
  106396. * Gets the value of the Right joystick
  106397. */
  106398. /**
  106399. * Sets the value of the Right joystick
  106400. */
  106401. buttonRightStick: number;
  106402. /**
  106403. * Gets the value of D-pad up
  106404. */
  106405. /**
  106406. * Sets the value of D-pad up
  106407. */
  106408. dPadUp: number;
  106409. /**
  106410. * Gets the value of D-pad down
  106411. */
  106412. /**
  106413. * Sets the value of D-pad down
  106414. */
  106415. dPadDown: number;
  106416. /**
  106417. * Gets the value of D-pad left
  106418. */
  106419. /**
  106420. * Sets the value of D-pad left
  106421. */
  106422. dPadLeft: number;
  106423. /**
  106424. * Gets the value of D-pad right
  106425. */
  106426. /**
  106427. * Sets the value of D-pad right
  106428. */
  106429. dPadRight: number;
  106430. /**
  106431. * Force the gamepad to synchronize with device values
  106432. */
  106433. update(): void;
  106434. /**
  106435. * Disposes the gamepad
  106436. */
  106437. dispose(): void;
  106438. }
  106439. }
  106440. declare module BABYLON {
  106441. /**
  106442. * Defines supported buttons for DualShock compatible gamepads
  106443. */
  106444. export enum DualShockButton {
  106445. /** Cross */
  106446. Cross = 0,
  106447. /** Circle */
  106448. Circle = 1,
  106449. /** Square */
  106450. Square = 2,
  106451. /** Triangle */
  106452. Triangle = 3,
  106453. /** Options */
  106454. Options = 4,
  106455. /** Share */
  106456. Share = 5,
  106457. /** L1 */
  106458. L1 = 6,
  106459. /** R1 */
  106460. R1 = 7,
  106461. /** Left stick */
  106462. LeftStick = 8,
  106463. /** Right stick */
  106464. RightStick = 9
  106465. }
  106466. /** Defines values for DualShock DPad */
  106467. export enum DualShockDpad {
  106468. /** Up */
  106469. Up = 0,
  106470. /** Down */
  106471. Down = 1,
  106472. /** Left */
  106473. Left = 2,
  106474. /** Right */
  106475. Right = 3
  106476. }
  106477. /**
  106478. * Defines a DualShock gamepad
  106479. */
  106480. export class DualShockPad extends Gamepad {
  106481. private _leftTrigger;
  106482. private _rightTrigger;
  106483. private _onlefttriggerchanged;
  106484. private _onrighttriggerchanged;
  106485. private _onbuttondown;
  106486. private _onbuttonup;
  106487. private _ondpaddown;
  106488. private _ondpadup;
  106489. /** Observable raised when a button is pressed */
  106490. onButtonDownObservable: Observable<DualShockButton>;
  106491. /** Observable raised when a button is released */
  106492. onButtonUpObservable: Observable<DualShockButton>;
  106493. /** Observable raised when a pad is pressed */
  106494. onPadDownObservable: Observable<DualShockDpad>;
  106495. /** Observable raised when a pad is released */
  106496. onPadUpObservable: Observable<DualShockDpad>;
  106497. private _buttonCross;
  106498. private _buttonCircle;
  106499. private _buttonSquare;
  106500. private _buttonTriangle;
  106501. private _buttonShare;
  106502. private _buttonOptions;
  106503. private _buttonL1;
  106504. private _buttonR1;
  106505. private _buttonLeftStick;
  106506. private _buttonRightStick;
  106507. private _dPadUp;
  106508. private _dPadDown;
  106509. private _dPadLeft;
  106510. private _dPadRight;
  106511. /**
  106512. * Creates a new DualShock gamepad object
  106513. * @param id defines the id of this gamepad
  106514. * @param index defines its index
  106515. * @param gamepad defines the internal HTML gamepad object
  106516. */
  106517. constructor(id: string, index: number, gamepad: any);
  106518. /**
  106519. * Defines the callback to call when left trigger is pressed
  106520. * @param callback defines the callback to use
  106521. */
  106522. onlefttriggerchanged(callback: (value: number) => void): void;
  106523. /**
  106524. * Defines the callback to call when right trigger is pressed
  106525. * @param callback defines the callback to use
  106526. */
  106527. onrighttriggerchanged(callback: (value: number) => void): void;
  106528. /**
  106529. * Gets the left trigger value
  106530. */
  106531. /**
  106532. * Sets the left trigger value
  106533. */
  106534. leftTrigger: number;
  106535. /**
  106536. * Gets the right trigger value
  106537. */
  106538. /**
  106539. * Sets the right trigger value
  106540. */
  106541. rightTrigger: number;
  106542. /**
  106543. * Defines the callback to call when a button is pressed
  106544. * @param callback defines the callback to use
  106545. */
  106546. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106547. /**
  106548. * Defines the callback to call when a button is released
  106549. * @param callback defines the callback to use
  106550. */
  106551. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106552. /**
  106553. * Defines the callback to call when a pad is pressed
  106554. * @param callback defines the callback to use
  106555. */
  106556. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106557. /**
  106558. * Defines the callback to call when a pad is released
  106559. * @param callback defines the callback to use
  106560. */
  106561. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106562. private _setButtonValue;
  106563. private _setDPadValue;
  106564. /**
  106565. * Gets the value of the `Cross` button
  106566. */
  106567. /**
  106568. * Sets the value of the `Cross` button
  106569. */
  106570. buttonCross: number;
  106571. /**
  106572. * Gets the value of the `Circle` button
  106573. */
  106574. /**
  106575. * Sets the value of the `Circle` button
  106576. */
  106577. buttonCircle: number;
  106578. /**
  106579. * Gets the value of the `Square` button
  106580. */
  106581. /**
  106582. * Sets the value of the `Square` button
  106583. */
  106584. buttonSquare: number;
  106585. /**
  106586. * Gets the value of the `Triangle` button
  106587. */
  106588. /**
  106589. * Sets the value of the `Triangle` button
  106590. */
  106591. buttonTriangle: number;
  106592. /**
  106593. * Gets the value of the `Options` button
  106594. */
  106595. /**
  106596. * Sets the value of the `Options` button
  106597. */
  106598. buttonOptions: number;
  106599. /**
  106600. * Gets the value of the `Share` button
  106601. */
  106602. /**
  106603. * Sets the value of the `Share` button
  106604. */
  106605. buttonShare: number;
  106606. /**
  106607. * Gets the value of the `L1` button
  106608. */
  106609. /**
  106610. * Sets the value of the `L1` button
  106611. */
  106612. buttonL1: number;
  106613. /**
  106614. * Gets the value of the `R1` button
  106615. */
  106616. /**
  106617. * Sets the value of the `R1` button
  106618. */
  106619. buttonR1: number;
  106620. /**
  106621. * Gets the value of the Left joystick
  106622. */
  106623. /**
  106624. * Sets the value of the Left joystick
  106625. */
  106626. buttonLeftStick: number;
  106627. /**
  106628. * Gets the value of the Right joystick
  106629. */
  106630. /**
  106631. * Sets the value of the Right joystick
  106632. */
  106633. buttonRightStick: number;
  106634. /**
  106635. * Gets the value of D-pad up
  106636. */
  106637. /**
  106638. * Sets the value of D-pad up
  106639. */
  106640. dPadUp: number;
  106641. /**
  106642. * Gets the value of D-pad down
  106643. */
  106644. /**
  106645. * Sets the value of D-pad down
  106646. */
  106647. dPadDown: number;
  106648. /**
  106649. * Gets the value of D-pad left
  106650. */
  106651. /**
  106652. * Sets the value of D-pad left
  106653. */
  106654. dPadLeft: number;
  106655. /**
  106656. * Gets the value of D-pad right
  106657. */
  106658. /**
  106659. * Sets the value of D-pad right
  106660. */
  106661. dPadRight: number;
  106662. /**
  106663. * Force the gamepad to synchronize with device values
  106664. */
  106665. update(): void;
  106666. /**
  106667. * Disposes the gamepad
  106668. */
  106669. dispose(): void;
  106670. }
  106671. }
  106672. declare module BABYLON {
  106673. /**
  106674. * Manager for handling gamepads
  106675. */
  106676. export class GamepadManager {
  106677. private _scene?;
  106678. private _babylonGamepads;
  106679. private _oneGamepadConnected;
  106680. /** @hidden */
  106681. _isMonitoring: boolean;
  106682. private _gamepadEventSupported;
  106683. private _gamepadSupport;
  106684. /**
  106685. * observable to be triggered when the gamepad controller has been connected
  106686. */
  106687. onGamepadConnectedObservable: Observable<Gamepad>;
  106688. /**
  106689. * observable to be triggered when the gamepad controller has been disconnected
  106690. */
  106691. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106692. private _onGamepadConnectedEvent;
  106693. private _onGamepadDisconnectedEvent;
  106694. /**
  106695. * Initializes the gamepad manager
  106696. * @param _scene BabylonJS scene
  106697. */
  106698. constructor(_scene?: Scene | undefined);
  106699. /**
  106700. * The gamepads in the game pad manager
  106701. */
  106702. readonly gamepads: Gamepad[];
  106703. /**
  106704. * Get the gamepad controllers based on type
  106705. * @param type The type of gamepad controller
  106706. * @returns Nullable gamepad
  106707. */
  106708. getGamepadByType(type?: number): Nullable<Gamepad>;
  106709. /**
  106710. * Disposes the gamepad manager
  106711. */
  106712. dispose(): void;
  106713. private _addNewGamepad;
  106714. private _startMonitoringGamepads;
  106715. private _stopMonitoringGamepads;
  106716. /** @hidden */
  106717. _checkGamepadsStatus(): void;
  106718. private _updateGamepadObjects;
  106719. }
  106720. }
  106721. declare module BABYLON {
  106722. interface Scene {
  106723. /** @hidden */
  106724. _gamepadManager: Nullable<GamepadManager>;
  106725. /**
  106726. * Gets the gamepad manager associated with the scene
  106727. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106728. */
  106729. gamepadManager: GamepadManager;
  106730. }
  106731. /**
  106732. * Interface representing a free camera inputs manager
  106733. */
  106734. interface FreeCameraInputsManager {
  106735. /**
  106736. * Adds gamepad input support to the FreeCameraInputsManager.
  106737. * @returns the FreeCameraInputsManager
  106738. */
  106739. addGamepad(): FreeCameraInputsManager;
  106740. }
  106741. /**
  106742. * Interface representing an arc rotate camera inputs manager
  106743. */
  106744. interface ArcRotateCameraInputsManager {
  106745. /**
  106746. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106747. * @returns the camera inputs manager
  106748. */
  106749. addGamepad(): ArcRotateCameraInputsManager;
  106750. }
  106751. /**
  106752. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106753. */
  106754. export class GamepadSystemSceneComponent implements ISceneComponent {
  106755. /**
  106756. * The component name helpfull to identify the component in the list of scene components.
  106757. */
  106758. readonly name: string;
  106759. /**
  106760. * The scene the component belongs to.
  106761. */
  106762. scene: Scene;
  106763. /**
  106764. * Creates a new instance of the component for the given scene
  106765. * @param scene Defines the scene to register the component in
  106766. */
  106767. constructor(scene: Scene);
  106768. /**
  106769. * Registers the component in a given scene
  106770. */
  106771. register(): void;
  106772. /**
  106773. * Rebuilds the elements related to this component in case of
  106774. * context lost for instance.
  106775. */
  106776. rebuild(): void;
  106777. /**
  106778. * Disposes the component and the associated ressources
  106779. */
  106780. dispose(): void;
  106781. private _beforeCameraUpdate;
  106782. }
  106783. }
  106784. declare module BABYLON {
  106785. /**
  106786. * 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,
  106787. * which still works and will still be found in many Playgrounds.
  106788. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106789. */
  106790. export class UniversalCamera extends TouchCamera {
  106791. /**
  106792. * Defines the gamepad rotation sensiblity.
  106793. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106794. */
  106795. gamepadAngularSensibility: number;
  106796. /**
  106797. * Defines the gamepad move sensiblity.
  106798. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106799. */
  106800. gamepadMoveSensibility: number;
  106801. /**
  106802. * 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,
  106803. * which still works and will still be found in many Playgrounds.
  106804. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106805. * @param name Define the name of the camera in the scene
  106806. * @param position Define the start position of the camera in the scene
  106807. * @param scene Define the scene the camera belongs to
  106808. */
  106809. constructor(name: string, position: Vector3, scene: Scene);
  106810. /**
  106811. * Gets the current object class name.
  106812. * @return the class name
  106813. */
  106814. getClassName(): string;
  106815. }
  106816. }
  106817. declare module BABYLON {
  106818. /**
  106819. * This represents a FPS type of camera. This is only here for back compat purpose.
  106820. * Please use the UniversalCamera instead as both are identical.
  106821. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106822. */
  106823. export class GamepadCamera extends UniversalCamera {
  106824. /**
  106825. * Instantiates a new Gamepad Camera
  106826. * This represents a FPS type of camera. This is only here for back compat purpose.
  106827. * Please use the UniversalCamera instead as both are identical.
  106828. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106829. * @param name Define the name of the camera in the scene
  106830. * @param position Define the start position of the camera in the scene
  106831. * @param scene Define the scene the camera belongs to
  106832. */
  106833. constructor(name: string, position: Vector3, scene: Scene);
  106834. /**
  106835. * Gets the current object class name.
  106836. * @return the class name
  106837. */
  106838. getClassName(): string;
  106839. }
  106840. }
  106841. declare module BABYLON {
  106842. /** @hidden */
  106843. export var passPixelShader: {
  106844. name: string;
  106845. shader: string;
  106846. };
  106847. }
  106848. declare module BABYLON {
  106849. /** @hidden */
  106850. export var passCubePixelShader: {
  106851. name: string;
  106852. shader: string;
  106853. };
  106854. }
  106855. declare module BABYLON {
  106856. /**
  106857. * PassPostProcess which produces an output the same as it's input
  106858. */
  106859. export class PassPostProcess extends PostProcess {
  106860. /**
  106861. * Creates the PassPostProcess
  106862. * @param name The name of the effect.
  106863. * @param options The required width/height ratio to downsize to before computing the render pass.
  106864. * @param camera The camera to apply the render pass to.
  106865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106866. * @param engine The engine which the post process will be applied. (default: current engine)
  106867. * @param reusable If the post process can be reused on the same frame. (default: false)
  106868. * @param textureType The type of texture to be used when performing the post processing.
  106869. * @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)
  106870. */
  106871. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106872. }
  106873. /**
  106874. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106875. */
  106876. export class PassCubePostProcess extends PostProcess {
  106877. private _face;
  106878. /**
  106879. * Gets or sets the cube face to display.
  106880. * * 0 is +X
  106881. * * 1 is -X
  106882. * * 2 is +Y
  106883. * * 3 is -Y
  106884. * * 4 is +Z
  106885. * * 5 is -Z
  106886. */
  106887. face: number;
  106888. /**
  106889. * Creates the PassCubePostProcess
  106890. * @param name The name of the effect.
  106891. * @param options The required width/height ratio to downsize to before computing the render pass.
  106892. * @param camera The camera to apply the render pass to.
  106893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106894. * @param engine The engine which the post process will be applied. (default: current engine)
  106895. * @param reusable If the post process can be reused on the same frame. (default: false)
  106896. * @param textureType The type of texture to be used when performing the post processing.
  106897. * @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)
  106898. */
  106899. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106900. }
  106901. }
  106902. declare module BABYLON {
  106903. /** @hidden */
  106904. export var anaglyphPixelShader: {
  106905. name: string;
  106906. shader: string;
  106907. };
  106908. }
  106909. declare module BABYLON {
  106910. /**
  106911. * Postprocess used to generate anaglyphic rendering
  106912. */
  106913. export class AnaglyphPostProcess extends PostProcess {
  106914. private _passedProcess;
  106915. /**
  106916. * Creates a new AnaglyphPostProcess
  106917. * @param name defines postprocess name
  106918. * @param options defines creation options or target ratio scale
  106919. * @param rigCameras defines cameras using this postprocess
  106920. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106921. * @param engine defines hosting engine
  106922. * @param reusable defines if the postprocess will be reused multiple times per frame
  106923. */
  106924. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106925. }
  106926. }
  106927. declare module BABYLON {
  106928. /**
  106929. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106930. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106931. */
  106932. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106933. /**
  106934. * Creates a new AnaglyphArcRotateCamera
  106935. * @param name defines camera name
  106936. * @param alpha defines alpha angle (in radians)
  106937. * @param beta defines beta angle (in radians)
  106938. * @param radius defines radius
  106939. * @param target defines camera target
  106940. * @param interaxialDistance defines distance between each color axis
  106941. * @param scene defines the hosting scene
  106942. */
  106943. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106944. /**
  106945. * Gets camera class name
  106946. * @returns AnaglyphArcRotateCamera
  106947. */
  106948. getClassName(): string;
  106949. }
  106950. }
  106951. declare module BABYLON {
  106952. /**
  106953. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106954. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106955. */
  106956. export class AnaglyphFreeCamera extends FreeCamera {
  106957. /**
  106958. * Creates a new AnaglyphFreeCamera
  106959. * @param name defines camera name
  106960. * @param position defines initial position
  106961. * @param interaxialDistance defines distance between each color axis
  106962. * @param scene defines the hosting scene
  106963. */
  106964. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106965. /**
  106966. * Gets camera class name
  106967. * @returns AnaglyphFreeCamera
  106968. */
  106969. getClassName(): string;
  106970. }
  106971. }
  106972. declare module BABYLON {
  106973. /**
  106974. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106975. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106976. */
  106977. export class AnaglyphGamepadCamera extends GamepadCamera {
  106978. /**
  106979. * Creates a new AnaglyphGamepadCamera
  106980. * @param name defines camera name
  106981. * @param position defines initial position
  106982. * @param interaxialDistance defines distance between each color axis
  106983. * @param scene defines the hosting scene
  106984. */
  106985. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106986. /**
  106987. * Gets camera class name
  106988. * @returns AnaglyphGamepadCamera
  106989. */
  106990. getClassName(): string;
  106991. }
  106992. }
  106993. declare module BABYLON {
  106994. /**
  106995. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106996. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106997. */
  106998. export class AnaglyphUniversalCamera extends UniversalCamera {
  106999. /**
  107000. * Creates a new AnaglyphUniversalCamera
  107001. * @param name defines camera name
  107002. * @param position defines initial position
  107003. * @param interaxialDistance defines distance between each color axis
  107004. * @param scene defines the hosting scene
  107005. */
  107006. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107007. /**
  107008. * Gets camera class name
  107009. * @returns AnaglyphUniversalCamera
  107010. */
  107011. getClassName(): string;
  107012. }
  107013. }
  107014. declare module BABYLON {
  107015. /** @hidden */
  107016. export var stereoscopicInterlacePixelShader: {
  107017. name: string;
  107018. shader: string;
  107019. };
  107020. }
  107021. declare module BABYLON {
  107022. /**
  107023. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107024. */
  107025. export class StereoscopicInterlacePostProcess extends PostProcess {
  107026. private _stepSize;
  107027. private _passedProcess;
  107028. /**
  107029. * Initializes a StereoscopicInterlacePostProcess
  107030. * @param name The name of the effect.
  107031. * @param rigCameras The rig cameras to be appled to the post process
  107032. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107034. * @param engine The engine which the post process will be applied. (default: current engine)
  107035. * @param reusable If the post process can be reused on the same frame. (default: false)
  107036. */
  107037. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107038. }
  107039. }
  107040. declare module BABYLON {
  107041. /**
  107042. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107043. * @see http://doc.babylonjs.com/features/cameras
  107044. */
  107045. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107046. /**
  107047. * Creates a new StereoscopicArcRotateCamera
  107048. * @param name defines camera name
  107049. * @param alpha defines alpha angle (in radians)
  107050. * @param beta defines beta angle (in radians)
  107051. * @param radius defines radius
  107052. * @param target defines camera target
  107053. * @param interaxialDistance defines distance between each color axis
  107054. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107055. * @param scene defines the hosting scene
  107056. */
  107057. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107058. /**
  107059. * Gets camera class name
  107060. * @returns StereoscopicArcRotateCamera
  107061. */
  107062. getClassName(): string;
  107063. }
  107064. }
  107065. declare module BABYLON {
  107066. /**
  107067. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107068. * @see http://doc.babylonjs.com/features/cameras
  107069. */
  107070. export class StereoscopicFreeCamera extends FreeCamera {
  107071. /**
  107072. * Creates a new StereoscopicFreeCamera
  107073. * @param name defines camera name
  107074. * @param position defines initial position
  107075. * @param interaxialDistance defines distance between each color axis
  107076. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107077. * @param scene defines the hosting scene
  107078. */
  107079. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107080. /**
  107081. * Gets camera class name
  107082. * @returns StereoscopicFreeCamera
  107083. */
  107084. getClassName(): string;
  107085. }
  107086. }
  107087. declare module BABYLON {
  107088. /**
  107089. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107090. * @see http://doc.babylonjs.com/features/cameras
  107091. */
  107092. export class StereoscopicGamepadCamera extends GamepadCamera {
  107093. /**
  107094. * Creates a new StereoscopicGamepadCamera
  107095. * @param name defines camera name
  107096. * @param position defines initial position
  107097. * @param interaxialDistance defines distance between each color axis
  107098. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107099. * @param scene defines the hosting scene
  107100. */
  107101. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107102. /**
  107103. * Gets camera class name
  107104. * @returns StereoscopicGamepadCamera
  107105. */
  107106. getClassName(): string;
  107107. }
  107108. }
  107109. declare module BABYLON {
  107110. /**
  107111. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107112. * @see http://doc.babylonjs.com/features/cameras
  107113. */
  107114. export class StereoscopicUniversalCamera extends UniversalCamera {
  107115. /**
  107116. * Creates a new StereoscopicUniversalCamera
  107117. * @param name defines camera name
  107118. * @param position defines initial position
  107119. * @param interaxialDistance defines distance between each color axis
  107120. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107121. * @param scene defines the hosting scene
  107122. */
  107123. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107124. /**
  107125. * Gets camera class name
  107126. * @returns StereoscopicUniversalCamera
  107127. */
  107128. getClassName(): string;
  107129. }
  107130. }
  107131. declare module BABYLON {
  107132. /**
  107133. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107134. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107135. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107136. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107137. */
  107138. export class VirtualJoysticksCamera extends FreeCamera {
  107139. /**
  107140. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107141. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107142. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107143. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107144. * @param name Define the name of the camera in the scene
  107145. * @param position Define the start position of the camera in the scene
  107146. * @param scene Define the scene the camera belongs to
  107147. */
  107148. constructor(name: string, position: Vector3, scene: Scene);
  107149. /**
  107150. * Gets the current object class name.
  107151. * @return the class name
  107152. */
  107153. getClassName(): string;
  107154. }
  107155. }
  107156. declare module BABYLON {
  107157. /**
  107158. * This represents all the required metrics to create a VR camera.
  107159. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107160. */
  107161. export class VRCameraMetrics {
  107162. /**
  107163. * Define the horizontal resolution off the screen.
  107164. */
  107165. hResolution: number;
  107166. /**
  107167. * Define the vertical resolution off the screen.
  107168. */
  107169. vResolution: number;
  107170. /**
  107171. * Define the horizontal screen size.
  107172. */
  107173. hScreenSize: number;
  107174. /**
  107175. * Define the vertical screen size.
  107176. */
  107177. vScreenSize: number;
  107178. /**
  107179. * Define the vertical screen center position.
  107180. */
  107181. vScreenCenter: number;
  107182. /**
  107183. * Define the distance of the eyes to the screen.
  107184. */
  107185. eyeToScreenDistance: number;
  107186. /**
  107187. * Define the distance between both lenses
  107188. */
  107189. lensSeparationDistance: number;
  107190. /**
  107191. * Define the distance between both viewer's eyes.
  107192. */
  107193. interpupillaryDistance: number;
  107194. /**
  107195. * Define the distortion factor of the VR postprocess.
  107196. * Please, touch with care.
  107197. */
  107198. distortionK: number[];
  107199. /**
  107200. * Define the chromatic aberration correction factors for the VR post process.
  107201. */
  107202. chromaAbCorrection: number[];
  107203. /**
  107204. * Define the scale factor of the post process.
  107205. * The smaller the better but the slower.
  107206. */
  107207. postProcessScaleFactor: number;
  107208. /**
  107209. * Define an offset for the lens center.
  107210. */
  107211. lensCenterOffset: number;
  107212. /**
  107213. * Define if the current vr camera should compensate the distortion of the lense or not.
  107214. */
  107215. compensateDistortion: boolean;
  107216. /**
  107217. * Defines if multiview should be enabled when rendering (Default: false)
  107218. */
  107219. multiviewEnabled: boolean;
  107220. /**
  107221. * Gets the rendering aspect ratio based on the provided resolutions.
  107222. */
  107223. readonly aspectRatio: number;
  107224. /**
  107225. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107226. */
  107227. readonly aspectRatioFov: number;
  107228. /**
  107229. * @hidden
  107230. */
  107231. readonly leftHMatrix: Matrix;
  107232. /**
  107233. * @hidden
  107234. */
  107235. readonly rightHMatrix: Matrix;
  107236. /**
  107237. * @hidden
  107238. */
  107239. readonly leftPreViewMatrix: Matrix;
  107240. /**
  107241. * @hidden
  107242. */
  107243. readonly rightPreViewMatrix: Matrix;
  107244. /**
  107245. * Get the default VRMetrics based on the most generic setup.
  107246. * @returns the default vr metrics
  107247. */
  107248. static GetDefault(): VRCameraMetrics;
  107249. }
  107250. }
  107251. declare module BABYLON {
  107252. /** @hidden */
  107253. export var vrDistortionCorrectionPixelShader: {
  107254. name: string;
  107255. shader: string;
  107256. };
  107257. }
  107258. declare module BABYLON {
  107259. /**
  107260. * VRDistortionCorrectionPostProcess used for mobile VR
  107261. */
  107262. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107263. private _isRightEye;
  107264. private _distortionFactors;
  107265. private _postProcessScaleFactor;
  107266. private _lensCenterOffset;
  107267. private _scaleIn;
  107268. private _scaleFactor;
  107269. private _lensCenter;
  107270. /**
  107271. * Initializes the VRDistortionCorrectionPostProcess
  107272. * @param name The name of the effect.
  107273. * @param camera The camera to apply the render pass to.
  107274. * @param isRightEye If this is for the right eye distortion
  107275. * @param vrMetrics All the required metrics for the VR camera
  107276. */
  107277. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107278. }
  107279. }
  107280. declare module BABYLON {
  107281. /**
  107282. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107283. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107284. */
  107285. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107286. /**
  107287. * Creates a new VRDeviceOrientationArcRotateCamera
  107288. * @param name defines camera name
  107289. * @param alpha defines the camera rotation along the logitudinal axis
  107290. * @param beta defines the camera rotation along the latitudinal axis
  107291. * @param radius defines the camera distance from its target
  107292. * @param target defines the camera target
  107293. * @param scene defines the scene the camera belongs to
  107294. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107295. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107296. */
  107297. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107298. /**
  107299. * Gets camera class name
  107300. * @returns VRDeviceOrientationArcRotateCamera
  107301. */
  107302. getClassName(): string;
  107303. }
  107304. }
  107305. declare module BABYLON {
  107306. /**
  107307. * Camera used to simulate VR rendering (based on FreeCamera)
  107308. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107309. */
  107310. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107311. /**
  107312. * Creates a new VRDeviceOrientationFreeCamera
  107313. * @param name defines camera name
  107314. * @param position defines the start position of the camera
  107315. * @param scene defines the scene the camera belongs to
  107316. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107317. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107318. */
  107319. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107320. /**
  107321. * Gets camera class name
  107322. * @returns VRDeviceOrientationFreeCamera
  107323. */
  107324. getClassName(): string;
  107325. }
  107326. }
  107327. declare module BABYLON {
  107328. /**
  107329. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107330. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107331. */
  107332. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107333. /**
  107334. * Creates a new VRDeviceOrientationGamepadCamera
  107335. * @param name defines camera name
  107336. * @param position defines the start position of the camera
  107337. * @param scene defines the scene the camera belongs to
  107338. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107339. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107340. */
  107341. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107342. /**
  107343. * Gets camera class name
  107344. * @returns VRDeviceOrientationGamepadCamera
  107345. */
  107346. getClassName(): string;
  107347. }
  107348. }
  107349. declare module BABYLON {
  107350. /**
  107351. * Base class of materials working in push mode in babylon JS
  107352. * @hidden
  107353. */
  107354. export class PushMaterial extends Material {
  107355. protected _activeEffect: Effect;
  107356. protected _normalMatrix: Matrix;
  107357. /**
  107358. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107359. * This means that the material can keep using a previous shader while a new one is being compiled.
  107360. * This is mostly used when shader parallel compilation is supported (true by default)
  107361. */
  107362. allowShaderHotSwapping: boolean;
  107363. constructor(name: string, scene: Scene);
  107364. getEffect(): Effect;
  107365. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107366. /**
  107367. * Binds the given world matrix to the active effect
  107368. *
  107369. * @param world the matrix to bind
  107370. */
  107371. bindOnlyWorldMatrix(world: Matrix): void;
  107372. /**
  107373. * Binds the given normal matrix to the active effect
  107374. *
  107375. * @param normalMatrix the matrix to bind
  107376. */
  107377. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107378. bind(world: Matrix, mesh?: Mesh): void;
  107379. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107380. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107381. }
  107382. }
  107383. declare module BABYLON {
  107384. /**
  107385. * This groups all the flags used to control the materials channel.
  107386. */
  107387. export class MaterialFlags {
  107388. private static _DiffuseTextureEnabled;
  107389. /**
  107390. * Are diffuse textures enabled in the application.
  107391. */
  107392. static DiffuseTextureEnabled: boolean;
  107393. private static _AmbientTextureEnabled;
  107394. /**
  107395. * Are ambient textures enabled in the application.
  107396. */
  107397. static AmbientTextureEnabled: boolean;
  107398. private static _OpacityTextureEnabled;
  107399. /**
  107400. * Are opacity textures enabled in the application.
  107401. */
  107402. static OpacityTextureEnabled: boolean;
  107403. private static _ReflectionTextureEnabled;
  107404. /**
  107405. * Are reflection textures enabled in the application.
  107406. */
  107407. static ReflectionTextureEnabled: boolean;
  107408. private static _EmissiveTextureEnabled;
  107409. /**
  107410. * Are emissive textures enabled in the application.
  107411. */
  107412. static EmissiveTextureEnabled: boolean;
  107413. private static _SpecularTextureEnabled;
  107414. /**
  107415. * Are specular textures enabled in the application.
  107416. */
  107417. static SpecularTextureEnabled: boolean;
  107418. private static _BumpTextureEnabled;
  107419. /**
  107420. * Are bump textures enabled in the application.
  107421. */
  107422. static BumpTextureEnabled: boolean;
  107423. private static _LightmapTextureEnabled;
  107424. /**
  107425. * Are lightmap textures enabled in the application.
  107426. */
  107427. static LightmapTextureEnabled: boolean;
  107428. private static _RefractionTextureEnabled;
  107429. /**
  107430. * Are refraction textures enabled in the application.
  107431. */
  107432. static RefractionTextureEnabled: boolean;
  107433. private static _ColorGradingTextureEnabled;
  107434. /**
  107435. * Are color grading textures enabled in the application.
  107436. */
  107437. static ColorGradingTextureEnabled: boolean;
  107438. private static _FresnelEnabled;
  107439. /**
  107440. * Are fresnels enabled in the application.
  107441. */
  107442. static FresnelEnabled: boolean;
  107443. private static _ClearCoatTextureEnabled;
  107444. /**
  107445. * Are clear coat textures enabled in the application.
  107446. */
  107447. static ClearCoatTextureEnabled: boolean;
  107448. private static _ClearCoatBumpTextureEnabled;
  107449. /**
  107450. * Are clear coat bump textures enabled in the application.
  107451. */
  107452. static ClearCoatBumpTextureEnabled: boolean;
  107453. private static _ClearCoatTintTextureEnabled;
  107454. /**
  107455. * Are clear coat tint textures enabled in the application.
  107456. */
  107457. static ClearCoatTintTextureEnabled: boolean;
  107458. private static _SheenTextureEnabled;
  107459. /**
  107460. * Are sheen textures enabled in the application.
  107461. */
  107462. static SheenTextureEnabled: boolean;
  107463. private static _AnisotropicTextureEnabled;
  107464. /**
  107465. * Are anisotropic textures enabled in the application.
  107466. */
  107467. static AnisotropicTextureEnabled: boolean;
  107468. private static _ThicknessTextureEnabled;
  107469. /**
  107470. * Are thickness textures enabled in the application.
  107471. */
  107472. static ThicknessTextureEnabled: boolean;
  107473. }
  107474. }
  107475. declare module BABYLON {
  107476. /** @hidden */
  107477. export var defaultFragmentDeclaration: {
  107478. name: string;
  107479. shader: string;
  107480. };
  107481. }
  107482. declare module BABYLON {
  107483. /** @hidden */
  107484. export var defaultUboDeclaration: {
  107485. name: string;
  107486. shader: string;
  107487. };
  107488. }
  107489. declare module BABYLON {
  107490. /** @hidden */
  107491. export var lightFragmentDeclaration: {
  107492. name: string;
  107493. shader: string;
  107494. };
  107495. }
  107496. declare module BABYLON {
  107497. /** @hidden */
  107498. export var lightUboDeclaration: {
  107499. name: string;
  107500. shader: string;
  107501. };
  107502. }
  107503. declare module BABYLON {
  107504. /** @hidden */
  107505. export var lightsFragmentFunctions: {
  107506. name: string;
  107507. shader: string;
  107508. };
  107509. }
  107510. declare module BABYLON {
  107511. /** @hidden */
  107512. export var shadowsFragmentFunctions: {
  107513. name: string;
  107514. shader: string;
  107515. };
  107516. }
  107517. declare module BABYLON {
  107518. /** @hidden */
  107519. export var fresnelFunction: {
  107520. name: string;
  107521. shader: string;
  107522. };
  107523. }
  107524. declare module BABYLON {
  107525. /** @hidden */
  107526. export var reflectionFunction: {
  107527. name: string;
  107528. shader: string;
  107529. };
  107530. }
  107531. declare module BABYLON {
  107532. /** @hidden */
  107533. export var bumpFragmentFunctions: {
  107534. name: string;
  107535. shader: string;
  107536. };
  107537. }
  107538. declare module BABYLON {
  107539. /** @hidden */
  107540. export var logDepthDeclaration: {
  107541. name: string;
  107542. shader: string;
  107543. };
  107544. }
  107545. declare module BABYLON {
  107546. /** @hidden */
  107547. export var bumpFragment: {
  107548. name: string;
  107549. shader: string;
  107550. };
  107551. }
  107552. declare module BABYLON {
  107553. /** @hidden */
  107554. export var depthPrePass: {
  107555. name: string;
  107556. shader: string;
  107557. };
  107558. }
  107559. declare module BABYLON {
  107560. /** @hidden */
  107561. export var lightFragment: {
  107562. name: string;
  107563. shader: string;
  107564. };
  107565. }
  107566. declare module BABYLON {
  107567. /** @hidden */
  107568. export var logDepthFragment: {
  107569. name: string;
  107570. shader: string;
  107571. };
  107572. }
  107573. declare module BABYLON {
  107574. /** @hidden */
  107575. export var defaultPixelShader: {
  107576. name: string;
  107577. shader: string;
  107578. };
  107579. }
  107580. declare module BABYLON {
  107581. /** @hidden */
  107582. export var defaultVertexDeclaration: {
  107583. name: string;
  107584. shader: string;
  107585. };
  107586. }
  107587. declare module BABYLON {
  107588. /** @hidden */
  107589. export var bumpVertexDeclaration: {
  107590. name: string;
  107591. shader: string;
  107592. };
  107593. }
  107594. declare module BABYLON {
  107595. /** @hidden */
  107596. export var bumpVertex: {
  107597. name: string;
  107598. shader: string;
  107599. };
  107600. }
  107601. declare module BABYLON {
  107602. /** @hidden */
  107603. export var fogVertex: {
  107604. name: string;
  107605. shader: string;
  107606. };
  107607. }
  107608. declare module BABYLON {
  107609. /** @hidden */
  107610. export var shadowsVertex: {
  107611. name: string;
  107612. shader: string;
  107613. };
  107614. }
  107615. declare module BABYLON {
  107616. /** @hidden */
  107617. export var pointCloudVertex: {
  107618. name: string;
  107619. shader: string;
  107620. };
  107621. }
  107622. declare module BABYLON {
  107623. /** @hidden */
  107624. export var logDepthVertex: {
  107625. name: string;
  107626. shader: string;
  107627. };
  107628. }
  107629. declare module BABYLON {
  107630. /** @hidden */
  107631. export var defaultVertexShader: {
  107632. name: string;
  107633. shader: string;
  107634. };
  107635. }
  107636. declare module BABYLON {
  107637. /** @hidden */
  107638. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107639. MAINUV1: boolean;
  107640. MAINUV2: boolean;
  107641. DIFFUSE: boolean;
  107642. DIFFUSEDIRECTUV: number;
  107643. AMBIENT: boolean;
  107644. AMBIENTDIRECTUV: number;
  107645. OPACITY: boolean;
  107646. OPACITYDIRECTUV: number;
  107647. OPACITYRGB: boolean;
  107648. REFLECTION: boolean;
  107649. EMISSIVE: boolean;
  107650. EMISSIVEDIRECTUV: number;
  107651. SPECULAR: boolean;
  107652. SPECULARDIRECTUV: number;
  107653. BUMP: boolean;
  107654. BUMPDIRECTUV: number;
  107655. PARALLAX: boolean;
  107656. PARALLAXOCCLUSION: boolean;
  107657. SPECULAROVERALPHA: boolean;
  107658. CLIPPLANE: boolean;
  107659. CLIPPLANE2: boolean;
  107660. CLIPPLANE3: boolean;
  107661. CLIPPLANE4: boolean;
  107662. ALPHATEST: boolean;
  107663. DEPTHPREPASS: boolean;
  107664. ALPHAFROMDIFFUSE: boolean;
  107665. POINTSIZE: boolean;
  107666. FOG: boolean;
  107667. SPECULARTERM: boolean;
  107668. DIFFUSEFRESNEL: boolean;
  107669. OPACITYFRESNEL: boolean;
  107670. REFLECTIONFRESNEL: boolean;
  107671. REFRACTIONFRESNEL: boolean;
  107672. EMISSIVEFRESNEL: boolean;
  107673. FRESNEL: boolean;
  107674. NORMAL: boolean;
  107675. UV1: boolean;
  107676. UV2: boolean;
  107677. VERTEXCOLOR: boolean;
  107678. VERTEXALPHA: boolean;
  107679. NUM_BONE_INFLUENCERS: number;
  107680. BonesPerMesh: number;
  107681. BONETEXTURE: boolean;
  107682. INSTANCES: boolean;
  107683. GLOSSINESS: boolean;
  107684. ROUGHNESS: boolean;
  107685. EMISSIVEASILLUMINATION: boolean;
  107686. LINKEMISSIVEWITHDIFFUSE: boolean;
  107687. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107688. LIGHTMAP: boolean;
  107689. LIGHTMAPDIRECTUV: number;
  107690. OBJECTSPACE_NORMALMAP: boolean;
  107691. USELIGHTMAPASSHADOWMAP: boolean;
  107692. REFLECTIONMAP_3D: boolean;
  107693. REFLECTIONMAP_SPHERICAL: boolean;
  107694. REFLECTIONMAP_PLANAR: boolean;
  107695. REFLECTIONMAP_CUBIC: boolean;
  107696. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107697. REFLECTIONMAP_PROJECTION: boolean;
  107698. REFLECTIONMAP_SKYBOX: boolean;
  107699. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107700. REFLECTIONMAP_EXPLICIT: boolean;
  107701. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107702. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107703. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107704. INVERTCUBICMAP: boolean;
  107705. LOGARITHMICDEPTH: boolean;
  107706. REFRACTION: boolean;
  107707. REFRACTIONMAP_3D: boolean;
  107708. REFLECTIONOVERALPHA: boolean;
  107709. TWOSIDEDLIGHTING: boolean;
  107710. SHADOWFLOAT: boolean;
  107711. MORPHTARGETS: boolean;
  107712. MORPHTARGETS_NORMAL: boolean;
  107713. MORPHTARGETS_TANGENT: boolean;
  107714. MORPHTARGETS_UV: boolean;
  107715. NUM_MORPH_INFLUENCERS: number;
  107716. NONUNIFORMSCALING: boolean;
  107717. PREMULTIPLYALPHA: boolean;
  107718. IMAGEPROCESSING: boolean;
  107719. VIGNETTE: boolean;
  107720. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107721. VIGNETTEBLENDMODEOPAQUE: boolean;
  107722. TONEMAPPING: boolean;
  107723. TONEMAPPING_ACES: boolean;
  107724. CONTRAST: boolean;
  107725. COLORCURVES: boolean;
  107726. COLORGRADING: boolean;
  107727. COLORGRADING3D: boolean;
  107728. SAMPLER3DGREENDEPTH: boolean;
  107729. SAMPLER3DBGRMAP: boolean;
  107730. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107731. MULTIVIEW: boolean;
  107732. /**
  107733. * If the reflection texture on this material is in linear color space
  107734. * @hidden
  107735. */
  107736. IS_REFLECTION_LINEAR: boolean;
  107737. /**
  107738. * If the refraction texture on this material is in linear color space
  107739. * @hidden
  107740. */
  107741. IS_REFRACTION_LINEAR: boolean;
  107742. EXPOSURE: boolean;
  107743. constructor();
  107744. setReflectionMode(modeToEnable: string): void;
  107745. }
  107746. /**
  107747. * This is the default material used in Babylon. It is the best trade off between quality
  107748. * and performances.
  107749. * @see http://doc.babylonjs.com/babylon101/materials
  107750. */
  107751. export class StandardMaterial extends PushMaterial {
  107752. private _diffuseTexture;
  107753. /**
  107754. * The basic texture of the material as viewed under a light.
  107755. */
  107756. diffuseTexture: Nullable<BaseTexture>;
  107757. private _ambientTexture;
  107758. /**
  107759. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107760. */
  107761. ambientTexture: Nullable<BaseTexture>;
  107762. private _opacityTexture;
  107763. /**
  107764. * Define the transparency of the material from a texture.
  107765. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107766. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107767. */
  107768. opacityTexture: Nullable<BaseTexture>;
  107769. private _reflectionTexture;
  107770. /**
  107771. * Define the texture used to display the reflection.
  107772. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107773. */
  107774. reflectionTexture: Nullable<BaseTexture>;
  107775. private _emissiveTexture;
  107776. /**
  107777. * Define texture of the material as if self lit.
  107778. * This will be mixed in the final result even in the absence of light.
  107779. */
  107780. emissiveTexture: Nullable<BaseTexture>;
  107781. private _specularTexture;
  107782. /**
  107783. * Define how the color and intensity of the highlight given by the light in the material.
  107784. */
  107785. specularTexture: Nullable<BaseTexture>;
  107786. private _bumpTexture;
  107787. /**
  107788. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107789. * 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.
  107790. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107791. */
  107792. bumpTexture: Nullable<BaseTexture>;
  107793. private _lightmapTexture;
  107794. /**
  107795. * Complex lighting can be computationally expensive to compute at runtime.
  107796. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107797. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107798. */
  107799. lightmapTexture: Nullable<BaseTexture>;
  107800. private _refractionTexture;
  107801. /**
  107802. * Define the texture used to display the refraction.
  107803. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107804. */
  107805. refractionTexture: Nullable<BaseTexture>;
  107806. /**
  107807. * The color of the material lit by the environmental background lighting.
  107808. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107809. */
  107810. ambientColor: Color3;
  107811. /**
  107812. * The basic color of the material as viewed under a light.
  107813. */
  107814. diffuseColor: Color3;
  107815. /**
  107816. * Define how the color and intensity of the highlight given by the light in the material.
  107817. */
  107818. specularColor: Color3;
  107819. /**
  107820. * Define the color of the material as if self lit.
  107821. * This will be mixed in the final result even in the absence of light.
  107822. */
  107823. emissiveColor: Color3;
  107824. /**
  107825. * Defines how sharp are the highlights in the material.
  107826. * The bigger the value the sharper giving a more glossy feeling to the result.
  107827. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107828. */
  107829. specularPower: number;
  107830. private _useAlphaFromDiffuseTexture;
  107831. /**
  107832. * Does the transparency come from the diffuse texture alpha channel.
  107833. */
  107834. useAlphaFromDiffuseTexture: boolean;
  107835. private _useEmissiveAsIllumination;
  107836. /**
  107837. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107838. */
  107839. useEmissiveAsIllumination: boolean;
  107840. private _linkEmissiveWithDiffuse;
  107841. /**
  107842. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107843. * the emissive level when the final color is close to one.
  107844. */
  107845. linkEmissiveWithDiffuse: boolean;
  107846. private _useSpecularOverAlpha;
  107847. /**
  107848. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107849. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107850. */
  107851. useSpecularOverAlpha: boolean;
  107852. private _useReflectionOverAlpha;
  107853. /**
  107854. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107855. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107856. */
  107857. useReflectionOverAlpha: boolean;
  107858. private _disableLighting;
  107859. /**
  107860. * Does lights from the scene impacts this material.
  107861. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107862. */
  107863. disableLighting: boolean;
  107864. private _useObjectSpaceNormalMap;
  107865. /**
  107866. * Allows using an object space normal map (instead of tangent space).
  107867. */
  107868. useObjectSpaceNormalMap: boolean;
  107869. private _useParallax;
  107870. /**
  107871. * Is parallax enabled or not.
  107872. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107873. */
  107874. useParallax: boolean;
  107875. private _useParallaxOcclusion;
  107876. /**
  107877. * Is parallax occlusion enabled or not.
  107878. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107879. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107880. */
  107881. useParallaxOcclusion: boolean;
  107882. /**
  107883. * 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.
  107884. */
  107885. parallaxScaleBias: number;
  107886. private _roughness;
  107887. /**
  107888. * Helps to define how blurry the reflections should appears in the material.
  107889. */
  107890. roughness: number;
  107891. /**
  107892. * In case of refraction, define the value of the index of refraction.
  107893. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107894. */
  107895. indexOfRefraction: number;
  107896. /**
  107897. * Invert the refraction texture alongside the y axis.
  107898. * It can be useful with procedural textures or probe for instance.
  107899. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107900. */
  107901. invertRefractionY: boolean;
  107902. /**
  107903. * Defines the alpha limits in alpha test mode.
  107904. */
  107905. alphaCutOff: number;
  107906. private _useLightmapAsShadowmap;
  107907. /**
  107908. * In case of light mapping, define whether the map contains light or shadow informations.
  107909. */
  107910. useLightmapAsShadowmap: boolean;
  107911. private _diffuseFresnelParameters;
  107912. /**
  107913. * Define the diffuse fresnel parameters of the material.
  107914. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107915. */
  107916. diffuseFresnelParameters: FresnelParameters;
  107917. private _opacityFresnelParameters;
  107918. /**
  107919. * Define the opacity fresnel parameters of the material.
  107920. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107921. */
  107922. opacityFresnelParameters: FresnelParameters;
  107923. private _reflectionFresnelParameters;
  107924. /**
  107925. * Define the reflection fresnel parameters of the material.
  107926. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107927. */
  107928. reflectionFresnelParameters: FresnelParameters;
  107929. private _refractionFresnelParameters;
  107930. /**
  107931. * Define the refraction fresnel parameters of the material.
  107932. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107933. */
  107934. refractionFresnelParameters: FresnelParameters;
  107935. private _emissiveFresnelParameters;
  107936. /**
  107937. * Define the emissive fresnel parameters of the material.
  107938. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107939. */
  107940. emissiveFresnelParameters: FresnelParameters;
  107941. private _useReflectionFresnelFromSpecular;
  107942. /**
  107943. * If true automatically deducts the fresnels values from the material specularity.
  107944. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107945. */
  107946. useReflectionFresnelFromSpecular: boolean;
  107947. private _useGlossinessFromSpecularMapAlpha;
  107948. /**
  107949. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107950. */
  107951. useGlossinessFromSpecularMapAlpha: boolean;
  107952. private _maxSimultaneousLights;
  107953. /**
  107954. * Defines the maximum number of lights that can be used in the material
  107955. */
  107956. maxSimultaneousLights: number;
  107957. private _invertNormalMapX;
  107958. /**
  107959. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107960. */
  107961. invertNormalMapX: boolean;
  107962. private _invertNormalMapY;
  107963. /**
  107964. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107965. */
  107966. invertNormalMapY: boolean;
  107967. private _twoSidedLighting;
  107968. /**
  107969. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107970. */
  107971. twoSidedLighting: boolean;
  107972. /**
  107973. * Default configuration related to image processing available in the standard Material.
  107974. */
  107975. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107976. /**
  107977. * Gets the image processing configuration used either in this material.
  107978. */
  107979. /**
  107980. * Sets the Default image processing configuration used either in the this material.
  107981. *
  107982. * If sets to null, the scene one is in use.
  107983. */
  107984. imageProcessingConfiguration: ImageProcessingConfiguration;
  107985. /**
  107986. * Keep track of the image processing observer to allow dispose and replace.
  107987. */
  107988. private _imageProcessingObserver;
  107989. /**
  107990. * Attaches a new image processing configuration to the Standard Material.
  107991. * @param configuration
  107992. */
  107993. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107994. /**
  107995. * Gets wether the color curves effect is enabled.
  107996. */
  107997. /**
  107998. * Sets wether the color curves effect is enabled.
  107999. */
  108000. cameraColorCurvesEnabled: boolean;
  108001. /**
  108002. * Gets wether the color grading effect is enabled.
  108003. */
  108004. /**
  108005. * Gets wether the color grading effect is enabled.
  108006. */
  108007. cameraColorGradingEnabled: boolean;
  108008. /**
  108009. * Gets wether tonemapping is enabled or not.
  108010. */
  108011. /**
  108012. * Sets wether tonemapping is enabled or not
  108013. */
  108014. cameraToneMappingEnabled: boolean;
  108015. /**
  108016. * The camera exposure used on this material.
  108017. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108018. * This corresponds to a photographic exposure.
  108019. */
  108020. /**
  108021. * The camera exposure used on this material.
  108022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108023. * This corresponds to a photographic exposure.
  108024. */
  108025. cameraExposure: number;
  108026. /**
  108027. * Gets The camera contrast used on this material.
  108028. */
  108029. /**
  108030. * Sets The camera contrast used on this material.
  108031. */
  108032. cameraContrast: number;
  108033. /**
  108034. * Gets the Color Grading 2D Lookup Texture.
  108035. */
  108036. /**
  108037. * Sets the Color Grading 2D Lookup Texture.
  108038. */
  108039. cameraColorGradingTexture: Nullable<BaseTexture>;
  108040. /**
  108041. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108042. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108043. * 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;
  108044. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108045. */
  108046. /**
  108047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108049. * 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;
  108050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108051. */
  108052. cameraColorCurves: Nullable<ColorCurves>;
  108053. /**
  108054. * Custom callback helping to override the default shader used in the material.
  108055. */
  108056. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108057. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108058. protected _worldViewProjectionMatrix: Matrix;
  108059. protected _globalAmbientColor: Color3;
  108060. protected _useLogarithmicDepth: boolean;
  108061. protected _rebuildInParallel: boolean;
  108062. /**
  108063. * Instantiates a new standard material.
  108064. * This is the default material used in Babylon. It is the best trade off between quality
  108065. * and performances.
  108066. * @see http://doc.babylonjs.com/babylon101/materials
  108067. * @param name Define the name of the material in the scene
  108068. * @param scene Define the scene the material belong to
  108069. */
  108070. constructor(name: string, scene: Scene);
  108071. /**
  108072. * Gets a boolean indicating that current material needs to register RTT
  108073. */
  108074. readonly hasRenderTargetTextures: boolean;
  108075. /**
  108076. * Gets the current class name of the material e.g. "StandardMaterial"
  108077. * Mainly use in serialization.
  108078. * @returns the class name
  108079. */
  108080. getClassName(): string;
  108081. /**
  108082. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108083. * You can try switching to logarithmic depth.
  108084. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108085. */
  108086. useLogarithmicDepth: boolean;
  108087. /**
  108088. * Specifies if the material will require alpha blending
  108089. * @returns a boolean specifying if alpha blending is needed
  108090. */
  108091. needAlphaBlending(): boolean;
  108092. /**
  108093. * Specifies if this material should be rendered in alpha test mode
  108094. * @returns a boolean specifying if an alpha test is needed.
  108095. */
  108096. needAlphaTesting(): boolean;
  108097. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108098. /**
  108099. * Get the texture used for alpha test purpose.
  108100. * @returns the diffuse texture in case of the standard material.
  108101. */
  108102. getAlphaTestTexture(): Nullable<BaseTexture>;
  108103. /**
  108104. * Get if the submesh is ready to be used and all its information available.
  108105. * Child classes can use it to update shaders
  108106. * @param mesh defines the mesh to check
  108107. * @param subMesh defines which submesh to check
  108108. * @param useInstances specifies that instances should be used
  108109. * @returns a boolean indicating that the submesh is ready or not
  108110. */
  108111. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108112. /**
  108113. * Builds the material UBO layouts.
  108114. * Used internally during the effect preparation.
  108115. */
  108116. buildUniformLayout(): void;
  108117. /**
  108118. * Unbinds the material from the mesh
  108119. */
  108120. unbind(): void;
  108121. /**
  108122. * Binds the submesh to this material by preparing the effect and shader to draw
  108123. * @param world defines the world transformation matrix
  108124. * @param mesh defines the mesh containing the submesh
  108125. * @param subMesh defines the submesh to bind the material to
  108126. */
  108127. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108128. /**
  108129. * Get the list of animatables in the material.
  108130. * @returns the list of animatables object used in the material
  108131. */
  108132. getAnimatables(): IAnimatable[];
  108133. /**
  108134. * Gets the active textures from the material
  108135. * @returns an array of textures
  108136. */
  108137. getActiveTextures(): BaseTexture[];
  108138. /**
  108139. * Specifies if the material uses a texture
  108140. * @param texture defines the texture to check against the material
  108141. * @returns a boolean specifying if the material uses the texture
  108142. */
  108143. hasTexture(texture: BaseTexture): boolean;
  108144. /**
  108145. * Disposes the material
  108146. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108147. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108148. */
  108149. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108150. /**
  108151. * Makes a duplicate of the material, and gives it a new name
  108152. * @param name defines the new name for the duplicated material
  108153. * @returns the cloned material
  108154. */
  108155. clone(name: string): StandardMaterial;
  108156. /**
  108157. * Serializes this material in a JSON representation
  108158. * @returns the serialized material object
  108159. */
  108160. serialize(): any;
  108161. /**
  108162. * Creates a standard material from parsed material data
  108163. * @param source defines the JSON representation of the material
  108164. * @param scene defines the hosting scene
  108165. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108166. * @returns a new standard material
  108167. */
  108168. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108169. /**
  108170. * Are diffuse textures enabled in the application.
  108171. */
  108172. static DiffuseTextureEnabled: boolean;
  108173. /**
  108174. * Are ambient textures enabled in the application.
  108175. */
  108176. static AmbientTextureEnabled: boolean;
  108177. /**
  108178. * Are opacity textures enabled in the application.
  108179. */
  108180. static OpacityTextureEnabled: boolean;
  108181. /**
  108182. * Are reflection textures enabled in the application.
  108183. */
  108184. static ReflectionTextureEnabled: boolean;
  108185. /**
  108186. * Are emissive textures enabled in the application.
  108187. */
  108188. static EmissiveTextureEnabled: boolean;
  108189. /**
  108190. * Are specular textures enabled in the application.
  108191. */
  108192. static SpecularTextureEnabled: boolean;
  108193. /**
  108194. * Are bump textures enabled in the application.
  108195. */
  108196. static BumpTextureEnabled: boolean;
  108197. /**
  108198. * Are lightmap textures enabled in the application.
  108199. */
  108200. static LightmapTextureEnabled: boolean;
  108201. /**
  108202. * Are refraction textures enabled in the application.
  108203. */
  108204. static RefractionTextureEnabled: boolean;
  108205. /**
  108206. * Are color grading textures enabled in the application.
  108207. */
  108208. static ColorGradingTextureEnabled: boolean;
  108209. /**
  108210. * Are fresnels enabled in the application.
  108211. */
  108212. static FresnelEnabled: boolean;
  108213. }
  108214. }
  108215. declare module BABYLON {
  108216. /** @hidden */
  108217. export var imageProcessingPixelShader: {
  108218. name: string;
  108219. shader: string;
  108220. };
  108221. }
  108222. declare module BABYLON {
  108223. /**
  108224. * ImageProcessingPostProcess
  108225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108226. */
  108227. export class ImageProcessingPostProcess extends PostProcess {
  108228. /**
  108229. * Default configuration related to image processing available in the PBR Material.
  108230. */
  108231. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108232. /**
  108233. * Gets the image processing configuration used either in this material.
  108234. */
  108235. /**
  108236. * Sets the Default image processing configuration used either in the this material.
  108237. *
  108238. * If sets to null, the scene one is in use.
  108239. */
  108240. imageProcessingConfiguration: ImageProcessingConfiguration;
  108241. /**
  108242. * Keep track of the image processing observer to allow dispose and replace.
  108243. */
  108244. private _imageProcessingObserver;
  108245. /**
  108246. * Attaches a new image processing configuration to the PBR Material.
  108247. * @param configuration
  108248. */
  108249. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108250. /**
  108251. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108252. */
  108253. /**
  108254. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108255. */
  108256. colorCurves: Nullable<ColorCurves>;
  108257. /**
  108258. * Gets wether the color curves effect is enabled.
  108259. */
  108260. /**
  108261. * Sets wether the color curves effect is enabled.
  108262. */
  108263. colorCurvesEnabled: boolean;
  108264. /**
  108265. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108266. */
  108267. /**
  108268. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108269. */
  108270. colorGradingTexture: Nullable<BaseTexture>;
  108271. /**
  108272. * Gets wether the color grading effect is enabled.
  108273. */
  108274. /**
  108275. * Gets wether the color grading effect is enabled.
  108276. */
  108277. colorGradingEnabled: boolean;
  108278. /**
  108279. * Gets exposure used in the effect.
  108280. */
  108281. /**
  108282. * Sets exposure used in the effect.
  108283. */
  108284. exposure: number;
  108285. /**
  108286. * Gets wether tonemapping is enabled or not.
  108287. */
  108288. /**
  108289. * Sets wether tonemapping is enabled or not
  108290. */
  108291. toneMappingEnabled: boolean;
  108292. /**
  108293. * Gets the type of tone mapping effect.
  108294. */
  108295. /**
  108296. * Sets the type of tone mapping effect.
  108297. */
  108298. toneMappingType: number;
  108299. /**
  108300. * Gets contrast used in the effect.
  108301. */
  108302. /**
  108303. * Sets contrast used in the effect.
  108304. */
  108305. contrast: number;
  108306. /**
  108307. * Gets Vignette stretch size.
  108308. */
  108309. /**
  108310. * Sets Vignette stretch size.
  108311. */
  108312. vignetteStretch: number;
  108313. /**
  108314. * Gets Vignette centre X Offset.
  108315. */
  108316. /**
  108317. * Sets Vignette centre X Offset.
  108318. */
  108319. vignetteCentreX: number;
  108320. /**
  108321. * Gets Vignette centre Y Offset.
  108322. */
  108323. /**
  108324. * Sets Vignette centre Y Offset.
  108325. */
  108326. vignetteCentreY: number;
  108327. /**
  108328. * Gets Vignette weight or intensity of the vignette effect.
  108329. */
  108330. /**
  108331. * Sets Vignette weight or intensity of the vignette effect.
  108332. */
  108333. vignetteWeight: number;
  108334. /**
  108335. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108336. * if vignetteEnabled is set to true.
  108337. */
  108338. /**
  108339. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108340. * if vignetteEnabled is set to true.
  108341. */
  108342. vignetteColor: Color4;
  108343. /**
  108344. * Gets Camera field of view used by the Vignette effect.
  108345. */
  108346. /**
  108347. * Sets Camera field of view used by the Vignette effect.
  108348. */
  108349. vignetteCameraFov: number;
  108350. /**
  108351. * Gets the vignette blend mode allowing different kind of effect.
  108352. */
  108353. /**
  108354. * Sets the vignette blend mode allowing different kind of effect.
  108355. */
  108356. vignetteBlendMode: number;
  108357. /**
  108358. * Gets wether the vignette effect is enabled.
  108359. */
  108360. /**
  108361. * Sets wether the vignette effect is enabled.
  108362. */
  108363. vignetteEnabled: boolean;
  108364. private _fromLinearSpace;
  108365. /**
  108366. * Gets wether the input of the processing is in Gamma or Linear Space.
  108367. */
  108368. /**
  108369. * Sets wether the input of the processing is in Gamma or Linear Space.
  108370. */
  108371. fromLinearSpace: boolean;
  108372. /**
  108373. * Defines cache preventing GC.
  108374. */
  108375. private _defines;
  108376. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108377. /**
  108378. * "ImageProcessingPostProcess"
  108379. * @returns "ImageProcessingPostProcess"
  108380. */
  108381. getClassName(): string;
  108382. protected _updateParameters(): void;
  108383. dispose(camera?: Camera): void;
  108384. }
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * Class containing static functions to help procedurally build meshes
  108389. */
  108390. export class GroundBuilder {
  108391. /**
  108392. * Creates a ground mesh
  108393. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108394. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108396. * @param name defines the name of the mesh
  108397. * @param options defines the options used to create the mesh
  108398. * @param scene defines the hosting scene
  108399. * @returns the ground mesh
  108400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108401. */
  108402. static CreateGround(name: string, options: {
  108403. width?: number;
  108404. height?: number;
  108405. subdivisions?: number;
  108406. subdivisionsX?: number;
  108407. subdivisionsY?: number;
  108408. updatable?: boolean;
  108409. }, scene: any): Mesh;
  108410. /**
  108411. * Creates a tiled ground mesh
  108412. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108413. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108414. * * 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
  108415. * * 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
  108416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108417. * @param name defines the name of the mesh
  108418. * @param options defines the options used to create the mesh
  108419. * @param scene defines the hosting scene
  108420. * @returns the tiled ground mesh
  108421. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108422. */
  108423. static CreateTiledGround(name: string, options: {
  108424. xmin: number;
  108425. zmin: number;
  108426. xmax: number;
  108427. zmax: number;
  108428. subdivisions?: {
  108429. w: number;
  108430. h: number;
  108431. };
  108432. precision?: {
  108433. w: number;
  108434. h: number;
  108435. };
  108436. updatable?: boolean;
  108437. }, scene?: Nullable<Scene>): Mesh;
  108438. /**
  108439. * Creates a ground mesh from a height map
  108440. * * The parameter `url` sets the URL of the height map image resource.
  108441. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108442. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108443. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108444. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108445. * * 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.
  108446. * * 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).
  108447. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108449. * @param name defines the name of the mesh
  108450. * @param url defines the url to the height map
  108451. * @param options defines the options used to create the mesh
  108452. * @param scene defines the hosting scene
  108453. * @returns the ground mesh
  108454. * @see https://doc.babylonjs.com/babylon101/height_map
  108455. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108456. */
  108457. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108458. width?: number;
  108459. height?: number;
  108460. subdivisions?: number;
  108461. minHeight?: number;
  108462. maxHeight?: number;
  108463. colorFilter?: Color3;
  108464. alphaFilter?: number;
  108465. updatable?: boolean;
  108466. onReady?: (mesh: GroundMesh) => void;
  108467. }, scene?: Nullable<Scene>): GroundMesh;
  108468. }
  108469. }
  108470. declare module BABYLON {
  108471. /**
  108472. * Class containing static functions to help procedurally build meshes
  108473. */
  108474. export class TorusBuilder {
  108475. /**
  108476. * Creates a torus mesh
  108477. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108478. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108479. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108483. * @param name defines the name of the mesh
  108484. * @param options defines the options used to create the mesh
  108485. * @param scene defines the hosting scene
  108486. * @returns the torus mesh
  108487. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108488. */
  108489. static CreateTorus(name: string, options: {
  108490. diameter?: number;
  108491. thickness?: number;
  108492. tessellation?: number;
  108493. updatable?: boolean;
  108494. sideOrientation?: number;
  108495. frontUVs?: Vector4;
  108496. backUVs?: Vector4;
  108497. }, scene: any): Mesh;
  108498. }
  108499. }
  108500. declare module BABYLON {
  108501. /**
  108502. * Class containing static functions to help procedurally build meshes
  108503. */
  108504. export class CylinderBuilder {
  108505. /**
  108506. * Creates a cylinder or a cone mesh
  108507. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108508. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108509. * * 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.
  108510. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108511. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108512. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108513. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108514. * * 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).
  108515. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108516. * * 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).
  108517. * * 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
  108518. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108519. * * 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
  108520. * * 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.
  108521. * * If `enclose` is false, a ring surface is one element.
  108522. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108523. * * 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
  108524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108527. * @param name defines the name of the mesh
  108528. * @param options defines the options used to create the mesh
  108529. * @param scene defines the hosting scene
  108530. * @returns the cylinder mesh
  108531. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108532. */
  108533. static CreateCylinder(name: string, options: {
  108534. height?: number;
  108535. diameterTop?: number;
  108536. diameterBottom?: number;
  108537. diameter?: number;
  108538. tessellation?: number;
  108539. subdivisions?: number;
  108540. arc?: number;
  108541. faceColors?: Color4[];
  108542. faceUV?: Vector4[];
  108543. updatable?: boolean;
  108544. hasRings?: boolean;
  108545. enclose?: boolean;
  108546. cap?: number;
  108547. sideOrientation?: number;
  108548. frontUVs?: Vector4;
  108549. backUVs?: Vector4;
  108550. }, scene: any): Mesh;
  108551. }
  108552. }
  108553. declare module BABYLON {
  108554. /**
  108555. * Options to modify the vr teleportation behavior.
  108556. */
  108557. export interface VRTeleportationOptions {
  108558. /**
  108559. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108560. */
  108561. floorMeshName?: string;
  108562. /**
  108563. * A list of meshes to be used as the teleportation floor. (default: empty)
  108564. */
  108565. floorMeshes?: Mesh[];
  108566. }
  108567. /**
  108568. * Options to modify the vr experience helper's behavior.
  108569. */
  108570. export interface VRExperienceHelperOptions extends WebVROptions {
  108571. /**
  108572. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108573. */
  108574. createDeviceOrientationCamera?: boolean;
  108575. /**
  108576. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108577. */
  108578. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108579. /**
  108580. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108581. */
  108582. laserToggle?: boolean;
  108583. /**
  108584. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108585. */
  108586. floorMeshes?: Mesh[];
  108587. /**
  108588. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108589. */
  108590. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108591. }
  108592. /**
  108593. * Event containing information after VR has been entered
  108594. */
  108595. export class OnAfterEnteringVRObservableEvent {
  108596. /**
  108597. * If entering vr was successful
  108598. */
  108599. success: boolean;
  108600. }
  108601. /**
  108602. * Helps to quickly add VR support to an existing scene.
  108603. * See http://doc.babylonjs.com/how_to/webvr_helper
  108604. */
  108605. export class VRExperienceHelper {
  108606. /** Options to modify the vr experience helper's behavior. */
  108607. webVROptions: VRExperienceHelperOptions;
  108608. private _scene;
  108609. private _position;
  108610. private _btnVR;
  108611. private _btnVRDisplayed;
  108612. private _webVRsupported;
  108613. private _webVRready;
  108614. private _webVRrequesting;
  108615. private _webVRpresenting;
  108616. private _hasEnteredVR;
  108617. private _fullscreenVRpresenting;
  108618. private _canvas;
  108619. private _webVRCamera;
  108620. private _vrDeviceOrientationCamera;
  108621. private _deviceOrientationCamera;
  108622. private _existingCamera;
  108623. private _onKeyDown;
  108624. private _onVrDisplayPresentChange;
  108625. private _onVRDisplayChanged;
  108626. private _onVRRequestPresentStart;
  108627. private _onVRRequestPresentComplete;
  108628. /**
  108629. * 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)
  108630. */
  108631. enableGazeEvenWhenNoPointerLock: boolean;
  108632. /**
  108633. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108634. */
  108635. exitVROnDoubleTap: boolean;
  108636. /**
  108637. * Observable raised right before entering VR.
  108638. */
  108639. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108640. /**
  108641. * Observable raised when entering VR has completed.
  108642. */
  108643. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108644. /**
  108645. * Observable raised when exiting VR.
  108646. */
  108647. onExitingVRObservable: Observable<VRExperienceHelper>;
  108648. /**
  108649. * Observable raised when controller mesh is loaded.
  108650. */
  108651. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108652. /** Return this.onEnteringVRObservable
  108653. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108654. */
  108655. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108656. /** Return this.onExitingVRObservable
  108657. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108658. */
  108659. readonly onExitingVR: Observable<VRExperienceHelper>;
  108660. /** Return this.onControllerMeshLoadedObservable
  108661. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108662. */
  108663. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108664. private _rayLength;
  108665. private _useCustomVRButton;
  108666. private _teleportationRequested;
  108667. private _teleportActive;
  108668. private _floorMeshName;
  108669. private _floorMeshesCollection;
  108670. private _rotationAllowed;
  108671. private _teleportBackwardsVector;
  108672. private _teleportationTarget;
  108673. private _isDefaultTeleportationTarget;
  108674. private _postProcessMove;
  108675. private _teleportationFillColor;
  108676. private _teleportationBorderColor;
  108677. private _rotationAngle;
  108678. private _haloCenter;
  108679. private _cameraGazer;
  108680. private _padSensibilityUp;
  108681. private _padSensibilityDown;
  108682. private _leftController;
  108683. private _rightController;
  108684. /**
  108685. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108686. */
  108687. onNewMeshSelected: Observable<AbstractMesh>;
  108688. /**
  108689. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108690. * This observable will provide the mesh and the controller used to select the mesh
  108691. */
  108692. onMeshSelectedWithController: Observable<{
  108693. mesh: AbstractMesh;
  108694. controller: WebVRController;
  108695. }>;
  108696. /**
  108697. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108698. */
  108699. onNewMeshPicked: Observable<PickingInfo>;
  108700. private _circleEase;
  108701. /**
  108702. * Observable raised before camera teleportation
  108703. */
  108704. onBeforeCameraTeleport: Observable<Vector3>;
  108705. /**
  108706. * Observable raised after camera teleportation
  108707. */
  108708. onAfterCameraTeleport: Observable<Vector3>;
  108709. /**
  108710. * Observable raised when current selected mesh gets unselected
  108711. */
  108712. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108713. private _raySelectionPredicate;
  108714. /**
  108715. * To be optionaly changed by user to define custom ray selection
  108716. */
  108717. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108718. /**
  108719. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108720. */
  108721. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108722. /**
  108723. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108724. */
  108725. teleportationEnabled: boolean;
  108726. private _defaultHeight;
  108727. private _teleportationInitialized;
  108728. private _interactionsEnabled;
  108729. private _interactionsRequested;
  108730. private _displayGaze;
  108731. private _displayLaserPointer;
  108732. /**
  108733. * The mesh used to display where the user is going to teleport.
  108734. */
  108735. /**
  108736. * Sets the mesh to be used to display where the user is going to teleport.
  108737. */
  108738. teleportationTarget: Mesh;
  108739. /**
  108740. * 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
  108741. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108742. * See http://doc.babylonjs.com/resources/baking_transformations
  108743. */
  108744. gazeTrackerMesh: Mesh;
  108745. /**
  108746. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108747. */
  108748. updateGazeTrackerScale: boolean;
  108749. /**
  108750. * If the gaze trackers color should be updated when selecting meshes
  108751. */
  108752. updateGazeTrackerColor: boolean;
  108753. /**
  108754. * If the controller laser color should be updated when selecting meshes
  108755. */
  108756. updateControllerLaserColor: boolean;
  108757. /**
  108758. * The gaze tracking mesh corresponding to the left controller
  108759. */
  108760. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108761. /**
  108762. * The gaze tracking mesh corresponding to the right controller
  108763. */
  108764. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108765. /**
  108766. * If the ray of the gaze should be displayed.
  108767. */
  108768. /**
  108769. * Sets if the ray of the gaze should be displayed.
  108770. */
  108771. displayGaze: boolean;
  108772. /**
  108773. * If the ray of the LaserPointer should be displayed.
  108774. */
  108775. /**
  108776. * Sets if the ray of the LaserPointer should be displayed.
  108777. */
  108778. displayLaserPointer: boolean;
  108779. /**
  108780. * The deviceOrientationCamera used as the camera when not in VR.
  108781. */
  108782. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108783. /**
  108784. * Based on the current WebVR support, returns the current VR camera used.
  108785. */
  108786. readonly currentVRCamera: Nullable<Camera>;
  108787. /**
  108788. * The webVRCamera which is used when in VR.
  108789. */
  108790. readonly webVRCamera: WebVRFreeCamera;
  108791. /**
  108792. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108793. */
  108794. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108795. /**
  108796. * The html button that is used to trigger entering into VR.
  108797. */
  108798. readonly vrButton: Nullable<HTMLButtonElement>;
  108799. private readonly _teleportationRequestInitiated;
  108800. /**
  108801. * Defines wether or not Pointer lock should be requested when switching to
  108802. * full screen.
  108803. */
  108804. requestPointerLockOnFullScreen: boolean;
  108805. /**
  108806. * Instantiates a VRExperienceHelper.
  108807. * Helps to quickly add VR support to an existing scene.
  108808. * @param scene The scene the VRExperienceHelper belongs to.
  108809. * @param webVROptions Options to modify the vr experience helper's behavior.
  108810. */
  108811. constructor(scene: Scene,
  108812. /** Options to modify the vr experience helper's behavior. */
  108813. webVROptions?: VRExperienceHelperOptions);
  108814. private _onDefaultMeshLoaded;
  108815. private _onResize;
  108816. private _onFullscreenChange;
  108817. /**
  108818. * Gets a value indicating if we are currently in VR mode.
  108819. */
  108820. readonly isInVRMode: boolean;
  108821. private onVrDisplayPresentChange;
  108822. private onVRDisplayChanged;
  108823. private moveButtonToBottomRight;
  108824. private displayVRButton;
  108825. private updateButtonVisibility;
  108826. private _cachedAngularSensibility;
  108827. /**
  108828. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108829. * Otherwise, will use the fullscreen API.
  108830. */
  108831. enterVR(): void;
  108832. /**
  108833. * Attempt to exit VR, or fullscreen.
  108834. */
  108835. exitVR(): void;
  108836. /**
  108837. * The position of the vr experience helper.
  108838. */
  108839. /**
  108840. * Sets the position of the vr experience helper.
  108841. */
  108842. position: Vector3;
  108843. /**
  108844. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108845. */
  108846. enableInteractions(): void;
  108847. private readonly _noControllerIsActive;
  108848. private beforeRender;
  108849. private _isTeleportationFloor;
  108850. /**
  108851. * Adds a floor mesh to be used for teleportation.
  108852. * @param floorMesh the mesh to be used for teleportation.
  108853. */
  108854. addFloorMesh(floorMesh: Mesh): void;
  108855. /**
  108856. * Removes a floor mesh from being used for teleportation.
  108857. * @param floorMesh the mesh to be removed.
  108858. */
  108859. removeFloorMesh(floorMesh: Mesh): void;
  108860. /**
  108861. * Enables interactions and teleportation using the VR controllers and gaze.
  108862. * @param vrTeleportationOptions options to modify teleportation behavior.
  108863. */
  108864. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108865. private _onNewGamepadConnected;
  108866. private _tryEnableInteractionOnController;
  108867. private _onNewGamepadDisconnected;
  108868. private _enableInteractionOnController;
  108869. private _checkTeleportWithRay;
  108870. private _checkRotate;
  108871. private _checkTeleportBackwards;
  108872. private _enableTeleportationOnController;
  108873. private _createTeleportationCircles;
  108874. private _displayTeleportationTarget;
  108875. private _hideTeleportationTarget;
  108876. private _rotateCamera;
  108877. private _moveTeleportationSelectorTo;
  108878. private _workingVector;
  108879. private _workingQuaternion;
  108880. private _workingMatrix;
  108881. /**
  108882. * Teleports the users feet to the desired location
  108883. * @param location The location where the user's feet should be placed
  108884. */
  108885. teleportCamera(location: Vector3): void;
  108886. private _convertNormalToDirectionOfRay;
  108887. private _castRayAndSelectObject;
  108888. private _notifySelectedMeshUnselected;
  108889. /**
  108890. * Sets the color of the laser ray from the vr controllers.
  108891. * @param color new color for the ray.
  108892. */
  108893. changeLaserColor(color: Color3): void;
  108894. /**
  108895. * Sets the color of the ray from the vr headsets gaze.
  108896. * @param color new color for the ray.
  108897. */
  108898. changeGazeColor(color: Color3): void;
  108899. /**
  108900. * Exits VR and disposes of the vr experience helper
  108901. */
  108902. dispose(): void;
  108903. /**
  108904. * Gets the name of the VRExperienceHelper class
  108905. * @returns "VRExperienceHelper"
  108906. */
  108907. getClassName(): string;
  108908. }
  108909. }
  108910. declare module BABYLON {
  108911. /**
  108912. * Manages an XRSession to work with Babylon's engine
  108913. * @see https://doc.babylonjs.com/how_to/webxr
  108914. */
  108915. export class WebXRSessionManager implements IDisposable {
  108916. private scene;
  108917. /**
  108918. * Fires every time a new xrFrame arrives which can be used to update the camera
  108919. */
  108920. onXRFrameObservable: Observable<any>;
  108921. /**
  108922. * Fires when the xr session is ended either by the device or manually done
  108923. */
  108924. onXRSessionEnded: Observable<any>;
  108925. /**
  108926. * Underlying xr session
  108927. */
  108928. session: XRSession;
  108929. /**
  108930. * Type of reference space used when creating the session
  108931. */
  108932. referenceSpace: XRReferenceSpace;
  108933. /** @hidden */
  108934. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108935. /**
  108936. * Current XR frame
  108937. */
  108938. currentFrame: Nullable<XRFrame>;
  108939. private _xrNavigator;
  108940. private baseLayer;
  108941. private _sessionEnded;
  108942. /**
  108943. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108944. * @param scene The scene which the session should be created for
  108945. */
  108946. constructor(scene: Scene);
  108947. /**
  108948. * Initializes the manager
  108949. * After initialization enterXR can be called to start an XR session
  108950. * @returns Promise which resolves after it is initialized
  108951. */
  108952. initializeAsync(): Promise<void>;
  108953. /**
  108954. * Initializes an xr session
  108955. * @param xrSessionMode mode to initialize
  108956. * @returns a promise which will resolve once the session has been initialized
  108957. */
  108958. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108959. /**
  108960. * Sets the reference space on the xr session
  108961. * @param referenceSpace space to set
  108962. * @returns a promise that will resolve once the reference space has been set
  108963. */
  108964. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108965. /**
  108966. * Updates the render state of the session
  108967. * @param state state to set
  108968. * @returns a promise that resolves once the render state has been updated
  108969. */
  108970. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108971. /**
  108972. * Starts rendering to the xr layer
  108973. * @returns a promise that will resolve once rendering has started
  108974. */
  108975. startRenderingToXRAsync(): Promise<void>;
  108976. /**
  108977. * Stops the xrSession and restores the renderloop
  108978. * @returns Promise which resolves after it exits XR
  108979. */
  108980. exitXRAsync(): Promise<unknown>;
  108981. /**
  108982. * Checks if a session would be supported for the creation options specified
  108983. * @param sessionMode session mode to check if supported eg. immersive-vr
  108984. * @returns true if supported
  108985. */
  108986. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108987. /**
  108988. * @hidden
  108989. * Converts the render layer of xrSession to a render target
  108990. * @param session session to create render target for
  108991. * @param scene scene the new render target should be created for
  108992. */
  108993. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108994. /**
  108995. * Disposes of the session manager
  108996. */
  108997. dispose(): void;
  108998. }
  108999. }
  109000. declare module BABYLON {
  109001. /**
  109002. * WebXR Camera which holds the views for the xrSession
  109003. * @see https://doc.babylonjs.com/how_to/webxr
  109004. */
  109005. export class WebXRCamera extends FreeCamera {
  109006. private static _TmpMatrix;
  109007. /**
  109008. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109009. * @param name the name of the camera
  109010. * @param scene the scene to add the camera to
  109011. */
  109012. constructor(name: string, scene: Scene);
  109013. private _updateNumberOfRigCameras;
  109014. /** @hidden */
  109015. _updateForDualEyeDebugging(): void;
  109016. /**
  109017. * Updates the cameras position from the current pose information of the XR session
  109018. * @param xrSessionManager the session containing pose information
  109019. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109020. */
  109021. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109022. }
  109023. }
  109024. declare module BABYLON {
  109025. /**
  109026. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109027. */
  109028. export class WebXRManagedOutputCanvas implements IDisposable {
  109029. private helper;
  109030. private _canvas;
  109031. /**
  109032. * xrpresent context of the canvas which can be used to display/mirror xr content
  109033. */
  109034. canvasContext: WebGLRenderingContext;
  109035. /**
  109036. * xr layer for the canvas
  109037. */
  109038. xrLayer: Nullable<XRWebGLLayer>;
  109039. /**
  109040. * Initializes the xr layer for the session
  109041. * @param xrSession xr session
  109042. * @returns a promise that will resolve once the XR Layer has been created
  109043. */
  109044. initializeXRLayerAsync(xrSession: any): any;
  109045. /**
  109046. * Initializes the canvas to be added/removed upon entering/exiting xr
  109047. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  109048. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109049. */
  109050. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  109051. /**
  109052. * Disposes of the object
  109053. */
  109054. dispose(): void;
  109055. private _setManagedOutputCanvas;
  109056. private _addCanvas;
  109057. private _removeCanvas;
  109058. }
  109059. }
  109060. declare module BABYLON {
  109061. /**
  109062. * States of the webXR experience
  109063. */
  109064. export enum WebXRState {
  109065. /**
  109066. * Transitioning to being in XR mode
  109067. */
  109068. ENTERING_XR = 0,
  109069. /**
  109070. * Transitioning to non XR mode
  109071. */
  109072. EXITING_XR = 1,
  109073. /**
  109074. * In XR mode and presenting
  109075. */
  109076. IN_XR = 2,
  109077. /**
  109078. * Not entered XR mode
  109079. */
  109080. NOT_IN_XR = 3
  109081. }
  109082. /**
  109083. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109084. * @see https://doc.babylonjs.com/how_to/webxr
  109085. */
  109086. export class WebXRExperienceHelper implements IDisposable {
  109087. private scene;
  109088. /**
  109089. * 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
  109090. */
  109091. container: AbstractMesh;
  109092. /**
  109093. * Camera used to render xr content
  109094. */
  109095. camera: WebXRCamera;
  109096. /**
  109097. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109098. */
  109099. state: WebXRState;
  109100. private _setState;
  109101. private static _TmpVector;
  109102. /**
  109103. * Fires when the state of the experience helper has changed
  109104. */
  109105. onStateChangedObservable: Observable<WebXRState>;
  109106. /** Session manager used to keep track of xr session */
  109107. sessionManager: WebXRSessionManager;
  109108. private _nonVRCamera;
  109109. private _originalSceneAutoClear;
  109110. private _supported;
  109111. /**
  109112. * Creates the experience helper
  109113. * @param scene the scene to attach the experience helper to
  109114. * @returns a promise for the experience helper
  109115. */
  109116. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109117. /**
  109118. * Creates a WebXRExperienceHelper
  109119. * @param scene The scene the helper should be created in
  109120. */
  109121. private constructor();
  109122. /**
  109123. * Exits XR mode and returns the scene to its original state
  109124. * @returns promise that resolves after xr mode has exited
  109125. */
  109126. exitXRAsync(): Promise<unknown>;
  109127. /**
  109128. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109129. * @param sessionCreationOptions options for the XR session
  109130. * @param referenceSpaceType frame of reference of the XR session
  109131. * @param outputCanvas the output canvas that will be used to enter XR mode
  109132. * @returns promise that resolves after xr mode has entered
  109133. */
  109134. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  109135. /**
  109136. * Updates the global position of the camera by moving the camera's container
  109137. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109138. * @param position The desired global position of the camera
  109139. */
  109140. setPositionOfCameraUsingContainer(position: Vector3): void;
  109141. /**
  109142. * Rotates the xr camera by rotating the camera's container around the camera's position
  109143. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109144. * @param rotation the desired quaternion rotation to apply to the camera
  109145. */
  109146. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109147. /**
  109148. * Disposes of the experience helper
  109149. */
  109150. dispose(): void;
  109151. }
  109152. }
  109153. declare module BABYLON {
  109154. /**
  109155. * Button which can be used to enter a different mode of XR
  109156. */
  109157. export class WebXREnterExitUIButton {
  109158. /** button element */
  109159. element: HTMLElement;
  109160. /** XR initialization options for the button */
  109161. sessionMode: XRSessionMode;
  109162. /** Reference space type */
  109163. referenceSpaceType: XRReferenceSpaceType;
  109164. /**
  109165. * Creates a WebXREnterExitUIButton
  109166. * @param element button element
  109167. * @param sessionMode XR initialization session mode
  109168. * @param referenceSpaceType the type of reference space to be used
  109169. */
  109170. constructor(
  109171. /** button element */
  109172. element: HTMLElement,
  109173. /** XR initialization options for the button */
  109174. sessionMode: XRSessionMode,
  109175. /** Reference space type */
  109176. referenceSpaceType: XRReferenceSpaceType);
  109177. /**
  109178. * Overwritable function which can be used to update the button's visuals when the state changes
  109179. * @param activeButton the current active button in the UI
  109180. */
  109181. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109182. }
  109183. /**
  109184. * Options to create the webXR UI
  109185. */
  109186. export class WebXREnterExitUIOptions {
  109187. /**
  109188. * Context to enter xr with
  109189. */
  109190. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  109191. /**
  109192. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109193. */
  109194. customButtons?: Array<WebXREnterExitUIButton>;
  109195. }
  109196. /**
  109197. * UI to allow the user to enter/exit XR mode
  109198. */
  109199. export class WebXREnterExitUI implements IDisposable {
  109200. private scene;
  109201. private _overlay;
  109202. private _buttons;
  109203. private _activeButton;
  109204. /**
  109205. * Fired every time the active button is changed.
  109206. *
  109207. * When xr is entered via a button that launches xr that button will be the callback parameter
  109208. *
  109209. * When exiting xr the callback parameter will be null)
  109210. */
  109211. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109212. /**
  109213. * Creates UI to allow the user to enter/exit XR mode
  109214. * @param scene the scene to add the ui to
  109215. * @param helper the xr experience helper to enter/exit xr with
  109216. * @param options options to configure the UI
  109217. * @returns the created ui
  109218. */
  109219. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109220. private constructor();
  109221. private _updateButtons;
  109222. /**
  109223. * Disposes of the object
  109224. */
  109225. dispose(): void;
  109226. }
  109227. }
  109228. declare module BABYLON {
  109229. /**
  109230. * Represents an XR input
  109231. */
  109232. export class WebXRController {
  109233. private scene;
  109234. /** The underlying input source for the controller */
  109235. inputSource: XRInputSource;
  109236. private parentContainer;
  109237. /**
  109238. * 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
  109239. */
  109240. grip?: AbstractMesh;
  109241. /**
  109242. * Pointer which can be used to select objects or attach a visible laser to
  109243. */
  109244. pointer: AbstractMesh;
  109245. private _gamepadMode;
  109246. /**
  109247. * If available, this is the gamepad object related to this controller.
  109248. * Using this object it is possible to get click events and trackpad changes of the
  109249. * webxr controller that is currently being used.
  109250. */
  109251. gamepadController?: WebVRController;
  109252. /**
  109253. * Event that fires when the controller is removed/disposed
  109254. */
  109255. onDisposeObservable: Observable<{}>;
  109256. private _tmpMatrix;
  109257. private _tmpQuaternion;
  109258. private _tmpVector;
  109259. /**
  109260. * Creates the controller
  109261. * @see https://doc.babylonjs.com/how_to/webxr
  109262. * @param scene the scene which the controller should be associated to
  109263. * @param inputSource the underlying input source for the controller
  109264. * @param parentContainer parent that the controller meshes should be children of
  109265. */
  109266. constructor(scene: Scene,
  109267. /** The underlying input source for the controller */
  109268. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109269. /**
  109270. * Updates the controller pose based on the given XRFrame
  109271. * @param xrFrame xr frame to update the pose with
  109272. * @param referenceSpace reference space to use
  109273. */
  109274. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109275. /**
  109276. * Gets a world space ray coming from the controller
  109277. * @param result the resulting ray
  109278. */
  109279. getWorldPointerRayToRef(result: Ray): void;
  109280. /**
  109281. * Get the scene associated with this controller
  109282. * @returns the scene object
  109283. */
  109284. getScene(): Scene;
  109285. /**
  109286. * Disposes of the object
  109287. */
  109288. dispose(): void;
  109289. }
  109290. }
  109291. declare module BABYLON {
  109292. /**
  109293. * XR input used to track XR inputs such as controllers/rays
  109294. */
  109295. export class WebXRInput implements IDisposable {
  109296. /**
  109297. * Base experience the input listens to
  109298. */
  109299. baseExperience: WebXRExperienceHelper;
  109300. /**
  109301. * XR controllers being tracked
  109302. */
  109303. controllers: Array<WebXRController>;
  109304. private _frameObserver;
  109305. private _stateObserver;
  109306. /**
  109307. * Event when a controller has been connected/added
  109308. */
  109309. onControllerAddedObservable: Observable<WebXRController>;
  109310. /**
  109311. * Event when a controller has been removed/disconnected
  109312. */
  109313. onControllerRemovedObservable: Observable<WebXRController>;
  109314. /**
  109315. * Initializes the WebXRInput
  109316. * @param baseExperience experience helper which the input should be created for
  109317. */
  109318. constructor(
  109319. /**
  109320. * Base experience the input listens to
  109321. */
  109322. baseExperience: WebXRExperienceHelper);
  109323. private _onInputSourcesChange;
  109324. private _addAndRemoveControllers;
  109325. /**
  109326. * Disposes of the object
  109327. */
  109328. dispose(): void;
  109329. }
  109330. }
  109331. declare module BABYLON {
  109332. /**
  109333. * Enables teleportation
  109334. */
  109335. export class WebXRControllerTeleportation {
  109336. private _teleportationFillColor;
  109337. private _teleportationBorderColor;
  109338. private _tmpRay;
  109339. private _tmpVector;
  109340. /**
  109341. * Creates a WebXRControllerTeleportation
  109342. * @param input input manager to add teleportation to
  109343. * @param floorMeshes floormeshes which can be teleported to
  109344. */
  109345. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109346. }
  109347. }
  109348. declare module BABYLON {
  109349. /**
  109350. * Handles pointer input automatically for the pointer of XR controllers
  109351. */
  109352. export class WebXRControllerPointerSelection {
  109353. private static _idCounter;
  109354. private _tmpRay;
  109355. /**
  109356. * Creates a WebXRControllerPointerSelection
  109357. * @param input input manager to setup pointer selection
  109358. */
  109359. constructor(input: WebXRInput);
  109360. private _convertNormalToDirectionOfRay;
  109361. private _updatePointerDistance;
  109362. }
  109363. }
  109364. declare module BABYLON {
  109365. /**
  109366. * Class used to represent data loading progression
  109367. */
  109368. export class SceneLoaderProgressEvent {
  109369. /** defines if data length to load can be evaluated */
  109370. readonly lengthComputable: boolean;
  109371. /** defines the loaded data length */
  109372. readonly loaded: number;
  109373. /** defines the data length to load */
  109374. readonly total: number;
  109375. /**
  109376. * Create a new progress event
  109377. * @param lengthComputable defines if data length to load can be evaluated
  109378. * @param loaded defines the loaded data length
  109379. * @param total defines the data length to load
  109380. */
  109381. constructor(
  109382. /** defines if data length to load can be evaluated */
  109383. lengthComputable: boolean,
  109384. /** defines the loaded data length */
  109385. loaded: number,
  109386. /** defines the data length to load */
  109387. total: number);
  109388. /**
  109389. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109390. * @param event defines the source event
  109391. * @returns a new SceneLoaderProgressEvent
  109392. */
  109393. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109394. }
  109395. /**
  109396. * Interface used by SceneLoader plugins to define supported file extensions
  109397. */
  109398. export interface ISceneLoaderPluginExtensions {
  109399. /**
  109400. * Defines the list of supported extensions
  109401. */
  109402. [extension: string]: {
  109403. isBinary: boolean;
  109404. };
  109405. }
  109406. /**
  109407. * Interface used by SceneLoader plugin factory
  109408. */
  109409. export interface ISceneLoaderPluginFactory {
  109410. /**
  109411. * Defines the name of the factory
  109412. */
  109413. name: string;
  109414. /**
  109415. * Function called to create a new plugin
  109416. * @return the new plugin
  109417. */
  109418. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109419. /**
  109420. * The callback that returns true if the data can be directly loaded.
  109421. * @param data string containing the file data
  109422. * @returns if the data can be loaded directly
  109423. */
  109424. canDirectLoad?(data: string): boolean;
  109425. }
  109426. /**
  109427. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  109428. */
  109429. export interface ISceneLoaderPluginBase {
  109430. /**
  109431. * The friendly name of this plugin.
  109432. */
  109433. name: string;
  109434. /**
  109435. * The file extensions supported by this plugin.
  109436. */
  109437. extensions: string | ISceneLoaderPluginExtensions;
  109438. /**
  109439. * The callback called when loading from a url.
  109440. * @param scene scene loading this url
  109441. * @param url url to load
  109442. * @param onSuccess callback called when the file successfully loads
  109443. * @param onProgress callback called while file is loading (if the server supports this mode)
  109444. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109445. * @param onError callback called when the file fails to load
  109446. * @returns a file request object
  109447. */
  109448. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109449. /**
  109450. * The callback called when loading from a file object.
  109451. * @param scene scene loading this file
  109452. * @param file defines the file to load
  109453. * @param onSuccess defines the callback to call when data is loaded
  109454. * @param onProgress defines the callback to call during loading process
  109455. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  109456. * @param onError defines the callback to call when an error occurs
  109457. * @returns a file request object
  109458. */
  109459. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109460. /**
  109461. * The callback that returns true if the data can be directly loaded.
  109462. * @param data string containing the file data
  109463. * @returns if the data can be loaded directly
  109464. */
  109465. canDirectLoad?(data: string): boolean;
  109466. /**
  109467. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  109468. * @param scene scene loading this data
  109469. * @param data string containing the data
  109470. * @returns data to pass to the plugin
  109471. */
  109472. directLoad?(scene: Scene, data: string): any;
  109473. /**
  109474. * The callback that allows custom handling of the root url based on the response url.
  109475. * @param rootUrl the original root url
  109476. * @param responseURL the response url if available
  109477. * @returns the new root url
  109478. */
  109479. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  109480. }
  109481. /**
  109482. * Interface used to define a SceneLoader plugin
  109483. */
  109484. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  109485. /**
  109486. * Import meshes into a scene.
  109487. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109488. * @param scene The scene to import into
  109489. * @param data The data to import
  109490. * @param rootUrl The root url for scene and resources
  109491. * @param meshes The meshes array to import into
  109492. * @param particleSystems The particle systems array to import into
  109493. * @param skeletons The skeletons array to import into
  109494. * @param onError The callback when import fails
  109495. * @returns True if successful or false otherwise
  109496. */
  109497. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109498. /**
  109499. * Load into a scene.
  109500. * @param scene The scene to load into
  109501. * @param data The data to import
  109502. * @param rootUrl The root url for scene and resources
  109503. * @param onError The callback when import fails
  109504. * @returns True if successful or false otherwise
  109505. */
  109506. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109507. /**
  109508. * Load into an asset container.
  109509. * @param scene The scene to load into
  109510. * @param data The data to import
  109511. * @param rootUrl The root url for scene and resources
  109512. * @param onError The callback when import fails
  109513. * @returns The loaded asset container
  109514. */
  109515. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109516. }
  109517. /**
  109518. * Interface used to define an async SceneLoader plugin
  109519. */
  109520. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  109521. /**
  109522. * Import meshes into a scene.
  109523. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109524. * @param scene The scene to import into
  109525. * @param data The data to import
  109526. * @param rootUrl The root url for scene and resources
  109527. * @param onProgress The callback when the load progresses
  109528. * @param fileName Defines the name of the file to load
  109529. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109530. */
  109531. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109532. meshes: AbstractMesh[];
  109533. particleSystems: IParticleSystem[];
  109534. skeletons: Skeleton[];
  109535. animationGroups: AnimationGroup[];
  109536. }>;
  109537. /**
  109538. * Load into a scene.
  109539. * @param scene The scene to load into
  109540. * @param data The data to import
  109541. * @param rootUrl The root url for scene and resources
  109542. * @param onProgress The callback when the load progresses
  109543. * @param fileName Defines the name of the file to load
  109544. * @returns Nothing
  109545. */
  109546. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109547. /**
  109548. * Load into an asset container.
  109549. * @param scene The scene to load into
  109550. * @param data The data to import
  109551. * @param rootUrl The root url for scene and resources
  109552. * @param onProgress The callback when the load progresses
  109553. * @param fileName Defines the name of the file to load
  109554. * @returns The loaded asset container
  109555. */
  109556. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109557. }
  109558. /**
  109559. * Class used to load scene from various file formats using registered plugins
  109560. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109561. */
  109562. export class SceneLoader {
  109563. /**
  109564. * No logging while loading
  109565. */
  109566. static readonly NO_LOGGING: number;
  109567. /**
  109568. * Minimal logging while loading
  109569. */
  109570. static readonly MINIMAL_LOGGING: number;
  109571. /**
  109572. * Summary logging while loading
  109573. */
  109574. static readonly SUMMARY_LOGGING: number;
  109575. /**
  109576. * Detailled logging while loading
  109577. */
  109578. static readonly DETAILED_LOGGING: number;
  109579. /**
  109580. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109581. */
  109582. static ForceFullSceneLoadingForIncremental: boolean;
  109583. /**
  109584. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109585. */
  109586. static ShowLoadingScreen: boolean;
  109587. /**
  109588. * Defines the current logging level (while loading the scene)
  109589. * @ignorenaming
  109590. */
  109591. static loggingLevel: number;
  109592. /**
  109593. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109594. */
  109595. static CleanBoneMatrixWeights: boolean;
  109596. /**
  109597. * Event raised when a plugin is used to load a scene
  109598. */
  109599. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109600. private static _registeredPlugins;
  109601. private static _getDefaultPlugin;
  109602. private static _getPluginForExtension;
  109603. private static _getPluginForDirectLoad;
  109604. private static _getPluginForFilename;
  109605. private static _getDirectLoad;
  109606. private static _loadData;
  109607. private static _getFileInfo;
  109608. /**
  109609. * Gets a plugin that can load the given extension
  109610. * @param extension defines the extension to load
  109611. * @returns a plugin or null if none works
  109612. */
  109613. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109614. /**
  109615. * Gets a boolean indicating that the given extension can be loaded
  109616. * @param extension defines the extension to load
  109617. * @returns true if the extension is supported
  109618. */
  109619. static IsPluginForExtensionAvailable(extension: string): boolean;
  109620. /**
  109621. * Adds a new plugin to the list of registered plugins
  109622. * @param plugin defines the plugin to add
  109623. */
  109624. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109625. /**
  109626. * Import meshes into a scene
  109627. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109628. * @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)
  109629. * @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)
  109630. * @param scene the instance of BABYLON.Scene to append to
  109631. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109632. * @param onProgress a callback with a progress event for each file being loaded
  109633. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109634. * @param pluginExtension the extension used to determine the plugin
  109635. * @returns The loaded plugin
  109636. */
  109637. 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>;
  109638. /**
  109639. * Import meshes into a scene
  109640. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109641. * @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)
  109642. * @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)
  109643. * @param scene the instance of BABYLON.Scene to append to
  109644. * @param onProgress a callback with a progress event for each file being loaded
  109645. * @param pluginExtension the extension used to determine the plugin
  109646. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109647. */
  109648. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109649. meshes: AbstractMesh[];
  109650. particleSystems: IParticleSystem[];
  109651. skeletons: Skeleton[];
  109652. animationGroups: AnimationGroup[];
  109653. }>;
  109654. /**
  109655. * Load a scene
  109656. * @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)
  109657. * @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)
  109658. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109659. * @param onSuccess a callback with the scene when import succeeds
  109660. * @param onProgress a callback with a progress event for each file being loaded
  109661. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109662. * @param pluginExtension the extension used to determine the plugin
  109663. * @returns The loaded plugin
  109664. */
  109665. 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>;
  109666. /**
  109667. * Load a scene
  109668. * @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)
  109669. * @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)
  109670. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109671. * @param onProgress a callback with a progress event for each file being loaded
  109672. * @param pluginExtension the extension used to determine the plugin
  109673. * @returns The loaded scene
  109674. */
  109675. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109676. /**
  109677. * Append a scene
  109678. * @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)
  109679. * @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)
  109680. * @param scene is the instance of BABYLON.Scene to append to
  109681. * @param onSuccess a callback with the scene when import succeeds
  109682. * @param onProgress a callback with a progress event for each file being loaded
  109683. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109684. * @param pluginExtension the extension used to determine the plugin
  109685. * @returns The loaded plugin
  109686. */
  109687. 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>;
  109688. /**
  109689. * Append a scene
  109690. * @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)
  109691. * @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)
  109692. * @param scene is the instance of BABYLON.Scene to append to
  109693. * @param onProgress a callback with a progress event for each file being loaded
  109694. * @param pluginExtension the extension used to determine the plugin
  109695. * @returns The given scene
  109696. */
  109697. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109698. /**
  109699. * Load a scene into an asset container
  109700. * @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)
  109701. * @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)
  109702. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109703. * @param onSuccess a callback with the scene when import succeeds
  109704. * @param onProgress a callback with a progress event for each file being loaded
  109705. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109706. * @param pluginExtension the extension used to determine the plugin
  109707. * @returns The loaded plugin
  109708. */
  109709. 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>;
  109710. /**
  109711. * Load a scene into an asset container
  109712. * @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)
  109713. * @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)
  109714. * @param scene is the instance of Scene to append to
  109715. * @param onProgress a callback with a progress event for each file being loaded
  109716. * @param pluginExtension the extension used to determine the plugin
  109717. * @returns The loaded asset container
  109718. */
  109719. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  109720. }
  109721. }
  109722. declare module BABYLON {
  109723. /**
  109724. * Generic Controller
  109725. */
  109726. export class GenericController extends WebVRController {
  109727. /**
  109728. * Base Url for the controller model.
  109729. */
  109730. static readonly MODEL_BASE_URL: string;
  109731. /**
  109732. * File name for the controller model.
  109733. */
  109734. static readonly MODEL_FILENAME: string;
  109735. /**
  109736. * Creates a new GenericController from a gamepad
  109737. * @param vrGamepad the gamepad that the controller should be created from
  109738. */
  109739. constructor(vrGamepad: any);
  109740. /**
  109741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109742. * @param scene scene in which to add meshes
  109743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109744. */
  109745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109746. /**
  109747. * Called once for each button that changed state since the last frame
  109748. * @param buttonIdx Which button index changed
  109749. * @param state New state of the button
  109750. * @param changes Which properties on the state changed since last frame
  109751. */
  109752. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109753. }
  109754. }
  109755. declare module BABYLON {
  109756. /**
  109757. * Defines the WindowsMotionController object that the state of the windows motion controller
  109758. */
  109759. export class WindowsMotionController extends WebVRController {
  109760. /**
  109761. * The base url used to load the left and right controller models
  109762. */
  109763. static MODEL_BASE_URL: string;
  109764. /**
  109765. * The name of the left controller model file
  109766. */
  109767. static MODEL_LEFT_FILENAME: string;
  109768. /**
  109769. * The name of the right controller model file
  109770. */
  109771. static MODEL_RIGHT_FILENAME: string;
  109772. /**
  109773. * The controller name prefix for this controller type
  109774. */
  109775. static readonly GAMEPAD_ID_PREFIX: string;
  109776. /**
  109777. * The controller id pattern for this controller type
  109778. */
  109779. private static readonly GAMEPAD_ID_PATTERN;
  109780. private _loadedMeshInfo;
  109781. private readonly _mapping;
  109782. /**
  109783. * Fired when the trackpad on this controller is clicked
  109784. */
  109785. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109786. /**
  109787. * Fired when the trackpad on this controller is modified
  109788. */
  109789. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109790. /**
  109791. * The current x and y values of this controller's trackpad
  109792. */
  109793. trackpad: StickValues;
  109794. /**
  109795. * Creates a new WindowsMotionController from a gamepad
  109796. * @param vrGamepad the gamepad that the controller should be created from
  109797. */
  109798. constructor(vrGamepad: any);
  109799. /**
  109800. * Fired when the trigger on this controller is modified
  109801. */
  109802. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109803. /**
  109804. * Fired when the menu button on this controller is modified
  109805. */
  109806. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109807. /**
  109808. * Fired when the grip button on this controller is modified
  109809. */
  109810. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109811. /**
  109812. * Fired when the thumbstick button on this controller is modified
  109813. */
  109814. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109815. /**
  109816. * Fired when the touchpad button on this controller is modified
  109817. */
  109818. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109819. /**
  109820. * Fired when the touchpad values on this controller are modified
  109821. */
  109822. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109823. private _updateTrackpad;
  109824. /**
  109825. * Called once per frame by the engine.
  109826. */
  109827. update(): void;
  109828. /**
  109829. * Called once for each button that changed state since the last frame
  109830. * @param buttonIdx Which button index changed
  109831. * @param state New state of the button
  109832. * @param changes Which properties on the state changed since last frame
  109833. */
  109834. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109835. /**
  109836. * Moves the buttons on the controller mesh based on their current state
  109837. * @param buttonName the name of the button to move
  109838. * @param buttonValue the value of the button which determines the buttons new position
  109839. */
  109840. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109841. /**
  109842. * Moves the axis on the controller mesh based on its current state
  109843. * @param axis the index of the axis
  109844. * @param axisValue the value of the axis which determines the meshes new position
  109845. * @hidden
  109846. */
  109847. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109848. /**
  109849. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109850. * @param scene scene in which to add meshes
  109851. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109852. */
  109853. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109854. /**
  109855. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109856. * can be transformed by button presses and axes values, based on this._mapping.
  109857. *
  109858. * @param scene scene in which the meshes exist
  109859. * @param meshes list of meshes that make up the controller model to process
  109860. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109861. */
  109862. private processModel;
  109863. private createMeshInfo;
  109864. /**
  109865. * Gets the ray of the controller in the direction the controller is pointing
  109866. * @param length the length the resulting ray should be
  109867. * @returns a ray in the direction the controller is pointing
  109868. */
  109869. getForwardRay(length?: number): Ray;
  109870. /**
  109871. * Disposes of the controller
  109872. */
  109873. dispose(): void;
  109874. }
  109875. }
  109876. declare module BABYLON {
  109877. /**
  109878. * Oculus Touch Controller
  109879. */
  109880. export class OculusTouchController extends WebVRController {
  109881. /**
  109882. * Base Url for the controller model.
  109883. */
  109884. static MODEL_BASE_URL: string;
  109885. /**
  109886. * File name for the left controller model.
  109887. */
  109888. static MODEL_LEFT_FILENAME: string;
  109889. /**
  109890. * File name for the right controller model.
  109891. */
  109892. static MODEL_RIGHT_FILENAME: string;
  109893. /**
  109894. * Base Url for the Quest controller model.
  109895. */
  109896. static QUEST_MODEL_BASE_URL: string;
  109897. /**
  109898. * @hidden
  109899. * If the controllers are running on a device that needs the updated Quest controller models
  109900. */
  109901. static _IsQuest: boolean;
  109902. /**
  109903. * Fired when the secondary trigger on this controller is modified
  109904. */
  109905. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109906. /**
  109907. * Fired when the thumb rest on this controller is modified
  109908. */
  109909. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109910. /**
  109911. * Creates a new OculusTouchController from a gamepad
  109912. * @param vrGamepad the gamepad that the controller should be created from
  109913. */
  109914. constructor(vrGamepad: any);
  109915. /**
  109916. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109917. * @param scene scene in which to add meshes
  109918. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109919. */
  109920. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109921. /**
  109922. * Fired when the A button on this controller is modified
  109923. */
  109924. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109925. /**
  109926. * Fired when the B button on this controller is modified
  109927. */
  109928. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109929. /**
  109930. * Fired when the X button on this controller is modified
  109931. */
  109932. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109933. /**
  109934. * Fired when the Y button on this controller is modified
  109935. */
  109936. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109937. /**
  109938. * Called once for each button that changed state since the last frame
  109939. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109940. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109941. * 2) secondary trigger (same)
  109942. * 3) A (right) X (left), touch, pressed = value
  109943. * 4) B / Y
  109944. * 5) thumb rest
  109945. * @param buttonIdx Which button index changed
  109946. * @param state New state of the button
  109947. * @param changes Which properties on the state changed since last frame
  109948. */
  109949. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109950. }
  109951. }
  109952. declare module BABYLON {
  109953. /**
  109954. * Vive Controller
  109955. */
  109956. export class ViveController extends WebVRController {
  109957. /**
  109958. * Base Url for the controller model.
  109959. */
  109960. static MODEL_BASE_URL: string;
  109961. /**
  109962. * File name for the controller model.
  109963. */
  109964. static MODEL_FILENAME: string;
  109965. /**
  109966. * Creates a new ViveController from a gamepad
  109967. * @param vrGamepad the gamepad that the controller should be created from
  109968. */
  109969. constructor(vrGamepad: any);
  109970. /**
  109971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109972. * @param scene scene in which to add meshes
  109973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109974. */
  109975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109976. /**
  109977. * Fired when the left button on this controller is modified
  109978. */
  109979. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109980. /**
  109981. * Fired when the right button on this controller is modified
  109982. */
  109983. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109984. /**
  109985. * Fired when the menu button on this controller is modified
  109986. */
  109987. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109988. /**
  109989. * Called once for each button that changed state since the last frame
  109990. * Vive mapping:
  109991. * 0: touchpad
  109992. * 1: trigger
  109993. * 2: left AND right buttons
  109994. * 3: menu button
  109995. * @param buttonIdx Which button index changed
  109996. * @param state New state of the button
  109997. * @param changes Which properties on the state changed since last frame
  109998. */
  109999. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110000. }
  110001. }
  110002. declare module BABYLON {
  110003. /**
  110004. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110005. */
  110006. export class WebXRControllerModelLoader {
  110007. /**
  110008. * Creates the WebXRControllerModelLoader
  110009. * @param input xr input that creates the controllers
  110010. */
  110011. constructor(input: WebXRInput);
  110012. }
  110013. }
  110014. declare module BABYLON {
  110015. /**
  110016. * Contains an array of blocks representing the octree
  110017. */
  110018. export interface IOctreeContainer<T> {
  110019. /**
  110020. * Blocks within the octree
  110021. */
  110022. blocks: Array<OctreeBlock<T>>;
  110023. }
  110024. /**
  110025. * Class used to store a cell in an octree
  110026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110027. */
  110028. export class OctreeBlock<T> {
  110029. /**
  110030. * Gets the content of the current block
  110031. */
  110032. entries: T[];
  110033. /**
  110034. * Gets the list of block children
  110035. */
  110036. blocks: Array<OctreeBlock<T>>;
  110037. private _depth;
  110038. private _maxDepth;
  110039. private _capacity;
  110040. private _minPoint;
  110041. private _maxPoint;
  110042. private _boundingVectors;
  110043. private _creationFunc;
  110044. /**
  110045. * Creates a new block
  110046. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110047. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110048. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110049. * @param depth defines the current depth of this block in the octree
  110050. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110051. * @param creationFunc defines a callback to call when an element is added to the block
  110052. */
  110053. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110054. /**
  110055. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110056. */
  110057. readonly capacity: number;
  110058. /**
  110059. * Gets the minimum vector (in world space) of the block's bounding box
  110060. */
  110061. readonly minPoint: Vector3;
  110062. /**
  110063. * Gets the maximum vector (in world space) of the block's bounding box
  110064. */
  110065. readonly maxPoint: Vector3;
  110066. /**
  110067. * Add a new element to this block
  110068. * @param entry defines the element to add
  110069. */
  110070. addEntry(entry: T): void;
  110071. /**
  110072. * Remove an element from this block
  110073. * @param entry defines the element to remove
  110074. */
  110075. removeEntry(entry: T): void;
  110076. /**
  110077. * Add an array of elements to this block
  110078. * @param entries defines the array of elements to add
  110079. */
  110080. addEntries(entries: T[]): void;
  110081. /**
  110082. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110083. * @param frustumPlanes defines the frustum planes to test
  110084. * @param selection defines the array to store current content if selection is positive
  110085. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110086. */
  110087. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110088. /**
  110089. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110090. * @param sphereCenter defines the bounding sphere center
  110091. * @param sphereRadius defines the bounding sphere radius
  110092. * @param selection defines the array to store current content if selection is positive
  110093. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110094. */
  110095. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110096. /**
  110097. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110098. * @param ray defines the ray to test with
  110099. * @param selection defines the array to store current content if selection is positive
  110100. */
  110101. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110102. /**
  110103. * Subdivide the content into child blocks (this block will then be empty)
  110104. */
  110105. createInnerBlocks(): void;
  110106. /**
  110107. * @hidden
  110108. */
  110109. 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;
  110110. }
  110111. }
  110112. declare module BABYLON {
  110113. /**
  110114. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110115. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110116. */
  110117. export class Octree<T> {
  110118. /** 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.) */
  110119. maxDepth: number;
  110120. /**
  110121. * Blocks within the octree containing objects
  110122. */
  110123. blocks: Array<OctreeBlock<T>>;
  110124. /**
  110125. * Content stored in the octree
  110126. */
  110127. dynamicContent: T[];
  110128. private _maxBlockCapacity;
  110129. private _selectionContent;
  110130. private _creationFunc;
  110131. /**
  110132. * Creates a octree
  110133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110134. * @param creationFunc function to be used to instatiate the octree
  110135. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  110136. * @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.)
  110137. */
  110138. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  110139. /** 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.) */
  110140. maxDepth?: number);
  110141. /**
  110142. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  110143. * @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);
  110144. * @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);
  110145. * @param entries meshes to be added to the octree blocks
  110146. */
  110147. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  110148. /**
  110149. * Adds a mesh to the octree
  110150. * @param entry Mesh to add to the octree
  110151. */
  110152. addMesh(entry: T): void;
  110153. /**
  110154. * Remove an element from the octree
  110155. * @param entry defines the element to remove
  110156. */
  110157. removeMesh(entry: T): void;
  110158. /**
  110159. * Selects an array of meshes within the frustum
  110160. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110161. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110162. * @returns array of meshes within the frustum
  110163. */
  110164. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110165. /**
  110166. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110167. * @param sphereCenter defines the bounding sphere center
  110168. * @param sphereRadius defines the bounding sphere radius
  110169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110170. * @returns an array of objects that intersect the sphere
  110171. */
  110172. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110173. /**
  110174. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110175. * @param ray defines the ray to test with
  110176. * @returns array of intersected objects
  110177. */
  110178. intersectsRay(ray: Ray): SmartArray<T>;
  110179. /**
  110180. * Adds a mesh into the octree block if it intersects the block
  110181. */
  110182. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110183. /**
  110184. * Adds a submesh into the octree block if it intersects the block
  110185. */
  110186. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110187. }
  110188. }
  110189. declare module BABYLON {
  110190. interface Scene {
  110191. /**
  110192. * @hidden
  110193. * Backing Filed
  110194. */
  110195. _selectionOctree: Octree<AbstractMesh>;
  110196. /**
  110197. * Gets the octree used to boost mesh selection (picking)
  110198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110199. */
  110200. selectionOctree: Octree<AbstractMesh>;
  110201. /**
  110202. * Creates or updates the octree used to boost selection (picking)
  110203. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110204. * @param maxCapacity defines the maximum capacity per leaf
  110205. * @param maxDepth defines the maximum depth of the octree
  110206. * @returns an octree of AbstractMesh
  110207. */
  110208. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110209. }
  110210. interface AbstractMesh {
  110211. /**
  110212. * @hidden
  110213. * Backing Field
  110214. */
  110215. _submeshesOctree: Octree<SubMesh>;
  110216. /**
  110217. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110218. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110219. * @param maxCapacity defines the maximum size of each block (64 by default)
  110220. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110221. * @returns the new octree
  110222. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110223. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110224. */
  110225. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110226. }
  110227. /**
  110228. * Defines the octree scene component responsible to manage any octrees
  110229. * in a given scene.
  110230. */
  110231. export class OctreeSceneComponent {
  110232. /**
  110233. * The component name help to identify the component in the list of scene components.
  110234. */
  110235. readonly name: string;
  110236. /**
  110237. * The scene the component belongs to.
  110238. */
  110239. scene: Scene;
  110240. /**
  110241. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110242. */
  110243. readonly checksIsEnabled: boolean;
  110244. /**
  110245. * Creates a new instance of the component for the given scene
  110246. * @param scene Defines the scene to register the component in
  110247. */
  110248. constructor(scene: Scene);
  110249. /**
  110250. * Registers the component in a given scene
  110251. */
  110252. register(): void;
  110253. /**
  110254. * Return the list of active meshes
  110255. * @returns the list of active meshes
  110256. */
  110257. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110258. /**
  110259. * Return the list of active sub meshes
  110260. * @param mesh The mesh to get the candidates sub meshes from
  110261. * @returns the list of active sub meshes
  110262. */
  110263. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110264. private _tempRay;
  110265. /**
  110266. * Return the list of sub meshes intersecting with a given local ray
  110267. * @param mesh defines the mesh to find the submesh for
  110268. * @param localRay defines the ray in local space
  110269. * @returns the list of intersecting sub meshes
  110270. */
  110271. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110272. /**
  110273. * Return the list of sub meshes colliding with a collider
  110274. * @param mesh defines the mesh to find the submesh for
  110275. * @param collider defines the collider to evaluate the collision against
  110276. * @returns the list of colliding sub meshes
  110277. */
  110278. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110279. /**
  110280. * Rebuilds the elements related to this component in case of
  110281. * context lost for instance.
  110282. */
  110283. rebuild(): void;
  110284. /**
  110285. * Disposes the component and the associated ressources.
  110286. */
  110287. dispose(): void;
  110288. }
  110289. }
  110290. declare module BABYLON {
  110291. /**
  110292. * Renders a layer on top of an existing scene
  110293. */
  110294. export class UtilityLayerRenderer implements IDisposable {
  110295. /** the original scene that will be rendered on top of */
  110296. originalScene: Scene;
  110297. private _pointerCaptures;
  110298. private _lastPointerEvents;
  110299. private static _DefaultUtilityLayer;
  110300. private static _DefaultKeepDepthUtilityLayer;
  110301. private _sharedGizmoLight;
  110302. private _renderCamera;
  110303. /**
  110304. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110305. * @returns the camera that is used when rendering the utility layer
  110306. */
  110307. getRenderCamera(): Nullable<Camera>;
  110308. /**
  110309. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110310. * @param cam the camera that should be used when rendering the utility layer
  110311. */
  110312. setRenderCamera(cam: Nullable<Camera>): void;
  110313. /**
  110314. * @hidden
  110315. * Light which used by gizmos to get light shading
  110316. */
  110317. _getSharedGizmoLight(): HemisphericLight;
  110318. /**
  110319. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110320. */
  110321. pickUtilitySceneFirst: boolean;
  110322. /**
  110323. * 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)
  110324. */
  110325. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110326. /**
  110327. * 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)
  110328. */
  110329. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110330. /**
  110331. * The scene that is rendered on top of the original scene
  110332. */
  110333. utilityLayerScene: Scene;
  110334. /**
  110335. * If the utility layer should automatically be rendered on top of existing scene
  110336. */
  110337. shouldRender: boolean;
  110338. /**
  110339. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110340. */
  110341. onlyCheckPointerDownEvents: boolean;
  110342. /**
  110343. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110344. */
  110345. processAllEvents: boolean;
  110346. /**
  110347. * Observable raised when the pointer move from the utility layer scene to the main scene
  110348. */
  110349. onPointerOutObservable: Observable<number>;
  110350. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110351. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110352. private _afterRenderObserver;
  110353. private _sceneDisposeObserver;
  110354. private _originalPointerObserver;
  110355. /**
  110356. * Instantiates a UtilityLayerRenderer
  110357. * @param originalScene the original scene that will be rendered on top of
  110358. * @param handleEvents boolean indicating if the utility layer should handle events
  110359. */
  110360. constructor(
  110361. /** the original scene that will be rendered on top of */
  110362. originalScene: Scene, handleEvents?: boolean);
  110363. private _notifyObservers;
  110364. /**
  110365. * Renders the utility layers scene on top of the original scene
  110366. */
  110367. render(): void;
  110368. /**
  110369. * Disposes of the renderer
  110370. */
  110371. dispose(): void;
  110372. private _updateCamera;
  110373. }
  110374. }
  110375. declare module BABYLON {
  110376. /**
  110377. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110378. */
  110379. export class Gizmo implements IDisposable {
  110380. /** The utility layer the gizmo will be added to */
  110381. gizmoLayer: UtilityLayerRenderer;
  110382. /**
  110383. * The root mesh of the gizmo
  110384. */
  110385. _rootMesh: Mesh;
  110386. private _attachedMesh;
  110387. /**
  110388. * Ratio for the scale of the gizmo (Default: 1)
  110389. */
  110390. scaleRatio: number;
  110391. /**
  110392. * If a custom mesh has been set (Default: false)
  110393. */
  110394. protected _customMeshSet: boolean;
  110395. /**
  110396. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110397. * * When set, interactions will be enabled
  110398. */
  110399. attachedMesh: Nullable<AbstractMesh>;
  110400. /**
  110401. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110402. * @param mesh The mesh to replace the default mesh of the gizmo
  110403. */
  110404. setCustomMesh(mesh: Mesh): void;
  110405. /**
  110406. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110407. */
  110408. updateGizmoRotationToMatchAttachedMesh: boolean;
  110409. /**
  110410. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110411. */
  110412. updateGizmoPositionToMatchAttachedMesh: boolean;
  110413. /**
  110414. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110415. */
  110416. updateScale: boolean;
  110417. protected _interactionsEnabled: boolean;
  110418. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110419. private _beforeRenderObserver;
  110420. private _tempVector;
  110421. /**
  110422. * Creates a gizmo
  110423. * @param gizmoLayer The utility layer the gizmo will be added to
  110424. */
  110425. constructor(
  110426. /** The utility layer the gizmo will be added to */
  110427. gizmoLayer?: UtilityLayerRenderer);
  110428. /**
  110429. * Updates the gizmo to match the attached mesh's position/rotation
  110430. */
  110431. protected _update(): void;
  110432. /**
  110433. * Disposes of the gizmo
  110434. */
  110435. dispose(): void;
  110436. }
  110437. }
  110438. declare module BABYLON {
  110439. /**
  110440. * Single plane drag gizmo
  110441. */
  110442. export class PlaneDragGizmo extends Gizmo {
  110443. /**
  110444. * Drag behavior responsible for the gizmos dragging interactions
  110445. */
  110446. dragBehavior: PointerDragBehavior;
  110447. private _pointerObserver;
  110448. /**
  110449. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110450. */
  110451. snapDistance: number;
  110452. /**
  110453. * Event that fires each time the gizmo snaps to a new location.
  110454. * * snapDistance is the the change in distance
  110455. */
  110456. onSnapObservable: Observable<{
  110457. snapDistance: number;
  110458. }>;
  110459. private _plane;
  110460. private _coloredMaterial;
  110461. private _hoverMaterial;
  110462. private _isEnabled;
  110463. private _parent;
  110464. /** @hidden */
  110465. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110466. /** @hidden */
  110467. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110468. /**
  110469. * Creates a PlaneDragGizmo
  110470. * @param gizmoLayer The utility layer the gizmo will be added to
  110471. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110472. * @param color The color of the gizmo
  110473. */
  110474. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110475. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110476. /**
  110477. * If the gizmo is enabled
  110478. */
  110479. isEnabled: boolean;
  110480. /**
  110481. * Disposes of the gizmo
  110482. */
  110483. dispose(): void;
  110484. }
  110485. }
  110486. declare module BABYLON {
  110487. /**
  110488. * Gizmo that enables dragging a mesh along 3 axis
  110489. */
  110490. export class PositionGizmo extends Gizmo {
  110491. /**
  110492. * Internal gizmo used for interactions on the x axis
  110493. */
  110494. xGizmo: AxisDragGizmo;
  110495. /**
  110496. * Internal gizmo used for interactions on the y axis
  110497. */
  110498. yGizmo: AxisDragGizmo;
  110499. /**
  110500. * Internal gizmo used for interactions on the z axis
  110501. */
  110502. zGizmo: AxisDragGizmo;
  110503. /**
  110504. * Internal gizmo used for interactions on the yz plane
  110505. */
  110506. xPlaneGizmo: PlaneDragGizmo;
  110507. /**
  110508. * Internal gizmo used for interactions on the xz plane
  110509. */
  110510. yPlaneGizmo: PlaneDragGizmo;
  110511. /**
  110512. * Internal gizmo used for interactions on the xy plane
  110513. */
  110514. zPlaneGizmo: PlaneDragGizmo;
  110515. /**
  110516. * private variables
  110517. */
  110518. private _meshAttached;
  110519. private _updateGizmoRotationToMatchAttachedMesh;
  110520. private _snapDistance;
  110521. private _scaleRatio;
  110522. /** Fires an event when any of it's sub gizmos are dragged */
  110523. onDragStartObservable: Observable<unknown>;
  110524. /** Fires an event when any of it's sub gizmos are released from dragging */
  110525. onDragEndObservable: Observable<unknown>;
  110526. /**
  110527. * If set to true, planar drag is enabled
  110528. */
  110529. private _planarGizmoEnabled;
  110530. attachedMesh: Nullable<AbstractMesh>;
  110531. /**
  110532. * Creates a PositionGizmo
  110533. * @param gizmoLayer The utility layer the gizmo will be added to
  110534. */
  110535. constructor(gizmoLayer?: UtilityLayerRenderer);
  110536. /**
  110537. * If the planar drag gizmo is enabled
  110538. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110539. */
  110540. planarGizmoEnabled: boolean;
  110541. updateGizmoRotationToMatchAttachedMesh: boolean;
  110542. /**
  110543. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110544. */
  110545. snapDistance: number;
  110546. /**
  110547. * Ratio for the scale of the gizmo (Default: 1)
  110548. */
  110549. scaleRatio: number;
  110550. /**
  110551. * Disposes of the gizmo
  110552. */
  110553. dispose(): void;
  110554. /**
  110555. * CustomMeshes are not supported by this gizmo
  110556. * @param mesh The mesh to replace the default mesh of the gizmo
  110557. */
  110558. setCustomMesh(mesh: Mesh): void;
  110559. }
  110560. }
  110561. declare module BABYLON {
  110562. /**
  110563. * Single axis drag gizmo
  110564. */
  110565. export class AxisDragGizmo extends Gizmo {
  110566. /**
  110567. * Drag behavior responsible for the gizmos dragging interactions
  110568. */
  110569. dragBehavior: PointerDragBehavior;
  110570. private _pointerObserver;
  110571. /**
  110572. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110573. */
  110574. snapDistance: number;
  110575. /**
  110576. * Event that fires each time the gizmo snaps to a new location.
  110577. * * snapDistance is the the change in distance
  110578. */
  110579. onSnapObservable: Observable<{
  110580. snapDistance: number;
  110581. }>;
  110582. private _isEnabled;
  110583. private _parent;
  110584. private _arrow;
  110585. private _coloredMaterial;
  110586. private _hoverMaterial;
  110587. /** @hidden */
  110588. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110589. /** @hidden */
  110590. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110591. /**
  110592. * Creates an AxisDragGizmo
  110593. * @param gizmoLayer The utility layer the gizmo will be added to
  110594. * @param dragAxis The axis which the gizmo will be able to drag on
  110595. * @param color The color of the gizmo
  110596. */
  110597. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110598. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110599. /**
  110600. * If the gizmo is enabled
  110601. */
  110602. isEnabled: boolean;
  110603. /**
  110604. * Disposes of the gizmo
  110605. */
  110606. dispose(): void;
  110607. }
  110608. }
  110609. declare module BABYLON.Debug {
  110610. /**
  110611. * The Axes viewer will show 3 axes in a specific point in space
  110612. */
  110613. export class AxesViewer {
  110614. private _xAxis;
  110615. private _yAxis;
  110616. private _zAxis;
  110617. private _scaleLinesFactor;
  110618. private _instanced;
  110619. /**
  110620. * Gets the hosting scene
  110621. */
  110622. scene: Scene;
  110623. /**
  110624. * Gets or sets a number used to scale line length
  110625. */
  110626. scaleLines: number;
  110627. /** Gets the node hierarchy used to render x-axis */
  110628. readonly xAxis: TransformNode;
  110629. /** Gets the node hierarchy used to render y-axis */
  110630. readonly yAxis: TransformNode;
  110631. /** Gets the node hierarchy used to render z-axis */
  110632. readonly zAxis: TransformNode;
  110633. /**
  110634. * Creates a new AxesViewer
  110635. * @param scene defines the hosting scene
  110636. * @param scaleLines defines a number used to scale line length (1 by default)
  110637. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110638. * @param xAxis defines the node hierarchy used to render the x-axis
  110639. * @param yAxis defines the node hierarchy used to render the y-axis
  110640. * @param zAxis defines the node hierarchy used to render the z-axis
  110641. */
  110642. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110643. /**
  110644. * Force the viewer to update
  110645. * @param position defines the position of the viewer
  110646. * @param xaxis defines the x axis of the viewer
  110647. * @param yaxis defines the y axis of the viewer
  110648. * @param zaxis defines the z axis of the viewer
  110649. */
  110650. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110651. /**
  110652. * Creates an instance of this axes viewer.
  110653. * @returns a new axes viewer with instanced meshes
  110654. */
  110655. createInstance(): AxesViewer;
  110656. /** Releases resources */
  110657. dispose(): void;
  110658. private static _SetRenderingGroupId;
  110659. }
  110660. }
  110661. declare module BABYLON.Debug {
  110662. /**
  110663. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110664. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110665. */
  110666. export class BoneAxesViewer extends AxesViewer {
  110667. /**
  110668. * Gets or sets the target mesh where to display the axes viewer
  110669. */
  110670. mesh: Nullable<Mesh>;
  110671. /**
  110672. * Gets or sets the target bone where to display the axes viewer
  110673. */
  110674. bone: Nullable<Bone>;
  110675. /** Gets current position */
  110676. pos: Vector3;
  110677. /** Gets direction of X axis */
  110678. xaxis: Vector3;
  110679. /** Gets direction of Y axis */
  110680. yaxis: Vector3;
  110681. /** Gets direction of Z axis */
  110682. zaxis: Vector3;
  110683. /**
  110684. * Creates a new BoneAxesViewer
  110685. * @param scene defines the hosting scene
  110686. * @param bone defines the target bone
  110687. * @param mesh defines the target mesh
  110688. * @param scaleLines defines a scaling factor for line length (1 by default)
  110689. */
  110690. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110691. /**
  110692. * Force the viewer to update
  110693. */
  110694. update(): void;
  110695. /** Releases resources */
  110696. dispose(): void;
  110697. }
  110698. }
  110699. declare module BABYLON {
  110700. /**
  110701. * Interface used to define scene explorer extensibility option
  110702. */
  110703. export interface IExplorerExtensibilityOption {
  110704. /**
  110705. * Define the option label
  110706. */
  110707. label: string;
  110708. /**
  110709. * Defines the action to execute on click
  110710. */
  110711. action: (entity: any) => void;
  110712. }
  110713. /**
  110714. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  110715. */
  110716. export interface IExplorerExtensibilityGroup {
  110717. /**
  110718. * Defines a predicate to test if a given type mut be extended
  110719. */
  110720. predicate: (entity: any) => boolean;
  110721. /**
  110722. * Gets the list of options added to a type
  110723. */
  110724. entries: IExplorerExtensibilityOption[];
  110725. }
  110726. /**
  110727. * Interface used to define the options to use to create the Inspector
  110728. */
  110729. export interface IInspectorOptions {
  110730. /**
  110731. * Display in overlay mode (default: false)
  110732. */
  110733. overlay?: boolean;
  110734. /**
  110735. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110736. */
  110737. globalRoot?: HTMLElement;
  110738. /**
  110739. * Display the Scene explorer
  110740. */
  110741. showExplorer?: boolean;
  110742. /**
  110743. * Display the property inspector
  110744. */
  110745. showInspector?: boolean;
  110746. /**
  110747. * Display in embed mode (both panes on the right)
  110748. */
  110749. embedMode?: boolean;
  110750. /**
  110751. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110752. */
  110753. handleResize?: boolean;
  110754. /**
  110755. * Allow the panes to popup (default: true)
  110756. */
  110757. enablePopup?: boolean;
  110758. /**
  110759. * Allow the panes to be closed by users (default: true)
  110760. */
  110761. enableClose?: boolean;
  110762. /**
  110763. * Optional list of extensibility entries
  110764. */
  110765. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110766. /**
  110767. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110768. */
  110769. inspectorURL?: string;
  110770. }
  110771. interface Scene {
  110772. /**
  110773. * @hidden
  110774. * Backing field
  110775. */
  110776. _debugLayer: DebugLayer;
  110777. /**
  110778. * Gets the debug layer (aka Inspector) associated with the scene
  110779. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110780. */
  110781. debugLayer: DebugLayer;
  110782. }
  110783. /**
  110784. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110785. * what is happening in your scene
  110786. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110787. */
  110788. export class DebugLayer {
  110789. /**
  110790. * Define the url to get the inspector script from.
  110791. * By default it uses the babylonjs CDN.
  110792. * @ignoreNaming
  110793. */
  110794. static InspectorURL: string;
  110795. private _scene;
  110796. private BJSINSPECTOR;
  110797. private _onPropertyChangedObservable?;
  110798. /**
  110799. * Observable triggered when a property is changed through the inspector.
  110800. */
  110801. readonly onPropertyChangedObservable: any;
  110802. /**
  110803. * Instantiates a new debug layer.
  110804. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110805. * what is happening in your scene
  110806. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110807. * @param scene Defines the scene to inspect
  110808. */
  110809. constructor(scene: Scene);
  110810. /** Creates the inspector window. */
  110811. private _createInspector;
  110812. /**
  110813. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110814. * @param entity defines the entity to select
  110815. * @param lineContainerTitle defines the specific block to highlight
  110816. */
  110817. select(entity: any, lineContainerTitle?: string): void;
  110818. /** Get the inspector from bundle or global */
  110819. private _getGlobalInspector;
  110820. /**
  110821. * Get if the inspector is visible or not.
  110822. * @returns true if visible otherwise, false
  110823. */
  110824. isVisible(): boolean;
  110825. /**
  110826. * Hide the inspector and close its window.
  110827. */
  110828. hide(): void;
  110829. /**
  110830. * Launch the debugLayer.
  110831. * @param config Define the configuration of the inspector
  110832. * @return a promise fulfilled when the debug layer is visible
  110833. */
  110834. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110835. }
  110836. }
  110837. declare module BABYLON {
  110838. /**
  110839. * Class containing static functions to help procedurally build meshes
  110840. */
  110841. export class BoxBuilder {
  110842. /**
  110843. * Creates a box mesh
  110844. * * The parameter `size` sets the size (float) of each box side (default 1)
  110845. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110846. * * 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)
  110847. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110851. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110852. * @param name defines the name of the mesh
  110853. * @param options defines the options used to create the mesh
  110854. * @param scene defines the hosting scene
  110855. * @returns the box mesh
  110856. */
  110857. static CreateBox(name: string, options: {
  110858. size?: number;
  110859. width?: number;
  110860. height?: number;
  110861. depth?: number;
  110862. faceUV?: Vector4[];
  110863. faceColors?: Color4[];
  110864. sideOrientation?: number;
  110865. frontUVs?: Vector4;
  110866. backUVs?: Vector4;
  110867. wrap?: boolean;
  110868. topBaseAt?: number;
  110869. bottomBaseAt?: number;
  110870. updatable?: boolean;
  110871. }, scene?: Nullable<Scene>): Mesh;
  110872. }
  110873. }
  110874. declare module BABYLON {
  110875. /**
  110876. * Class containing static functions to help procedurally build meshes
  110877. */
  110878. export class SphereBuilder {
  110879. /**
  110880. * Creates a sphere mesh
  110881. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110882. * * 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`)
  110883. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110884. * * 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
  110885. * * 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)
  110886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110889. * @param name defines the name of the mesh
  110890. * @param options defines the options used to create the mesh
  110891. * @param scene defines the hosting scene
  110892. * @returns the sphere mesh
  110893. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110894. */
  110895. static CreateSphere(name: string, options: {
  110896. segments?: number;
  110897. diameter?: number;
  110898. diameterX?: number;
  110899. diameterY?: number;
  110900. diameterZ?: number;
  110901. arc?: number;
  110902. slice?: number;
  110903. sideOrientation?: number;
  110904. frontUVs?: Vector4;
  110905. backUVs?: Vector4;
  110906. updatable?: boolean;
  110907. }, scene?: Nullable<Scene>): Mesh;
  110908. }
  110909. }
  110910. declare module BABYLON.Debug {
  110911. /**
  110912. * Used to show the physics impostor around the specific mesh
  110913. */
  110914. export class PhysicsViewer {
  110915. /** @hidden */
  110916. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110917. /** @hidden */
  110918. protected _meshes: Array<Nullable<AbstractMesh>>;
  110919. /** @hidden */
  110920. protected _scene: Nullable<Scene>;
  110921. /** @hidden */
  110922. protected _numMeshes: number;
  110923. /** @hidden */
  110924. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110925. private _renderFunction;
  110926. private _utilityLayer;
  110927. private _debugBoxMesh;
  110928. private _debugSphereMesh;
  110929. private _debugCylinderMesh;
  110930. private _debugMaterial;
  110931. private _debugMeshMeshes;
  110932. /**
  110933. * Creates a new PhysicsViewer
  110934. * @param scene defines the hosting scene
  110935. */
  110936. constructor(scene: Scene);
  110937. /** @hidden */
  110938. protected _updateDebugMeshes(): void;
  110939. /**
  110940. * Renders a specified physic impostor
  110941. * @param impostor defines the impostor to render
  110942. * @param targetMesh defines the mesh represented by the impostor
  110943. * @returns the new debug mesh used to render the impostor
  110944. */
  110945. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110946. /**
  110947. * Hides a specified physic impostor
  110948. * @param impostor defines the impostor to hide
  110949. */
  110950. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110951. private _getDebugMaterial;
  110952. private _getDebugBoxMesh;
  110953. private _getDebugSphereMesh;
  110954. private _getDebugCylinderMesh;
  110955. private _getDebugMeshMesh;
  110956. private _getDebugMesh;
  110957. /** Releases all resources */
  110958. dispose(): void;
  110959. }
  110960. }
  110961. declare module BABYLON {
  110962. /**
  110963. * Class containing static functions to help procedurally build meshes
  110964. */
  110965. export class LinesBuilder {
  110966. /**
  110967. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110968. * * 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
  110969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110970. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110971. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110972. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110973. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110974. * * 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
  110975. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110978. * @param name defines the name of the new line system
  110979. * @param options defines the options used to create the line system
  110980. * @param scene defines the hosting scene
  110981. * @returns a new line system mesh
  110982. */
  110983. static CreateLineSystem(name: string, options: {
  110984. lines: Vector3[][];
  110985. updatable?: boolean;
  110986. instance?: Nullable<LinesMesh>;
  110987. colors?: Nullable<Color4[][]>;
  110988. useVertexAlpha?: boolean;
  110989. }, scene: Nullable<Scene>): LinesMesh;
  110990. /**
  110991. * Creates a line mesh
  110992. * 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
  110993. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110994. * * The parameter `points` is an array successive Vector3
  110995. * * 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
  110996. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110997. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110998. * * When updating an instance, remember that only point positions can change, not the number of points
  110999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111000. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111001. * @param name defines the name of the new line system
  111002. * @param options defines the options used to create the line system
  111003. * @param scene defines the hosting scene
  111004. * @returns a new line mesh
  111005. */
  111006. static CreateLines(name: string, options: {
  111007. points: Vector3[];
  111008. updatable?: boolean;
  111009. instance?: Nullable<LinesMesh>;
  111010. colors?: Color4[];
  111011. useVertexAlpha?: boolean;
  111012. }, scene?: Nullable<Scene>): LinesMesh;
  111013. /**
  111014. * Creates a dashed line mesh
  111015. * * 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
  111016. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111017. * * The parameter `points` is an array successive Vector3
  111018. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111019. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111020. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111021. * * 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
  111022. * * When updating an instance, remember that only point positions can change, not the number of points
  111023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111024. * @param name defines the name of the mesh
  111025. * @param options defines the options used to create the mesh
  111026. * @param scene defines the hosting scene
  111027. * @returns the dashed line mesh
  111028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111029. */
  111030. static CreateDashedLines(name: string, options: {
  111031. points: Vector3[];
  111032. dashSize?: number;
  111033. gapSize?: number;
  111034. dashNb?: number;
  111035. updatable?: boolean;
  111036. instance?: LinesMesh;
  111037. }, scene?: Nullable<Scene>): LinesMesh;
  111038. }
  111039. }
  111040. declare module BABYLON {
  111041. /**
  111042. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111043. * in order to better appreciate the issue one might have.
  111044. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111045. */
  111046. export class RayHelper {
  111047. /**
  111048. * Defines the ray we are currently tryin to visualize.
  111049. */
  111050. ray: Nullable<Ray>;
  111051. private _renderPoints;
  111052. private _renderLine;
  111053. private _renderFunction;
  111054. private _scene;
  111055. private _updateToMeshFunction;
  111056. private _attachedToMesh;
  111057. private _meshSpaceDirection;
  111058. private _meshSpaceOrigin;
  111059. /**
  111060. * Helper function to create a colored helper in a scene in one line.
  111061. * @param ray Defines the ray we are currently tryin to visualize
  111062. * @param scene Defines the scene the ray is used in
  111063. * @param color Defines the color we want to see the ray in
  111064. * @returns The newly created ray helper.
  111065. */
  111066. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111067. /**
  111068. * Instantiate a new ray helper.
  111069. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111070. * in order to better appreciate the issue one might have.
  111071. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111072. * @param ray Defines the ray we are currently tryin to visualize
  111073. */
  111074. constructor(ray: Ray);
  111075. /**
  111076. * Shows the ray we are willing to debug.
  111077. * @param scene Defines the scene the ray needs to be rendered in
  111078. * @param color Defines the color the ray needs to be rendered in
  111079. */
  111080. show(scene: Scene, color?: Color3): void;
  111081. /**
  111082. * Hides the ray we are debugging.
  111083. */
  111084. hide(): void;
  111085. private _render;
  111086. /**
  111087. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111088. * @param mesh Defines the mesh we want the helper attached to
  111089. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111090. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111091. * @param length Defines the length of the ray
  111092. */
  111093. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111094. /**
  111095. * Detach the ray helper from the mesh it has previously been attached to.
  111096. */
  111097. detachFromMesh(): void;
  111098. private _updateToMesh;
  111099. /**
  111100. * Dispose the helper and release its associated resources.
  111101. */
  111102. dispose(): void;
  111103. }
  111104. }
  111105. declare module BABYLON.Debug {
  111106. /**
  111107. * Class used to render a debug view of a given skeleton
  111108. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111109. */
  111110. export class SkeletonViewer {
  111111. /** defines the skeleton to render */
  111112. skeleton: Skeleton;
  111113. /** defines the mesh attached to the skeleton */
  111114. mesh: AbstractMesh;
  111115. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111116. autoUpdateBonesMatrices: boolean;
  111117. /** defines the rendering group id to use with the viewer */
  111118. renderingGroupId: number;
  111119. /** Gets or sets the color used to render the skeleton */
  111120. color: Color3;
  111121. private _scene;
  111122. private _debugLines;
  111123. private _debugMesh;
  111124. private _isEnabled;
  111125. private _renderFunction;
  111126. private _utilityLayer;
  111127. /**
  111128. * Returns the mesh used to render the bones
  111129. */
  111130. readonly debugMesh: Nullable<LinesMesh>;
  111131. /**
  111132. * Creates a new SkeletonViewer
  111133. * @param skeleton defines the skeleton to render
  111134. * @param mesh defines the mesh attached to the skeleton
  111135. * @param scene defines the hosting scene
  111136. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  111137. * @param renderingGroupId defines the rendering group id to use with the viewer
  111138. */
  111139. constructor(
  111140. /** defines the skeleton to render */
  111141. skeleton: Skeleton,
  111142. /** defines the mesh attached to the skeleton */
  111143. mesh: AbstractMesh, scene: Scene,
  111144. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111145. autoUpdateBonesMatrices?: boolean,
  111146. /** defines the rendering group id to use with the viewer */
  111147. renderingGroupId?: number);
  111148. /** Gets or sets a boolean indicating if the viewer is enabled */
  111149. isEnabled: boolean;
  111150. private _getBonePosition;
  111151. private _getLinesForBonesWithLength;
  111152. private _getLinesForBonesNoLength;
  111153. /** Update the viewer to sync with current skeleton state */
  111154. update(): void;
  111155. /** Release associated resources */
  111156. dispose(): void;
  111157. }
  111158. }
  111159. declare module BABYLON {
  111160. /**
  111161. * Options to create the null engine
  111162. */
  111163. export class NullEngineOptions {
  111164. /**
  111165. * Render width (Default: 512)
  111166. */
  111167. renderWidth: number;
  111168. /**
  111169. * Render height (Default: 256)
  111170. */
  111171. renderHeight: number;
  111172. /**
  111173. * Texture size (Default: 512)
  111174. */
  111175. textureSize: number;
  111176. /**
  111177. * If delta time between frames should be constant
  111178. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111179. */
  111180. deterministicLockstep: boolean;
  111181. /**
  111182. * Maximum about of steps between frames (Default: 4)
  111183. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111184. */
  111185. lockstepMaxSteps: number;
  111186. }
  111187. /**
  111188. * The null engine class provides support for headless version of babylon.js.
  111189. * This can be used in server side scenario or for testing purposes
  111190. */
  111191. export class NullEngine extends Engine {
  111192. private _options;
  111193. /**
  111194. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111195. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111196. * @returns true if engine is in deterministic lock step mode
  111197. */
  111198. isDeterministicLockStep(): boolean;
  111199. /**
  111200. * Gets the max steps when engine is running in deterministic lock step
  111201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111202. * @returns the max steps
  111203. */
  111204. getLockstepMaxSteps(): number;
  111205. /**
  111206. * Gets the current hardware scaling level.
  111207. * By default the hardware scaling level is computed from the window device ratio.
  111208. * 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.
  111209. * @returns a number indicating the current hardware scaling level
  111210. */
  111211. getHardwareScalingLevel(): number;
  111212. constructor(options?: NullEngineOptions);
  111213. /**
  111214. * Creates a vertex buffer
  111215. * @param vertices the data for the vertex buffer
  111216. * @returns the new WebGL static buffer
  111217. */
  111218. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111219. /**
  111220. * Creates a new index buffer
  111221. * @param indices defines the content of the index buffer
  111222. * @param updatable defines if the index buffer must be updatable
  111223. * @returns a new webGL buffer
  111224. */
  111225. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111226. /**
  111227. * Clear the current render buffer or the current render target (if any is set up)
  111228. * @param color defines the color to use
  111229. * @param backBuffer defines if the back buffer must be cleared
  111230. * @param depth defines if the depth buffer must be cleared
  111231. * @param stencil defines if the stencil buffer must be cleared
  111232. */
  111233. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111234. /**
  111235. * Gets the current render width
  111236. * @param useScreen defines if screen size must be used (or the current render target if any)
  111237. * @returns a number defining the current render width
  111238. */
  111239. getRenderWidth(useScreen?: boolean): number;
  111240. /**
  111241. * Gets the current render height
  111242. * @param useScreen defines if screen size must be used (or the current render target if any)
  111243. * @returns a number defining the current render height
  111244. */
  111245. getRenderHeight(useScreen?: boolean): number;
  111246. /**
  111247. * Set the WebGL's viewport
  111248. * @param viewport defines the viewport element to be used
  111249. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111250. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111251. */
  111252. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111253. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111254. /**
  111255. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111256. * @param pipelineContext defines the pipeline context to use
  111257. * @param uniformsNames defines the list of uniform names
  111258. * @returns an array of webGL uniform locations
  111259. */
  111260. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111261. /**
  111262. * Gets the lsit of active attributes for a given webGL program
  111263. * @param pipelineContext defines the pipeline context to use
  111264. * @param attributesNames defines the list of attribute names to get
  111265. * @returns an array of indices indicating the offset of each attribute
  111266. */
  111267. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111268. /**
  111269. * Binds an effect to the webGL context
  111270. * @param effect defines the effect to bind
  111271. */
  111272. bindSamplers(effect: Effect): void;
  111273. /**
  111274. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111275. * @param effect defines the effect to activate
  111276. */
  111277. enableEffect(effect: Effect): void;
  111278. /**
  111279. * Set various states to the webGL context
  111280. * @param culling defines backface culling state
  111281. * @param zOffset defines the value to apply to zOffset (0 by default)
  111282. * @param force defines if states must be applied even if cache is up to date
  111283. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111284. */
  111285. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111286. /**
  111287. * Set the value of an uniform to an array of int32
  111288. * @param uniform defines the webGL uniform location where to store the value
  111289. * @param array defines the array of int32 to store
  111290. */
  111291. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111292. /**
  111293. * Set the value of an uniform to an array of int32 (stored as vec2)
  111294. * @param uniform defines the webGL uniform location where to store the value
  111295. * @param array defines the array of int32 to store
  111296. */
  111297. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111298. /**
  111299. * Set the value of an uniform to an array of int32 (stored as vec3)
  111300. * @param uniform defines the webGL uniform location where to store the value
  111301. * @param array defines the array of int32 to store
  111302. */
  111303. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111304. /**
  111305. * Set the value of an uniform to an array of int32 (stored as vec4)
  111306. * @param uniform defines the webGL uniform location where to store the value
  111307. * @param array defines the array of int32 to store
  111308. */
  111309. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111310. /**
  111311. * Set the value of an uniform to an array of float32
  111312. * @param uniform defines the webGL uniform location where to store the value
  111313. * @param array defines the array of float32 to store
  111314. */
  111315. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111316. /**
  111317. * Set the value of an uniform to an array of float32 (stored as vec2)
  111318. * @param uniform defines the webGL uniform location where to store the value
  111319. * @param array defines the array of float32 to store
  111320. */
  111321. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111322. /**
  111323. * Set the value of an uniform to an array of float32 (stored as vec3)
  111324. * @param uniform defines the webGL uniform location where to store the value
  111325. * @param array defines the array of float32 to store
  111326. */
  111327. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111328. /**
  111329. * Set the value of an uniform to an array of float32 (stored as vec4)
  111330. * @param uniform defines the webGL uniform location where to store the value
  111331. * @param array defines the array of float32 to store
  111332. */
  111333. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111334. /**
  111335. * Set the value of an uniform to an array of number
  111336. * @param uniform defines the webGL uniform location where to store the value
  111337. * @param array defines the array of number to store
  111338. */
  111339. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111340. /**
  111341. * Set the value of an uniform to an array of number (stored as vec2)
  111342. * @param uniform defines the webGL uniform location where to store the value
  111343. * @param array defines the array of number to store
  111344. */
  111345. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111346. /**
  111347. * Set the value of an uniform to an array of number (stored as vec3)
  111348. * @param uniform defines the webGL uniform location where to store the value
  111349. * @param array defines the array of number to store
  111350. */
  111351. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111352. /**
  111353. * Set the value of an uniform to an array of number (stored as vec4)
  111354. * @param uniform defines the webGL uniform location where to store the value
  111355. * @param array defines the array of number to store
  111356. */
  111357. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111358. /**
  111359. * Set the value of an uniform to an array of float32 (stored as matrices)
  111360. * @param uniform defines the webGL uniform location where to store the value
  111361. * @param matrices defines the array of float32 to store
  111362. */
  111363. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111364. /**
  111365. * Set the value of an uniform to a matrix (3x3)
  111366. * @param uniform defines the webGL uniform location where to store the value
  111367. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111368. */
  111369. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111370. /**
  111371. * Set the value of an uniform to a matrix (2x2)
  111372. * @param uniform defines the webGL uniform location where to store the value
  111373. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111374. */
  111375. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111376. /**
  111377. * Set the value of an uniform to a number (float)
  111378. * @param uniform defines the webGL uniform location where to store the value
  111379. * @param value defines the float number to store
  111380. */
  111381. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111382. /**
  111383. * Set the value of an uniform to a vec2
  111384. * @param uniform defines the webGL uniform location where to store the value
  111385. * @param x defines the 1st component of the value
  111386. * @param y defines the 2nd component of the value
  111387. */
  111388. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111389. /**
  111390. * Set the value of an uniform to a vec3
  111391. * @param uniform defines the webGL uniform location where to store the value
  111392. * @param x defines the 1st component of the value
  111393. * @param y defines the 2nd component of the value
  111394. * @param z defines the 3rd component of the value
  111395. */
  111396. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111397. /**
  111398. * Set the value of an uniform to a boolean
  111399. * @param uniform defines the webGL uniform location where to store the value
  111400. * @param bool defines the boolean to store
  111401. */
  111402. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111403. /**
  111404. * Set the value of an uniform to a vec4
  111405. * @param uniform defines the webGL uniform location where to store the value
  111406. * @param x defines the 1st component of the value
  111407. * @param y defines the 2nd component of the value
  111408. * @param z defines the 3rd component of the value
  111409. * @param w defines the 4th component of the value
  111410. */
  111411. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111412. /**
  111413. * Sets the current alpha mode
  111414. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111415. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111416. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111417. */
  111418. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111419. /**
  111420. * Bind webGl buffers directly to the webGL context
  111421. * @param vertexBuffers defines the vertex buffer to bind
  111422. * @param indexBuffer defines the index buffer to bind
  111423. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111424. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111425. * @param effect defines the effect associated with the vertex buffer
  111426. */
  111427. bindBuffers(vertexBuffers: {
  111428. [key: string]: VertexBuffer;
  111429. }, indexBuffer: DataBuffer, effect: Effect): void;
  111430. /**
  111431. * Force the entire cache to be cleared
  111432. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111433. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111434. */
  111435. wipeCaches(bruteForce?: boolean): void;
  111436. /**
  111437. * Send a draw order
  111438. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111439. * @param indexStart defines the starting index
  111440. * @param indexCount defines the number of index to draw
  111441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111442. */
  111443. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111444. /**
  111445. * Draw a list of indexed primitives
  111446. * @param fillMode defines the primitive to use
  111447. * @param indexStart defines the starting index
  111448. * @param indexCount defines the number of index to draw
  111449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111450. */
  111451. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111452. /**
  111453. * Draw a list of unindexed primitives
  111454. * @param fillMode defines the primitive to use
  111455. * @param verticesStart defines the index of first vertex to draw
  111456. * @param verticesCount defines the count of vertices to draw
  111457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111458. */
  111459. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111460. /** @hidden */
  111461. _createTexture(): WebGLTexture;
  111462. /** @hidden */
  111463. _releaseTexture(texture: InternalTexture): void;
  111464. /**
  111465. * Usually called from Texture.ts.
  111466. * Passed information to create a WebGLTexture
  111467. * @param urlArg defines a value which contains one of the following:
  111468. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111469. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111470. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111471. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111472. * @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)
  111473. * @param scene needed for loading to the correct scene
  111474. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111475. * @param onLoad optional callback to be called upon successful completion
  111476. * @param onError optional callback to be called upon failure
  111477. * @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
  111478. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111479. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111480. * @param forcedExtension defines the extension to use to pick the right loader
  111481. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111482. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111483. */
  111484. 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;
  111485. /**
  111486. * Creates a new render target texture
  111487. * @param size defines the size of the texture
  111488. * @param options defines the options used to create the texture
  111489. * @returns a new render target texture stored in an InternalTexture
  111490. */
  111491. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111492. /**
  111493. * Update the sampling mode of a given texture
  111494. * @param samplingMode defines the required sampling mode
  111495. * @param texture defines the texture to update
  111496. */
  111497. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111498. /**
  111499. * Binds the frame buffer to the specified texture.
  111500. * @param texture The texture to render to or null for the default canvas
  111501. * @param faceIndex The face of the texture to render to in case of cube texture
  111502. * @param requiredWidth The width of the target to render to
  111503. * @param requiredHeight The height of the target to render to
  111504. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111505. * @param depthStencilTexture The depth stencil texture to use to render
  111506. * @param lodLevel defines le lod level to bind to the frame buffer
  111507. */
  111508. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111509. /**
  111510. * Unbind the current render target texture from the webGL context
  111511. * @param texture defines the render target texture to unbind
  111512. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111513. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111514. */
  111515. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111516. /**
  111517. * Creates a dynamic vertex buffer
  111518. * @param vertices the data for the dynamic vertex buffer
  111519. * @returns the new WebGL dynamic buffer
  111520. */
  111521. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111522. /**
  111523. * Update the content of a dynamic texture
  111524. * @param texture defines the texture to update
  111525. * @param canvas defines the canvas containing the source
  111526. * @param invertY defines if data must be stored with Y axis inverted
  111527. * @param premulAlpha defines if alpha is stored as premultiplied
  111528. * @param format defines the format of the data
  111529. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111530. */
  111531. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111532. /**
  111533. * Gets a boolean indicating if all created effects are ready
  111534. * @returns true if all effects are ready
  111535. */
  111536. areAllEffectsReady(): boolean;
  111537. /**
  111538. * @hidden
  111539. * Get the current error code of the webGL context
  111540. * @returns the error code
  111541. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111542. */
  111543. getError(): number;
  111544. /** @hidden */
  111545. _getUnpackAlignement(): number;
  111546. /** @hidden */
  111547. _unpackFlipY(value: boolean): void;
  111548. /**
  111549. * Update a dynamic index buffer
  111550. * @param indexBuffer defines the target index buffer
  111551. * @param indices defines the data to update
  111552. * @param offset defines the offset in the target index buffer where update should start
  111553. */
  111554. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111555. /**
  111556. * Updates a dynamic vertex buffer.
  111557. * @param vertexBuffer the vertex buffer to update
  111558. * @param vertices the data used to update the vertex buffer
  111559. * @param byteOffset the byte offset of the data (optional)
  111560. * @param byteLength the byte length of the data (optional)
  111561. */
  111562. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111563. /** @hidden */
  111564. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111565. /** @hidden */
  111566. _bindTexture(channel: number, texture: InternalTexture): void;
  111567. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111568. /**
  111569. * 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
  111570. */
  111571. releaseEffects(): void;
  111572. displayLoadingUI(): void;
  111573. hideLoadingUI(): void;
  111574. /** @hidden */
  111575. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111576. /** @hidden */
  111577. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111578. /** @hidden */
  111579. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111580. /** @hidden */
  111581. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111582. }
  111583. }
  111584. declare module BABYLON {
  111585. /** @hidden */
  111586. export class _OcclusionDataStorage {
  111587. /** @hidden */
  111588. occlusionInternalRetryCounter: number;
  111589. /** @hidden */
  111590. isOcclusionQueryInProgress: boolean;
  111591. /** @hidden */
  111592. isOccluded: boolean;
  111593. /** @hidden */
  111594. occlusionRetryCount: number;
  111595. /** @hidden */
  111596. occlusionType: number;
  111597. /** @hidden */
  111598. occlusionQueryAlgorithmType: number;
  111599. }
  111600. interface Engine {
  111601. /**
  111602. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111603. * @return the new query
  111604. */
  111605. createQuery(): WebGLQuery;
  111606. /**
  111607. * Delete and release a webGL query
  111608. * @param query defines the query to delete
  111609. * @return the current engine
  111610. */
  111611. deleteQuery(query: WebGLQuery): Engine;
  111612. /**
  111613. * Check if a given query has resolved and got its value
  111614. * @param query defines the query to check
  111615. * @returns true if the query got its value
  111616. */
  111617. isQueryResultAvailable(query: WebGLQuery): boolean;
  111618. /**
  111619. * Gets the value of a given query
  111620. * @param query defines the query to check
  111621. * @returns the value of the query
  111622. */
  111623. getQueryResult(query: WebGLQuery): number;
  111624. /**
  111625. * Initiates an occlusion query
  111626. * @param algorithmType defines the algorithm to use
  111627. * @param query defines the query to use
  111628. * @returns the current engine
  111629. * @see http://doc.babylonjs.com/features/occlusionquery
  111630. */
  111631. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111632. /**
  111633. * Ends an occlusion query
  111634. * @see http://doc.babylonjs.com/features/occlusionquery
  111635. * @param algorithmType defines the algorithm to use
  111636. * @returns the current engine
  111637. */
  111638. endOcclusionQuery(algorithmType: number): Engine;
  111639. /**
  111640. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111641. * Please note that only one query can be issued at a time
  111642. * @returns a time token used to track the time span
  111643. */
  111644. startTimeQuery(): Nullable<_TimeToken>;
  111645. /**
  111646. * Ends a time query
  111647. * @param token defines the token used to measure the time span
  111648. * @returns the time spent (in ns)
  111649. */
  111650. endTimeQuery(token: _TimeToken): int;
  111651. /** @hidden */
  111652. _currentNonTimestampToken: Nullable<_TimeToken>;
  111653. /** @hidden */
  111654. _createTimeQuery(): WebGLQuery;
  111655. /** @hidden */
  111656. _deleteTimeQuery(query: WebGLQuery): void;
  111657. /** @hidden */
  111658. _getGlAlgorithmType(algorithmType: number): number;
  111659. /** @hidden */
  111660. _getTimeQueryResult(query: WebGLQuery): any;
  111661. /** @hidden */
  111662. _getTimeQueryAvailability(query: WebGLQuery): any;
  111663. }
  111664. interface AbstractMesh {
  111665. /**
  111666. * Backing filed
  111667. * @hidden
  111668. */
  111669. __occlusionDataStorage: _OcclusionDataStorage;
  111670. /**
  111671. * Access property
  111672. * @hidden
  111673. */
  111674. _occlusionDataStorage: _OcclusionDataStorage;
  111675. /**
  111676. * 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.
  111677. * The default value is -1 which means don't break the query and wait till the result
  111678. * @see http://doc.babylonjs.com/features/occlusionquery
  111679. */
  111680. occlusionRetryCount: number;
  111681. /**
  111682. * 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:
  111683. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111684. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111685. * * 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.
  111686. * @see http://doc.babylonjs.com/features/occlusionquery
  111687. */
  111688. occlusionType: number;
  111689. /**
  111690. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111691. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111692. * * 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.
  111693. * @see http://doc.babylonjs.com/features/occlusionquery
  111694. */
  111695. occlusionQueryAlgorithmType: number;
  111696. /**
  111697. * 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
  111698. * @see http://doc.babylonjs.com/features/occlusionquery
  111699. */
  111700. isOccluded: boolean;
  111701. /**
  111702. * Flag to check the progress status of the query
  111703. * @see http://doc.babylonjs.com/features/occlusionquery
  111704. */
  111705. isOcclusionQueryInProgress: boolean;
  111706. }
  111707. }
  111708. declare module BABYLON {
  111709. /** @hidden */
  111710. export var _forceTransformFeedbackToBundle: boolean;
  111711. interface Engine {
  111712. /**
  111713. * Creates a webGL transform feedback object
  111714. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  111715. * @returns the webGL transform feedback object
  111716. */
  111717. createTransformFeedback(): WebGLTransformFeedback;
  111718. /**
  111719. * Delete a webGL transform feedback object
  111720. * @param value defines the webGL transform feedback object to delete
  111721. */
  111722. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  111723. /**
  111724. * Bind a webGL transform feedback object to the webgl context
  111725. * @param value defines the webGL transform feedback object to bind
  111726. */
  111727. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  111728. /**
  111729. * Begins a transform feedback operation
  111730. * @param usePoints defines if points or triangles must be used
  111731. */
  111732. beginTransformFeedback(usePoints: boolean): void;
  111733. /**
  111734. * Ends a transform feedback operation
  111735. */
  111736. endTransformFeedback(): void;
  111737. /**
  111738. * Specify the varyings to use with transform feedback
  111739. * @param program defines the associated webGL program
  111740. * @param value defines the list of strings representing the varying names
  111741. */
  111742. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111743. /**
  111744. * Bind a webGL buffer for a transform feedback operation
  111745. * @param value defines the webGL buffer to bind
  111746. */
  111747. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111748. }
  111749. }
  111750. declare module BABYLON {
  111751. /**
  111752. * Creation options of the multi render target texture.
  111753. */
  111754. export interface IMultiRenderTargetOptions {
  111755. /**
  111756. * Define if the texture needs to create mip maps after render.
  111757. */
  111758. generateMipMaps?: boolean;
  111759. /**
  111760. * Define the types of all the draw buffers we want to create
  111761. */
  111762. types?: number[];
  111763. /**
  111764. * Define the sampling modes of all the draw buffers we want to create
  111765. */
  111766. samplingModes?: number[];
  111767. /**
  111768. * Define if a depth buffer is required
  111769. */
  111770. generateDepthBuffer?: boolean;
  111771. /**
  111772. * Define if a stencil buffer is required
  111773. */
  111774. generateStencilBuffer?: boolean;
  111775. /**
  111776. * Define if a depth texture is required instead of a depth buffer
  111777. */
  111778. generateDepthTexture?: boolean;
  111779. /**
  111780. * Define the number of desired draw buffers
  111781. */
  111782. textureCount?: number;
  111783. /**
  111784. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111785. */
  111786. doNotChangeAspectRatio?: boolean;
  111787. /**
  111788. * Define the default type of the buffers we are creating
  111789. */
  111790. defaultType?: number;
  111791. }
  111792. /**
  111793. * A multi render target, like a render target provides the ability to render to a texture.
  111794. * Unlike the render target, it can render to several draw buffers in one draw.
  111795. * This is specially interesting in deferred rendering or for any effects requiring more than
  111796. * just one color from a single pass.
  111797. */
  111798. export class MultiRenderTarget extends RenderTargetTexture {
  111799. private _internalTextures;
  111800. private _textures;
  111801. private _multiRenderTargetOptions;
  111802. /**
  111803. * Get if draw buffers are currently supported by the used hardware and browser.
  111804. */
  111805. readonly isSupported: boolean;
  111806. /**
  111807. * Get the list of textures generated by the multi render target.
  111808. */
  111809. readonly textures: Texture[];
  111810. /**
  111811. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111812. */
  111813. readonly depthTexture: Texture;
  111814. /**
  111815. * Set the wrapping mode on U of all the textures we are rendering to.
  111816. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111817. */
  111818. wrapU: number;
  111819. /**
  111820. * Set the wrapping mode on V of all the textures we are rendering to.
  111821. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111822. */
  111823. wrapV: number;
  111824. /**
  111825. * Instantiate a new multi render target texture.
  111826. * A multi render target, like a render target provides the ability to render to a texture.
  111827. * Unlike the render target, it can render to several draw buffers in one draw.
  111828. * This is specially interesting in deferred rendering or for any effects requiring more than
  111829. * just one color from a single pass.
  111830. * @param name Define the name of the texture
  111831. * @param size Define the size of the buffers to render to
  111832. * @param count Define the number of target we are rendering into
  111833. * @param scene Define the scene the texture belongs to
  111834. * @param options Define the options used to create the multi render target
  111835. */
  111836. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111837. /** @hidden */
  111838. _rebuild(): void;
  111839. private _createInternalTextures;
  111840. private _createTextures;
  111841. /**
  111842. * Define the number of samples used if MSAA is enabled.
  111843. */
  111844. samples: number;
  111845. /**
  111846. * Resize all the textures in the multi render target.
  111847. * Be carrefull as it will recreate all the data in the new texture.
  111848. * @param size Define the new size
  111849. */
  111850. resize(size: any): void;
  111851. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111852. /**
  111853. * Dispose the render targets and their associated resources
  111854. */
  111855. dispose(): void;
  111856. /**
  111857. * Release all the underlying texture used as draw buffers.
  111858. */
  111859. releaseInternalTextures(): void;
  111860. }
  111861. }
  111862. declare module BABYLON {
  111863. interface ThinEngine {
  111864. /**
  111865. * Unbind a list of render target textures from the webGL context
  111866. * This is used only when drawBuffer extension or webGL2 are active
  111867. * @param textures defines the render target textures to unbind
  111868. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111869. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111870. */
  111871. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111872. /**
  111873. * Create a multi render target texture
  111874. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111875. * @param size defines the size of the texture
  111876. * @param options defines the creation options
  111877. * @returns the cube texture as an InternalTexture
  111878. */
  111879. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111880. /**
  111881. * Update the sample count for a given multiple render target texture
  111882. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111883. * @param textures defines the textures to update
  111884. * @param samples defines the sample count to set
  111885. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111886. */
  111887. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111888. }
  111889. }
  111890. declare module BABYLON {
  111891. /**
  111892. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111893. */
  111894. export interface CubeMapInfo {
  111895. /**
  111896. * The pixel array for the front face.
  111897. * This is stored in format, left to right, up to down format.
  111898. */
  111899. front: Nullable<ArrayBufferView>;
  111900. /**
  111901. * The pixel array for the back face.
  111902. * This is stored in format, left to right, up to down format.
  111903. */
  111904. back: Nullable<ArrayBufferView>;
  111905. /**
  111906. * The pixel array for the left face.
  111907. * This is stored in format, left to right, up to down format.
  111908. */
  111909. left: Nullable<ArrayBufferView>;
  111910. /**
  111911. * The pixel array for the right face.
  111912. * This is stored in format, left to right, up to down format.
  111913. */
  111914. right: Nullable<ArrayBufferView>;
  111915. /**
  111916. * The pixel array for the up face.
  111917. * This is stored in format, left to right, up to down format.
  111918. */
  111919. up: Nullable<ArrayBufferView>;
  111920. /**
  111921. * The pixel array for the down face.
  111922. * This is stored in format, left to right, up to down format.
  111923. */
  111924. down: Nullable<ArrayBufferView>;
  111925. /**
  111926. * The size of the cubemap stored.
  111927. *
  111928. * Each faces will be size * size pixels.
  111929. */
  111930. size: number;
  111931. /**
  111932. * The format of the texture.
  111933. *
  111934. * RGBA, RGB.
  111935. */
  111936. format: number;
  111937. /**
  111938. * The type of the texture data.
  111939. *
  111940. * UNSIGNED_INT, FLOAT.
  111941. */
  111942. type: number;
  111943. /**
  111944. * Specifies whether the texture is in gamma space.
  111945. */
  111946. gammaSpace: boolean;
  111947. }
  111948. /**
  111949. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111950. */
  111951. export class PanoramaToCubeMapTools {
  111952. private static FACE_FRONT;
  111953. private static FACE_BACK;
  111954. private static FACE_RIGHT;
  111955. private static FACE_LEFT;
  111956. private static FACE_DOWN;
  111957. private static FACE_UP;
  111958. /**
  111959. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111960. *
  111961. * @param float32Array The source data.
  111962. * @param inputWidth The width of the input panorama.
  111963. * @param inputHeight The height of the input panorama.
  111964. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111965. * @return The cubemap data
  111966. */
  111967. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111968. private static CreateCubemapTexture;
  111969. private static CalcProjectionSpherical;
  111970. }
  111971. }
  111972. declare module BABYLON {
  111973. /**
  111974. * Helper class dealing with the extraction of spherical polynomial dataArray
  111975. * from a cube map.
  111976. */
  111977. export class CubeMapToSphericalPolynomialTools {
  111978. private static FileFaces;
  111979. /**
  111980. * Converts a texture to the according Spherical Polynomial data.
  111981. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111982. *
  111983. * @param texture The texture to extract the information from.
  111984. * @return The Spherical Polynomial data.
  111985. */
  111986. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111987. /**
  111988. * Converts a cubemap to the according Spherical Polynomial data.
  111989. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111990. *
  111991. * @param cubeInfo The Cube map to extract the information from.
  111992. * @return The Spherical Polynomial data.
  111993. */
  111994. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111995. }
  111996. }
  111997. declare module BABYLON {
  111998. interface BaseTexture {
  111999. /**
  112000. * Get the polynomial representation of the texture data.
  112001. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112002. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112003. */
  112004. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112005. }
  112006. }
  112007. declare module BABYLON {
  112008. /** @hidden */
  112009. export var rgbdEncodePixelShader: {
  112010. name: string;
  112011. shader: string;
  112012. };
  112013. }
  112014. declare module BABYLON {
  112015. /** @hidden */
  112016. export var rgbdDecodePixelShader: {
  112017. name: string;
  112018. shader: string;
  112019. };
  112020. }
  112021. declare module BABYLON {
  112022. /**
  112023. * Raw texture data and descriptor sufficient for WebGL texture upload
  112024. */
  112025. export interface EnvironmentTextureInfo {
  112026. /**
  112027. * Version of the environment map
  112028. */
  112029. version: number;
  112030. /**
  112031. * Width of image
  112032. */
  112033. width: number;
  112034. /**
  112035. * Irradiance information stored in the file.
  112036. */
  112037. irradiance: any;
  112038. /**
  112039. * Specular information stored in the file.
  112040. */
  112041. specular: any;
  112042. }
  112043. /**
  112044. * Defines One Image in the file. It requires only the position in the file
  112045. * as well as the length.
  112046. */
  112047. interface BufferImageData {
  112048. /**
  112049. * Length of the image data.
  112050. */
  112051. length: number;
  112052. /**
  112053. * Position of the data from the null terminator delimiting the end of the JSON.
  112054. */
  112055. position: number;
  112056. }
  112057. /**
  112058. * Defines the specular data enclosed in the file.
  112059. * This corresponds to the version 1 of the data.
  112060. */
  112061. export interface EnvironmentTextureSpecularInfoV1 {
  112062. /**
  112063. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112064. */
  112065. specularDataPosition?: number;
  112066. /**
  112067. * This contains all the images data needed to reconstruct the cubemap.
  112068. */
  112069. mipmaps: Array<BufferImageData>;
  112070. /**
  112071. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112072. */
  112073. lodGenerationScale: number;
  112074. }
  112075. /**
  112076. * Sets of helpers addressing the serialization and deserialization of environment texture
  112077. * stored in a BabylonJS env file.
  112078. * Those files are usually stored as .env files.
  112079. */
  112080. export class EnvironmentTextureTools {
  112081. /**
  112082. * Magic number identifying the env file.
  112083. */
  112084. private static _MagicBytes;
  112085. /**
  112086. * Gets the environment info from an env file.
  112087. * @param data The array buffer containing the .env bytes.
  112088. * @returns the environment file info (the json header) if successfully parsed.
  112089. */
  112090. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112091. /**
  112092. * Creates an environment texture from a loaded cube texture.
  112093. * @param texture defines the cube texture to convert in env file
  112094. * @return a promise containing the environment data if succesfull.
  112095. */
  112096. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112097. /**
  112098. * Creates a JSON representation of the spherical data.
  112099. * @param texture defines the texture containing the polynomials
  112100. * @return the JSON representation of the spherical info
  112101. */
  112102. private static _CreateEnvTextureIrradiance;
  112103. /**
  112104. * Creates the ArrayBufferViews used for initializing environment texture image data.
  112105. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  112106. * @param info parameters that determine what views will be created for accessing the underlying buffer
  112107. * @return the views described by info providing access to the underlying buffer
  112108. */
  112109. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  112110. /**
  112111. * Uploads the texture info contained in the env file to the GPU.
  112112. * @param texture defines the internal texture to upload to
  112113. * @param arrayBuffer defines the buffer cotaining the data to load
  112114. * @param info defines the texture info retrieved through the GetEnvInfo method
  112115. * @returns a promise
  112116. */
  112117. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112118. private static _OnImageReadyAsync;
  112119. /**
  112120. * Uploads the levels of image data to the GPU.
  112121. * @param texture defines the internal texture to upload to
  112122. * @param imageData defines the array buffer views of image data [mipmap][face]
  112123. * @returns a promise
  112124. */
  112125. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112126. /**
  112127. * Uploads spherical polynomials information to the texture.
  112128. * @param texture defines the texture we are trying to upload the information to
  112129. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112130. */
  112131. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112132. /** @hidden */
  112133. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112134. }
  112135. }
  112136. declare module BABYLON {
  112137. /**
  112138. * Contains position and normal vectors for a vertex
  112139. */
  112140. export class PositionNormalVertex {
  112141. /** the position of the vertex (defaut: 0,0,0) */
  112142. position: Vector3;
  112143. /** the normal of the vertex (defaut: 0,1,0) */
  112144. normal: Vector3;
  112145. /**
  112146. * Creates a PositionNormalVertex
  112147. * @param position the position of the vertex (defaut: 0,0,0)
  112148. * @param normal the normal of the vertex (defaut: 0,1,0)
  112149. */
  112150. constructor(
  112151. /** the position of the vertex (defaut: 0,0,0) */
  112152. position?: Vector3,
  112153. /** the normal of the vertex (defaut: 0,1,0) */
  112154. normal?: Vector3);
  112155. /**
  112156. * Clones the PositionNormalVertex
  112157. * @returns the cloned PositionNormalVertex
  112158. */
  112159. clone(): PositionNormalVertex;
  112160. }
  112161. /**
  112162. * Contains position, normal and uv vectors for a vertex
  112163. */
  112164. export class PositionNormalTextureVertex {
  112165. /** the position of the vertex (defaut: 0,0,0) */
  112166. position: Vector3;
  112167. /** the normal of the vertex (defaut: 0,1,0) */
  112168. normal: Vector3;
  112169. /** the uv of the vertex (default: 0,0) */
  112170. uv: Vector2;
  112171. /**
  112172. * Creates a PositionNormalTextureVertex
  112173. * @param position the position of the vertex (defaut: 0,0,0)
  112174. * @param normal the normal of the vertex (defaut: 0,1,0)
  112175. * @param uv the uv of the vertex (default: 0,0)
  112176. */
  112177. constructor(
  112178. /** the position of the vertex (defaut: 0,0,0) */
  112179. position?: Vector3,
  112180. /** the normal of the vertex (defaut: 0,1,0) */
  112181. normal?: Vector3,
  112182. /** the uv of the vertex (default: 0,0) */
  112183. uv?: Vector2);
  112184. /**
  112185. * Clones the PositionNormalTextureVertex
  112186. * @returns the cloned PositionNormalTextureVertex
  112187. */
  112188. clone(): PositionNormalTextureVertex;
  112189. }
  112190. }
  112191. declare module BABYLON {
  112192. /** @hidden */
  112193. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112194. private _genericAttributeLocation;
  112195. private _varyingLocationCount;
  112196. private _varyingLocationMap;
  112197. private _replacements;
  112198. private _textureCount;
  112199. private _uniforms;
  112200. lineProcessor(line: string): string;
  112201. attributeProcessor(attribute: string): string;
  112202. varyingProcessor(varying: string, isFragment: boolean): string;
  112203. uniformProcessor(uniform: string): string;
  112204. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112205. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112206. }
  112207. }
  112208. declare module BABYLON {
  112209. /**
  112210. * Container for accessors for natively-stored mesh data buffers.
  112211. */
  112212. class NativeDataBuffer extends DataBuffer {
  112213. /**
  112214. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112215. */
  112216. nativeIndexBuffer?: any;
  112217. /**
  112218. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112219. */
  112220. nativeVertexBuffer?: any;
  112221. }
  112222. /** @hidden */
  112223. export class NativeEngine extends Engine {
  112224. private readonly _native;
  112225. getHardwareScalingLevel(): number;
  112226. constructor();
  112227. /**
  112228. * Can be used to override the current requestAnimationFrame requester.
  112229. * @hidden
  112230. */
  112231. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  112232. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112233. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112234. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112235. recordVertexArrayObject(vertexBuffers: {
  112236. [key: string]: VertexBuffer;
  112237. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112238. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112239. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112240. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112241. /**
  112242. * Draw a list of indexed primitives
  112243. * @param fillMode defines the primitive to use
  112244. * @param indexStart defines the starting index
  112245. * @param indexCount defines the number of index to draw
  112246. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112247. */
  112248. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112249. /**
  112250. * Draw a list of unindexed primitives
  112251. * @param fillMode defines the primitive to use
  112252. * @param verticesStart defines the index of first vertex to draw
  112253. * @param verticesCount defines the count of vertices to draw
  112254. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112255. */
  112256. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112257. createPipelineContext(): IPipelineContext;
  112258. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112259. /** @hidden */
  112260. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112261. /** @hidden */
  112262. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112263. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112264. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112265. protected _setProgram(program: WebGLProgram): void;
  112266. _releaseEffect(effect: Effect): void;
  112267. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112268. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112269. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112270. bindSamplers(effect: Effect): void;
  112271. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112272. getRenderWidth(useScreen?: boolean): number;
  112273. getRenderHeight(useScreen?: boolean): number;
  112274. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112275. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112276. /**
  112277. * Set the z offset to apply to current rendering
  112278. * @param value defines the offset to apply
  112279. */
  112280. setZOffset(value: number): void;
  112281. /**
  112282. * Gets the current value of the zOffset
  112283. * @returns the current zOffset state
  112284. */
  112285. getZOffset(): number;
  112286. /**
  112287. * Enable or disable depth buffering
  112288. * @param enable defines the state to set
  112289. */
  112290. setDepthBuffer(enable: boolean): void;
  112291. /**
  112292. * Gets a boolean indicating if depth writing is enabled
  112293. * @returns the current depth writing state
  112294. */
  112295. getDepthWrite(): boolean;
  112296. /**
  112297. * Enable or disable depth writing
  112298. * @param enable defines the state to set
  112299. */
  112300. setDepthWrite(enable: boolean): void;
  112301. /**
  112302. * Enable or disable color writing
  112303. * @param enable defines the state to set
  112304. */
  112305. setColorWrite(enable: boolean): void;
  112306. /**
  112307. * Gets a boolean indicating if color writing is enabled
  112308. * @returns the current color writing state
  112309. */
  112310. getColorWrite(): boolean;
  112311. /**
  112312. * Sets alpha constants used by some alpha blending modes
  112313. * @param r defines the red component
  112314. * @param g defines the green component
  112315. * @param b defines the blue component
  112316. * @param a defines the alpha component
  112317. */
  112318. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112319. /**
  112320. * Sets the current alpha mode
  112321. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112322. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112323. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112324. */
  112325. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112326. /**
  112327. * Gets the current alpha mode
  112328. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112329. * @returns the current alpha mode
  112330. */
  112331. getAlphaMode(): number;
  112332. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112333. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112334. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112335. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112336. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112337. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112338. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112339. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112340. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112341. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112342. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112343. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112344. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112345. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112346. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112347. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112348. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112349. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112350. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112351. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112352. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112353. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112354. wipeCaches(bruteForce?: boolean): void;
  112355. _createTexture(): WebGLTexture;
  112356. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112357. /**
  112358. * Usually called from BABYLON.Texture.ts.
  112359. * Passed information to create a WebGLTexture
  112360. * @param urlArg defines a value which contains one of the following:
  112361. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112362. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112363. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112364. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112365. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112366. * @param scene needed for loading to the correct scene
  112367. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112368. * @param onLoad optional callback to be called upon successful completion
  112369. * @param onError optional callback to be called upon failure
  112370. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112371. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112372. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112373. * @param forcedExtension defines the extension to use to pick the right loader
  112374. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112375. */
  112376. 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;
  112377. /**
  112378. * Creates a cube texture
  112379. * @param rootUrl defines the url where the files to load is located
  112380. * @param scene defines the current scene
  112381. * @param files defines the list of files to load (1 per face)
  112382. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112383. * @param onLoad defines an optional callback raised when the texture is loaded
  112384. * @param onError defines an optional callback raised if there is an issue to load the texture
  112385. * @param format defines the format of the data
  112386. * @param forcedExtension defines the extension to use to pick the right loader
  112387. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112388. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112389. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112390. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112391. * @returns the cube texture as an InternalTexture
  112392. */
  112393. 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;
  112394. private _getSamplingFilter;
  112395. private static _GetNativeTextureFormat;
  112396. createRenderTargetTexture(size: number | {
  112397. width: number;
  112398. height: number;
  112399. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112400. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112401. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112402. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112403. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112404. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112405. /**
  112406. * Updates a dynamic vertex buffer.
  112407. * @param vertexBuffer the vertex buffer to update
  112408. * @param data the data used to update the vertex buffer
  112409. * @param byteOffset the byte offset of the data (optional)
  112410. * @param byteLength the byte length of the data (optional)
  112411. */
  112412. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112413. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112414. private _updateAnisotropicLevel;
  112415. private _getAddressMode;
  112416. /** @hidden */
  112417. _bindTexture(channel: number, texture: InternalTexture): void;
  112418. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112419. releaseEffects(): void;
  112420. /** @hidden */
  112421. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112422. /** @hidden */
  112423. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112424. /** @hidden */
  112425. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112426. /** @hidden */
  112427. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112428. }
  112429. }
  112430. declare module BABYLON {
  112431. /**
  112432. * Gather the list of clipboard event types as constants.
  112433. */
  112434. export class ClipboardEventTypes {
  112435. /**
  112436. * The clipboard event is fired when a copy command is active (pressed).
  112437. */
  112438. static readonly COPY: number;
  112439. /**
  112440. * The clipboard event is fired when a cut command is active (pressed).
  112441. */
  112442. static readonly CUT: number;
  112443. /**
  112444. * The clipboard event is fired when a paste command is active (pressed).
  112445. */
  112446. static readonly PASTE: number;
  112447. }
  112448. /**
  112449. * This class is used to store clipboard related info for the onClipboardObservable event.
  112450. */
  112451. export class ClipboardInfo {
  112452. /**
  112453. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112454. */
  112455. type: number;
  112456. /**
  112457. * Defines the related dom event
  112458. */
  112459. event: ClipboardEvent;
  112460. /**
  112461. *Creates an instance of ClipboardInfo.
  112462. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112463. * @param event Defines the related dom event
  112464. */
  112465. constructor(
  112466. /**
  112467. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112468. */
  112469. type: number,
  112470. /**
  112471. * Defines the related dom event
  112472. */
  112473. event: ClipboardEvent);
  112474. /**
  112475. * Get the clipboard event's type from the keycode.
  112476. * @param keyCode Defines the keyCode for the current keyboard event.
  112477. * @return {number}
  112478. */
  112479. static GetTypeFromCharacter(keyCode: number): number;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * Google Daydream controller
  112485. */
  112486. export class DaydreamController extends WebVRController {
  112487. /**
  112488. * Base Url for the controller model.
  112489. */
  112490. static MODEL_BASE_URL: string;
  112491. /**
  112492. * File name for the controller model.
  112493. */
  112494. static MODEL_FILENAME: string;
  112495. /**
  112496. * Gamepad Id prefix used to identify Daydream Controller.
  112497. */
  112498. static readonly GAMEPAD_ID_PREFIX: string;
  112499. /**
  112500. * Creates a new DaydreamController from a gamepad
  112501. * @param vrGamepad the gamepad that the controller should be created from
  112502. */
  112503. constructor(vrGamepad: any);
  112504. /**
  112505. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112506. * @param scene scene in which to add meshes
  112507. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112508. */
  112509. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112510. /**
  112511. * Called once for each button that changed state since the last frame
  112512. * @param buttonIdx Which button index changed
  112513. * @param state New state of the button
  112514. * @param changes Which properties on the state changed since last frame
  112515. */
  112516. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112517. }
  112518. }
  112519. declare module BABYLON {
  112520. /**
  112521. * Gear VR Controller
  112522. */
  112523. export class GearVRController extends WebVRController {
  112524. /**
  112525. * Base Url for the controller model.
  112526. */
  112527. static MODEL_BASE_URL: string;
  112528. /**
  112529. * File name for the controller model.
  112530. */
  112531. static MODEL_FILENAME: string;
  112532. /**
  112533. * Gamepad Id prefix used to identify this controller.
  112534. */
  112535. static readonly GAMEPAD_ID_PREFIX: string;
  112536. private readonly _buttonIndexToObservableNameMap;
  112537. /**
  112538. * Creates a new GearVRController from a gamepad
  112539. * @param vrGamepad the gamepad that the controller should be created from
  112540. */
  112541. constructor(vrGamepad: any);
  112542. /**
  112543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112544. * @param scene scene in which to add meshes
  112545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112546. */
  112547. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112548. /**
  112549. * Called once for each button that changed state since the last frame
  112550. * @param buttonIdx Which button index changed
  112551. * @param state New state of the button
  112552. * @param changes Which properties on the state changed since last frame
  112553. */
  112554. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112555. }
  112556. }
  112557. declare module BABYLON {
  112558. /**
  112559. * Class containing static functions to help procedurally build meshes
  112560. */
  112561. export class PolyhedronBuilder {
  112562. /**
  112563. * Creates a polyhedron mesh
  112564. * * 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
  112565. * * The parameter `size` (positive float, default 1) sets the polygon size
  112566. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112567. * * 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`
  112568. * * 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
  112569. * * 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)`)
  112570. * * 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
  112571. * * 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
  112572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112575. * @param name defines the name of the mesh
  112576. * @param options defines the options used to create the mesh
  112577. * @param scene defines the hosting scene
  112578. * @returns the polyhedron mesh
  112579. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112580. */
  112581. static CreatePolyhedron(name: string, options: {
  112582. type?: number;
  112583. size?: number;
  112584. sizeX?: number;
  112585. sizeY?: number;
  112586. sizeZ?: number;
  112587. custom?: any;
  112588. faceUV?: Vector4[];
  112589. faceColors?: Color4[];
  112590. flat?: boolean;
  112591. updatable?: boolean;
  112592. sideOrientation?: number;
  112593. frontUVs?: Vector4;
  112594. backUVs?: Vector4;
  112595. }, scene?: Nullable<Scene>): Mesh;
  112596. }
  112597. }
  112598. declare module BABYLON {
  112599. /**
  112600. * Gizmo that enables scaling a mesh along 3 axis
  112601. */
  112602. export class ScaleGizmo extends Gizmo {
  112603. /**
  112604. * Internal gizmo used for interactions on the x axis
  112605. */
  112606. xGizmo: AxisScaleGizmo;
  112607. /**
  112608. * Internal gizmo used for interactions on the y axis
  112609. */
  112610. yGizmo: AxisScaleGizmo;
  112611. /**
  112612. * Internal gizmo used for interactions on the z axis
  112613. */
  112614. zGizmo: AxisScaleGizmo;
  112615. /**
  112616. * Internal gizmo used to scale all axis equally
  112617. */
  112618. uniformScaleGizmo: AxisScaleGizmo;
  112619. private _meshAttached;
  112620. private _updateGizmoRotationToMatchAttachedMesh;
  112621. private _snapDistance;
  112622. private _scaleRatio;
  112623. private _uniformScalingMesh;
  112624. private _octahedron;
  112625. /** Fires an event when any of it's sub gizmos are dragged */
  112626. onDragStartObservable: Observable<unknown>;
  112627. /** Fires an event when any of it's sub gizmos are released from dragging */
  112628. onDragEndObservable: Observable<unknown>;
  112629. attachedMesh: Nullable<AbstractMesh>;
  112630. /**
  112631. * Creates a ScaleGizmo
  112632. * @param gizmoLayer The utility layer the gizmo will be added to
  112633. */
  112634. constructor(gizmoLayer?: UtilityLayerRenderer);
  112635. updateGizmoRotationToMatchAttachedMesh: boolean;
  112636. /**
  112637. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112638. */
  112639. snapDistance: number;
  112640. /**
  112641. * Ratio for the scale of the gizmo (Default: 1)
  112642. */
  112643. scaleRatio: number;
  112644. /**
  112645. * Disposes of the gizmo
  112646. */
  112647. dispose(): void;
  112648. }
  112649. }
  112650. declare module BABYLON {
  112651. /**
  112652. * Single axis scale gizmo
  112653. */
  112654. export class AxisScaleGizmo extends Gizmo {
  112655. /**
  112656. * Drag behavior responsible for the gizmos dragging interactions
  112657. */
  112658. dragBehavior: PointerDragBehavior;
  112659. private _pointerObserver;
  112660. /**
  112661. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112662. */
  112663. snapDistance: number;
  112664. /**
  112665. * Event that fires each time the gizmo snaps to a new location.
  112666. * * snapDistance is the the change in distance
  112667. */
  112668. onSnapObservable: Observable<{
  112669. snapDistance: number;
  112670. }>;
  112671. /**
  112672. * If the scaling operation should be done on all axis (default: false)
  112673. */
  112674. uniformScaling: boolean;
  112675. private _isEnabled;
  112676. private _parent;
  112677. private _arrow;
  112678. private _coloredMaterial;
  112679. private _hoverMaterial;
  112680. /**
  112681. * Creates an AxisScaleGizmo
  112682. * @param gizmoLayer The utility layer the gizmo will be added to
  112683. * @param dragAxis The axis which the gizmo will be able to scale on
  112684. * @param color The color of the gizmo
  112685. */
  112686. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  112687. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112688. /**
  112689. * If the gizmo is enabled
  112690. */
  112691. isEnabled: boolean;
  112692. /**
  112693. * Disposes of the gizmo
  112694. */
  112695. dispose(): void;
  112696. /**
  112697. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112698. * @param mesh The mesh to replace the default mesh of the gizmo
  112699. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  112700. */
  112701. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  112702. }
  112703. }
  112704. declare module BABYLON {
  112705. /**
  112706. * Bounding box gizmo
  112707. */
  112708. export class BoundingBoxGizmo extends Gizmo {
  112709. private _lineBoundingBox;
  112710. private _rotateSpheresParent;
  112711. private _scaleBoxesParent;
  112712. private _boundingDimensions;
  112713. private _renderObserver;
  112714. private _pointerObserver;
  112715. private _scaleDragSpeed;
  112716. private _tmpQuaternion;
  112717. private _tmpVector;
  112718. private _tmpRotationMatrix;
  112719. /**
  112720. * 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)
  112721. */
  112722. ignoreChildren: boolean;
  112723. /**
  112724. * 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)
  112725. */
  112726. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  112727. /**
  112728. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  112729. */
  112730. rotationSphereSize: number;
  112731. /**
  112732. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  112733. */
  112734. scaleBoxSize: number;
  112735. /**
  112736. * 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)
  112737. */
  112738. fixedDragMeshScreenSize: boolean;
  112739. /**
  112740. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  112741. */
  112742. fixedDragMeshScreenSizeDistanceFactor: number;
  112743. /**
  112744. * Fired when a rotation sphere or scale box is dragged
  112745. */
  112746. onDragStartObservable: Observable<{}>;
  112747. /**
  112748. * Fired when a scale box is dragged
  112749. */
  112750. onScaleBoxDragObservable: Observable<{}>;
  112751. /**
  112752. * Fired when a scale box drag is ended
  112753. */
  112754. onScaleBoxDragEndObservable: Observable<{}>;
  112755. /**
  112756. * Fired when a rotation sphere is dragged
  112757. */
  112758. onRotationSphereDragObservable: Observable<{}>;
  112759. /**
  112760. * Fired when a rotation sphere drag is ended
  112761. */
  112762. onRotationSphereDragEndObservable: Observable<{}>;
  112763. /**
  112764. * 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)
  112765. */
  112766. scalePivot: Nullable<Vector3>;
  112767. /**
  112768. * Mesh used as a pivot to rotate the attached mesh
  112769. */
  112770. private _anchorMesh;
  112771. private _existingMeshScale;
  112772. private _dragMesh;
  112773. private pointerDragBehavior;
  112774. private coloredMaterial;
  112775. private hoverColoredMaterial;
  112776. /**
  112777. * Sets the color of the bounding box gizmo
  112778. * @param color the color to set
  112779. */
  112780. setColor(color: Color3): void;
  112781. /**
  112782. * Creates an BoundingBoxGizmo
  112783. * @param gizmoLayer The utility layer the gizmo will be added to
  112784. * @param color The color of the gizmo
  112785. */
  112786. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112787. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112788. private _selectNode;
  112789. /**
  112790. * Updates the bounding box information for the Gizmo
  112791. */
  112792. updateBoundingBox(): void;
  112793. private _updateRotationSpheres;
  112794. private _updateScaleBoxes;
  112795. /**
  112796. * Enables rotation on the specified axis and disables rotation on the others
  112797. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112798. */
  112799. setEnabledRotationAxis(axis: string): void;
  112800. /**
  112801. * Enables/disables scaling
  112802. * @param enable if scaling should be enabled
  112803. */
  112804. setEnabledScaling(enable: boolean): void;
  112805. private _updateDummy;
  112806. /**
  112807. * Enables a pointer drag behavior on the bounding box of the gizmo
  112808. */
  112809. enableDragBehavior(): void;
  112810. /**
  112811. * Disposes of the gizmo
  112812. */
  112813. dispose(): void;
  112814. /**
  112815. * 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)
  112816. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112817. * @returns the bounding box mesh with the passed in mesh as a child
  112818. */
  112819. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112820. /**
  112821. * CustomMeshes are not supported by this gizmo
  112822. * @param mesh The mesh to replace the default mesh of the gizmo
  112823. */
  112824. setCustomMesh(mesh: Mesh): void;
  112825. }
  112826. }
  112827. declare module BABYLON {
  112828. /**
  112829. * Single plane rotation gizmo
  112830. */
  112831. export class PlaneRotationGizmo extends Gizmo {
  112832. /**
  112833. * Drag behavior responsible for the gizmos dragging interactions
  112834. */
  112835. dragBehavior: PointerDragBehavior;
  112836. private _pointerObserver;
  112837. /**
  112838. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112839. */
  112840. snapDistance: number;
  112841. /**
  112842. * Event that fires each time the gizmo snaps to a new location.
  112843. * * snapDistance is the the change in distance
  112844. */
  112845. onSnapObservable: Observable<{
  112846. snapDistance: number;
  112847. }>;
  112848. private _isEnabled;
  112849. private _parent;
  112850. /**
  112851. * Creates a PlaneRotationGizmo
  112852. * @param gizmoLayer The utility layer the gizmo will be added to
  112853. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112854. * @param color The color of the gizmo
  112855. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112856. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112857. */
  112858. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112859. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112860. /**
  112861. * If the gizmo is enabled
  112862. */
  112863. isEnabled: boolean;
  112864. /**
  112865. * Disposes of the gizmo
  112866. */
  112867. dispose(): void;
  112868. }
  112869. }
  112870. declare module BABYLON {
  112871. /**
  112872. * Gizmo that enables rotating a mesh along 3 axis
  112873. */
  112874. export class RotationGizmo extends Gizmo {
  112875. /**
  112876. * Internal gizmo used for interactions on the x axis
  112877. */
  112878. xGizmo: PlaneRotationGizmo;
  112879. /**
  112880. * Internal gizmo used for interactions on the y axis
  112881. */
  112882. yGizmo: PlaneRotationGizmo;
  112883. /**
  112884. * Internal gizmo used for interactions on the z axis
  112885. */
  112886. zGizmo: PlaneRotationGizmo;
  112887. /** Fires an event when any of it's sub gizmos are dragged */
  112888. onDragStartObservable: Observable<unknown>;
  112889. /** Fires an event when any of it's sub gizmos are released from dragging */
  112890. onDragEndObservable: Observable<unknown>;
  112891. private _meshAttached;
  112892. attachedMesh: Nullable<AbstractMesh>;
  112893. /**
  112894. * Creates a RotationGizmo
  112895. * @param gizmoLayer The utility layer the gizmo will be added to
  112896. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112897. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112898. */
  112899. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112900. updateGizmoRotationToMatchAttachedMesh: boolean;
  112901. /**
  112902. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112903. */
  112904. snapDistance: number;
  112905. /**
  112906. * Ratio for the scale of the gizmo (Default: 1)
  112907. */
  112908. scaleRatio: number;
  112909. /**
  112910. * Disposes of the gizmo
  112911. */
  112912. dispose(): void;
  112913. /**
  112914. * CustomMeshes are not supported by this gizmo
  112915. * @param mesh The mesh to replace the default mesh of the gizmo
  112916. */
  112917. setCustomMesh(mesh: Mesh): void;
  112918. }
  112919. }
  112920. declare module BABYLON {
  112921. /**
  112922. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112923. */
  112924. export class GizmoManager implements IDisposable {
  112925. private scene;
  112926. /**
  112927. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112928. */
  112929. gizmos: {
  112930. positionGizmo: Nullable<PositionGizmo>;
  112931. rotationGizmo: Nullable<RotationGizmo>;
  112932. scaleGizmo: Nullable<ScaleGizmo>;
  112933. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112934. };
  112935. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112936. clearGizmoOnEmptyPointerEvent: boolean;
  112937. /** Fires an event when the manager is attached to a mesh */
  112938. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112939. private _gizmosEnabled;
  112940. private _pointerObserver;
  112941. private _attachedMesh;
  112942. private _boundingBoxColor;
  112943. private _defaultUtilityLayer;
  112944. private _defaultKeepDepthUtilityLayer;
  112945. /**
  112946. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112947. */
  112948. boundingBoxDragBehavior: SixDofDragBehavior;
  112949. /**
  112950. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112951. */
  112952. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112953. /**
  112954. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112955. */
  112956. usePointerToAttachGizmos: boolean;
  112957. /**
  112958. * Utility layer that the bounding box gizmo belongs to
  112959. */
  112960. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112961. /**
  112962. * Utility layer that all gizmos besides bounding box belong to
  112963. */
  112964. readonly utilityLayer: UtilityLayerRenderer;
  112965. /**
  112966. * Instatiates a gizmo manager
  112967. * @param scene the scene to overlay the gizmos on top of
  112968. */
  112969. constructor(scene: Scene);
  112970. /**
  112971. * Attaches a set of gizmos to the specified mesh
  112972. * @param mesh The mesh the gizmo's should be attached to
  112973. */
  112974. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112975. /**
  112976. * If the position gizmo is enabled
  112977. */
  112978. positionGizmoEnabled: boolean;
  112979. /**
  112980. * If the rotation gizmo is enabled
  112981. */
  112982. rotationGizmoEnabled: boolean;
  112983. /**
  112984. * If the scale gizmo is enabled
  112985. */
  112986. scaleGizmoEnabled: boolean;
  112987. /**
  112988. * If the boundingBox gizmo is enabled
  112989. */
  112990. boundingBoxGizmoEnabled: boolean;
  112991. /**
  112992. * Disposes of the gizmo manager
  112993. */
  112994. dispose(): void;
  112995. }
  112996. }
  112997. declare module BABYLON {
  112998. /**
  112999. * A directional light is defined by a direction (what a surprise!).
  113000. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113001. * 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.
  113002. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113003. */
  113004. export class DirectionalLight extends ShadowLight {
  113005. private _shadowFrustumSize;
  113006. /**
  113007. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113008. */
  113009. /**
  113010. * Specifies a fix frustum size for the shadow generation.
  113011. */
  113012. shadowFrustumSize: number;
  113013. private _shadowOrthoScale;
  113014. /**
  113015. * Gets the shadow projection scale against the optimal computed one.
  113016. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113017. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113018. */
  113019. /**
  113020. * Sets the shadow projection scale against the optimal computed one.
  113021. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113022. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113023. */
  113024. shadowOrthoScale: number;
  113025. /**
  113026. * Automatically compute the projection matrix to best fit (including all the casters)
  113027. * on each frame.
  113028. */
  113029. autoUpdateExtends: boolean;
  113030. private _orthoLeft;
  113031. private _orthoRight;
  113032. private _orthoTop;
  113033. private _orthoBottom;
  113034. /**
  113035. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113036. * The directional light is emitted from everywhere in the given direction.
  113037. * It can cast shadows.
  113038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113039. * @param name The friendly name of the light
  113040. * @param direction The direction of the light
  113041. * @param scene The scene the light belongs to
  113042. */
  113043. constructor(name: string, direction: Vector3, scene: Scene);
  113044. /**
  113045. * Returns the string "DirectionalLight".
  113046. * @return The class name
  113047. */
  113048. getClassName(): string;
  113049. /**
  113050. * Returns the integer 1.
  113051. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113052. */
  113053. getTypeID(): number;
  113054. /**
  113055. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113056. * Returns the DirectionalLight Shadow projection matrix.
  113057. */
  113058. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113059. /**
  113060. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113061. * Returns the DirectionalLight Shadow projection matrix.
  113062. */
  113063. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113064. /**
  113065. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113066. * Returns the DirectionalLight Shadow projection matrix.
  113067. */
  113068. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113069. protected _buildUniformLayout(): void;
  113070. /**
  113071. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113072. * @param effect The effect to update
  113073. * @param lightIndex The index of the light in the effect to update
  113074. * @returns The directional light
  113075. */
  113076. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113077. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113078. /**
  113079. * Gets the minZ used for shadow according to both the scene and the light.
  113080. *
  113081. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113082. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113083. * @param activeCamera The camera we are returning the min for
  113084. * @returns the depth min z
  113085. */
  113086. getDepthMinZ(activeCamera: Camera): number;
  113087. /**
  113088. * Gets the maxZ used for shadow according to both the scene and the light.
  113089. *
  113090. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113091. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113092. * @param activeCamera The camera we are returning the max for
  113093. * @returns the depth max z
  113094. */
  113095. getDepthMaxZ(activeCamera: Camera): number;
  113096. /**
  113097. * Prepares the list of defines specific to the light type.
  113098. * @param defines the list of defines
  113099. * @param lightIndex defines the index of the light for the effect
  113100. */
  113101. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113102. }
  113103. }
  113104. declare module BABYLON {
  113105. /**
  113106. * Class containing static functions to help procedurally build meshes
  113107. */
  113108. export class HemisphereBuilder {
  113109. /**
  113110. * Creates a hemisphere mesh
  113111. * @param name defines the name of the mesh
  113112. * @param options defines the options used to create the mesh
  113113. * @param scene defines the hosting scene
  113114. * @returns the hemisphere mesh
  113115. */
  113116. static CreateHemisphere(name: string, options: {
  113117. segments?: number;
  113118. diameter?: number;
  113119. sideOrientation?: number;
  113120. }, scene: any): Mesh;
  113121. }
  113122. }
  113123. declare module BABYLON {
  113124. /**
  113125. * A spot light is defined by a position, a direction, an angle, and an exponent.
  113126. * These values define a cone of light starting from the position, emitting toward the direction.
  113127. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  113128. * and the exponent defines the speed of the decay of the light with distance (reach).
  113129. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113130. */
  113131. export class SpotLight extends ShadowLight {
  113132. private _angle;
  113133. private _innerAngle;
  113134. private _cosHalfAngle;
  113135. private _lightAngleScale;
  113136. private _lightAngleOffset;
  113137. /**
  113138. * Gets the cone angle of the spot light in Radians.
  113139. */
  113140. /**
  113141. * Sets the cone angle of the spot light in Radians.
  113142. */
  113143. angle: number;
  113144. /**
  113145. * Only used in gltf falloff mode, this defines the angle where
  113146. * the directional falloff will start before cutting at angle which could be seen
  113147. * as outer angle.
  113148. */
  113149. /**
  113150. * Only used in gltf falloff mode, this defines the angle where
  113151. * the directional falloff will start before cutting at angle which could be seen
  113152. * as outer angle.
  113153. */
  113154. innerAngle: number;
  113155. private _shadowAngleScale;
  113156. /**
  113157. * Allows scaling the angle of the light for shadow generation only.
  113158. */
  113159. /**
  113160. * Allows scaling the angle of the light for shadow generation only.
  113161. */
  113162. shadowAngleScale: number;
  113163. /**
  113164. * The light decay speed with the distance from the emission spot.
  113165. */
  113166. exponent: number;
  113167. private _projectionTextureMatrix;
  113168. /**
  113169. * Allows reading the projecton texture
  113170. */
  113171. readonly projectionTextureMatrix: Matrix;
  113172. protected _projectionTextureLightNear: number;
  113173. /**
  113174. * Gets the near clip of the Spotlight for texture projection.
  113175. */
  113176. /**
  113177. * Sets the near clip of the Spotlight for texture projection.
  113178. */
  113179. projectionTextureLightNear: number;
  113180. protected _projectionTextureLightFar: number;
  113181. /**
  113182. * Gets the far clip of the Spotlight for texture projection.
  113183. */
  113184. /**
  113185. * Sets the far clip of the Spotlight for texture projection.
  113186. */
  113187. projectionTextureLightFar: number;
  113188. protected _projectionTextureUpDirection: Vector3;
  113189. /**
  113190. * Gets the Up vector of the Spotlight for texture projection.
  113191. */
  113192. /**
  113193. * Sets the Up vector of the Spotlight for texture projection.
  113194. */
  113195. projectionTextureUpDirection: Vector3;
  113196. private _projectionTexture;
  113197. /**
  113198. * Gets the projection texture of the light.
  113199. */
  113200. /**
  113201. * Sets the projection texture of the light.
  113202. */
  113203. projectionTexture: Nullable<BaseTexture>;
  113204. private _projectionTextureViewLightDirty;
  113205. private _projectionTextureProjectionLightDirty;
  113206. private _projectionTextureDirty;
  113207. private _projectionTextureViewTargetVector;
  113208. private _projectionTextureViewLightMatrix;
  113209. private _projectionTextureProjectionLightMatrix;
  113210. private _projectionTextureScalingMatrix;
  113211. /**
  113212. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113213. * It can cast shadows.
  113214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113215. * @param name The light friendly name
  113216. * @param position The position of the spot light in the scene
  113217. * @param direction The direction of the light in the scene
  113218. * @param angle The cone angle of the light in Radians
  113219. * @param exponent The light decay speed with the distance from the emission spot
  113220. * @param scene The scene the lights belongs to
  113221. */
  113222. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113223. /**
  113224. * Returns the string "SpotLight".
  113225. * @returns the class name
  113226. */
  113227. getClassName(): string;
  113228. /**
  113229. * Returns the integer 2.
  113230. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113231. */
  113232. getTypeID(): number;
  113233. /**
  113234. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113235. */
  113236. protected _setDirection(value: Vector3): void;
  113237. /**
  113238. * Overrides the position setter to recompute the projection texture view light Matrix.
  113239. */
  113240. protected _setPosition(value: Vector3): void;
  113241. /**
  113242. * 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.
  113243. * Returns the SpotLight.
  113244. */
  113245. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113246. protected _computeProjectionTextureViewLightMatrix(): void;
  113247. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113248. /**
  113249. * Main function for light texture projection matrix computing.
  113250. */
  113251. protected _computeProjectionTextureMatrix(): void;
  113252. protected _buildUniformLayout(): void;
  113253. private _computeAngleValues;
  113254. /**
  113255. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113256. * @param effect The effect to update
  113257. * @param lightIndex The index of the light in the effect to update
  113258. * @returns The spot light
  113259. */
  113260. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113261. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113262. /**
  113263. * Disposes the light and the associated resources.
  113264. */
  113265. dispose(): void;
  113266. /**
  113267. * Prepares the list of defines specific to the light type.
  113268. * @param defines the list of defines
  113269. * @param lightIndex defines the index of the light for the effect
  113270. */
  113271. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113272. }
  113273. }
  113274. declare module BABYLON {
  113275. /**
  113276. * Gizmo that enables viewing a light
  113277. */
  113278. export class LightGizmo extends Gizmo {
  113279. private _lightMesh;
  113280. private _material;
  113281. private cachedPosition;
  113282. private cachedForward;
  113283. /**
  113284. * Creates a LightGizmo
  113285. * @param gizmoLayer The utility layer the gizmo will be added to
  113286. */
  113287. constructor(gizmoLayer?: UtilityLayerRenderer);
  113288. private _light;
  113289. /**
  113290. * The light that the gizmo is attached to
  113291. */
  113292. light: Nullable<Light>;
  113293. /**
  113294. * Gets the material used to render the light gizmo
  113295. */
  113296. readonly material: StandardMaterial;
  113297. /**
  113298. * @hidden
  113299. * Updates the gizmo to match the attached mesh's position/rotation
  113300. */
  113301. protected _update(): void;
  113302. private static _Scale;
  113303. /**
  113304. * Creates the lines for a light mesh
  113305. */
  113306. private static _createLightLines;
  113307. /**
  113308. * Disposes of the light gizmo
  113309. */
  113310. dispose(): void;
  113311. private static _CreateHemisphericLightMesh;
  113312. private static _CreatePointLightMesh;
  113313. private static _CreateSpotLightMesh;
  113314. private static _CreateDirectionalLightMesh;
  113315. }
  113316. }
  113317. declare module BABYLON {
  113318. /** @hidden */
  113319. export var backgroundFragmentDeclaration: {
  113320. name: string;
  113321. shader: string;
  113322. };
  113323. }
  113324. declare module BABYLON {
  113325. /** @hidden */
  113326. export var backgroundUboDeclaration: {
  113327. name: string;
  113328. shader: string;
  113329. };
  113330. }
  113331. declare module BABYLON {
  113332. /** @hidden */
  113333. export var backgroundPixelShader: {
  113334. name: string;
  113335. shader: string;
  113336. };
  113337. }
  113338. declare module BABYLON {
  113339. /** @hidden */
  113340. export var backgroundVertexDeclaration: {
  113341. name: string;
  113342. shader: string;
  113343. };
  113344. }
  113345. declare module BABYLON {
  113346. /** @hidden */
  113347. export var backgroundVertexShader: {
  113348. name: string;
  113349. shader: string;
  113350. };
  113351. }
  113352. declare module BABYLON {
  113353. /**
  113354. * Background material used to create an efficient environement around your scene.
  113355. */
  113356. export class BackgroundMaterial extends PushMaterial {
  113357. /**
  113358. * Standard reflectance value at parallel view angle.
  113359. */
  113360. static StandardReflectance0: number;
  113361. /**
  113362. * Standard reflectance value at grazing angle.
  113363. */
  113364. static StandardReflectance90: number;
  113365. protected _primaryColor: Color3;
  113366. /**
  113367. * Key light Color (multiply against the environement texture)
  113368. */
  113369. primaryColor: Color3;
  113370. protected __perceptualColor: Nullable<Color3>;
  113371. /**
  113372. * Experimental Internal Use Only.
  113373. *
  113374. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113375. * This acts as a helper to set the primary color to a more "human friendly" value.
  113376. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113377. * output color as close as possible from the chosen value.
  113378. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113379. * part of lighting setup.)
  113380. */
  113381. _perceptualColor: Nullable<Color3>;
  113382. protected _primaryColorShadowLevel: float;
  113383. /**
  113384. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113385. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113386. */
  113387. primaryColorShadowLevel: float;
  113388. protected _primaryColorHighlightLevel: float;
  113389. /**
  113390. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113391. * The primary color is used at the level chosen to define what the white area would look.
  113392. */
  113393. primaryColorHighlightLevel: float;
  113394. protected _reflectionTexture: Nullable<BaseTexture>;
  113395. /**
  113396. * Reflection Texture used in the material.
  113397. * Should be author in a specific way for the best result (refer to the documentation).
  113398. */
  113399. reflectionTexture: Nullable<BaseTexture>;
  113400. protected _reflectionBlur: float;
  113401. /**
  113402. * Reflection Texture level of blur.
  113403. *
  113404. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113405. * texture twice.
  113406. */
  113407. reflectionBlur: float;
  113408. protected _diffuseTexture: Nullable<BaseTexture>;
  113409. /**
  113410. * Diffuse Texture used in the material.
  113411. * Should be author in a specific way for the best result (refer to the documentation).
  113412. */
  113413. diffuseTexture: Nullable<BaseTexture>;
  113414. protected _shadowLights: Nullable<IShadowLight[]>;
  113415. /**
  113416. * Specify the list of lights casting shadow on the material.
  113417. * All scene shadow lights will be included if null.
  113418. */
  113419. shadowLights: Nullable<IShadowLight[]>;
  113420. protected _shadowLevel: float;
  113421. /**
  113422. * Helps adjusting the shadow to a softer level if required.
  113423. * 0 means black shadows and 1 means no shadows.
  113424. */
  113425. shadowLevel: float;
  113426. protected _sceneCenter: Vector3;
  113427. /**
  113428. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113429. * It is usually zero but might be interesting to modify according to your setup.
  113430. */
  113431. sceneCenter: Vector3;
  113432. protected _opacityFresnel: boolean;
  113433. /**
  113434. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113435. * This helps ensuring a nice transition when the camera goes under the ground.
  113436. */
  113437. opacityFresnel: boolean;
  113438. protected _reflectionFresnel: boolean;
  113439. /**
  113440. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113441. * This helps adding a mirror texture on the ground.
  113442. */
  113443. reflectionFresnel: boolean;
  113444. protected _reflectionFalloffDistance: number;
  113445. /**
  113446. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113447. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113448. */
  113449. reflectionFalloffDistance: number;
  113450. protected _reflectionAmount: number;
  113451. /**
  113452. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113453. */
  113454. reflectionAmount: number;
  113455. protected _reflectionReflectance0: number;
  113456. /**
  113457. * This specifies the weight of the reflection at grazing angle.
  113458. */
  113459. reflectionReflectance0: number;
  113460. protected _reflectionReflectance90: number;
  113461. /**
  113462. * This specifies the weight of the reflection at a perpendicular point of view.
  113463. */
  113464. reflectionReflectance90: number;
  113465. /**
  113466. * Sets the reflection reflectance fresnel values according to the default standard
  113467. * empirically know to work well :-)
  113468. */
  113469. reflectionStandardFresnelWeight: number;
  113470. protected _useRGBColor: boolean;
  113471. /**
  113472. * Helps to directly use the maps channels instead of their level.
  113473. */
  113474. useRGBColor: boolean;
  113475. protected _enableNoise: boolean;
  113476. /**
  113477. * This helps reducing the banding effect that could occur on the background.
  113478. */
  113479. enableNoise: boolean;
  113480. /**
  113481. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113482. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113483. * Recommended to be keep at 1.0 except for special cases.
  113484. */
  113485. fovMultiplier: number;
  113486. private _fovMultiplier;
  113487. /**
  113488. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113489. */
  113490. useEquirectangularFOV: boolean;
  113491. private _maxSimultaneousLights;
  113492. /**
  113493. * Number of Simultaneous lights allowed on the material.
  113494. */
  113495. maxSimultaneousLights: int;
  113496. /**
  113497. * Default configuration related to image processing available in the Background Material.
  113498. */
  113499. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113500. /**
  113501. * Keep track of the image processing observer to allow dispose and replace.
  113502. */
  113503. private _imageProcessingObserver;
  113504. /**
  113505. * Attaches a new image processing configuration to the PBR Material.
  113506. * @param configuration (if null the scene configuration will be use)
  113507. */
  113508. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113509. /**
  113510. * Gets the image processing configuration used either in this material.
  113511. */
  113512. /**
  113513. * Sets the Default image processing configuration used either in the this material.
  113514. *
  113515. * If sets to null, the scene one is in use.
  113516. */
  113517. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113518. /**
  113519. * Gets wether the color curves effect is enabled.
  113520. */
  113521. /**
  113522. * Sets wether the color curves effect is enabled.
  113523. */
  113524. cameraColorCurvesEnabled: boolean;
  113525. /**
  113526. * Gets wether the color grading effect is enabled.
  113527. */
  113528. /**
  113529. * Gets wether the color grading effect is enabled.
  113530. */
  113531. cameraColorGradingEnabled: boolean;
  113532. /**
  113533. * Gets wether tonemapping is enabled or not.
  113534. */
  113535. /**
  113536. * Sets wether tonemapping is enabled or not
  113537. */
  113538. cameraToneMappingEnabled: boolean;
  113539. /**
  113540. * The camera exposure used on this material.
  113541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113542. * This corresponds to a photographic exposure.
  113543. */
  113544. /**
  113545. * The camera exposure used on this material.
  113546. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113547. * This corresponds to a photographic exposure.
  113548. */
  113549. cameraExposure: float;
  113550. /**
  113551. * Gets The camera contrast used on this material.
  113552. */
  113553. /**
  113554. * Sets The camera contrast used on this material.
  113555. */
  113556. cameraContrast: float;
  113557. /**
  113558. * Gets the Color Grading 2D Lookup Texture.
  113559. */
  113560. /**
  113561. * Sets the Color Grading 2D Lookup Texture.
  113562. */
  113563. cameraColorGradingTexture: Nullable<BaseTexture>;
  113564. /**
  113565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113567. * 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;
  113568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113569. */
  113570. /**
  113571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113573. * 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;
  113574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113575. */
  113576. cameraColorCurves: Nullable<ColorCurves>;
  113577. /**
  113578. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113579. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113580. */
  113581. switchToBGR: boolean;
  113582. private _renderTargets;
  113583. private _reflectionControls;
  113584. private _white;
  113585. private _primaryShadowColor;
  113586. private _primaryHighlightColor;
  113587. /**
  113588. * Instantiates a Background Material in the given scene
  113589. * @param name The friendly name of the material
  113590. * @param scene The scene to add the material to
  113591. */
  113592. constructor(name: string, scene: Scene);
  113593. /**
  113594. * Gets a boolean indicating that current material needs to register RTT
  113595. */
  113596. readonly hasRenderTargetTextures: boolean;
  113597. /**
  113598. * The entire material has been created in order to prevent overdraw.
  113599. * @returns false
  113600. */
  113601. needAlphaTesting(): boolean;
  113602. /**
  113603. * The entire material has been created in order to prevent overdraw.
  113604. * @returns true if blending is enable
  113605. */
  113606. needAlphaBlending(): boolean;
  113607. /**
  113608. * Checks wether the material is ready to be rendered for a given mesh.
  113609. * @param mesh The mesh to render
  113610. * @param subMesh The submesh to check against
  113611. * @param useInstances Specify wether or not the material is used with instances
  113612. * @returns true if all the dependencies are ready (Textures, Effects...)
  113613. */
  113614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113615. /**
  113616. * Compute the primary color according to the chosen perceptual color.
  113617. */
  113618. private _computePrimaryColorFromPerceptualColor;
  113619. /**
  113620. * Compute the highlights and shadow colors according to their chosen levels.
  113621. */
  113622. private _computePrimaryColors;
  113623. /**
  113624. * Build the uniform buffer used in the material.
  113625. */
  113626. buildUniformLayout(): void;
  113627. /**
  113628. * Unbind the material.
  113629. */
  113630. unbind(): void;
  113631. /**
  113632. * Bind only the world matrix to the material.
  113633. * @param world The world matrix to bind.
  113634. */
  113635. bindOnlyWorldMatrix(world: Matrix): void;
  113636. /**
  113637. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113638. * @param world The world matrix to bind.
  113639. * @param subMesh The submesh to bind for.
  113640. */
  113641. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113642. /**
  113643. * Checks to see if a texture is used in the material.
  113644. * @param texture - Base texture to use.
  113645. * @returns - Boolean specifying if a texture is used in the material.
  113646. */
  113647. hasTexture(texture: BaseTexture): boolean;
  113648. /**
  113649. * Dispose the material.
  113650. * @param forceDisposeEffect Force disposal of the associated effect.
  113651. * @param forceDisposeTextures Force disposal of the associated textures.
  113652. */
  113653. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113654. /**
  113655. * Clones the material.
  113656. * @param name The cloned name.
  113657. * @returns The cloned material.
  113658. */
  113659. clone(name: string): BackgroundMaterial;
  113660. /**
  113661. * Serializes the current material to its JSON representation.
  113662. * @returns The JSON representation.
  113663. */
  113664. serialize(): any;
  113665. /**
  113666. * Gets the class name of the material
  113667. * @returns "BackgroundMaterial"
  113668. */
  113669. getClassName(): string;
  113670. /**
  113671. * Parse a JSON input to create back a background material.
  113672. * @param source The JSON data to parse
  113673. * @param scene The scene to create the parsed material in
  113674. * @param rootUrl The root url of the assets the material depends upon
  113675. * @returns the instantiated BackgroundMaterial.
  113676. */
  113677. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113678. }
  113679. }
  113680. declare module BABYLON {
  113681. /**
  113682. * Represents the different options available during the creation of
  113683. * a Environment helper.
  113684. *
  113685. * This can control the default ground, skybox and image processing setup of your scene.
  113686. */
  113687. export interface IEnvironmentHelperOptions {
  113688. /**
  113689. * Specifies wether or not to create a ground.
  113690. * True by default.
  113691. */
  113692. createGround: boolean;
  113693. /**
  113694. * Specifies the ground size.
  113695. * 15 by default.
  113696. */
  113697. groundSize: number;
  113698. /**
  113699. * The texture used on the ground for the main color.
  113700. * Comes from the BabylonJS CDN by default.
  113701. *
  113702. * Remarks: Can be either a texture or a url.
  113703. */
  113704. groundTexture: string | BaseTexture;
  113705. /**
  113706. * The color mixed in the ground texture by default.
  113707. * BabylonJS clearColor by default.
  113708. */
  113709. groundColor: Color3;
  113710. /**
  113711. * Specifies the ground opacity.
  113712. * 1 by default.
  113713. */
  113714. groundOpacity: number;
  113715. /**
  113716. * Enables the ground to receive shadows.
  113717. * True by default.
  113718. */
  113719. enableGroundShadow: boolean;
  113720. /**
  113721. * Helps preventing the shadow to be fully black on the ground.
  113722. * 0.5 by default.
  113723. */
  113724. groundShadowLevel: number;
  113725. /**
  113726. * Creates a mirror texture attach to the ground.
  113727. * false by default.
  113728. */
  113729. enableGroundMirror: boolean;
  113730. /**
  113731. * Specifies the ground mirror size ratio.
  113732. * 0.3 by default as the default kernel is 64.
  113733. */
  113734. groundMirrorSizeRatio: number;
  113735. /**
  113736. * Specifies the ground mirror blur kernel size.
  113737. * 64 by default.
  113738. */
  113739. groundMirrorBlurKernel: number;
  113740. /**
  113741. * Specifies the ground mirror visibility amount.
  113742. * 1 by default
  113743. */
  113744. groundMirrorAmount: number;
  113745. /**
  113746. * Specifies the ground mirror reflectance weight.
  113747. * This uses the standard weight of the background material to setup the fresnel effect
  113748. * of the mirror.
  113749. * 1 by default.
  113750. */
  113751. groundMirrorFresnelWeight: number;
  113752. /**
  113753. * Specifies the ground mirror Falloff distance.
  113754. * This can helps reducing the size of the reflection.
  113755. * 0 by Default.
  113756. */
  113757. groundMirrorFallOffDistance: number;
  113758. /**
  113759. * Specifies the ground mirror texture type.
  113760. * Unsigned Int by Default.
  113761. */
  113762. groundMirrorTextureType: number;
  113763. /**
  113764. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  113765. * the shown objects.
  113766. */
  113767. groundYBias: number;
  113768. /**
  113769. * Specifies wether or not to create a skybox.
  113770. * True by default.
  113771. */
  113772. createSkybox: boolean;
  113773. /**
  113774. * Specifies the skybox size.
  113775. * 20 by default.
  113776. */
  113777. skyboxSize: number;
  113778. /**
  113779. * The texture used on the skybox for the main color.
  113780. * Comes from the BabylonJS CDN by default.
  113781. *
  113782. * Remarks: Can be either a texture or a url.
  113783. */
  113784. skyboxTexture: string | BaseTexture;
  113785. /**
  113786. * The color mixed in the skybox texture by default.
  113787. * BabylonJS clearColor by default.
  113788. */
  113789. skyboxColor: Color3;
  113790. /**
  113791. * The background rotation around the Y axis of the scene.
  113792. * This helps aligning the key lights of your scene with the background.
  113793. * 0 by default.
  113794. */
  113795. backgroundYRotation: number;
  113796. /**
  113797. * Compute automatically the size of the elements to best fit with the scene.
  113798. */
  113799. sizeAuto: boolean;
  113800. /**
  113801. * Default position of the rootMesh if autoSize is not true.
  113802. */
  113803. rootPosition: Vector3;
  113804. /**
  113805. * Sets up the image processing in the scene.
  113806. * true by default.
  113807. */
  113808. setupImageProcessing: boolean;
  113809. /**
  113810. * The texture used as your environment texture in the scene.
  113811. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113812. *
  113813. * Remarks: Can be either a texture or a url.
  113814. */
  113815. environmentTexture: string | BaseTexture;
  113816. /**
  113817. * The value of the exposure to apply to the scene.
  113818. * 0.6 by default if setupImageProcessing is true.
  113819. */
  113820. cameraExposure: number;
  113821. /**
  113822. * The value of the contrast to apply to the scene.
  113823. * 1.6 by default if setupImageProcessing is true.
  113824. */
  113825. cameraContrast: number;
  113826. /**
  113827. * Specifies wether or not tonemapping should be enabled in the scene.
  113828. * true by default if setupImageProcessing is true.
  113829. */
  113830. toneMappingEnabled: boolean;
  113831. }
  113832. /**
  113833. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113834. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113835. * It also helps with the default setup of your imageProcessing configuration.
  113836. */
  113837. export class EnvironmentHelper {
  113838. /**
  113839. * Default ground texture URL.
  113840. */
  113841. private static _groundTextureCDNUrl;
  113842. /**
  113843. * Default skybox texture URL.
  113844. */
  113845. private static _skyboxTextureCDNUrl;
  113846. /**
  113847. * Default environment texture URL.
  113848. */
  113849. private static _environmentTextureCDNUrl;
  113850. /**
  113851. * Creates the default options for the helper.
  113852. */
  113853. private static _getDefaultOptions;
  113854. private _rootMesh;
  113855. /**
  113856. * Gets the root mesh created by the helper.
  113857. */
  113858. readonly rootMesh: Mesh;
  113859. private _skybox;
  113860. /**
  113861. * Gets the skybox created by the helper.
  113862. */
  113863. readonly skybox: Nullable<Mesh>;
  113864. private _skyboxTexture;
  113865. /**
  113866. * Gets the skybox texture created by the helper.
  113867. */
  113868. readonly skyboxTexture: Nullable<BaseTexture>;
  113869. private _skyboxMaterial;
  113870. /**
  113871. * Gets the skybox material created by the helper.
  113872. */
  113873. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113874. private _ground;
  113875. /**
  113876. * Gets the ground mesh created by the helper.
  113877. */
  113878. readonly ground: Nullable<Mesh>;
  113879. private _groundTexture;
  113880. /**
  113881. * Gets the ground texture created by the helper.
  113882. */
  113883. readonly groundTexture: Nullable<BaseTexture>;
  113884. private _groundMirror;
  113885. /**
  113886. * Gets the ground mirror created by the helper.
  113887. */
  113888. readonly groundMirror: Nullable<MirrorTexture>;
  113889. /**
  113890. * Gets the ground mirror render list to helps pushing the meshes
  113891. * you wish in the ground reflection.
  113892. */
  113893. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113894. private _groundMaterial;
  113895. /**
  113896. * Gets the ground material created by the helper.
  113897. */
  113898. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113899. /**
  113900. * Stores the creation options.
  113901. */
  113902. private readonly _scene;
  113903. private _options;
  113904. /**
  113905. * This observable will be notified with any error during the creation of the environment,
  113906. * mainly texture creation errors.
  113907. */
  113908. onErrorObservable: Observable<{
  113909. message?: string;
  113910. exception?: any;
  113911. }>;
  113912. /**
  113913. * constructor
  113914. * @param options Defines the options we want to customize the helper
  113915. * @param scene The scene to add the material to
  113916. */
  113917. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113918. /**
  113919. * Updates the background according to the new options
  113920. * @param options
  113921. */
  113922. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113923. /**
  113924. * Sets the primary color of all the available elements.
  113925. * @param color the main color to affect to the ground and the background
  113926. */
  113927. setMainColor(color: Color3): void;
  113928. /**
  113929. * Setup the image processing according to the specified options.
  113930. */
  113931. private _setupImageProcessing;
  113932. /**
  113933. * Setup the environment texture according to the specified options.
  113934. */
  113935. private _setupEnvironmentTexture;
  113936. /**
  113937. * Setup the background according to the specified options.
  113938. */
  113939. private _setupBackground;
  113940. /**
  113941. * Get the scene sizes according to the setup.
  113942. */
  113943. private _getSceneSize;
  113944. /**
  113945. * Setup the ground according to the specified options.
  113946. */
  113947. private _setupGround;
  113948. /**
  113949. * Setup the ground material according to the specified options.
  113950. */
  113951. private _setupGroundMaterial;
  113952. /**
  113953. * Setup the ground diffuse texture according to the specified options.
  113954. */
  113955. private _setupGroundDiffuseTexture;
  113956. /**
  113957. * Setup the ground mirror texture according to the specified options.
  113958. */
  113959. private _setupGroundMirrorTexture;
  113960. /**
  113961. * Setup the ground to receive the mirror texture.
  113962. */
  113963. private _setupMirrorInGroundMaterial;
  113964. /**
  113965. * Setup the skybox according to the specified options.
  113966. */
  113967. private _setupSkybox;
  113968. /**
  113969. * Setup the skybox material according to the specified options.
  113970. */
  113971. private _setupSkyboxMaterial;
  113972. /**
  113973. * Setup the skybox reflection texture according to the specified options.
  113974. */
  113975. private _setupSkyboxReflectionTexture;
  113976. private _errorHandler;
  113977. /**
  113978. * Dispose all the elements created by the Helper.
  113979. */
  113980. dispose(): void;
  113981. }
  113982. }
  113983. declare module BABYLON {
  113984. /**
  113985. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113986. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113987. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113988. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113989. */
  113990. export class PhotoDome extends TransformNode {
  113991. /**
  113992. * Define the image as a Monoscopic panoramic 360 image.
  113993. */
  113994. static readonly MODE_MONOSCOPIC: number;
  113995. /**
  113996. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113997. */
  113998. static readonly MODE_TOPBOTTOM: number;
  113999. /**
  114000. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114001. */
  114002. static readonly MODE_SIDEBYSIDE: number;
  114003. private _useDirectMapping;
  114004. /**
  114005. * The texture being displayed on the sphere
  114006. */
  114007. protected _photoTexture: Texture;
  114008. /**
  114009. * Gets or sets the texture being displayed on the sphere
  114010. */
  114011. photoTexture: Texture;
  114012. /**
  114013. * Observable raised when an error occured while loading the 360 image
  114014. */
  114015. onLoadErrorObservable: Observable<string>;
  114016. /**
  114017. * The skybox material
  114018. */
  114019. protected _material: BackgroundMaterial;
  114020. /**
  114021. * The surface used for the skybox
  114022. */
  114023. protected _mesh: Mesh;
  114024. /**
  114025. * Gets the mesh used for the skybox.
  114026. */
  114027. readonly mesh: Mesh;
  114028. /**
  114029. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114030. * Also see the options.resolution property.
  114031. */
  114032. fovMultiplier: number;
  114033. private _imageMode;
  114034. /**
  114035. * Gets or set the current video mode for the video. It can be:
  114036. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114037. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114038. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114039. */
  114040. imageMode: number;
  114041. /**
  114042. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114043. * @param name Element's name, child elements will append suffixes for their own names.
  114044. * @param urlsOfPhoto defines the url of the photo to display
  114045. * @param options defines an object containing optional or exposed sub element properties
  114046. * @param onError defines a callback called when an error occured while loading the texture
  114047. */
  114048. constructor(name: string, urlOfPhoto: string, options: {
  114049. resolution?: number;
  114050. size?: number;
  114051. useDirectMapping?: boolean;
  114052. faceForward?: boolean;
  114053. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114054. private _onBeforeCameraRenderObserver;
  114055. private _changeImageMode;
  114056. /**
  114057. * Releases resources associated with this node.
  114058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114060. */
  114061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114062. }
  114063. }
  114064. declare module BABYLON {
  114065. /**
  114066. * Class used to host RGBD texture specific utilities
  114067. */
  114068. export class RGBDTextureTools {
  114069. /**
  114070. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114071. * @param texture the texture to expand.
  114072. */
  114073. static ExpandRGBDTexture(texture: Texture): void;
  114074. }
  114075. }
  114076. declare module BABYLON {
  114077. /**
  114078. * Class used to host texture specific utilities
  114079. */
  114080. export class BRDFTextureTools {
  114081. /**
  114082. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  114083. * @param scene defines the hosting scene
  114084. * @returns the environment BRDF texture
  114085. */
  114086. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  114087. private static _environmentBRDFBase64Texture;
  114088. }
  114089. }
  114090. declare module BABYLON {
  114091. /**
  114092. * @hidden
  114093. */
  114094. export interface IMaterialClearCoatDefines {
  114095. CLEARCOAT: boolean;
  114096. CLEARCOAT_DEFAULTIOR: boolean;
  114097. CLEARCOAT_TEXTURE: boolean;
  114098. CLEARCOAT_TEXTUREDIRECTUV: number;
  114099. CLEARCOAT_BUMP: boolean;
  114100. CLEARCOAT_BUMPDIRECTUV: number;
  114101. CLEARCOAT_TINT: boolean;
  114102. CLEARCOAT_TINT_TEXTURE: boolean;
  114103. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114104. /** @hidden */
  114105. _areTexturesDirty: boolean;
  114106. }
  114107. /**
  114108. * Define the code related to the clear coat parameters of the pbr material.
  114109. */
  114110. export class PBRClearCoatConfiguration {
  114111. /**
  114112. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114113. * The default fits with a polyurethane material.
  114114. */
  114115. private static readonly _DefaultIndexOfRefraction;
  114116. private _isEnabled;
  114117. /**
  114118. * Defines if the clear coat is enabled in the material.
  114119. */
  114120. isEnabled: boolean;
  114121. /**
  114122. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  114123. */
  114124. intensity: number;
  114125. /**
  114126. * Defines the clear coat layer roughness.
  114127. */
  114128. roughness: number;
  114129. private _indexOfRefraction;
  114130. /**
  114131. * Defines the index of refraction of the clear coat.
  114132. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114133. * The default fits with a polyurethane material.
  114134. * Changing the default value is more performance intensive.
  114135. */
  114136. indexOfRefraction: number;
  114137. private _texture;
  114138. /**
  114139. * Stores the clear coat values in a texture.
  114140. */
  114141. texture: Nullable<BaseTexture>;
  114142. private _bumpTexture;
  114143. /**
  114144. * Define the clear coat specific bump texture.
  114145. */
  114146. bumpTexture: Nullable<BaseTexture>;
  114147. private _isTintEnabled;
  114148. /**
  114149. * Defines if the clear coat tint is enabled in the material.
  114150. */
  114151. isTintEnabled: boolean;
  114152. /**
  114153. * Defines the clear coat tint of the material.
  114154. * This is only use if tint is enabled
  114155. */
  114156. tintColor: Color3;
  114157. /**
  114158. * Defines the distance at which the tint color should be found in the
  114159. * clear coat media.
  114160. * This is only use if tint is enabled
  114161. */
  114162. tintColorAtDistance: number;
  114163. /**
  114164. * Defines the clear coat layer thickness.
  114165. * This is only use if tint is enabled
  114166. */
  114167. tintThickness: number;
  114168. private _tintTexture;
  114169. /**
  114170. * Stores the clear tint values in a texture.
  114171. * rgb is tint
  114172. * a is a thickness factor
  114173. */
  114174. tintTexture: Nullable<BaseTexture>;
  114175. /** @hidden */
  114176. private _internalMarkAllSubMeshesAsTexturesDirty;
  114177. /** @hidden */
  114178. _markAllSubMeshesAsTexturesDirty(): void;
  114179. /**
  114180. * Instantiate a new istance of clear coat configuration.
  114181. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114182. */
  114183. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114184. /**
  114185. * Gets wehter the submesh is ready to be used or not.
  114186. * @param defines the list of "defines" to update.
  114187. * @param scene defines the scene the material belongs to.
  114188. * @param engine defines the engine the material belongs to.
  114189. * @param disableBumpMap defines wether the material disables bump or not.
  114190. * @returns - boolean indicating that the submesh is ready or not.
  114191. */
  114192. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114193. /**
  114194. * Checks to see if a texture is used in the material.
  114195. * @param defines the list of "defines" to update.
  114196. * @param scene defines the scene to the material belongs to.
  114197. */
  114198. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114199. /**
  114200. * Binds the material data.
  114201. * @param uniformBuffer defines the Uniform buffer to fill in.
  114202. * @param scene defines the scene the material belongs to.
  114203. * @param engine defines the engine the material belongs to.
  114204. * @param disableBumpMap defines wether the material disables bump or not.
  114205. * @param isFrozen defines wether the material is frozen or not.
  114206. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114207. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114208. */
  114209. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114210. /**
  114211. * Checks to see if a texture is used in the material.
  114212. * @param texture - Base texture to use.
  114213. * @returns - Boolean specifying if a texture is used in the material.
  114214. */
  114215. hasTexture(texture: BaseTexture): boolean;
  114216. /**
  114217. * Returns an array of the actively used textures.
  114218. * @param activeTextures Array of BaseTextures
  114219. */
  114220. getActiveTextures(activeTextures: BaseTexture[]): void;
  114221. /**
  114222. * Returns the animatable textures.
  114223. * @param animatables Array of animatable textures.
  114224. */
  114225. getAnimatables(animatables: IAnimatable[]): void;
  114226. /**
  114227. * Disposes the resources of the material.
  114228. * @param forceDisposeTextures - Forces the disposal of all textures.
  114229. */
  114230. dispose(forceDisposeTextures?: boolean): void;
  114231. /**
  114232. * Get the current class name of the texture useful for serialization or dynamic coding.
  114233. * @returns "PBRClearCoatConfiguration"
  114234. */
  114235. getClassName(): string;
  114236. /**
  114237. * Add fallbacks to the effect fallbacks list.
  114238. * @param defines defines the Base texture to use.
  114239. * @param fallbacks defines the current fallback list.
  114240. * @param currentRank defines the current fallback rank.
  114241. * @returns the new fallback rank.
  114242. */
  114243. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114244. /**
  114245. * Add the required uniforms to the current list.
  114246. * @param uniforms defines the current uniform list.
  114247. */
  114248. static AddUniforms(uniforms: string[]): void;
  114249. /**
  114250. * Add the required samplers to the current list.
  114251. * @param samplers defines the current sampler list.
  114252. */
  114253. static AddSamplers(samplers: string[]): void;
  114254. /**
  114255. * Add the required uniforms to the current buffer.
  114256. * @param uniformBuffer defines the current uniform buffer.
  114257. */
  114258. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114259. /**
  114260. * Makes a duplicate of the current configuration into another one.
  114261. * @param clearCoatConfiguration define the config where to copy the info
  114262. */
  114263. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114264. /**
  114265. * Serializes this clear coat configuration.
  114266. * @returns - An object with the serialized config.
  114267. */
  114268. serialize(): any;
  114269. /**
  114270. * Parses a anisotropy Configuration from a serialized object.
  114271. * @param source - Serialized object.
  114272. * @param scene Defines the scene we are parsing for
  114273. * @param rootUrl Defines the rootUrl to load from
  114274. */
  114275. parse(source: any, scene: Scene, rootUrl: string): void;
  114276. }
  114277. }
  114278. declare module BABYLON {
  114279. /**
  114280. * @hidden
  114281. */
  114282. export interface IMaterialAnisotropicDefines {
  114283. ANISOTROPIC: boolean;
  114284. ANISOTROPIC_TEXTURE: boolean;
  114285. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114286. MAINUV1: boolean;
  114287. _areTexturesDirty: boolean;
  114288. _needUVs: boolean;
  114289. }
  114290. /**
  114291. * Define the code related to the anisotropic parameters of the pbr material.
  114292. */
  114293. export class PBRAnisotropicConfiguration {
  114294. private _isEnabled;
  114295. /**
  114296. * Defines if the anisotropy is enabled in the material.
  114297. */
  114298. isEnabled: boolean;
  114299. /**
  114300. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114301. */
  114302. intensity: number;
  114303. /**
  114304. * Defines if the effect is along the tangents, bitangents or in between.
  114305. * By default, the effect is "strectching" the highlights along the tangents.
  114306. */
  114307. direction: Vector2;
  114308. private _texture;
  114309. /**
  114310. * Stores the anisotropy values in a texture.
  114311. * rg is direction (like normal from -1 to 1)
  114312. * b is a intensity
  114313. */
  114314. texture: Nullable<BaseTexture>;
  114315. /** @hidden */
  114316. private _internalMarkAllSubMeshesAsTexturesDirty;
  114317. /** @hidden */
  114318. _markAllSubMeshesAsTexturesDirty(): void;
  114319. /**
  114320. * Instantiate a new istance of anisotropy configuration.
  114321. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114322. */
  114323. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114324. /**
  114325. * Specifies that the submesh is ready to be used.
  114326. * @param defines the list of "defines" to update.
  114327. * @param scene defines the scene the material belongs to.
  114328. * @returns - boolean indicating that the submesh is ready or not.
  114329. */
  114330. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114331. /**
  114332. * Checks to see if a texture is used in the material.
  114333. * @param defines the list of "defines" to update.
  114334. * @param mesh the mesh we are preparing the defines for.
  114335. * @param scene defines the scene the material belongs to.
  114336. */
  114337. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114338. /**
  114339. * Binds the material data.
  114340. * @param uniformBuffer defines the Uniform buffer to fill in.
  114341. * @param scene defines the scene the material belongs to.
  114342. * @param isFrozen defines wether the material is frozen or not.
  114343. */
  114344. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114345. /**
  114346. * Checks to see if a texture is used in the material.
  114347. * @param texture - Base texture to use.
  114348. * @returns - Boolean specifying if a texture is used in the material.
  114349. */
  114350. hasTexture(texture: BaseTexture): boolean;
  114351. /**
  114352. * Returns an array of the actively used textures.
  114353. * @param activeTextures Array of BaseTextures
  114354. */
  114355. getActiveTextures(activeTextures: BaseTexture[]): void;
  114356. /**
  114357. * Returns the animatable textures.
  114358. * @param animatables Array of animatable textures.
  114359. */
  114360. getAnimatables(animatables: IAnimatable[]): void;
  114361. /**
  114362. * Disposes the resources of the material.
  114363. * @param forceDisposeTextures - Forces the disposal of all textures.
  114364. */
  114365. dispose(forceDisposeTextures?: boolean): void;
  114366. /**
  114367. * Get the current class name of the texture useful for serialization or dynamic coding.
  114368. * @returns "PBRAnisotropicConfiguration"
  114369. */
  114370. getClassName(): string;
  114371. /**
  114372. * Add fallbacks to the effect fallbacks list.
  114373. * @param defines defines the Base texture to use.
  114374. * @param fallbacks defines the current fallback list.
  114375. * @param currentRank defines the current fallback rank.
  114376. * @returns the new fallback rank.
  114377. */
  114378. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114379. /**
  114380. * Add the required uniforms to the current list.
  114381. * @param uniforms defines the current uniform list.
  114382. */
  114383. static AddUniforms(uniforms: string[]): void;
  114384. /**
  114385. * Add the required uniforms to the current buffer.
  114386. * @param uniformBuffer defines the current uniform buffer.
  114387. */
  114388. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114389. /**
  114390. * Add the required samplers to the current list.
  114391. * @param samplers defines the current sampler list.
  114392. */
  114393. static AddSamplers(samplers: string[]): void;
  114394. /**
  114395. * Makes a duplicate of the current configuration into another one.
  114396. * @param anisotropicConfiguration define the config where to copy the info
  114397. */
  114398. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114399. /**
  114400. * Serializes this anisotropy configuration.
  114401. * @returns - An object with the serialized config.
  114402. */
  114403. serialize(): any;
  114404. /**
  114405. * Parses a anisotropy Configuration from a serialized object.
  114406. * @param source - Serialized object.
  114407. * @param scene Defines the scene we are parsing for
  114408. * @param rootUrl Defines the rootUrl to load from
  114409. */
  114410. parse(source: any, scene: Scene, rootUrl: string): void;
  114411. }
  114412. }
  114413. declare module BABYLON {
  114414. /**
  114415. * @hidden
  114416. */
  114417. export interface IMaterialBRDFDefines {
  114418. BRDF_V_HEIGHT_CORRELATED: boolean;
  114419. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114420. SPHERICAL_HARMONICS: boolean;
  114421. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114422. /** @hidden */
  114423. _areMiscDirty: boolean;
  114424. }
  114425. /**
  114426. * Define the code related to the BRDF parameters of the pbr material.
  114427. */
  114428. export class PBRBRDFConfiguration {
  114429. /**
  114430. * Default value used for the energy conservation.
  114431. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114432. */
  114433. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114434. /**
  114435. * Default value used for the Smith Visibility Height Correlated mode.
  114436. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114437. */
  114438. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114439. /**
  114440. * Default value used for the IBL diffuse part.
  114441. * This can help switching back to the polynomials mode globally which is a tiny bit
  114442. * less GPU intensive at the drawback of a lower quality.
  114443. */
  114444. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114445. /**
  114446. * Default value used for activating energy conservation for the specular workflow.
  114447. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114448. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114449. */
  114450. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114451. private _useEnergyConservation;
  114452. /**
  114453. * Defines if the material uses energy conservation.
  114454. */
  114455. useEnergyConservation: boolean;
  114456. private _useSmithVisibilityHeightCorrelated;
  114457. /**
  114458. * LEGACY Mode set to false
  114459. * Defines if the material uses height smith correlated visibility term.
  114460. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114461. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114462. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114463. * Not relying on height correlated will also disable energy conservation.
  114464. */
  114465. useSmithVisibilityHeightCorrelated: boolean;
  114466. private _useSphericalHarmonics;
  114467. /**
  114468. * LEGACY Mode set to false
  114469. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114470. * diffuse part of the IBL.
  114471. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114472. * to the ground truth.
  114473. */
  114474. useSphericalHarmonics: boolean;
  114475. private _useSpecularGlossinessInputEnergyConservation;
  114476. /**
  114477. * Defines if the material uses energy conservation, when the specular workflow is active.
  114478. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114479. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114480. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114481. */
  114482. useSpecularGlossinessInputEnergyConservation: boolean;
  114483. /** @hidden */
  114484. private _internalMarkAllSubMeshesAsMiscDirty;
  114485. /** @hidden */
  114486. _markAllSubMeshesAsMiscDirty(): void;
  114487. /**
  114488. * Instantiate a new istance of clear coat configuration.
  114489. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114490. */
  114491. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114492. /**
  114493. * Checks to see if a texture is used in the material.
  114494. * @param defines the list of "defines" to update.
  114495. */
  114496. prepareDefines(defines: IMaterialBRDFDefines): void;
  114497. /**
  114498. * Get the current class name of the texture useful for serialization or dynamic coding.
  114499. * @returns "PBRClearCoatConfiguration"
  114500. */
  114501. getClassName(): string;
  114502. /**
  114503. * Makes a duplicate of the current configuration into another one.
  114504. * @param brdfConfiguration define the config where to copy the info
  114505. */
  114506. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114507. /**
  114508. * Serializes this BRDF configuration.
  114509. * @returns - An object with the serialized config.
  114510. */
  114511. serialize(): any;
  114512. /**
  114513. * Parses a anisotropy Configuration from a serialized object.
  114514. * @param source - Serialized object.
  114515. * @param scene Defines the scene we are parsing for
  114516. * @param rootUrl Defines the rootUrl to load from
  114517. */
  114518. parse(source: any, scene: Scene, rootUrl: string): void;
  114519. }
  114520. }
  114521. declare module BABYLON {
  114522. /**
  114523. * @hidden
  114524. */
  114525. export interface IMaterialSheenDefines {
  114526. SHEEN: boolean;
  114527. SHEEN_TEXTURE: boolean;
  114528. SHEEN_TEXTUREDIRECTUV: number;
  114529. SHEEN_LINKWITHALBEDO: boolean;
  114530. /** @hidden */
  114531. _areTexturesDirty: boolean;
  114532. }
  114533. /**
  114534. * Define the code related to the Sheen parameters of the pbr material.
  114535. */
  114536. export class PBRSheenConfiguration {
  114537. private _isEnabled;
  114538. /**
  114539. * Defines if the material uses sheen.
  114540. */
  114541. isEnabled: boolean;
  114542. private _linkSheenWithAlbedo;
  114543. /**
  114544. * Defines if the sheen is linked to the sheen color.
  114545. */
  114546. linkSheenWithAlbedo: boolean;
  114547. /**
  114548. * Defines the sheen intensity.
  114549. */
  114550. intensity: number;
  114551. /**
  114552. * Defines the sheen color.
  114553. */
  114554. color: Color3;
  114555. private _texture;
  114556. /**
  114557. * Stores the sheen tint values in a texture.
  114558. * rgb is tint
  114559. * a is a intensity
  114560. */
  114561. texture: Nullable<BaseTexture>;
  114562. /** @hidden */
  114563. private _internalMarkAllSubMeshesAsTexturesDirty;
  114564. /** @hidden */
  114565. _markAllSubMeshesAsTexturesDirty(): void;
  114566. /**
  114567. * Instantiate a new istance of clear coat configuration.
  114568. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114569. */
  114570. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114571. /**
  114572. * Specifies that the submesh is ready to be used.
  114573. * @param defines the list of "defines" to update.
  114574. * @param scene defines the scene the material belongs to.
  114575. * @returns - boolean indicating that the submesh is ready or not.
  114576. */
  114577. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114578. /**
  114579. * Checks to see if a texture is used in the material.
  114580. * @param defines the list of "defines" to update.
  114581. * @param scene defines the scene the material belongs to.
  114582. */
  114583. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114584. /**
  114585. * Binds the material data.
  114586. * @param uniformBuffer defines the Uniform buffer to fill in.
  114587. * @param scene defines the scene the material belongs to.
  114588. * @param isFrozen defines wether the material is frozen or not.
  114589. */
  114590. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114591. /**
  114592. * Checks to see if a texture is used in the material.
  114593. * @param texture - Base texture to use.
  114594. * @returns - Boolean specifying if a texture is used in the material.
  114595. */
  114596. hasTexture(texture: BaseTexture): boolean;
  114597. /**
  114598. * Returns an array of the actively used textures.
  114599. * @param activeTextures Array of BaseTextures
  114600. */
  114601. getActiveTextures(activeTextures: BaseTexture[]): void;
  114602. /**
  114603. * Returns the animatable textures.
  114604. * @param animatables Array of animatable textures.
  114605. */
  114606. getAnimatables(animatables: IAnimatable[]): void;
  114607. /**
  114608. * Disposes the resources of the material.
  114609. * @param forceDisposeTextures - Forces the disposal of all textures.
  114610. */
  114611. dispose(forceDisposeTextures?: boolean): void;
  114612. /**
  114613. * Get the current class name of the texture useful for serialization or dynamic coding.
  114614. * @returns "PBRSheenConfiguration"
  114615. */
  114616. getClassName(): string;
  114617. /**
  114618. * Add fallbacks to the effect fallbacks list.
  114619. * @param defines defines the Base texture to use.
  114620. * @param fallbacks defines the current fallback list.
  114621. * @param currentRank defines the current fallback rank.
  114622. * @returns the new fallback rank.
  114623. */
  114624. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114625. /**
  114626. * Add the required uniforms to the current list.
  114627. * @param uniforms defines the current uniform list.
  114628. */
  114629. static AddUniforms(uniforms: string[]): void;
  114630. /**
  114631. * Add the required uniforms to the current buffer.
  114632. * @param uniformBuffer defines the current uniform buffer.
  114633. */
  114634. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114635. /**
  114636. * Add the required samplers to the current list.
  114637. * @param samplers defines the current sampler list.
  114638. */
  114639. static AddSamplers(samplers: string[]): void;
  114640. /**
  114641. * Makes a duplicate of the current configuration into another one.
  114642. * @param sheenConfiguration define the config where to copy the info
  114643. */
  114644. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114645. /**
  114646. * Serializes this BRDF configuration.
  114647. * @returns - An object with the serialized config.
  114648. */
  114649. serialize(): any;
  114650. /**
  114651. * Parses a anisotropy Configuration from a serialized object.
  114652. * @param source - Serialized object.
  114653. * @param scene Defines the scene we are parsing for
  114654. * @param rootUrl Defines the rootUrl to load from
  114655. */
  114656. parse(source: any, scene: Scene, rootUrl: string): void;
  114657. }
  114658. }
  114659. declare module BABYLON {
  114660. /**
  114661. * @hidden
  114662. */
  114663. export interface IMaterialSubSurfaceDefines {
  114664. SUBSURFACE: boolean;
  114665. SS_REFRACTION: boolean;
  114666. SS_TRANSLUCENCY: boolean;
  114667. SS_SCATERRING: boolean;
  114668. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114669. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114670. SS_REFRACTIONMAP_3D: boolean;
  114671. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114672. SS_LODINREFRACTIONALPHA: boolean;
  114673. SS_GAMMAREFRACTION: boolean;
  114674. SS_RGBDREFRACTION: boolean;
  114675. SS_LINEARSPECULARREFRACTION: boolean;
  114676. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114677. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114678. /** @hidden */
  114679. _areTexturesDirty: boolean;
  114680. }
  114681. /**
  114682. * Define the code related to the sub surface parameters of the pbr material.
  114683. */
  114684. export class PBRSubSurfaceConfiguration {
  114685. private _isRefractionEnabled;
  114686. /**
  114687. * Defines if the refraction is enabled in the material.
  114688. */
  114689. isRefractionEnabled: boolean;
  114690. private _isTranslucencyEnabled;
  114691. /**
  114692. * Defines if the translucency is enabled in the material.
  114693. */
  114694. isTranslucencyEnabled: boolean;
  114695. private _isScatteringEnabled;
  114696. /**
  114697. * Defines the refraction intensity of the material.
  114698. * The refraction when enabled replaces the Diffuse part of the material.
  114699. * The intensity helps transitionning between diffuse and refraction.
  114700. */
  114701. refractionIntensity: number;
  114702. /**
  114703. * Defines the translucency intensity of the material.
  114704. * When translucency has been enabled, this defines how much of the "translucency"
  114705. * is addded to the diffuse part of the material.
  114706. */
  114707. translucencyIntensity: number;
  114708. /**
  114709. * Defines the scattering intensity of the material.
  114710. * When scattering has been enabled, this defines how much of the "scattered light"
  114711. * is addded to the diffuse part of the material.
  114712. */
  114713. scatteringIntensity: number;
  114714. private _thicknessTexture;
  114715. /**
  114716. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  114717. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  114718. * 0 would mean minimumThickness
  114719. * 1 would mean maximumThickness
  114720. * The other channels might be use as a mask to vary the different effects intensity.
  114721. */
  114722. thicknessTexture: Nullable<BaseTexture>;
  114723. private _refractionTexture;
  114724. /**
  114725. * Defines the texture to use for refraction.
  114726. */
  114727. refractionTexture: Nullable<BaseTexture>;
  114728. private _indexOfRefraction;
  114729. /**
  114730. * Defines the index of refraction used in the material.
  114731. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  114732. */
  114733. indexOfRefraction: number;
  114734. private _invertRefractionY;
  114735. /**
  114736. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114737. */
  114738. invertRefractionY: boolean;
  114739. private _linkRefractionWithTransparency;
  114740. /**
  114741. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114742. * Materials half opaque for instance using refraction could benefit from this control.
  114743. */
  114744. linkRefractionWithTransparency: boolean;
  114745. /**
  114746. * Defines the minimum thickness stored in the thickness map.
  114747. * If no thickness map is defined, this value will be used to simulate thickness.
  114748. */
  114749. minimumThickness: number;
  114750. /**
  114751. * Defines the maximum thickness stored in the thickness map.
  114752. */
  114753. maximumThickness: number;
  114754. /**
  114755. * Defines the volume tint of the material.
  114756. * This is used for both translucency and scattering.
  114757. */
  114758. tintColor: Color3;
  114759. /**
  114760. * Defines the distance at which the tint color should be found in the media.
  114761. * This is used for refraction only.
  114762. */
  114763. tintColorAtDistance: number;
  114764. /**
  114765. * Defines how far each channel transmit through the media.
  114766. * It is defined as a color to simplify it selection.
  114767. */
  114768. diffusionDistance: Color3;
  114769. private _useMaskFromThicknessTexture;
  114770. /**
  114771. * Stores the intensity of the different subsurface effects in the thickness texture.
  114772. * * the green channel is the translucency intensity.
  114773. * * the blue channel is the scattering intensity.
  114774. * * the alpha channel is the refraction intensity.
  114775. */
  114776. useMaskFromThicknessTexture: boolean;
  114777. /** @hidden */
  114778. private _internalMarkAllSubMeshesAsTexturesDirty;
  114779. /** @hidden */
  114780. _markAllSubMeshesAsTexturesDirty(): void;
  114781. /**
  114782. * Instantiate a new istance of sub surface configuration.
  114783. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114784. */
  114785. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114786. /**
  114787. * Gets wehter the submesh is ready to be used or not.
  114788. * @param defines the list of "defines" to update.
  114789. * @param scene defines the scene the material belongs to.
  114790. * @returns - boolean indicating that the submesh is ready or not.
  114791. */
  114792. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114793. /**
  114794. * Checks to see if a texture is used in the material.
  114795. * @param defines the list of "defines" to update.
  114796. * @param scene defines the scene to the material belongs to.
  114797. */
  114798. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114799. /**
  114800. * Binds the material data.
  114801. * @param uniformBuffer defines the Uniform buffer to fill in.
  114802. * @param scene defines the scene the material belongs to.
  114803. * @param engine defines the engine the material belongs to.
  114804. * @param isFrozen defines wether the material is frozen or not.
  114805. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114806. */
  114807. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114808. /**
  114809. * Unbinds the material from the mesh.
  114810. * @param activeEffect defines the effect that should be unbound from.
  114811. * @returns true if unbound, otherwise false
  114812. */
  114813. unbind(activeEffect: Effect): boolean;
  114814. /**
  114815. * Returns the texture used for refraction or null if none is used.
  114816. * @param scene defines the scene the material belongs to.
  114817. * @returns - Refraction texture if present. If no refraction texture and refraction
  114818. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114819. */
  114820. private _getRefractionTexture;
  114821. /**
  114822. * Returns true if alpha blending should be disabled.
  114823. */
  114824. readonly disableAlphaBlending: boolean;
  114825. /**
  114826. * Fills the list of render target textures.
  114827. * @param renderTargets the list of render targets to update
  114828. */
  114829. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114830. /**
  114831. * Checks to see if a texture is used in the material.
  114832. * @param texture - Base texture to use.
  114833. * @returns - Boolean specifying if a texture is used in the material.
  114834. */
  114835. hasTexture(texture: BaseTexture): boolean;
  114836. /**
  114837. * Gets a boolean indicating that current material needs to register RTT
  114838. * @returns true if this uses a render target otherwise false.
  114839. */
  114840. hasRenderTargetTextures(): boolean;
  114841. /**
  114842. * Returns an array of the actively used textures.
  114843. * @param activeTextures Array of BaseTextures
  114844. */
  114845. getActiveTextures(activeTextures: BaseTexture[]): void;
  114846. /**
  114847. * Returns the animatable textures.
  114848. * @param animatables Array of animatable textures.
  114849. */
  114850. getAnimatables(animatables: IAnimatable[]): void;
  114851. /**
  114852. * Disposes the resources of the material.
  114853. * @param forceDisposeTextures - Forces the disposal of all textures.
  114854. */
  114855. dispose(forceDisposeTextures?: boolean): void;
  114856. /**
  114857. * Get the current class name of the texture useful for serialization or dynamic coding.
  114858. * @returns "PBRSubSurfaceConfiguration"
  114859. */
  114860. getClassName(): string;
  114861. /**
  114862. * Add fallbacks to the effect fallbacks list.
  114863. * @param defines defines the Base texture to use.
  114864. * @param fallbacks defines the current fallback list.
  114865. * @param currentRank defines the current fallback rank.
  114866. * @returns the new fallback rank.
  114867. */
  114868. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114869. /**
  114870. * Add the required uniforms to the current list.
  114871. * @param uniforms defines the current uniform list.
  114872. */
  114873. static AddUniforms(uniforms: string[]): void;
  114874. /**
  114875. * Add the required samplers to the current list.
  114876. * @param samplers defines the current sampler list.
  114877. */
  114878. static AddSamplers(samplers: string[]): void;
  114879. /**
  114880. * Add the required uniforms to the current buffer.
  114881. * @param uniformBuffer defines the current uniform buffer.
  114882. */
  114883. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114884. /**
  114885. * Makes a duplicate of the current configuration into another one.
  114886. * @param configuration define the config where to copy the info
  114887. */
  114888. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114889. /**
  114890. * Serializes this Sub Surface configuration.
  114891. * @returns - An object with the serialized config.
  114892. */
  114893. serialize(): any;
  114894. /**
  114895. * Parses a anisotropy Configuration from a serialized object.
  114896. * @param source - Serialized object.
  114897. * @param scene Defines the scene we are parsing for
  114898. * @param rootUrl Defines the rootUrl to load from
  114899. */
  114900. parse(source: any, scene: Scene, rootUrl: string): void;
  114901. }
  114902. }
  114903. declare module BABYLON {
  114904. /** @hidden */
  114905. export var pbrFragmentDeclaration: {
  114906. name: string;
  114907. shader: string;
  114908. };
  114909. }
  114910. declare module BABYLON {
  114911. /** @hidden */
  114912. export var pbrUboDeclaration: {
  114913. name: string;
  114914. shader: string;
  114915. };
  114916. }
  114917. declare module BABYLON {
  114918. /** @hidden */
  114919. export var pbrFragmentExtraDeclaration: {
  114920. name: string;
  114921. shader: string;
  114922. };
  114923. }
  114924. declare module BABYLON {
  114925. /** @hidden */
  114926. export var pbrFragmentSamplersDeclaration: {
  114927. name: string;
  114928. shader: string;
  114929. };
  114930. }
  114931. declare module BABYLON {
  114932. /** @hidden */
  114933. export var pbrHelperFunctions: {
  114934. name: string;
  114935. shader: string;
  114936. };
  114937. }
  114938. declare module BABYLON {
  114939. /** @hidden */
  114940. export var harmonicsFunctions: {
  114941. name: string;
  114942. shader: string;
  114943. };
  114944. }
  114945. declare module BABYLON {
  114946. /** @hidden */
  114947. export var pbrDirectLightingSetupFunctions: {
  114948. name: string;
  114949. shader: string;
  114950. };
  114951. }
  114952. declare module BABYLON {
  114953. /** @hidden */
  114954. export var pbrDirectLightingFalloffFunctions: {
  114955. name: string;
  114956. shader: string;
  114957. };
  114958. }
  114959. declare module BABYLON {
  114960. /** @hidden */
  114961. export var pbrBRDFFunctions: {
  114962. name: string;
  114963. shader: string;
  114964. };
  114965. }
  114966. declare module BABYLON {
  114967. /** @hidden */
  114968. export var pbrDirectLightingFunctions: {
  114969. name: string;
  114970. shader: string;
  114971. };
  114972. }
  114973. declare module BABYLON {
  114974. /** @hidden */
  114975. export var pbrIBLFunctions: {
  114976. name: string;
  114977. shader: string;
  114978. };
  114979. }
  114980. declare module BABYLON {
  114981. /** @hidden */
  114982. export var pbrDebug: {
  114983. name: string;
  114984. shader: string;
  114985. };
  114986. }
  114987. declare module BABYLON {
  114988. /** @hidden */
  114989. export var pbrPixelShader: {
  114990. name: string;
  114991. shader: string;
  114992. };
  114993. }
  114994. declare module BABYLON {
  114995. /** @hidden */
  114996. export var pbrVertexDeclaration: {
  114997. name: string;
  114998. shader: string;
  114999. };
  115000. }
  115001. declare module BABYLON {
  115002. /** @hidden */
  115003. export var pbrVertexShader: {
  115004. name: string;
  115005. shader: string;
  115006. };
  115007. }
  115008. declare module BABYLON {
  115009. /**
  115010. * Manages the defines for the PBR Material.
  115011. * @hidden
  115012. */
  115013. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115014. PBR: boolean;
  115015. MAINUV1: boolean;
  115016. MAINUV2: boolean;
  115017. UV1: boolean;
  115018. UV2: boolean;
  115019. ALBEDO: boolean;
  115020. ALBEDODIRECTUV: number;
  115021. VERTEXCOLOR: boolean;
  115022. AMBIENT: boolean;
  115023. AMBIENTDIRECTUV: number;
  115024. AMBIENTINGRAYSCALE: boolean;
  115025. OPACITY: boolean;
  115026. VERTEXALPHA: boolean;
  115027. OPACITYDIRECTUV: number;
  115028. OPACITYRGB: boolean;
  115029. ALPHATEST: boolean;
  115030. DEPTHPREPASS: boolean;
  115031. ALPHABLEND: boolean;
  115032. ALPHAFROMALBEDO: boolean;
  115033. ALPHATESTVALUE: string;
  115034. SPECULAROVERALPHA: boolean;
  115035. RADIANCEOVERALPHA: boolean;
  115036. ALPHAFRESNEL: boolean;
  115037. LINEARALPHAFRESNEL: boolean;
  115038. PREMULTIPLYALPHA: boolean;
  115039. EMISSIVE: boolean;
  115040. EMISSIVEDIRECTUV: number;
  115041. REFLECTIVITY: boolean;
  115042. REFLECTIVITYDIRECTUV: number;
  115043. SPECULARTERM: boolean;
  115044. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115045. MICROSURFACEAUTOMATIC: boolean;
  115046. LODBASEDMICROSFURACE: boolean;
  115047. MICROSURFACEMAP: boolean;
  115048. MICROSURFACEMAPDIRECTUV: number;
  115049. METALLICWORKFLOW: boolean;
  115050. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115051. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115052. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115053. AOSTOREINMETALMAPRED: boolean;
  115054. ENVIRONMENTBRDF: boolean;
  115055. ENVIRONMENTBRDF_RGBD: boolean;
  115056. NORMAL: boolean;
  115057. TANGENT: boolean;
  115058. BUMP: boolean;
  115059. BUMPDIRECTUV: number;
  115060. OBJECTSPACE_NORMALMAP: boolean;
  115061. PARALLAX: boolean;
  115062. PARALLAXOCCLUSION: boolean;
  115063. NORMALXYSCALE: boolean;
  115064. LIGHTMAP: boolean;
  115065. LIGHTMAPDIRECTUV: number;
  115066. USELIGHTMAPASSHADOWMAP: boolean;
  115067. GAMMALIGHTMAP: boolean;
  115068. RGBDLIGHTMAP: boolean;
  115069. REFLECTION: boolean;
  115070. REFLECTIONMAP_3D: boolean;
  115071. REFLECTIONMAP_SPHERICAL: boolean;
  115072. REFLECTIONMAP_PLANAR: boolean;
  115073. REFLECTIONMAP_CUBIC: boolean;
  115074. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115075. REFLECTIONMAP_PROJECTION: boolean;
  115076. REFLECTIONMAP_SKYBOX: boolean;
  115077. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115078. REFLECTIONMAP_EXPLICIT: boolean;
  115079. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115080. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  115081. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  115082. INVERTCUBICMAP: boolean;
  115083. USESPHERICALFROMREFLECTIONMAP: boolean;
  115084. USEIRRADIANCEMAP: boolean;
  115085. SPHERICAL_HARMONICS: boolean;
  115086. USESPHERICALINVERTEX: boolean;
  115087. REFLECTIONMAP_OPPOSITEZ: boolean;
  115088. LODINREFLECTIONALPHA: boolean;
  115089. GAMMAREFLECTION: boolean;
  115090. RGBDREFLECTION: boolean;
  115091. LINEARSPECULARREFLECTION: boolean;
  115092. RADIANCEOCCLUSION: boolean;
  115093. HORIZONOCCLUSION: boolean;
  115094. INSTANCES: boolean;
  115095. NUM_BONE_INFLUENCERS: number;
  115096. BonesPerMesh: number;
  115097. BONETEXTURE: boolean;
  115098. NONUNIFORMSCALING: boolean;
  115099. MORPHTARGETS: boolean;
  115100. MORPHTARGETS_NORMAL: boolean;
  115101. MORPHTARGETS_TANGENT: boolean;
  115102. MORPHTARGETS_UV: boolean;
  115103. NUM_MORPH_INFLUENCERS: number;
  115104. IMAGEPROCESSING: boolean;
  115105. VIGNETTE: boolean;
  115106. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115107. VIGNETTEBLENDMODEOPAQUE: boolean;
  115108. TONEMAPPING: boolean;
  115109. TONEMAPPING_ACES: boolean;
  115110. CONTRAST: boolean;
  115111. COLORCURVES: boolean;
  115112. COLORGRADING: boolean;
  115113. COLORGRADING3D: boolean;
  115114. SAMPLER3DGREENDEPTH: boolean;
  115115. SAMPLER3DBGRMAP: boolean;
  115116. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115117. EXPOSURE: boolean;
  115118. MULTIVIEW: boolean;
  115119. USEPHYSICALLIGHTFALLOFF: boolean;
  115120. USEGLTFLIGHTFALLOFF: boolean;
  115121. TWOSIDEDLIGHTING: boolean;
  115122. SHADOWFLOAT: boolean;
  115123. CLIPPLANE: boolean;
  115124. CLIPPLANE2: boolean;
  115125. CLIPPLANE3: boolean;
  115126. CLIPPLANE4: boolean;
  115127. POINTSIZE: boolean;
  115128. FOG: boolean;
  115129. LOGARITHMICDEPTH: boolean;
  115130. FORCENORMALFORWARD: boolean;
  115131. SPECULARAA: boolean;
  115132. CLEARCOAT: boolean;
  115133. CLEARCOAT_DEFAULTIOR: boolean;
  115134. CLEARCOAT_TEXTURE: boolean;
  115135. CLEARCOAT_TEXTUREDIRECTUV: number;
  115136. CLEARCOAT_BUMP: boolean;
  115137. CLEARCOAT_BUMPDIRECTUV: number;
  115138. CLEARCOAT_TINT: boolean;
  115139. CLEARCOAT_TINT_TEXTURE: boolean;
  115140. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115141. ANISOTROPIC: boolean;
  115142. ANISOTROPIC_TEXTURE: boolean;
  115143. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115144. BRDF_V_HEIGHT_CORRELATED: boolean;
  115145. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115146. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115147. SHEEN: boolean;
  115148. SHEEN_TEXTURE: boolean;
  115149. SHEEN_TEXTUREDIRECTUV: number;
  115150. SHEEN_LINKWITHALBEDO: boolean;
  115151. SUBSURFACE: boolean;
  115152. SS_REFRACTION: boolean;
  115153. SS_TRANSLUCENCY: boolean;
  115154. SS_SCATERRING: boolean;
  115155. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115156. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115157. SS_REFRACTIONMAP_3D: boolean;
  115158. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115159. SS_LODINREFRACTIONALPHA: boolean;
  115160. SS_GAMMAREFRACTION: boolean;
  115161. SS_RGBDREFRACTION: boolean;
  115162. SS_LINEARSPECULARREFRACTION: boolean;
  115163. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115164. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115165. UNLIT: boolean;
  115166. DEBUGMODE: number;
  115167. /**
  115168. * Initializes the PBR Material defines.
  115169. */
  115170. constructor();
  115171. /**
  115172. * Resets the PBR Material defines.
  115173. */
  115174. reset(): void;
  115175. }
  115176. /**
  115177. * The Physically based material base class of BJS.
  115178. *
  115179. * This offers the main features of a standard PBR material.
  115180. * For more information, please refer to the documentation :
  115181. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115182. */
  115183. export abstract class PBRBaseMaterial extends PushMaterial {
  115184. /**
  115185. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115186. */
  115187. static readonly PBRMATERIAL_OPAQUE: number;
  115188. /**
  115189. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115190. */
  115191. static readonly PBRMATERIAL_ALPHATEST: number;
  115192. /**
  115193. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115194. */
  115195. static readonly PBRMATERIAL_ALPHABLEND: number;
  115196. /**
  115197. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115198. * They are also discarded below the alpha cutoff threshold to improve performances.
  115199. */
  115200. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115201. /**
  115202. * Defines the default value of how much AO map is occluding the analytical lights
  115203. * (point spot...).
  115204. */
  115205. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115206. /**
  115207. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115208. */
  115209. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115210. /**
  115211. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115212. * to enhance interoperability with other engines.
  115213. */
  115214. static readonly LIGHTFALLOFF_GLTF: number;
  115215. /**
  115216. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115217. * to enhance interoperability with other materials.
  115218. */
  115219. static readonly LIGHTFALLOFF_STANDARD: number;
  115220. /**
  115221. * Intensity of the direct lights e.g. the four lights available in your scene.
  115222. * This impacts both the direct diffuse and specular highlights.
  115223. */
  115224. protected _directIntensity: number;
  115225. /**
  115226. * Intensity of the emissive part of the material.
  115227. * This helps controlling the emissive effect without modifying the emissive color.
  115228. */
  115229. protected _emissiveIntensity: number;
  115230. /**
  115231. * Intensity of the environment e.g. how much the environment will light the object
  115232. * either through harmonics for rough material or through the refelction for shiny ones.
  115233. */
  115234. protected _environmentIntensity: number;
  115235. /**
  115236. * This is a special control allowing the reduction of the specular highlights coming from the
  115237. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115238. */
  115239. protected _specularIntensity: number;
  115240. /**
  115241. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115242. */
  115243. private _lightingInfos;
  115244. /**
  115245. * Debug Control allowing disabling the bump map on this material.
  115246. */
  115247. protected _disableBumpMap: boolean;
  115248. /**
  115249. * AKA Diffuse Texture in standard nomenclature.
  115250. */
  115251. protected _albedoTexture: Nullable<BaseTexture>;
  115252. /**
  115253. * AKA Occlusion Texture in other nomenclature.
  115254. */
  115255. protected _ambientTexture: Nullable<BaseTexture>;
  115256. /**
  115257. * AKA Occlusion Texture Intensity in other nomenclature.
  115258. */
  115259. protected _ambientTextureStrength: number;
  115260. /**
  115261. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115262. * 1 means it completely occludes it
  115263. * 0 mean it has no impact
  115264. */
  115265. protected _ambientTextureImpactOnAnalyticalLights: number;
  115266. /**
  115267. * Stores the alpha values in a texture.
  115268. */
  115269. protected _opacityTexture: Nullable<BaseTexture>;
  115270. /**
  115271. * Stores the reflection values in a texture.
  115272. */
  115273. protected _reflectionTexture: Nullable<BaseTexture>;
  115274. /**
  115275. * Stores the emissive values in a texture.
  115276. */
  115277. protected _emissiveTexture: Nullable<BaseTexture>;
  115278. /**
  115279. * AKA Specular texture in other nomenclature.
  115280. */
  115281. protected _reflectivityTexture: Nullable<BaseTexture>;
  115282. /**
  115283. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115284. */
  115285. protected _metallicTexture: Nullable<BaseTexture>;
  115286. /**
  115287. * Specifies the metallic scalar of the metallic/roughness workflow.
  115288. * Can also be used to scale the metalness values of the metallic texture.
  115289. */
  115290. protected _metallic: Nullable<number>;
  115291. /**
  115292. * Specifies the roughness scalar of the metallic/roughness workflow.
  115293. * Can also be used to scale the roughness values of the metallic texture.
  115294. */
  115295. protected _roughness: Nullable<number>;
  115296. /**
  115297. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115298. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115299. */
  115300. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115301. /**
  115302. * Stores surface normal data used to displace a mesh in a texture.
  115303. */
  115304. protected _bumpTexture: Nullable<BaseTexture>;
  115305. /**
  115306. * Stores the pre-calculated light information of a mesh in a texture.
  115307. */
  115308. protected _lightmapTexture: Nullable<BaseTexture>;
  115309. /**
  115310. * The color of a material in ambient lighting.
  115311. */
  115312. protected _ambientColor: Color3;
  115313. /**
  115314. * AKA Diffuse Color in other nomenclature.
  115315. */
  115316. protected _albedoColor: Color3;
  115317. /**
  115318. * AKA Specular Color in other nomenclature.
  115319. */
  115320. protected _reflectivityColor: Color3;
  115321. /**
  115322. * The color applied when light is reflected from a material.
  115323. */
  115324. protected _reflectionColor: Color3;
  115325. /**
  115326. * The color applied when light is emitted from a material.
  115327. */
  115328. protected _emissiveColor: Color3;
  115329. /**
  115330. * AKA Glossiness in other nomenclature.
  115331. */
  115332. protected _microSurface: number;
  115333. /**
  115334. * Specifies that the material will use the light map as a show map.
  115335. */
  115336. protected _useLightmapAsShadowmap: boolean;
  115337. /**
  115338. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115339. * makes the reflect vector face the model (under horizon).
  115340. */
  115341. protected _useHorizonOcclusion: boolean;
  115342. /**
  115343. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115344. * too much the area relying on ambient texture to define their ambient occlusion.
  115345. */
  115346. protected _useRadianceOcclusion: boolean;
  115347. /**
  115348. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115349. */
  115350. protected _useAlphaFromAlbedoTexture: boolean;
  115351. /**
  115352. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115353. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115354. */
  115355. protected _useSpecularOverAlpha: boolean;
  115356. /**
  115357. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115358. */
  115359. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115360. /**
  115361. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115362. */
  115363. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115364. /**
  115365. * Specifies if the metallic texture contains the roughness information in its green channel.
  115366. */
  115367. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115368. /**
  115369. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115370. */
  115371. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115372. /**
  115373. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115374. */
  115375. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115376. /**
  115377. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115378. */
  115379. protected _useAmbientInGrayScale: boolean;
  115380. /**
  115381. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115382. * The material will try to infer what glossiness each pixel should be.
  115383. */
  115384. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115385. /**
  115386. * Defines the falloff type used in this material.
  115387. * It by default is Physical.
  115388. */
  115389. protected _lightFalloff: number;
  115390. /**
  115391. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115392. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115393. */
  115394. protected _useRadianceOverAlpha: boolean;
  115395. /**
  115396. * Allows using an object space normal map (instead of tangent space).
  115397. */
  115398. protected _useObjectSpaceNormalMap: boolean;
  115399. /**
  115400. * Allows using the bump map in parallax mode.
  115401. */
  115402. protected _useParallax: boolean;
  115403. /**
  115404. * Allows using the bump map in parallax occlusion mode.
  115405. */
  115406. protected _useParallaxOcclusion: boolean;
  115407. /**
  115408. * Controls the scale bias of the parallax mode.
  115409. */
  115410. protected _parallaxScaleBias: number;
  115411. /**
  115412. * If sets to true, disables all the lights affecting the material.
  115413. */
  115414. protected _disableLighting: boolean;
  115415. /**
  115416. * Number of Simultaneous lights allowed on the material.
  115417. */
  115418. protected _maxSimultaneousLights: number;
  115419. /**
  115420. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115421. */
  115422. protected _invertNormalMapX: boolean;
  115423. /**
  115424. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115425. */
  115426. protected _invertNormalMapY: boolean;
  115427. /**
  115428. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115429. */
  115430. protected _twoSidedLighting: boolean;
  115431. /**
  115432. * Defines the alpha limits in alpha test mode.
  115433. */
  115434. protected _alphaCutOff: number;
  115435. /**
  115436. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115437. */
  115438. protected _forceAlphaTest: boolean;
  115439. /**
  115440. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115441. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115442. */
  115443. protected _useAlphaFresnel: boolean;
  115444. /**
  115445. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115446. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115447. */
  115448. protected _useLinearAlphaFresnel: boolean;
  115449. /**
  115450. * The transparency mode of the material.
  115451. */
  115452. protected _transparencyMode: Nullable<number>;
  115453. /**
  115454. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115455. * from cos thetav and roughness:
  115456. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115457. */
  115458. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115459. /**
  115460. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115461. */
  115462. protected _forceIrradianceInFragment: boolean;
  115463. /**
  115464. * Force normal to face away from face.
  115465. */
  115466. protected _forceNormalForward: boolean;
  115467. /**
  115468. * Enables specular anti aliasing in the PBR shader.
  115469. * It will both interacts on the Geometry for analytical and IBL lighting.
  115470. * It also prefilter the roughness map based on the bump values.
  115471. */
  115472. protected _enableSpecularAntiAliasing: boolean;
  115473. /**
  115474. * Default configuration related to image processing available in the PBR Material.
  115475. */
  115476. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115477. /**
  115478. * Keep track of the image processing observer to allow dispose and replace.
  115479. */
  115480. private _imageProcessingObserver;
  115481. /**
  115482. * Attaches a new image processing configuration to the PBR Material.
  115483. * @param configuration
  115484. */
  115485. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115486. /**
  115487. * Stores the available render targets.
  115488. */
  115489. private _renderTargets;
  115490. /**
  115491. * Sets the global ambient color for the material used in lighting calculations.
  115492. */
  115493. private _globalAmbientColor;
  115494. /**
  115495. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115496. */
  115497. private _useLogarithmicDepth;
  115498. /**
  115499. * If set to true, no lighting calculations will be applied.
  115500. */
  115501. private _unlit;
  115502. private _debugMode;
  115503. /**
  115504. * @hidden
  115505. * This is reserved for the inspector.
  115506. * Defines the material debug mode.
  115507. * It helps seeing only some components of the material while troubleshooting.
  115508. */
  115509. debugMode: number;
  115510. /**
  115511. * @hidden
  115512. * This is reserved for the inspector.
  115513. * Specify from where on screen the debug mode should start.
  115514. * The value goes from -1 (full screen) to 1 (not visible)
  115515. * It helps with side by side comparison against the final render
  115516. * This defaults to -1
  115517. */
  115518. private debugLimit;
  115519. /**
  115520. * @hidden
  115521. * This is reserved for the inspector.
  115522. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115523. * You can use the factor to better multiply the final value.
  115524. */
  115525. private debugFactor;
  115526. /**
  115527. * Defines the clear coat layer parameters for the material.
  115528. */
  115529. readonly clearCoat: PBRClearCoatConfiguration;
  115530. /**
  115531. * Defines the anisotropic parameters for the material.
  115532. */
  115533. readonly anisotropy: PBRAnisotropicConfiguration;
  115534. /**
  115535. * Defines the BRDF parameters for the material.
  115536. */
  115537. readonly brdf: PBRBRDFConfiguration;
  115538. /**
  115539. * Defines the Sheen parameters for the material.
  115540. */
  115541. readonly sheen: PBRSheenConfiguration;
  115542. /**
  115543. * Defines the SubSurface parameters for the material.
  115544. */
  115545. readonly subSurface: PBRSubSurfaceConfiguration;
  115546. /**
  115547. * Custom callback helping to override the default shader used in the material.
  115548. */
  115549. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115550. protected _rebuildInParallel: boolean;
  115551. /**
  115552. * Instantiates a new PBRMaterial instance.
  115553. *
  115554. * @param name The material name
  115555. * @param scene The scene the material will be use in.
  115556. */
  115557. constructor(name: string, scene: Scene);
  115558. /**
  115559. * Gets a boolean indicating that current material needs to register RTT
  115560. */
  115561. readonly hasRenderTargetTextures: boolean;
  115562. /**
  115563. * Gets the name of the material class.
  115564. */
  115565. getClassName(): string;
  115566. /**
  115567. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115568. */
  115569. /**
  115570. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115571. */
  115572. useLogarithmicDepth: boolean;
  115573. /**
  115574. * Gets the current transparency mode.
  115575. */
  115576. /**
  115577. * Sets the transparency mode of the material.
  115578. *
  115579. * | Value | Type | Description |
  115580. * | ----- | ----------------------------------- | ----------- |
  115581. * | 0 | OPAQUE | |
  115582. * | 1 | ALPHATEST | |
  115583. * | 2 | ALPHABLEND | |
  115584. * | 3 | ALPHATESTANDBLEND | |
  115585. *
  115586. */
  115587. transparencyMode: Nullable<number>;
  115588. /**
  115589. * Returns true if alpha blending should be disabled.
  115590. */
  115591. private readonly _disableAlphaBlending;
  115592. /**
  115593. * Specifies whether or not this material should be rendered in alpha blend mode.
  115594. */
  115595. needAlphaBlending(): boolean;
  115596. /**
  115597. * Specifies if the mesh will require alpha blending.
  115598. * @param mesh - BJS mesh.
  115599. */
  115600. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115601. /**
  115602. * Specifies whether or not this material should be rendered in alpha test mode.
  115603. */
  115604. needAlphaTesting(): boolean;
  115605. /**
  115606. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115607. */
  115608. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115609. /**
  115610. * Gets the texture used for the alpha test.
  115611. */
  115612. getAlphaTestTexture(): Nullable<BaseTexture>;
  115613. /**
  115614. * Specifies that the submesh is ready to be used.
  115615. * @param mesh - BJS mesh.
  115616. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115617. * @param useInstances - Specifies that instances should be used.
  115618. * @returns - boolean indicating that the submesh is ready or not.
  115619. */
  115620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115621. /**
  115622. * Specifies if the material uses metallic roughness workflow.
  115623. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115624. */
  115625. isMetallicWorkflow(): boolean;
  115626. private _prepareEffect;
  115627. private _prepareDefines;
  115628. /**
  115629. * Force shader compilation
  115630. */
  115631. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  115632. /**
  115633. * Initializes the uniform buffer layout for the shader.
  115634. */
  115635. buildUniformLayout(): void;
  115636. /**
  115637. * Unbinds the material from the mesh
  115638. */
  115639. unbind(): void;
  115640. /**
  115641. * Binds the submesh data.
  115642. * @param world - The world matrix.
  115643. * @param mesh - The BJS mesh.
  115644. * @param subMesh - A submesh of the BJS mesh.
  115645. */
  115646. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115647. /**
  115648. * Returns the animatable textures.
  115649. * @returns - Array of animatable textures.
  115650. */
  115651. getAnimatables(): IAnimatable[];
  115652. /**
  115653. * Returns the texture used for reflections.
  115654. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115655. */
  115656. private _getReflectionTexture;
  115657. /**
  115658. * Returns an array of the actively used textures.
  115659. * @returns - Array of BaseTextures
  115660. */
  115661. getActiveTextures(): BaseTexture[];
  115662. /**
  115663. * Checks to see if a texture is used in the material.
  115664. * @param texture - Base texture to use.
  115665. * @returns - Boolean specifying if a texture is used in the material.
  115666. */
  115667. hasTexture(texture: BaseTexture): boolean;
  115668. /**
  115669. * Disposes the resources of the material.
  115670. * @param forceDisposeEffect - Forces the disposal of effects.
  115671. * @param forceDisposeTextures - Forces the disposal of all textures.
  115672. */
  115673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115674. }
  115675. }
  115676. declare module BABYLON {
  115677. /**
  115678. * The Physically based material of BJS.
  115679. *
  115680. * This offers the main features of a standard PBR material.
  115681. * For more information, please refer to the documentation :
  115682. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115683. */
  115684. export class PBRMaterial extends PBRBaseMaterial {
  115685. /**
  115686. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115687. */
  115688. static readonly PBRMATERIAL_OPAQUE: number;
  115689. /**
  115690. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115691. */
  115692. static readonly PBRMATERIAL_ALPHATEST: number;
  115693. /**
  115694. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115695. */
  115696. static readonly PBRMATERIAL_ALPHABLEND: number;
  115697. /**
  115698. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115699. * They are also discarded below the alpha cutoff threshold to improve performances.
  115700. */
  115701. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115702. /**
  115703. * Defines the default value of how much AO map is occluding the analytical lights
  115704. * (point spot...).
  115705. */
  115706. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115707. /**
  115708. * Intensity of the direct lights e.g. the four lights available in your scene.
  115709. * This impacts both the direct diffuse and specular highlights.
  115710. */
  115711. directIntensity: number;
  115712. /**
  115713. * Intensity of the emissive part of the material.
  115714. * This helps controlling the emissive effect without modifying the emissive color.
  115715. */
  115716. emissiveIntensity: number;
  115717. /**
  115718. * Intensity of the environment e.g. how much the environment will light the object
  115719. * either through harmonics for rough material or through the refelction for shiny ones.
  115720. */
  115721. environmentIntensity: number;
  115722. /**
  115723. * This is a special control allowing the reduction of the specular highlights coming from the
  115724. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115725. */
  115726. specularIntensity: number;
  115727. /**
  115728. * Debug Control allowing disabling the bump map on this material.
  115729. */
  115730. disableBumpMap: boolean;
  115731. /**
  115732. * AKA Diffuse Texture in standard nomenclature.
  115733. */
  115734. albedoTexture: BaseTexture;
  115735. /**
  115736. * AKA Occlusion Texture in other nomenclature.
  115737. */
  115738. ambientTexture: BaseTexture;
  115739. /**
  115740. * AKA Occlusion Texture Intensity in other nomenclature.
  115741. */
  115742. ambientTextureStrength: number;
  115743. /**
  115744. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115745. * 1 means it completely occludes it
  115746. * 0 mean it has no impact
  115747. */
  115748. ambientTextureImpactOnAnalyticalLights: number;
  115749. /**
  115750. * Stores the alpha values in a texture.
  115751. */
  115752. opacityTexture: BaseTexture;
  115753. /**
  115754. * Stores the reflection values in a texture.
  115755. */
  115756. reflectionTexture: Nullable<BaseTexture>;
  115757. /**
  115758. * Stores the emissive values in a texture.
  115759. */
  115760. emissiveTexture: BaseTexture;
  115761. /**
  115762. * AKA Specular texture in other nomenclature.
  115763. */
  115764. reflectivityTexture: BaseTexture;
  115765. /**
  115766. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115767. */
  115768. metallicTexture: BaseTexture;
  115769. /**
  115770. * Specifies the metallic scalar of the metallic/roughness workflow.
  115771. * Can also be used to scale the metalness values of the metallic texture.
  115772. */
  115773. metallic: Nullable<number>;
  115774. /**
  115775. * Specifies the roughness scalar of the metallic/roughness workflow.
  115776. * Can also be used to scale the roughness values of the metallic texture.
  115777. */
  115778. roughness: Nullable<number>;
  115779. /**
  115780. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115781. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115782. */
  115783. microSurfaceTexture: BaseTexture;
  115784. /**
  115785. * Stores surface normal data used to displace a mesh in a texture.
  115786. */
  115787. bumpTexture: BaseTexture;
  115788. /**
  115789. * Stores the pre-calculated light information of a mesh in a texture.
  115790. */
  115791. lightmapTexture: BaseTexture;
  115792. /**
  115793. * Stores the refracted light information in a texture.
  115794. */
  115795. refractionTexture: Nullable<BaseTexture>;
  115796. /**
  115797. * The color of a material in ambient lighting.
  115798. */
  115799. ambientColor: Color3;
  115800. /**
  115801. * AKA Diffuse Color in other nomenclature.
  115802. */
  115803. albedoColor: Color3;
  115804. /**
  115805. * AKA Specular Color in other nomenclature.
  115806. */
  115807. reflectivityColor: Color3;
  115808. /**
  115809. * The color reflected from the material.
  115810. */
  115811. reflectionColor: Color3;
  115812. /**
  115813. * The color emitted from the material.
  115814. */
  115815. emissiveColor: Color3;
  115816. /**
  115817. * AKA Glossiness in other nomenclature.
  115818. */
  115819. microSurface: number;
  115820. /**
  115821. * source material index of refraction (IOR)' / 'destination material IOR.
  115822. */
  115823. indexOfRefraction: number;
  115824. /**
  115825. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115826. */
  115827. invertRefractionY: boolean;
  115828. /**
  115829. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115830. * Materials half opaque for instance using refraction could benefit from this control.
  115831. */
  115832. linkRefractionWithTransparency: boolean;
  115833. /**
  115834. * If true, the light map contains occlusion information instead of lighting info.
  115835. */
  115836. useLightmapAsShadowmap: boolean;
  115837. /**
  115838. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115839. */
  115840. useAlphaFromAlbedoTexture: boolean;
  115841. /**
  115842. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115843. */
  115844. forceAlphaTest: boolean;
  115845. /**
  115846. * Defines the alpha limits in alpha test mode.
  115847. */
  115848. alphaCutOff: number;
  115849. /**
  115850. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115851. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115852. */
  115853. useSpecularOverAlpha: boolean;
  115854. /**
  115855. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115856. */
  115857. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115858. /**
  115859. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115860. */
  115861. useRoughnessFromMetallicTextureAlpha: boolean;
  115862. /**
  115863. * Specifies if the metallic texture contains the roughness information in its green channel.
  115864. */
  115865. useRoughnessFromMetallicTextureGreen: boolean;
  115866. /**
  115867. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115868. */
  115869. useMetallnessFromMetallicTextureBlue: boolean;
  115870. /**
  115871. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115872. */
  115873. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115874. /**
  115875. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115876. */
  115877. useAmbientInGrayScale: boolean;
  115878. /**
  115879. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115880. * The material will try to infer what glossiness each pixel should be.
  115881. */
  115882. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115883. /**
  115884. * BJS is using an harcoded light falloff based on a manually sets up range.
  115885. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115886. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115887. */
  115888. /**
  115889. * BJS is using an harcoded light falloff based on a manually sets up range.
  115890. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115891. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115892. */
  115893. usePhysicalLightFalloff: boolean;
  115894. /**
  115895. * In order to support the falloff compatibility with gltf, a special mode has been added
  115896. * to reproduce the gltf light falloff.
  115897. */
  115898. /**
  115899. * In order to support the falloff compatibility with gltf, a special mode has been added
  115900. * to reproduce the gltf light falloff.
  115901. */
  115902. useGLTFLightFalloff: boolean;
  115903. /**
  115904. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115905. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115906. */
  115907. useRadianceOverAlpha: boolean;
  115908. /**
  115909. * Allows using an object space normal map (instead of tangent space).
  115910. */
  115911. useObjectSpaceNormalMap: boolean;
  115912. /**
  115913. * Allows using the bump map in parallax mode.
  115914. */
  115915. useParallax: boolean;
  115916. /**
  115917. * Allows using the bump map in parallax occlusion mode.
  115918. */
  115919. useParallaxOcclusion: boolean;
  115920. /**
  115921. * Controls the scale bias of the parallax mode.
  115922. */
  115923. parallaxScaleBias: number;
  115924. /**
  115925. * If sets to true, disables all the lights affecting the material.
  115926. */
  115927. disableLighting: boolean;
  115928. /**
  115929. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115930. */
  115931. forceIrradianceInFragment: boolean;
  115932. /**
  115933. * Number of Simultaneous lights allowed on the material.
  115934. */
  115935. maxSimultaneousLights: number;
  115936. /**
  115937. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115938. */
  115939. invertNormalMapX: boolean;
  115940. /**
  115941. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115942. */
  115943. invertNormalMapY: boolean;
  115944. /**
  115945. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115946. */
  115947. twoSidedLighting: boolean;
  115948. /**
  115949. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115950. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115951. */
  115952. useAlphaFresnel: boolean;
  115953. /**
  115954. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115955. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115956. */
  115957. useLinearAlphaFresnel: boolean;
  115958. /**
  115959. * Let user defines the brdf lookup texture used for IBL.
  115960. * A default 8bit version is embedded but you could point at :
  115961. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115962. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115963. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115964. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115965. */
  115966. environmentBRDFTexture: Nullable<BaseTexture>;
  115967. /**
  115968. * Force normal to face away from face.
  115969. */
  115970. forceNormalForward: boolean;
  115971. /**
  115972. * Enables specular anti aliasing in the PBR shader.
  115973. * It will both interacts on the Geometry for analytical and IBL lighting.
  115974. * It also prefilter the roughness map based on the bump values.
  115975. */
  115976. enableSpecularAntiAliasing: boolean;
  115977. /**
  115978. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115979. * makes the reflect vector face the model (under horizon).
  115980. */
  115981. useHorizonOcclusion: boolean;
  115982. /**
  115983. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115984. * too much the area relying on ambient texture to define their ambient occlusion.
  115985. */
  115986. useRadianceOcclusion: boolean;
  115987. /**
  115988. * If set to true, no lighting calculations will be applied.
  115989. */
  115990. unlit: boolean;
  115991. /**
  115992. * Gets the image processing configuration used either in this material.
  115993. */
  115994. /**
  115995. * Sets the Default image processing configuration used either in the this material.
  115996. *
  115997. * If sets to null, the scene one is in use.
  115998. */
  115999. imageProcessingConfiguration: ImageProcessingConfiguration;
  116000. /**
  116001. * Gets wether the color curves effect is enabled.
  116002. */
  116003. /**
  116004. * Sets wether the color curves effect is enabled.
  116005. */
  116006. cameraColorCurvesEnabled: boolean;
  116007. /**
  116008. * Gets wether the color grading effect is enabled.
  116009. */
  116010. /**
  116011. * Gets wether the color grading effect is enabled.
  116012. */
  116013. cameraColorGradingEnabled: boolean;
  116014. /**
  116015. * Gets wether tonemapping is enabled or not.
  116016. */
  116017. /**
  116018. * Sets wether tonemapping is enabled or not
  116019. */
  116020. cameraToneMappingEnabled: boolean;
  116021. /**
  116022. * The camera exposure used on this material.
  116023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116024. * This corresponds to a photographic exposure.
  116025. */
  116026. /**
  116027. * The camera exposure used on this material.
  116028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116029. * This corresponds to a photographic exposure.
  116030. */
  116031. cameraExposure: number;
  116032. /**
  116033. * Gets The camera contrast used on this material.
  116034. */
  116035. /**
  116036. * Sets The camera contrast used on this material.
  116037. */
  116038. cameraContrast: number;
  116039. /**
  116040. * Gets the Color Grading 2D Lookup Texture.
  116041. */
  116042. /**
  116043. * Sets the Color Grading 2D Lookup Texture.
  116044. */
  116045. cameraColorGradingTexture: Nullable<BaseTexture>;
  116046. /**
  116047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116049. * 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;
  116050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116051. */
  116052. /**
  116053. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116054. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116055. * 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;
  116056. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116057. */
  116058. cameraColorCurves: Nullable<ColorCurves>;
  116059. /**
  116060. * Instantiates a new PBRMaterial instance.
  116061. *
  116062. * @param name The material name
  116063. * @param scene The scene the material will be use in.
  116064. */
  116065. constructor(name: string, scene: Scene);
  116066. /**
  116067. * Returns the name of this material class.
  116068. */
  116069. getClassName(): string;
  116070. /**
  116071. * Makes a duplicate of the current material.
  116072. * @param name - name to use for the new material.
  116073. */
  116074. clone(name: string): PBRMaterial;
  116075. /**
  116076. * Serializes this PBR Material.
  116077. * @returns - An object with the serialized material.
  116078. */
  116079. serialize(): any;
  116080. /**
  116081. * Parses a PBR Material from a serialized object.
  116082. * @param source - Serialized object.
  116083. * @param scene - BJS scene instance.
  116084. * @param rootUrl - url for the scene object
  116085. * @returns - PBRMaterial
  116086. */
  116087. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  116088. }
  116089. }
  116090. declare module BABYLON {
  116091. /**
  116092. * Direct draw surface info
  116093. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  116094. */
  116095. export interface DDSInfo {
  116096. /**
  116097. * Width of the texture
  116098. */
  116099. width: number;
  116100. /**
  116101. * Width of the texture
  116102. */
  116103. height: number;
  116104. /**
  116105. * Number of Mipmaps for the texture
  116106. * @see https://en.wikipedia.org/wiki/Mipmap
  116107. */
  116108. mipmapCount: number;
  116109. /**
  116110. * If the textures format is a known fourCC format
  116111. * @see https://www.fourcc.org/
  116112. */
  116113. isFourCC: boolean;
  116114. /**
  116115. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  116116. */
  116117. isRGB: boolean;
  116118. /**
  116119. * If the texture is a lumincance format
  116120. */
  116121. isLuminance: boolean;
  116122. /**
  116123. * If this is a cube texture
  116124. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  116125. */
  116126. isCube: boolean;
  116127. /**
  116128. * If the texture is a compressed format eg. FOURCC_DXT1
  116129. */
  116130. isCompressed: boolean;
  116131. /**
  116132. * The dxgiFormat of the texture
  116133. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  116134. */
  116135. dxgiFormat: number;
  116136. /**
  116137. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  116138. */
  116139. textureType: number;
  116140. /**
  116141. * Sphericle polynomial created for the dds texture
  116142. */
  116143. sphericalPolynomial?: SphericalPolynomial;
  116144. }
  116145. /**
  116146. * Class used to provide DDS decompression tools
  116147. */
  116148. export class DDSTools {
  116149. /**
  116150. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  116151. */
  116152. static StoreLODInAlphaChannel: boolean;
  116153. /**
  116154. * Gets DDS information from an array buffer
  116155. * @param arrayBuffer defines the array buffer to read data from
  116156. * @returns the DDS information
  116157. */
  116158. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116159. private static _FloatView;
  116160. private static _Int32View;
  116161. private static _ToHalfFloat;
  116162. private static _FromHalfFloat;
  116163. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116164. private static _GetHalfFloatRGBAArrayBuffer;
  116165. private static _GetFloatRGBAArrayBuffer;
  116166. private static _GetFloatAsUIntRGBAArrayBuffer;
  116167. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116168. private static _GetRGBAArrayBuffer;
  116169. private static _ExtractLongWordOrder;
  116170. private static _GetRGBArrayBuffer;
  116171. private static _GetLuminanceArrayBuffer;
  116172. /**
  116173. * Uploads DDS Levels to a Babylon Texture
  116174. * @hidden
  116175. */
  116176. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116177. }
  116178. interface ThinEngine {
  116179. /**
  116180. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116181. * @param rootUrl defines the url where the file to load is located
  116182. * @param scene defines the current scene
  116183. * @param lodScale defines scale to apply to the mip map selection
  116184. * @param lodOffset defines offset to apply to the mip map selection
  116185. * @param onLoad defines an optional callback raised when the texture is loaded
  116186. * @param onError defines an optional callback raised if there is an issue to load the texture
  116187. * @param format defines the format of the data
  116188. * @param forcedExtension defines the extension to use to pick the right loader
  116189. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116190. * @returns the cube texture as an InternalTexture
  116191. */
  116192. 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;
  116193. }
  116194. }
  116195. declare module BABYLON {
  116196. /**
  116197. * Implementation of the DDS Texture Loader.
  116198. * @hidden
  116199. */
  116200. export class _DDSTextureLoader implements IInternalTextureLoader {
  116201. /**
  116202. * Defines wether the loader supports cascade loading the different faces.
  116203. */
  116204. readonly supportCascades: boolean;
  116205. /**
  116206. * This returns if the loader support the current file information.
  116207. * @param extension defines the file extension of the file being loaded
  116208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116209. * @param fallback defines the fallback internal texture if any
  116210. * @param isBase64 defines whether the texture is encoded as a base64
  116211. * @param isBuffer defines whether the texture data are stored as a buffer
  116212. * @returns true if the loader can load the specified file
  116213. */
  116214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116215. /**
  116216. * Transform the url before loading if required.
  116217. * @param rootUrl the url of the texture
  116218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116219. * @returns the transformed texture
  116220. */
  116221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116222. /**
  116223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116224. * @param rootUrl the url of the texture
  116225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116226. * @returns the fallback texture
  116227. */
  116228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116229. /**
  116230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116231. * @param data contains the texture data
  116232. * @param texture defines the BabylonJS internal texture
  116233. * @param createPolynomials will be true if polynomials have been requested
  116234. * @param onLoad defines the callback to trigger once the texture is ready
  116235. * @param onError defines the callback to trigger in case of error
  116236. */
  116237. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116238. /**
  116239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116240. * @param data contains the texture data
  116241. * @param texture defines the BabylonJS internal texture
  116242. * @param callback defines the method to call once ready to upload
  116243. */
  116244. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116245. }
  116246. }
  116247. declare module BABYLON {
  116248. /**
  116249. * Implementation of the ENV Texture Loader.
  116250. * @hidden
  116251. */
  116252. export class _ENVTextureLoader implements IInternalTextureLoader {
  116253. /**
  116254. * Defines wether the loader supports cascade loading the different faces.
  116255. */
  116256. readonly supportCascades: boolean;
  116257. /**
  116258. * This returns if the loader support the current file information.
  116259. * @param extension defines the file extension of the file being loaded
  116260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116261. * @param fallback defines the fallback internal texture if any
  116262. * @param isBase64 defines whether the texture is encoded as a base64
  116263. * @param isBuffer defines whether the texture data are stored as a buffer
  116264. * @returns true if the loader can load the specified file
  116265. */
  116266. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116267. /**
  116268. * Transform the url before loading if required.
  116269. * @param rootUrl the url of the texture
  116270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116271. * @returns the transformed texture
  116272. */
  116273. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116274. /**
  116275. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116276. * @param rootUrl the url of the texture
  116277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116278. * @returns the fallback texture
  116279. */
  116280. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116281. /**
  116282. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116283. * @param data contains the texture data
  116284. * @param texture defines the BabylonJS internal texture
  116285. * @param createPolynomials will be true if polynomials have been requested
  116286. * @param onLoad defines the callback to trigger once the texture is ready
  116287. * @param onError defines the callback to trigger in case of error
  116288. */
  116289. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116290. /**
  116291. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116292. * @param data contains the texture data
  116293. * @param texture defines the BabylonJS internal texture
  116294. * @param callback defines the method to call once ready to upload
  116295. */
  116296. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116297. }
  116298. }
  116299. declare module BABYLON {
  116300. /**
  116301. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  116302. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  116303. */
  116304. export class KhronosTextureContainer {
  116305. /** contents of the KTX container file */
  116306. arrayBuffer: any;
  116307. private static HEADER_LEN;
  116308. private static COMPRESSED_2D;
  116309. private static COMPRESSED_3D;
  116310. private static TEX_2D;
  116311. private static TEX_3D;
  116312. /**
  116313. * Gets the openGL type
  116314. */
  116315. glType: number;
  116316. /**
  116317. * Gets the openGL type size
  116318. */
  116319. glTypeSize: number;
  116320. /**
  116321. * Gets the openGL format
  116322. */
  116323. glFormat: number;
  116324. /**
  116325. * Gets the openGL internal format
  116326. */
  116327. glInternalFormat: number;
  116328. /**
  116329. * Gets the base internal format
  116330. */
  116331. glBaseInternalFormat: number;
  116332. /**
  116333. * Gets image width in pixel
  116334. */
  116335. pixelWidth: number;
  116336. /**
  116337. * Gets image height in pixel
  116338. */
  116339. pixelHeight: number;
  116340. /**
  116341. * Gets image depth in pixels
  116342. */
  116343. pixelDepth: number;
  116344. /**
  116345. * Gets the number of array elements
  116346. */
  116347. numberOfArrayElements: number;
  116348. /**
  116349. * Gets the number of faces
  116350. */
  116351. numberOfFaces: number;
  116352. /**
  116353. * Gets the number of mipmap levels
  116354. */
  116355. numberOfMipmapLevels: number;
  116356. /**
  116357. * Gets the bytes of key value data
  116358. */
  116359. bytesOfKeyValueData: number;
  116360. /**
  116361. * Gets the load type
  116362. */
  116363. loadType: number;
  116364. /**
  116365. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116366. */
  116367. isInvalid: boolean;
  116368. /**
  116369. * Creates a new KhronosTextureContainer
  116370. * @param arrayBuffer contents of the KTX container file
  116371. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116372. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116373. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116374. */
  116375. constructor(
  116376. /** contents of the KTX container file */
  116377. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116378. /**
  116379. * Uploads KTX content to a Babylon Texture.
  116380. * It is assumed that the texture has already been created & is currently bound
  116381. * @hidden
  116382. */
  116383. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116384. private _upload2DCompressedLevels;
  116385. }
  116386. }
  116387. declare module BABYLON {
  116388. /**
  116389. * Implementation of the KTX Texture Loader.
  116390. * @hidden
  116391. */
  116392. export class _KTXTextureLoader implements IInternalTextureLoader {
  116393. /**
  116394. * Defines wether the loader supports cascade loading the different faces.
  116395. */
  116396. readonly supportCascades: boolean;
  116397. /**
  116398. * This returns if the loader support the current file information.
  116399. * @param extension defines the file extension of the file being loaded
  116400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116401. * @param fallback defines the fallback internal texture if any
  116402. * @param isBase64 defines whether the texture is encoded as a base64
  116403. * @param isBuffer defines whether the texture data are stored as a buffer
  116404. * @returns true if the loader can load the specified file
  116405. */
  116406. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116407. /**
  116408. * Transform the url before loading if required.
  116409. * @param rootUrl the url of the texture
  116410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116411. * @returns the transformed texture
  116412. */
  116413. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116414. /**
  116415. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116416. * @param rootUrl the url of the texture
  116417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116418. * @returns the fallback texture
  116419. */
  116420. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116421. /**
  116422. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116423. * @param data contains the texture data
  116424. * @param texture defines the BabylonJS internal texture
  116425. * @param createPolynomials will be true if polynomials have been requested
  116426. * @param onLoad defines the callback to trigger once the texture is ready
  116427. * @param onError defines the callback to trigger in case of error
  116428. */
  116429. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116430. /**
  116431. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116432. * @param data contains the texture data
  116433. * @param texture defines the BabylonJS internal texture
  116434. * @param callback defines the method to call once ready to upload
  116435. */
  116436. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116437. }
  116438. }
  116439. declare module BABYLON {
  116440. /**
  116441. * Options for the default xr helper
  116442. */
  116443. export class WebXRDefaultExperienceOptions {
  116444. /**
  116445. * Floor meshes that should be used for teleporting
  116446. */
  116447. floorMeshes: Array<AbstractMesh>;
  116448. }
  116449. /**
  116450. * Default experience which provides a similar setup to the previous webVRExperience
  116451. */
  116452. export class WebXRDefaultExperience {
  116453. /**
  116454. * Base experience
  116455. */
  116456. baseExperience: WebXRExperienceHelper;
  116457. /**
  116458. * Input experience extension
  116459. */
  116460. input: WebXRInput;
  116461. /**
  116462. * Loads the controller models
  116463. */
  116464. controllerModelLoader: WebXRControllerModelLoader;
  116465. /**
  116466. * Enables laser pointer and selection
  116467. */
  116468. pointerSelection: WebXRControllerPointerSelection;
  116469. /**
  116470. * Enables teleportation
  116471. */
  116472. teleportation: WebXRControllerTeleportation;
  116473. /**
  116474. * Enables ui for enetering/exiting xr
  116475. */
  116476. enterExitUI: WebXREnterExitUI;
  116477. /**
  116478. * Default output canvas xr should render to
  116479. */
  116480. outputCanvas: WebXRManagedOutputCanvas;
  116481. /**
  116482. * Creates the default xr experience
  116483. * @param scene scene
  116484. * @param options options for basic configuration
  116485. * @returns resulting WebXRDefaultExperience
  116486. */
  116487. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116488. private constructor();
  116489. /**
  116490. * DIsposes of the experience helper
  116491. */
  116492. dispose(): void;
  116493. }
  116494. }
  116495. declare module BABYLON {
  116496. /** @hidden */
  116497. export var _forceSceneHelpersToBundle: boolean;
  116498. interface Scene {
  116499. /**
  116500. * Creates a default light for the scene.
  116501. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116502. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116503. */
  116504. createDefaultLight(replace?: boolean): void;
  116505. /**
  116506. * Creates a default camera for the scene.
  116507. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116508. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116509. * @param replace has default false, when true replaces the active camera in the scene
  116510. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116511. */
  116512. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116513. /**
  116514. * Creates a default camera and a default light.
  116515. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116516. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116517. * @param replace has the default false, when true replaces the active camera/light in the scene
  116518. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116519. */
  116520. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116521. /**
  116522. * Creates a new sky box
  116523. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116524. * @param environmentTexture defines the texture to use as environment texture
  116525. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116526. * @param scale defines the overall scale of the skybox
  116527. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116528. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116529. * @returns a new mesh holding the sky box
  116530. */
  116531. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116532. /**
  116533. * Creates a new environment
  116534. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116535. * @param options defines the options you can use to configure the environment
  116536. * @returns the new EnvironmentHelper
  116537. */
  116538. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116539. /**
  116540. * Creates a new VREXperienceHelper
  116541. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116542. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116543. * @returns a new VREXperienceHelper
  116544. */
  116545. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116546. /**
  116547. * Creates a new WebXRDefaultExperience
  116548. * @see http://doc.babylonjs.com/how_to/webxr
  116549. * @param options experience options
  116550. * @returns a promise for a new WebXRDefaultExperience
  116551. */
  116552. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116553. }
  116554. }
  116555. declare module BABYLON {
  116556. /**
  116557. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116558. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116559. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116560. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116561. */
  116562. export class VideoDome extends TransformNode {
  116563. /**
  116564. * Define the video source as a Monoscopic panoramic 360 video.
  116565. */
  116566. static readonly MODE_MONOSCOPIC: number;
  116567. /**
  116568. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116569. */
  116570. static readonly MODE_TOPBOTTOM: number;
  116571. /**
  116572. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116573. */
  116574. static readonly MODE_SIDEBYSIDE: number;
  116575. private _halfDome;
  116576. private _useDirectMapping;
  116577. /**
  116578. * The video texture being displayed on the sphere
  116579. */
  116580. protected _videoTexture: VideoTexture;
  116581. /**
  116582. * Gets the video texture being displayed on the sphere
  116583. */
  116584. readonly videoTexture: VideoTexture;
  116585. /**
  116586. * The skybox material
  116587. */
  116588. protected _material: BackgroundMaterial;
  116589. /**
  116590. * The surface used for the skybox
  116591. */
  116592. protected _mesh: Mesh;
  116593. /**
  116594. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116595. */
  116596. private _halfDomeMask;
  116597. /**
  116598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116599. * Also see the options.resolution property.
  116600. */
  116601. fovMultiplier: number;
  116602. private _videoMode;
  116603. /**
  116604. * Gets or set the current video mode for the video. It can be:
  116605. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116606. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116607. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116608. */
  116609. videoMode: number;
  116610. /**
  116611. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116612. *
  116613. */
  116614. /**
  116615. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116616. */
  116617. halfDome: boolean;
  116618. /**
  116619. * Oberserver used in Stereoscopic VR Mode.
  116620. */
  116621. private _onBeforeCameraRenderObserver;
  116622. /**
  116623. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116624. * @param name Element's name, child elements will append suffixes for their own names.
  116625. * @param urlsOrVideo defines the url(s) or the video element to use
  116626. * @param options An object containing optional or exposed sub element properties
  116627. */
  116628. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116629. resolution?: number;
  116630. clickToPlay?: boolean;
  116631. autoPlay?: boolean;
  116632. loop?: boolean;
  116633. size?: number;
  116634. poster?: string;
  116635. faceForward?: boolean;
  116636. useDirectMapping?: boolean;
  116637. halfDomeMode?: boolean;
  116638. }, scene: Scene);
  116639. private _changeVideoMode;
  116640. /**
  116641. * Releases resources associated with this node.
  116642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116644. */
  116645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116646. }
  116647. }
  116648. declare module BABYLON {
  116649. /**
  116650. * This class can be used to get instrumentation data from a Babylon engine
  116651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116652. */
  116653. export class EngineInstrumentation implements IDisposable {
  116654. /**
  116655. * Define the instrumented engine.
  116656. */
  116657. engine: Engine;
  116658. private _captureGPUFrameTime;
  116659. private _gpuFrameTimeToken;
  116660. private _gpuFrameTime;
  116661. private _captureShaderCompilationTime;
  116662. private _shaderCompilationTime;
  116663. private _onBeginFrameObserver;
  116664. private _onEndFrameObserver;
  116665. private _onBeforeShaderCompilationObserver;
  116666. private _onAfterShaderCompilationObserver;
  116667. /**
  116668. * Gets the perf counter used for GPU frame time
  116669. */
  116670. readonly gpuFrameTimeCounter: PerfCounter;
  116671. /**
  116672. * Gets the GPU frame time capture status
  116673. */
  116674. /**
  116675. * Enable or disable the GPU frame time capture
  116676. */
  116677. captureGPUFrameTime: boolean;
  116678. /**
  116679. * Gets the perf counter used for shader compilation time
  116680. */
  116681. readonly shaderCompilationTimeCounter: PerfCounter;
  116682. /**
  116683. * Gets the shader compilation time capture status
  116684. */
  116685. /**
  116686. * Enable or disable the shader compilation time capture
  116687. */
  116688. captureShaderCompilationTime: boolean;
  116689. /**
  116690. * Instantiates a new engine instrumentation.
  116691. * This class can be used to get instrumentation data from a Babylon engine
  116692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116693. * @param engine Defines the engine to instrument
  116694. */
  116695. constructor(
  116696. /**
  116697. * Define the instrumented engine.
  116698. */
  116699. engine: Engine);
  116700. /**
  116701. * Dispose and release associated resources.
  116702. */
  116703. dispose(): void;
  116704. }
  116705. }
  116706. declare module BABYLON {
  116707. /**
  116708. * This class can be used to get instrumentation data from a Babylon engine
  116709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116710. */
  116711. export class SceneInstrumentation implements IDisposable {
  116712. /**
  116713. * Defines the scene to instrument
  116714. */
  116715. scene: Scene;
  116716. private _captureActiveMeshesEvaluationTime;
  116717. private _activeMeshesEvaluationTime;
  116718. private _captureRenderTargetsRenderTime;
  116719. private _renderTargetsRenderTime;
  116720. private _captureFrameTime;
  116721. private _frameTime;
  116722. private _captureRenderTime;
  116723. private _renderTime;
  116724. private _captureInterFrameTime;
  116725. private _interFrameTime;
  116726. private _captureParticlesRenderTime;
  116727. private _particlesRenderTime;
  116728. private _captureSpritesRenderTime;
  116729. private _spritesRenderTime;
  116730. private _capturePhysicsTime;
  116731. private _physicsTime;
  116732. private _captureAnimationsTime;
  116733. private _animationsTime;
  116734. private _captureCameraRenderTime;
  116735. private _cameraRenderTime;
  116736. private _onBeforeActiveMeshesEvaluationObserver;
  116737. private _onAfterActiveMeshesEvaluationObserver;
  116738. private _onBeforeRenderTargetsRenderObserver;
  116739. private _onAfterRenderTargetsRenderObserver;
  116740. private _onAfterRenderObserver;
  116741. private _onBeforeDrawPhaseObserver;
  116742. private _onAfterDrawPhaseObserver;
  116743. private _onBeforeAnimationsObserver;
  116744. private _onBeforeParticlesRenderingObserver;
  116745. private _onAfterParticlesRenderingObserver;
  116746. private _onBeforeSpritesRenderingObserver;
  116747. private _onAfterSpritesRenderingObserver;
  116748. private _onBeforePhysicsObserver;
  116749. private _onAfterPhysicsObserver;
  116750. private _onAfterAnimationsObserver;
  116751. private _onBeforeCameraRenderObserver;
  116752. private _onAfterCameraRenderObserver;
  116753. /**
  116754. * Gets the perf counter used for active meshes evaluation time
  116755. */
  116756. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  116757. /**
  116758. * Gets the active meshes evaluation time capture status
  116759. */
  116760. /**
  116761. * Enable or disable the active meshes evaluation time capture
  116762. */
  116763. captureActiveMeshesEvaluationTime: boolean;
  116764. /**
  116765. * Gets the perf counter used for render targets render time
  116766. */
  116767. readonly renderTargetsRenderTimeCounter: PerfCounter;
  116768. /**
  116769. * Gets the render targets render time capture status
  116770. */
  116771. /**
  116772. * Enable or disable the render targets render time capture
  116773. */
  116774. captureRenderTargetsRenderTime: boolean;
  116775. /**
  116776. * Gets the perf counter used for particles render time
  116777. */
  116778. readonly particlesRenderTimeCounter: PerfCounter;
  116779. /**
  116780. * Gets the particles render time capture status
  116781. */
  116782. /**
  116783. * Enable or disable the particles render time capture
  116784. */
  116785. captureParticlesRenderTime: boolean;
  116786. /**
  116787. * Gets the perf counter used for sprites render time
  116788. */
  116789. readonly spritesRenderTimeCounter: PerfCounter;
  116790. /**
  116791. * Gets the sprites render time capture status
  116792. */
  116793. /**
  116794. * Enable or disable the sprites render time capture
  116795. */
  116796. captureSpritesRenderTime: boolean;
  116797. /**
  116798. * Gets the perf counter used for physics time
  116799. */
  116800. readonly physicsTimeCounter: PerfCounter;
  116801. /**
  116802. * Gets the physics time capture status
  116803. */
  116804. /**
  116805. * Enable or disable the physics time capture
  116806. */
  116807. capturePhysicsTime: boolean;
  116808. /**
  116809. * Gets the perf counter used for animations time
  116810. */
  116811. readonly animationsTimeCounter: PerfCounter;
  116812. /**
  116813. * Gets the animations time capture status
  116814. */
  116815. /**
  116816. * Enable or disable the animations time capture
  116817. */
  116818. captureAnimationsTime: boolean;
  116819. /**
  116820. * Gets the perf counter used for frame time capture
  116821. */
  116822. readonly frameTimeCounter: PerfCounter;
  116823. /**
  116824. * Gets the frame time capture status
  116825. */
  116826. /**
  116827. * Enable or disable the frame time capture
  116828. */
  116829. captureFrameTime: boolean;
  116830. /**
  116831. * Gets the perf counter used for inter-frames time capture
  116832. */
  116833. readonly interFrameTimeCounter: PerfCounter;
  116834. /**
  116835. * Gets the inter-frames time capture status
  116836. */
  116837. /**
  116838. * Enable or disable the inter-frames time capture
  116839. */
  116840. captureInterFrameTime: boolean;
  116841. /**
  116842. * Gets the perf counter used for render time capture
  116843. */
  116844. readonly renderTimeCounter: PerfCounter;
  116845. /**
  116846. * Gets the render time capture status
  116847. */
  116848. /**
  116849. * Enable or disable the render time capture
  116850. */
  116851. captureRenderTime: boolean;
  116852. /**
  116853. * Gets the perf counter used for camera render time capture
  116854. */
  116855. readonly cameraRenderTimeCounter: PerfCounter;
  116856. /**
  116857. * Gets the camera render time capture status
  116858. */
  116859. /**
  116860. * Enable or disable the camera render time capture
  116861. */
  116862. captureCameraRenderTime: boolean;
  116863. /**
  116864. * Gets the perf counter used for draw calls
  116865. */
  116866. readonly drawCallsCounter: PerfCounter;
  116867. /**
  116868. * Instantiates a new scene instrumentation.
  116869. * This class can be used to get instrumentation data from a Babylon engine
  116870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116871. * @param scene Defines the scene to instrument
  116872. */
  116873. constructor(
  116874. /**
  116875. * Defines the scene to instrument
  116876. */
  116877. scene: Scene);
  116878. /**
  116879. * Dispose and release associated resources.
  116880. */
  116881. dispose(): void;
  116882. }
  116883. }
  116884. declare module BABYLON {
  116885. /** @hidden */
  116886. export var glowMapGenerationPixelShader: {
  116887. name: string;
  116888. shader: string;
  116889. };
  116890. }
  116891. declare module BABYLON {
  116892. /** @hidden */
  116893. export var glowMapGenerationVertexShader: {
  116894. name: string;
  116895. shader: string;
  116896. };
  116897. }
  116898. declare module BABYLON {
  116899. /**
  116900. * Effect layer options. This helps customizing the behaviour
  116901. * of the effect layer.
  116902. */
  116903. export interface IEffectLayerOptions {
  116904. /**
  116905. * Multiplication factor apply to the canvas size to compute the render target size
  116906. * used to generated the objects (the smaller the faster).
  116907. */
  116908. mainTextureRatio: number;
  116909. /**
  116910. * Enforces a fixed size texture to ensure effect stability across devices.
  116911. */
  116912. mainTextureFixedSize?: number;
  116913. /**
  116914. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116915. */
  116916. alphaBlendingMode: number;
  116917. /**
  116918. * The camera attached to the layer.
  116919. */
  116920. camera: Nullable<Camera>;
  116921. /**
  116922. * The rendering group to draw the layer in.
  116923. */
  116924. renderingGroupId: number;
  116925. }
  116926. /**
  116927. * The effect layer Helps adding post process effect blended with the main pass.
  116928. *
  116929. * This can be for instance use to generate glow or higlight effects on the scene.
  116930. *
  116931. * The effect layer class can not be used directly and is intented to inherited from to be
  116932. * customized per effects.
  116933. */
  116934. export abstract class EffectLayer {
  116935. private _vertexBuffers;
  116936. private _indexBuffer;
  116937. private _cachedDefines;
  116938. private _effectLayerMapGenerationEffect;
  116939. private _effectLayerOptions;
  116940. private _mergeEffect;
  116941. protected _scene: Scene;
  116942. protected _engine: Engine;
  116943. protected _maxSize: number;
  116944. protected _mainTextureDesiredSize: ISize;
  116945. protected _mainTexture: RenderTargetTexture;
  116946. protected _shouldRender: boolean;
  116947. protected _postProcesses: PostProcess[];
  116948. protected _textures: BaseTexture[];
  116949. protected _emissiveTextureAndColor: {
  116950. texture: Nullable<BaseTexture>;
  116951. color: Color4;
  116952. };
  116953. /**
  116954. * The name of the layer
  116955. */
  116956. name: string;
  116957. /**
  116958. * The clear color of the texture used to generate the glow map.
  116959. */
  116960. neutralColor: Color4;
  116961. /**
  116962. * Specifies wether the highlight layer is enabled or not.
  116963. */
  116964. isEnabled: boolean;
  116965. /**
  116966. * Gets the camera attached to the layer.
  116967. */
  116968. readonly camera: Nullable<Camera>;
  116969. /**
  116970. * Gets the rendering group id the layer should render in.
  116971. */
  116972. renderingGroupId: number;
  116973. /**
  116974. * An event triggered when the effect layer has been disposed.
  116975. */
  116976. onDisposeObservable: Observable<EffectLayer>;
  116977. /**
  116978. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116979. */
  116980. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116981. /**
  116982. * An event triggered when the generated texture is being merged in the scene.
  116983. */
  116984. onBeforeComposeObservable: Observable<EffectLayer>;
  116985. /**
  116986. * An event triggered when the generated texture has been merged in the scene.
  116987. */
  116988. onAfterComposeObservable: Observable<EffectLayer>;
  116989. /**
  116990. * An event triggered when the efffect layer changes its size.
  116991. */
  116992. onSizeChangedObservable: Observable<EffectLayer>;
  116993. /** @hidden */
  116994. static _SceneComponentInitialization: (scene: Scene) => void;
  116995. /**
  116996. * Instantiates a new effect Layer and references it in the scene.
  116997. * @param name The name of the layer
  116998. * @param scene The scene to use the layer in
  116999. */
  117000. constructor(
  117001. /** The Friendly of the effect in the scene */
  117002. name: string, scene: Scene);
  117003. /**
  117004. * Get the effect name of the layer.
  117005. * @return The effect name
  117006. */
  117007. abstract getEffectName(): string;
  117008. /**
  117009. * Checks for the readiness of the element composing the layer.
  117010. * @param subMesh the mesh to check for
  117011. * @param useInstances specify wether or not to use instances to render the mesh
  117012. * @return true if ready otherwise, false
  117013. */
  117014. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117015. /**
  117016. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117017. * @returns true if the effect requires stencil during the main canvas render pass.
  117018. */
  117019. abstract needStencil(): boolean;
  117020. /**
  117021. * Create the merge effect. This is the shader use to blit the information back
  117022. * to the main canvas at the end of the scene rendering.
  117023. * @returns The effect containing the shader used to merge the effect on the main canvas
  117024. */
  117025. protected abstract _createMergeEffect(): Effect;
  117026. /**
  117027. * Creates the render target textures and post processes used in the effect layer.
  117028. */
  117029. protected abstract _createTextureAndPostProcesses(): void;
  117030. /**
  117031. * Implementation specific of rendering the generating effect on the main canvas.
  117032. * @param effect The effect used to render through
  117033. */
  117034. protected abstract _internalRender(effect: Effect): void;
  117035. /**
  117036. * Sets the required values for both the emissive texture and and the main color.
  117037. */
  117038. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117039. /**
  117040. * Free any resources and references associated to a mesh.
  117041. * Internal use
  117042. * @param mesh The mesh to free.
  117043. */
  117044. abstract _disposeMesh(mesh: Mesh): void;
  117045. /**
  117046. * Serializes this layer (Glow or Highlight for example)
  117047. * @returns a serialized layer object
  117048. */
  117049. abstract serialize?(): any;
  117050. /**
  117051. * Initializes the effect layer with the required options.
  117052. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  117053. */
  117054. protected _init(options: Partial<IEffectLayerOptions>): void;
  117055. /**
  117056. * Generates the index buffer of the full screen quad blending to the main canvas.
  117057. */
  117058. private _generateIndexBuffer;
  117059. /**
  117060. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  117061. */
  117062. private _generateVertexBuffer;
  117063. /**
  117064. * Sets the main texture desired size which is the closest power of two
  117065. * of the engine canvas size.
  117066. */
  117067. private _setMainTextureSize;
  117068. /**
  117069. * Creates the main texture for the effect layer.
  117070. */
  117071. protected _createMainTexture(): void;
  117072. /**
  117073. * Adds specific effects defines.
  117074. * @param defines The defines to add specifics to.
  117075. */
  117076. protected _addCustomEffectDefines(defines: string[]): void;
  117077. /**
  117078. * Checks for the readiness of the element composing the layer.
  117079. * @param subMesh the mesh to check for
  117080. * @param useInstances specify wether or not to use instances to render the mesh
  117081. * @param emissiveTexture the associated emissive texture used to generate the glow
  117082. * @return true if ready otherwise, false
  117083. */
  117084. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  117085. /**
  117086. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  117087. */
  117088. render(): void;
  117089. /**
  117090. * Determine if a given mesh will be used in the current effect.
  117091. * @param mesh mesh to test
  117092. * @returns true if the mesh will be used
  117093. */
  117094. hasMesh(mesh: AbstractMesh): boolean;
  117095. /**
  117096. * Returns true if the layer contains information to display, otherwise false.
  117097. * @returns true if the glow layer should be rendered
  117098. */
  117099. shouldRender(): boolean;
  117100. /**
  117101. * Returns true if the mesh should render, otherwise false.
  117102. * @param mesh The mesh to render
  117103. * @returns true if it should render otherwise false
  117104. */
  117105. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  117106. /**
  117107. * Returns true if the mesh can be rendered, otherwise false.
  117108. * @param mesh The mesh to render
  117109. * @param material The material used on the mesh
  117110. * @returns true if it can be rendered otherwise false
  117111. */
  117112. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117113. /**
  117114. * Returns true if the mesh should render, otherwise false.
  117115. * @param mesh The mesh to render
  117116. * @returns true if it should render otherwise false
  117117. */
  117118. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  117119. /**
  117120. * Renders the submesh passed in parameter to the generation map.
  117121. */
  117122. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  117123. /**
  117124. * Rebuild the required buffers.
  117125. * @hidden Internal use only.
  117126. */
  117127. _rebuild(): void;
  117128. /**
  117129. * Dispose only the render target textures and post process.
  117130. */
  117131. private _disposeTextureAndPostProcesses;
  117132. /**
  117133. * Dispose the highlight layer and free resources.
  117134. */
  117135. dispose(): void;
  117136. /**
  117137. * Gets the class name of the effect layer
  117138. * @returns the string with the class name of the effect layer
  117139. */
  117140. getClassName(): string;
  117141. /**
  117142. * Creates an effect layer from parsed effect layer data
  117143. * @param parsedEffectLayer defines effect layer data
  117144. * @param scene defines the current scene
  117145. * @param rootUrl defines the root URL containing the effect layer information
  117146. * @returns a parsed effect Layer
  117147. */
  117148. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  117149. }
  117150. }
  117151. declare module BABYLON {
  117152. interface AbstractScene {
  117153. /**
  117154. * The list of effect layers (highlights/glow) added to the scene
  117155. * @see http://doc.babylonjs.com/how_to/highlight_layer
  117156. * @see http://doc.babylonjs.com/how_to/glow_layer
  117157. */
  117158. effectLayers: Array<EffectLayer>;
  117159. /**
  117160. * Removes the given effect layer from this scene.
  117161. * @param toRemove defines the effect layer to remove
  117162. * @returns the index of the removed effect layer
  117163. */
  117164. removeEffectLayer(toRemove: EffectLayer): number;
  117165. /**
  117166. * Adds the given effect layer to this scene
  117167. * @param newEffectLayer defines the effect layer to add
  117168. */
  117169. addEffectLayer(newEffectLayer: EffectLayer): void;
  117170. }
  117171. /**
  117172. * Defines the layer scene component responsible to manage any effect layers
  117173. * in a given scene.
  117174. */
  117175. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117176. /**
  117177. * The component name helpfull to identify the component in the list of scene components.
  117178. */
  117179. readonly name: string;
  117180. /**
  117181. * The scene the component belongs to.
  117182. */
  117183. scene: Scene;
  117184. private _engine;
  117185. private _renderEffects;
  117186. private _needStencil;
  117187. private _previousStencilState;
  117188. /**
  117189. * Creates a new instance of the component for the given scene
  117190. * @param scene Defines the scene to register the component in
  117191. */
  117192. constructor(scene: Scene);
  117193. /**
  117194. * Registers the component in a given scene
  117195. */
  117196. register(): void;
  117197. /**
  117198. * Rebuilds the elements related to this component in case of
  117199. * context lost for instance.
  117200. */
  117201. rebuild(): void;
  117202. /**
  117203. * Serializes the component data to the specified json object
  117204. * @param serializationObject The object to serialize to
  117205. */
  117206. serialize(serializationObject: any): void;
  117207. /**
  117208. * Adds all the elements from the container to the scene
  117209. * @param container the container holding the elements
  117210. */
  117211. addFromContainer(container: AbstractScene): void;
  117212. /**
  117213. * Removes all the elements in the container from the scene
  117214. * @param container contains the elements to remove
  117215. * @param dispose if the removed element should be disposed (default: false)
  117216. */
  117217. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117218. /**
  117219. * Disposes the component and the associated ressources.
  117220. */
  117221. dispose(): void;
  117222. private _isReadyForMesh;
  117223. private _renderMainTexture;
  117224. private _setStencil;
  117225. private _setStencilBack;
  117226. private _draw;
  117227. private _drawCamera;
  117228. private _drawRenderingGroup;
  117229. }
  117230. }
  117231. declare module BABYLON {
  117232. /** @hidden */
  117233. export var glowMapMergePixelShader: {
  117234. name: string;
  117235. shader: string;
  117236. };
  117237. }
  117238. declare module BABYLON {
  117239. /** @hidden */
  117240. export var glowMapMergeVertexShader: {
  117241. name: string;
  117242. shader: string;
  117243. };
  117244. }
  117245. declare module BABYLON {
  117246. interface AbstractScene {
  117247. /**
  117248. * Return a the first highlight layer of the scene with a given name.
  117249. * @param name The name of the highlight layer to look for.
  117250. * @return The highlight layer if found otherwise null.
  117251. */
  117252. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117253. }
  117254. /**
  117255. * Glow layer options. This helps customizing the behaviour
  117256. * of the glow layer.
  117257. */
  117258. export interface IGlowLayerOptions {
  117259. /**
  117260. * Multiplication factor apply to the canvas size to compute the render target size
  117261. * used to generated the glowing objects (the smaller the faster).
  117262. */
  117263. mainTextureRatio: number;
  117264. /**
  117265. * Enforces a fixed size texture to ensure resize independant blur.
  117266. */
  117267. mainTextureFixedSize?: number;
  117268. /**
  117269. * How big is the kernel of the blur texture.
  117270. */
  117271. blurKernelSize: number;
  117272. /**
  117273. * The camera attached to the layer.
  117274. */
  117275. camera: Nullable<Camera>;
  117276. /**
  117277. * Enable MSAA by chosing the number of samples.
  117278. */
  117279. mainTextureSamples?: number;
  117280. /**
  117281. * The rendering group to draw the layer in.
  117282. */
  117283. renderingGroupId: number;
  117284. }
  117285. /**
  117286. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  117287. *
  117288. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  117289. * glowy meshes to your scene.
  117290. *
  117291. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  117292. */
  117293. export class GlowLayer extends EffectLayer {
  117294. /**
  117295. * Effect Name of the layer.
  117296. */
  117297. static readonly EffectName: string;
  117298. /**
  117299. * The default blur kernel size used for the glow.
  117300. */
  117301. static DefaultBlurKernelSize: number;
  117302. /**
  117303. * The default texture size ratio used for the glow.
  117304. */
  117305. static DefaultTextureRatio: number;
  117306. /**
  117307. * Sets the kernel size of the blur.
  117308. */
  117309. /**
  117310. * Gets the kernel size of the blur.
  117311. */
  117312. blurKernelSize: number;
  117313. /**
  117314. * Sets the glow intensity.
  117315. */
  117316. /**
  117317. * Gets the glow intensity.
  117318. */
  117319. intensity: number;
  117320. private _options;
  117321. private _intensity;
  117322. private _horizontalBlurPostprocess1;
  117323. private _verticalBlurPostprocess1;
  117324. private _horizontalBlurPostprocess2;
  117325. private _verticalBlurPostprocess2;
  117326. private _blurTexture1;
  117327. private _blurTexture2;
  117328. private _postProcesses1;
  117329. private _postProcesses2;
  117330. private _includedOnlyMeshes;
  117331. private _excludedMeshes;
  117332. /**
  117333. * Callback used to let the user override the color selection on a per mesh basis
  117334. */
  117335. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117336. /**
  117337. * Callback used to let the user override the texture selection on a per mesh basis
  117338. */
  117339. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117340. /**
  117341. * Instantiates a new glow Layer and references it to the scene.
  117342. * @param name The name of the layer
  117343. * @param scene The scene to use the layer in
  117344. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117345. */
  117346. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117347. /**
  117348. * Get the effect name of the layer.
  117349. * @return The effect name
  117350. */
  117351. getEffectName(): string;
  117352. /**
  117353. * Create the merge effect. This is the shader use to blit the information back
  117354. * to the main canvas at the end of the scene rendering.
  117355. */
  117356. protected _createMergeEffect(): Effect;
  117357. /**
  117358. * Creates the render target textures and post processes used in the glow layer.
  117359. */
  117360. protected _createTextureAndPostProcesses(): void;
  117361. /**
  117362. * Checks for the readiness of the element composing the layer.
  117363. * @param subMesh the mesh to check for
  117364. * @param useInstances specify wether or not to use instances to render the mesh
  117365. * @param emissiveTexture the associated emissive texture used to generate the glow
  117366. * @return true if ready otherwise, false
  117367. */
  117368. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117369. /**
  117370. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117371. */
  117372. needStencil(): boolean;
  117373. /**
  117374. * Returns true if the mesh can be rendered, otherwise false.
  117375. * @param mesh The mesh to render
  117376. * @param material The material used on the mesh
  117377. * @returns true if it can be rendered otherwise false
  117378. */
  117379. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117380. /**
  117381. * Implementation specific of rendering the generating effect on the main canvas.
  117382. * @param effect The effect used to render through
  117383. */
  117384. protected _internalRender(effect: Effect): void;
  117385. /**
  117386. * Sets the required values for both the emissive texture and and the main color.
  117387. */
  117388. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117389. /**
  117390. * Returns true if the mesh should render, otherwise false.
  117391. * @param mesh The mesh to render
  117392. * @returns true if it should render otherwise false
  117393. */
  117394. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117395. /**
  117396. * Adds specific effects defines.
  117397. * @param defines The defines to add specifics to.
  117398. */
  117399. protected _addCustomEffectDefines(defines: string[]): void;
  117400. /**
  117401. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117402. * @param mesh The mesh to exclude from the glow layer
  117403. */
  117404. addExcludedMesh(mesh: Mesh): void;
  117405. /**
  117406. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117407. * @param mesh The mesh to remove
  117408. */
  117409. removeExcludedMesh(mesh: Mesh): void;
  117410. /**
  117411. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117412. * @param mesh The mesh to include in the glow layer
  117413. */
  117414. addIncludedOnlyMesh(mesh: Mesh): void;
  117415. /**
  117416. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117417. * @param mesh The mesh to remove
  117418. */
  117419. removeIncludedOnlyMesh(mesh: Mesh): void;
  117420. /**
  117421. * Determine if a given mesh will be used in the glow layer
  117422. * @param mesh The mesh to test
  117423. * @returns true if the mesh will be highlighted by the current glow layer
  117424. */
  117425. hasMesh(mesh: AbstractMesh): boolean;
  117426. /**
  117427. * Free any resources and references associated to a mesh.
  117428. * Internal use
  117429. * @param mesh The mesh to free.
  117430. * @hidden
  117431. */
  117432. _disposeMesh(mesh: Mesh): void;
  117433. /**
  117434. * Gets the class name of the effect layer
  117435. * @returns the string with the class name of the effect layer
  117436. */
  117437. getClassName(): string;
  117438. /**
  117439. * Serializes this glow layer
  117440. * @returns a serialized glow layer object
  117441. */
  117442. serialize(): any;
  117443. /**
  117444. * Creates a Glow Layer from parsed glow layer data
  117445. * @param parsedGlowLayer defines glow layer data
  117446. * @param scene defines the current scene
  117447. * @param rootUrl defines the root URL containing the glow layer information
  117448. * @returns a parsed Glow Layer
  117449. */
  117450. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117451. }
  117452. }
  117453. declare module BABYLON {
  117454. /** @hidden */
  117455. export var glowBlurPostProcessPixelShader: {
  117456. name: string;
  117457. shader: string;
  117458. };
  117459. }
  117460. declare module BABYLON {
  117461. interface AbstractScene {
  117462. /**
  117463. * Return a the first highlight layer of the scene with a given name.
  117464. * @param name The name of the highlight layer to look for.
  117465. * @return The highlight layer if found otherwise null.
  117466. */
  117467. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117468. }
  117469. /**
  117470. * Highlight layer options. This helps customizing the behaviour
  117471. * of the highlight layer.
  117472. */
  117473. export interface IHighlightLayerOptions {
  117474. /**
  117475. * Multiplication factor apply to the canvas size to compute the render target size
  117476. * used to generated the glowing objects (the smaller the faster).
  117477. */
  117478. mainTextureRatio: number;
  117479. /**
  117480. * Enforces a fixed size texture to ensure resize independant blur.
  117481. */
  117482. mainTextureFixedSize?: number;
  117483. /**
  117484. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117485. * of the picture to blur (the smaller the faster).
  117486. */
  117487. blurTextureSizeRatio: number;
  117488. /**
  117489. * How big in texel of the blur texture is the vertical blur.
  117490. */
  117491. blurVerticalSize: number;
  117492. /**
  117493. * How big in texel of the blur texture is the horizontal blur.
  117494. */
  117495. blurHorizontalSize: number;
  117496. /**
  117497. * Alpha blending mode used to apply the blur. Default is combine.
  117498. */
  117499. alphaBlendingMode: number;
  117500. /**
  117501. * The camera attached to the layer.
  117502. */
  117503. camera: Nullable<Camera>;
  117504. /**
  117505. * Should we display highlight as a solid stroke?
  117506. */
  117507. isStroke?: boolean;
  117508. /**
  117509. * The rendering group to draw the layer in.
  117510. */
  117511. renderingGroupId: number;
  117512. }
  117513. /**
  117514. * The highlight layer Helps adding a glow effect around a mesh.
  117515. *
  117516. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  117517. * glowy meshes to your scene.
  117518. *
  117519. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117520. */
  117521. export class HighlightLayer extends EffectLayer {
  117522. name: string;
  117523. /**
  117524. * Effect Name of the highlight layer.
  117525. */
  117526. static readonly EffectName: string;
  117527. /**
  117528. * The neutral color used during the preparation of the glow effect.
  117529. * This is black by default as the blend operation is a blend operation.
  117530. */
  117531. static NeutralColor: Color4;
  117532. /**
  117533. * Stencil value used for glowing meshes.
  117534. */
  117535. static GlowingMeshStencilReference: number;
  117536. /**
  117537. * Stencil value used for the other meshes in the scene.
  117538. */
  117539. static NormalMeshStencilReference: number;
  117540. /**
  117541. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117542. */
  117543. innerGlow: boolean;
  117544. /**
  117545. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117546. */
  117547. outerGlow: boolean;
  117548. /**
  117549. * Specifies the horizontal size of the blur.
  117550. */
  117551. /**
  117552. * Gets the horizontal size of the blur.
  117553. */
  117554. blurHorizontalSize: number;
  117555. /**
  117556. * Specifies the vertical size of the blur.
  117557. */
  117558. /**
  117559. * Gets the vertical size of the blur.
  117560. */
  117561. blurVerticalSize: number;
  117562. /**
  117563. * An event triggered when the highlight layer is being blurred.
  117564. */
  117565. onBeforeBlurObservable: Observable<HighlightLayer>;
  117566. /**
  117567. * An event triggered when the highlight layer has been blurred.
  117568. */
  117569. onAfterBlurObservable: Observable<HighlightLayer>;
  117570. private _instanceGlowingMeshStencilReference;
  117571. private _options;
  117572. private _downSamplePostprocess;
  117573. private _horizontalBlurPostprocess;
  117574. private _verticalBlurPostprocess;
  117575. private _blurTexture;
  117576. private _meshes;
  117577. private _excludedMeshes;
  117578. /**
  117579. * Instantiates a new highlight Layer and references it to the scene..
  117580. * @param name The name of the layer
  117581. * @param scene The scene to use the layer in
  117582. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117583. */
  117584. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117585. /**
  117586. * Get the effect name of the layer.
  117587. * @return The effect name
  117588. */
  117589. getEffectName(): string;
  117590. /**
  117591. * Create the merge effect. This is the shader use to blit the information back
  117592. * to the main canvas at the end of the scene rendering.
  117593. */
  117594. protected _createMergeEffect(): Effect;
  117595. /**
  117596. * Creates the render target textures and post processes used in the highlight layer.
  117597. */
  117598. protected _createTextureAndPostProcesses(): void;
  117599. /**
  117600. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117601. */
  117602. needStencil(): boolean;
  117603. /**
  117604. * Checks for the readiness of the element composing the layer.
  117605. * @param subMesh the mesh to check for
  117606. * @param useInstances specify wether or not to use instances to render the mesh
  117607. * @param emissiveTexture the associated emissive texture used to generate the glow
  117608. * @return true if ready otherwise, false
  117609. */
  117610. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117611. /**
  117612. * Implementation specific of rendering the generating effect on the main canvas.
  117613. * @param effect The effect used to render through
  117614. */
  117615. protected _internalRender(effect: Effect): void;
  117616. /**
  117617. * Returns true if the layer contains information to display, otherwise false.
  117618. */
  117619. shouldRender(): boolean;
  117620. /**
  117621. * Returns true if the mesh should render, otherwise false.
  117622. * @param mesh The mesh to render
  117623. * @returns true if it should render otherwise false
  117624. */
  117625. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117626. /**
  117627. * Sets the required values for both the emissive texture and and the main color.
  117628. */
  117629. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117630. /**
  117631. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117632. * @param mesh The mesh to exclude from the highlight layer
  117633. */
  117634. addExcludedMesh(mesh: Mesh): void;
  117635. /**
  117636. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117637. * @param mesh The mesh to highlight
  117638. */
  117639. removeExcludedMesh(mesh: Mesh): void;
  117640. /**
  117641. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117642. * @param mesh mesh to test
  117643. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117644. */
  117645. hasMesh(mesh: AbstractMesh): boolean;
  117646. /**
  117647. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117648. * @param mesh The mesh to highlight
  117649. * @param color The color of the highlight
  117650. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117651. */
  117652. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117653. /**
  117654. * Remove a mesh from the highlight layer in order to make it stop glowing.
  117655. * @param mesh The mesh to highlight
  117656. */
  117657. removeMesh(mesh: Mesh): void;
  117658. /**
  117659. * Force the stencil to the normal expected value for none glowing parts
  117660. */
  117661. private _defaultStencilReference;
  117662. /**
  117663. * Free any resources and references associated to a mesh.
  117664. * Internal use
  117665. * @param mesh The mesh to free.
  117666. * @hidden
  117667. */
  117668. _disposeMesh(mesh: Mesh): void;
  117669. /**
  117670. * Dispose the highlight layer and free resources.
  117671. */
  117672. dispose(): void;
  117673. /**
  117674. * Gets the class name of the effect layer
  117675. * @returns the string with the class name of the effect layer
  117676. */
  117677. getClassName(): string;
  117678. /**
  117679. * Serializes this Highlight layer
  117680. * @returns a serialized Highlight layer object
  117681. */
  117682. serialize(): any;
  117683. /**
  117684. * Creates a Highlight layer from parsed Highlight layer data
  117685. * @param parsedHightlightLayer defines the Highlight layer data
  117686. * @param scene defines the current scene
  117687. * @param rootUrl defines the root URL containing the Highlight layer information
  117688. * @returns a parsed Highlight layer
  117689. */
  117690. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  117691. }
  117692. }
  117693. declare module BABYLON {
  117694. interface AbstractScene {
  117695. /**
  117696. * The list of layers (background and foreground) of the scene
  117697. */
  117698. layers: Array<Layer>;
  117699. }
  117700. /**
  117701. * Defines the layer scene component responsible to manage any layers
  117702. * in a given scene.
  117703. */
  117704. export class LayerSceneComponent implements ISceneComponent {
  117705. /**
  117706. * The component name helpfull to identify the component in the list of scene components.
  117707. */
  117708. readonly name: string;
  117709. /**
  117710. * The scene the component belongs to.
  117711. */
  117712. scene: Scene;
  117713. private _engine;
  117714. /**
  117715. * Creates a new instance of the component for the given scene
  117716. * @param scene Defines the scene to register the component in
  117717. */
  117718. constructor(scene: Scene);
  117719. /**
  117720. * Registers the component in a given scene
  117721. */
  117722. register(): void;
  117723. /**
  117724. * Rebuilds the elements related to this component in case of
  117725. * context lost for instance.
  117726. */
  117727. rebuild(): void;
  117728. /**
  117729. * Disposes the component and the associated ressources.
  117730. */
  117731. dispose(): void;
  117732. private _draw;
  117733. private _drawCameraPredicate;
  117734. private _drawCameraBackground;
  117735. private _drawCameraForeground;
  117736. private _drawRenderTargetPredicate;
  117737. private _drawRenderTargetBackground;
  117738. private _drawRenderTargetForeground;
  117739. /**
  117740. * Adds all the elements from the container to the scene
  117741. * @param container the container holding the elements
  117742. */
  117743. addFromContainer(container: AbstractScene): void;
  117744. /**
  117745. * Removes all the elements in the container from the scene
  117746. * @param container contains the elements to remove
  117747. * @param dispose if the removed element should be disposed (default: false)
  117748. */
  117749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117750. }
  117751. }
  117752. declare module BABYLON {
  117753. /** @hidden */
  117754. export var layerPixelShader: {
  117755. name: string;
  117756. shader: string;
  117757. };
  117758. }
  117759. declare module BABYLON {
  117760. /** @hidden */
  117761. export var layerVertexShader: {
  117762. name: string;
  117763. shader: string;
  117764. };
  117765. }
  117766. declare module BABYLON {
  117767. /**
  117768. * This represents a full screen 2d layer.
  117769. * This can be useful to display a picture in the background of your scene for instance.
  117770. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117771. */
  117772. export class Layer {
  117773. /**
  117774. * Define the name of the layer.
  117775. */
  117776. name: string;
  117777. /**
  117778. * Define the texture the layer should display.
  117779. */
  117780. texture: Nullable<Texture>;
  117781. /**
  117782. * Is the layer in background or foreground.
  117783. */
  117784. isBackground: boolean;
  117785. /**
  117786. * Define the color of the layer (instead of texture).
  117787. */
  117788. color: Color4;
  117789. /**
  117790. * Define the scale of the layer in order to zoom in out of the texture.
  117791. */
  117792. scale: Vector2;
  117793. /**
  117794. * Define an offset for the layer in order to shift the texture.
  117795. */
  117796. offset: Vector2;
  117797. /**
  117798. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117799. */
  117800. alphaBlendingMode: number;
  117801. /**
  117802. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117803. * Alpha test will not mix with the background color in case of transparency.
  117804. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117805. */
  117806. alphaTest: boolean;
  117807. /**
  117808. * Define a mask to restrict the layer to only some of the scene cameras.
  117809. */
  117810. layerMask: number;
  117811. /**
  117812. * Define the list of render target the layer is visible into.
  117813. */
  117814. renderTargetTextures: RenderTargetTexture[];
  117815. /**
  117816. * Define if the layer is only used in renderTarget or if it also
  117817. * renders in the main frame buffer of the canvas.
  117818. */
  117819. renderOnlyInRenderTargetTextures: boolean;
  117820. private _scene;
  117821. private _vertexBuffers;
  117822. private _indexBuffer;
  117823. private _effect;
  117824. private _alphaTestEffect;
  117825. /**
  117826. * An event triggered when the layer is disposed.
  117827. */
  117828. onDisposeObservable: Observable<Layer>;
  117829. private _onDisposeObserver;
  117830. /**
  117831. * Back compatibility with callback before the onDisposeObservable existed.
  117832. * The set callback will be triggered when the layer has been disposed.
  117833. */
  117834. onDispose: () => void;
  117835. /**
  117836. * An event triggered before rendering the scene
  117837. */
  117838. onBeforeRenderObservable: Observable<Layer>;
  117839. private _onBeforeRenderObserver;
  117840. /**
  117841. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117842. * The set callback will be triggered just before rendering the layer.
  117843. */
  117844. onBeforeRender: () => void;
  117845. /**
  117846. * An event triggered after rendering the scene
  117847. */
  117848. onAfterRenderObservable: Observable<Layer>;
  117849. private _onAfterRenderObserver;
  117850. /**
  117851. * Back compatibility with callback before the onAfterRenderObservable existed.
  117852. * The set callback will be triggered just after rendering the layer.
  117853. */
  117854. onAfterRender: () => void;
  117855. /**
  117856. * Instantiates a new layer.
  117857. * This represents a full screen 2d layer.
  117858. * This can be useful to display a picture in the background of your scene for instance.
  117859. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117860. * @param name Define the name of the layer in the scene
  117861. * @param imgUrl Define the url of the texture to display in the layer
  117862. * @param scene Define the scene the layer belongs to
  117863. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117864. * @param color Defines a color for the layer
  117865. */
  117866. constructor(
  117867. /**
  117868. * Define the name of the layer.
  117869. */
  117870. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117871. private _createIndexBuffer;
  117872. /** @hidden */
  117873. _rebuild(): void;
  117874. /**
  117875. * Renders the layer in the scene.
  117876. */
  117877. render(): void;
  117878. /**
  117879. * Disposes and releases the associated ressources.
  117880. */
  117881. dispose(): void;
  117882. }
  117883. }
  117884. declare module BABYLON {
  117885. /** @hidden */
  117886. export var lensFlarePixelShader: {
  117887. name: string;
  117888. shader: string;
  117889. };
  117890. }
  117891. declare module BABYLON {
  117892. /** @hidden */
  117893. export var lensFlareVertexShader: {
  117894. name: string;
  117895. shader: string;
  117896. };
  117897. }
  117898. declare module BABYLON {
  117899. /**
  117900. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117901. * It is usually composed of several `lensFlare`.
  117902. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117903. */
  117904. export class LensFlareSystem {
  117905. /**
  117906. * Define the name of the lens flare system
  117907. */
  117908. name: string;
  117909. /**
  117910. * List of lens flares used in this system.
  117911. */
  117912. lensFlares: LensFlare[];
  117913. /**
  117914. * Define a limit from the border the lens flare can be visible.
  117915. */
  117916. borderLimit: number;
  117917. /**
  117918. * Define a viewport border we do not want to see the lens flare in.
  117919. */
  117920. viewportBorder: number;
  117921. /**
  117922. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117923. */
  117924. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117925. /**
  117926. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117927. */
  117928. layerMask: number;
  117929. /**
  117930. * Define the id of the lens flare system in the scene.
  117931. * (equal to name by default)
  117932. */
  117933. id: string;
  117934. private _scene;
  117935. private _emitter;
  117936. private _vertexBuffers;
  117937. private _indexBuffer;
  117938. private _effect;
  117939. private _positionX;
  117940. private _positionY;
  117941. private _isEnabled;
  117942. /** @hidden */
  117943. static _SceneComponentInitialization: (scene: Scene) => void;
  117944. /**
  117945. * Instantiates a lens flare system.
  117946. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117947. * It is usually composed of several `lensFlare`.
  117948. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117949. * @param name Define the name of the lens flare system in the scene
  117950. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117951. * @param scene Define the scene the lens flare system belongs to
  117952. */
  117953. constructor(
  117954. /**
  117955. * Define the name of the lens flare system
  117956. */
  117957. name: string, emitter: any, scene: Scene);
  117958. /**
  117959. * Define if the lens flare system is enabled.
  117960. */
  117961. isEnabled: boolean;
  117962. /**
  117963. * Get the scene the effects belongs to.
  117964. * @returns the scene holding the lens flare system
  117965. */
  117966. getScene(): Scene;
  117967. /**
  117968. * Get the emitter of the lens flare system.
  117969. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117970. * @returns the emitter of the lens flare system
  117971. */
  117972. getEmitter(): any;
  117973. /**
  117974. * Set the emitter of the lens flare system.
  117975. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117976. * @param newEmitter Define the new emitter of the system
  117977. */
  117978. setEmitter(newEmitter: any): void;
  117979. /**
  117980. * Get the lens flare system emitter position.
  117981. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117982. * @returns the position
  117983. */
  117984. getEmitterPosition(): Vector3;
  117985. /**
  117986. * @hidden
  117987. */
  117988. computeEffectivePosition(globalViewport: Viewport): boolean;
  117989. /** @hidden */
  117990. _isVisible(): boolean;
  117991. /**
  117992. * @hidden
  117993. */
  117994. render(): boolean;
  117995. /**
  117996. * Dispose and release the lens flare with its associated resources.
  117997. */
  117998. dispose(): void;
  117999. /**
  118000. * Parse a lens flare system from a JSON repressentation
  118001. * @param parsedLensFlareSystem Define the JSON to parse
  118002. * @param scene Define the scene the parsed system should be instantiated in
  118003. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  118004. * @returns the parsed system
  118005. */
  118006. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  118007. /**
  118008. * Serialize the current Lens Flare System into a JSON representation.
  118009. * @returns the serialized JSON
  118010. */
  118011. serialize(): any;
  118012. }
  118013. }
  118014. declare module BABYLON {
  118015. /**
  118016. * This represents one of the lens effect in a `lensFlareSystem`.
  118017. * It controls one of the indiviual texture used in the effect.
  118018. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118019. */
  118020. export class LensFlare {
  118021. /**
  118022. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118023. */
  118024. size: number;
  118025. /**
  118026. * 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.
  118027. */
  118028. position: number;
  118029. /**
  118030. * Define the lens color.
  118031. */
  118032. color: Color3;
  118033. /**
  118034. * Define the lens texture.
  118035. */
  118036. texture: Nullable<Texture>;
  118037. /**
  118038. * Define the alpha mode to render this particular lens.
  118039. */
  118040. alphaMode: number;
  118041. private _system;
  118042. /**
  118043. * Creates a new Lens Flare.
  118044. * This represents one of the lens effect in a `lensFlareSystem`.
  118045. * It controls one of the indiviual texture used in the effect.
  118046. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118047. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  118048. * @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.
  118049. * @param color Define the lens color
  118050. * @param imgUrl Define the lens texture url
  118051. * @param system Define the `lensFlareSystem` this flare is part of
  118052. * @returns The newly created Lens Flare
  118053. */
  118054. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  118055. /**
  118056. * Instantiates a new Lens Flare.
  118057. * This represents one of the lens effect in a `lensFlareSystem`.
  118058. * It controls one of the indiviual texture used in the effect.
  118059. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118060. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  118061. * @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.
  118062. * @param color Define the lens color
  118063. * @param imgUrl Define the lens texture url
  118064. * @param system Define the `lensFlareSystem` this flare is part of
  118065. */
  118066. constructor(
  118067. /**
  118068. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118069. */
  118070. size: number,
  118071. /**
  118072. * 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.
  118073. */
  118074. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  118075. /**
  118076. * Dispose and release the lens flare with its associated resources.
  118077. */
  118078. dispose(): void;
  118079. }
  118080. }
  118081. declare module BABYLON {
  118082. interface AbstractScene {
  118083. /**
  118084. * The list of lens flare system added to the scene
  118085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118086. */
  118087. lensFlareSystems: Array<LensFlareSystem>;
  118088. /**
  118089. * Removes the given lens flare system from this scene.
  118090. * @param toRemove The lens flare system to remove
  118091. * @returns The index of the removed lens flare system
  118092. */
  118093. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  118094. /**
  118095. * Adds the given lens flare system to this scene
  118096. * @param newLensFlareSystem The lens flare system to add
  118097. */
  118098. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  118099. /**
  118100. * Gets a lens flare system using its name
  118101. * @param name defines the name to look for
  118102. * @returns the lens flare system or null if not found
  118103. */
  118104. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  118105. /**
  118106. * Gets a lens flare system using its id
  118107. * @param id defines the id to look for
  118108. * @returns the lens flare system or null if not found
  118109. */
  118110. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  118111. }
  118112. /**
  118113. * Defines the lens flare scene component responsible to manage any lens flares
  118114. * in a given scene.
  118115. */
  118116. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  118117. /**
  118118. * The component name helpfull to identify the component in the list of scene components.
  118119. */
  118120. readonly name: string;
  118121. /**
  118122. * The scene the component belongs to.
  118123. */
  118124. scene: Scene;
  118125. /**
  118126. * Creates a new instance of the component for the given scene
  118127. * @param scene Defines the scene to register the component in
  118128. */
  118129. constructor(scene: Scene);
  118130. /**
  118131. * Registers the component in a given scene
  118132. */
  118133. register(): void;
  118134. /**
  118135. * Rebuilds the elements related to this component in case of
  118136. * context lost for instance.
  118137. */
  118138. rebuild(): void;
  118139. /**
  118140. * Adds all the elements from the container to the scene
  118141. * @param container the container holding the elements
  118142. */
  118143. addFromContainer(container: AbstractScene): void;
  118144. /**
  118145. * Removes all the elements in the container from the scene
  118146. * @param container contains the elements to remove
  118147. * @param dispose if the removed element should be disposed (default: false)
  118148. */
  118149. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118150. /**
  118151. * Serializes the component data to the specified json object
  118152. * @param serializationObject The object to serialize to
  118153. */
  118154. serialize(serializationObject: any): void;
  118155. /**
  118156. * Disposes the component and the associated ressources.
  118157. */
  118158. dispose(): void;
  118159. private _draw;
  118160. }
  118161. }
  118162. declare module BABYLON {
  118163. /**
  118164. * Defines the shadow generator component responsible to manage any shadow generators
  118165. * in a given scene.
  118166. */
  118167. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118168. /**
  118169. * The component name helpfull to identify the component in the list of scene components.
  118170. */
  118171. readonly name: string;
  118172. /**
  118173. * The scene the component belongs to.
  118174. */
  118175. scene: Scene;
  118176. /**
  118177. * Creates a new instance of the component for the given scene
  118178. * @param scene Defines the scene to register the component in
  118179. */
  118180. constructor(scene: Scene);
  118181. /**
  118182. * Registers the component in a given scene
  118183. */
  118184. register(): void;
  118185. /**
  118186. * Rebuilds the elements related to this component in case of
  118187. * context lost for instance.
  118188. */
  118189. rebuild(): void;
  118190. /**
  118191. * Serializes the component data to the specified json object
  118192. * @param serializationObject The object to serialize to
  118193. */
  118194. serialize(serializationObject: any): void;
  118195. /**
  118196. * Adds all the elements from the container to the scene
  118197. * @param container the container holding the elements
  118198. */
  118199. addFromContainer(container: AbstractScene): void;
  118200. /**
  118201. * Removes all the elements in the container from the scene
  118202. * @param container contains the elements to remove
  118203. * @param dispose if the removed element should be disposed (default: false)
  118204. */
  118205. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118206. /**
  118207. * Rebuilds the elements related to this component in case of
  118208. * context lost for instance.
  118209. */
  118210. dispose(): void;
  118211. private _gatherRenderTargets;
  118212. }
  118213. }
  118214. declare module BABYLON {
  118215. /**
  118216. * A point light is a light defined by an unique point in world space.
  118217. * The light is emitted in every direction from this point.
  118218. * A good example of a point light is a standard light bulb.
  118219. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118220. */
  118221. export class PointLight extends ShadowLight {
  118222. private _shadowAngle;
  118223. /**
  118224. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118225. * This specifies what angle the shadow will use to be created.
  118226. *
  118227. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118228. */
  118229. /**
  118230. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118231. * This specifies what angle the shadow will use to be created.
  118232. *
  118233. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118234. */
  118235. shadowAngle: number;
  118236. /**
  118237. * Gets the direction if it has been set.
  118238. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118239. */
  118240. /**
  118241. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118242. */
  118243. direction: Vector3;
  118244. /**
  118245. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118246. * A PointLight emits the light in every direction.
  118247. * It can cast shadows.
  118248. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118249. * ```javascript
  118250. * var pointLight = new PointLight("pl", camera.position, scene);
  118251. * ```
  118252. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118253. * @param name The light friendly name
  118254. * @param position The position of the point light in the scene
  118255. * @param scene The scene the lights belongs to
  118256. */
  118257. constructor(name: string, position: Vector3, scene: Scene);
  118258. /**
  118259. * Returns the string "PointLight"
  118260. * @returns the class name
  118261. */
  118262. getClassName(): string;
  118263. /**
  118264. * Returns the integer 0.
  118265. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118266. */
  118267. getTypeID(): number;
  118268. /**
  118269. * Specifies wether or not the shadowmap should be a cube texture.
  118270. * @returns true if the shadowmap needs to be a cube texture.
  118271. */
  118272. needCube(): boolean;
  118273. /**
  118274. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  118275. * @param faceIndex The index of the face we are computed the direction to generate shadow
  118276. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  118277. */
  118278. getShadowDirection(faceIndex?: number): Vector3;
  118279. /**
  118280. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  118281. * - fov = PI / 2
  118282. * - aspect ratio : 1.0
  118283. * - z-near and far equal to the active camera minZ and maxZ.
  118284. * Returns the PointLight.
  118285. */
  118286. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118287. protected _buildUniformLayout(): void;
  118288. /**
  118289. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  118290. * @param effect The effect to update
  118291. * @param lightIndex The index of the light in the effect to update
  118292. * @returns The point light
  118293. */
  118294. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  118295. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118296. /**
  118297. * Prepares the list of defines specific to the light type.
  118298. * @param defines the list of defines
  118299. * @param lightIndex defines the index of the light for the effect
  118300. */
  118301. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118302. }
  118303. }
  118304. declare module BABYLON {
  118305. /**
  118306. * Header information of HDR texture files.
  118307. */
  118308. export interface HDRInfo {
  118309. /**
  118310. * The height of the texture in pixels.
  118311. */
  118312. height: number;
  118313. /**
  118314. * The width of the texture in pixels.
  118315. */
  118316. width: number;
  118317. /**
  118318. * The index of the beginning of the data in the binary file.
  118319. */
  118320. dataPosition: number;
  118321. }
  118322. /**
  118323. * This groups tools to convert HDR texture to native colors array.
  118324. */
  118325. export class HDRTools {
  118326. private static Ldexp;
  118327. private static Rgbe2float;
  118328. private static readStringLine;
  118329. /**
  118330. * Reads header information from an RGBE texture stored in a native array.
  118331. * More information on this format are available here:
  118332. * https://en.wikipedia.org/wiki/RGBE_image_format
  118333. *
  118334. * @param uint8array The binary file stored in native array.
  118335. * @return The header information.
  118336. */
  118337. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118338. /**
  118339. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118340. * This RGBE texture needs to store the information as a panorama.
  118341. *
  118342. * More information on this format are available here:
  118343. * https://en.wikipedia.org/wiki/RGBE_image_format
  118344. *
  118345. * @param buffer The binary file stored in an array buffer.
  118346. * @param size The expected size of the extracted cubemap.
  118347. * @return The Cube Map information.
  118348. */
  118349. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118350. /**
  118351. * Returns the pixels data extracted from an RGBE texture.
  118352. * This pixels will be stored left to right up to down in the R G B order in one array.
  118353. *
  118354. * More information on this format are available here:
  118355. * https://en.wikipedia.org/wiki/RGBE_image_format
  118356. *
  118357. * @param uint8array The binary file stored in an array buffer.
  118358. * @param hdrInfo The header information of the file.
  118359. * @return The pixels data in RGB right to left up to down order.
  118360. */
  118361. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118362. private static RGBE_ReadPixels_RLE;
  118363. }
  118364. }
  118365. declare module BABYLON {
  118366. /**
  118367. * This represents a texture coming from an HDR input.
  118368. *
  118369. * The only supported format is currently panorama picture stored in RGBE format.
  118370. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118371. */
  118372. export class HDRCubeTexture extends BaseTexture {
  118373. private static _facesMapping;
  118374. private _generateHarmonics;
  118375. private _noMipmap;
  118376. private _textureMatrix;
  118377. private _size;
  118378. private _onLoad;
  118379. private _onError;
  118380. /**
  118381. * The texture URL.
  118382. */
  118383. url: string;
  118384. /**
  118385. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118386. */
  118387. coordinatesMode: number;
  118388. protected _isBlocking: boolean;
  118389. /**
  118390. * Sets wether or not the texture is blocking during loading.
  118391. */
  118392. /**
  118393. * Gets wether or not the texture is blocking during loading.
  118394. */
  118395. isBlocking: boolean;
  118396. protected _rotationY: number;
  118397. /**
  118398. * Sets texture matrix rotation angle around Y axis in radians.
  118399. */
  118400. /**
  118401. * Gets texture matrix rotation angle around Y axis radians.
  118402. */
  118403. rotationY: number;
  118404. /**
  118405. * Gets or sets the center of the bounding box associated with the cube texture
  118406. * It must define where the camera used to render the texture was set
  118407. */
  118408. boundingBoxPosition: Vector3;
  118409. private _boundingBoxSize;
  118410. /**
  118411. * Gets or sets the size of the bounding box associated with the cube texture
  118412. * When defined, the cubemap will switch to local mode
  118413. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118414. * @example https://www.babylonjs-playground.com/#RNASML
  118415. */
  118416. boundingBoxSize: Vector3;
  118417. /**
  118418. * Instantiates an HDRTexture from the following parameters.
  118419. *
  118420. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118421. * @param scene The scene the texture will be used in
  118422. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118423. * @param noMipmap Forces to not generate the mipmap if true
  118424. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118425. * @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)
  118426. * @param reserved Reserved flag for internal use.
  118427. */
  118428. 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>);
  118429. /**
  118430. * Get the current class name of the texture useful for serialization or dynamic coding.
  118431. * @returns "HDRCubeTexture"
  118432. */
  118433. getClassName(): string;
  118434. /**
  118435. * Occurs when the file is raw .hdr file.
  118436. */
  118437. private loadTexture;
  118438. clone(): HDRCubeTexture;
  118439. delayLoad(): void;
  118440. /**
  118441. * Get the texture reflection matrix used to rotate/transform the reflection.
  118442. * @returns the reflection matrix
  118443. */
  118444. getReflectionTextureMatrix(): Matrix;
  118445. /**
  118446. * Set the texture reflection matrix used to rotate/transform the reflection.
  118447. * @param value Define the reflection matrix to set
  118448. */
  118449. setReflectionTextureMatrix(value: Matrix): void;
  118450. /**
  118451. * Parses a JSON representation of an HDR Texture in order to create the texture
  118452. * @param parsedTexture Define the JSON representation
  118453. * @param scene Define the scene the texture should be created in
  118454. * @param rootUrl Define the root url in case we need to load relative dependencies
  118455. * @returns the newly created texture after parsing
  118456. */
  118457. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118458. serialize(): any;
  118459. }
  118460. }
  118461. declare module BABYLON {
  118462. /**
  118463. * Class used to control physics engine
  118464. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118465. */
  118466. export class PhysicsEngine implements IPhysicsEngine {
  118467. private _physicsPlugin;
  118468. /**
  118469. * Global value used to control the smallest number supported by the simulation
  118470. */
  118471. static Epsilon: number;
  118472. private _impostors;
  118473. private _joints;
  118474. /**
  118475. * Gets the gravity vector used by the simulation
  118476. */
  118477. gravity: Vector3;
  118478. /**
  118479. * Factory used to create the default physics plugin.
  118480. * @returns The default physics plugin
  118481. */
  118482. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118483. /**
  118484. * Creates a new Physics Engine
  118485. * @param gravity defines the gravity vector used by the simulation
  118486. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118487. */
  118488. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118489. /**
  118490. * Sets the gravity vector used by the simulation
  118491. * @param gravity defines the gravity vector to use
  118492. */
  118493. setGravity(gravity: Vector3): void;
  118494. /**
  118495. * Set the time step of the physics engine.
  118496. * Default is 1/60.
  118497. * To slow it down, enter 1/600 for example.
  118498. * To speed it up, 1/30
  118499. * @param newTimeStep defines the new timestep to apply to this world.
  118500. */
  118501. setTimeStep(newTimeStep?: number): void;
  118502. /**
  118503. * Get the time step of the physics engine.
  118504. * @returns the current time step
  118505. */
  118506. getTimeStep(): number;
  118507. /**
  118508. * Release all resources
  118509. */
  118510. dispose(): void;
  118511. /**
  118512. * Gets the name of the current physics plugin
  118513. * @returns the name of the plugin
  118514. */
  118515. getPhysicsPluginName(): string;
  118516. /**
  118517. * Adding a new impostor for the impostor tracking.
  118518. * This will be done by the impostor itself.
  118519. * @param impostor the impostor to add
  118520. */
  118521. addImpostor(impostor: PhysicsImpostor): void;
  118522. /**
  118523. * Remove an impostor from the engine.
  118524. * This impostor and its mesh will not longer be updated by the physics engine.
  118525. * @param impostor the impostor to remove
  118526. */
  118527. removeImpostor(impostor: PhysicsImpostor): void;
  118528. /**
  118529. * Add a joint to the physics engine
  118530. * @param mainImpostor defines the main impostor to which the joint is added.
  118531. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118532. * @param joint defines the joint that will connect both impostors.
  118533. */
  118534. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118535. /**
  118536. * Removes a joint from the simulation
  118537. * @param mainImpostor defines the impostor used with the joint
  118538. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118539. * @param joint defines the joint to remove
  118540. */
  118541. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118542. /**
  118543. * Called by the scene. No need to call it.
  118544. * @param delta defines the timespam between frames
  118545. */
  118546. _step(delta: number): void;
  118547. /**
  118548. * Gets the current plugin used to run the simulation
  118549. * @returns current plugin
  118550. */
  118551. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118552. /**
  118553. * Gets the list of physic impostors
  118554. * @returns an array of PhysicsImpostor
  118555. */
  118556. getImpostors(): Array<PhysicsImpostor>;
  118557. /**
  118558. * Gets the impostor for a physics enabled object
  118559. * @param object defines the object impersonated by the impostor
  118560. * @returns the PhysicsImpostor or null if not found
  118561. */
  118562. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118563. /**
  118564. * Gets the impostor for a physics body object
  118565. * @param body defines physics body used by the impostor
  118566. * @returns the PhysicsImpostor or null if not found
  118567. */
  118568. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118569. /**
  118570. * Does a raycast in the physics world
  118571. * @param from when should the ray start?
  118572. * @param to when should the ray end?
  118573. * @returns PhysicsRaycastResult
  118574. */
  118575. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118576. }
  118577. }
  118578. declare module BABYLON {
  118579. /** @hidden */
  118580. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118581. private _useDeltaForWorldStep;
  118582. world: any;
  118583. name: string;
  118584. private _physicsMaterials;
  118585. private _fixedTimeStep;
  118586. private _cannonRaycastResult;
  118587. private _raycastResult;
  118588. private _physicsBodysToRemoveAfterStep;
  118589. BJSCANNON: any;
  118590. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118591. setGravity(gravity: Vector3): void;
  118592. setTimeStep(timeStep: number): void;
  118593. getTimeStep(): number;
  118594. executeStep(delta: number): void;
  118595. private _removeMarkedPhysicsBodiesFromWorld;
  118596. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118597. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118598. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118599. private _processChildMeshes;
  118600. removePhysicsBody(impostor: PhysicsImpostor): void;
  118601. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118602. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118603. private _addMaterial;
  118604. private _checkWithEpsilon;
  118605. private _createShape;
  118606. private _createHeightmap;
  118607. private _minus90X;
  118608. private _plus90X;
  118609. private _tmpPosition;
  118610. private _tmpDeltaPosition;
  118611. private _tmpUnityRotation;
  118612. private _updatePhysicsBodyTransformation;
  118613. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118614. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118615. isSupported(): boolean;
  118616. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118617. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118618. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118619. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118620. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118621. getBodyMass(impostor: PhysicsImpostor): number;
  118622. getBodyFriction(impostor: PhysicsImpostor): number;
  118623. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118624. getBodyRestitution(impostor: PhysicsImpostor): number;
  118625. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118626. sleepBody(impostor: PhysicsImpostor): void;
  118627. wakeUpBody(impostor: PhysicsImpostor): void;
  118628. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118629. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118630. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118631. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118632. getRadius(impostor: PhysicsImpostor): number;
  118633. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118634. dispose(): void;
  118635. private _extendNamespace;
  118636. /**
  118637. * Does a raycast in the physics world
  118638. * @param from when should the ray start?
  118639. * @param to when should the ray end?
  118640. * @returns PhysicsRaycastResult
  118641. */
  118642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118643. }
  118644. }
  118645. declare module BABYLON {
  118646. /** @hidden */
  118647. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118648. world: any;
  118649. name: string;
  118650. BJSOIMO: any;
  118651. private _raycastResult;
  118652. constructor(iterations?: number, oimoInjection?: any);
  118653. setGravity(gravity: Vector3): void;
  118654. setTimeStep(timeStep: number): void;
  118655. getTimeStep(): number;
  118656. private _tmpImpostorsArray;
  118657. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118658. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118659. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118660. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118661. private _tmpPositionVector;
  118662. removePhysicsBody(impostor: PhysicsImpostor): void;
  118663. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118664. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118665. isSupported(): boolean;
  118666. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118667. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118668. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118669. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118670. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118671. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118672. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118673. getBodyMass(impostor: PhysicsImpostor): number;
  118674. getBodyFriction(impostor: PhysicsImpostor): number;
  118675. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118676. getBodyRestitution(impostor: PhysicsImpostor): number;
  118677. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118678. sleepBody(impostor: PhysicsImpostor): void;
  118679. wakeUpBody(impostor: PhysicsImpostor): void;
  118680. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118681. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  118682. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118683. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118684. getRadius(impostor: PhysicsImpostor): number;
  118685. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118686. dispose(): void;
  118687. /**
  118688. * Does a raycast in the physics world
  118689. * @param from when should the ray start?
  118690. * @param to when should the ray end?
  118691. * @returns PhysicsRaycastResult
  118692. */
  118693. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118694. }
  118695. }
  118696. declare module BABYLON {
  118697. /**
  118698. * Class containing static functions to help procedurally build meshes
  118699. */
  118700. export class RibbonBuilder {
  118701. /**
  118702. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118703. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118704. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118705. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118706. * * 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
  118707. * * 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
  118708. * * 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
  118709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118712. * * 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
  118713. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118714. * * 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
  118715. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118717. * @param name defines the name of the mesh
  118718. * @param options defines the options used to create the mesh
  118719. * @param scene defines the hosting scene
  118720. * @returns the ribbon mesh
  118721. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118723. */
  118724. static CreateRibbon(name: string, options: {
  118725. pathArray: Vector3[][];
  118726. closeArray?: boolean;
  118727. closePath?: boolean;
  118728. offset?: number;
  118729. updatable?: boolean;
  118730. sideOrientation?: number;
  118731. frontUVs?: Vector4;
  118732. backUVs?: Vector4;
  118733. instance?: Mesh;
  118734. invertUV?: boolean;
  118735. uvs?: Vector2[];
  118736. colors?: Color4[];
  118737. }, scene?: Nullable<Scene>): Mesh;
  118738. }
  118739. }
  118740. declare module BABYLON {
  118741. /**
  118742. * Class containing static functions to help procedurally build meshes
  118743. */
  118744. export class ShapeBuilder {
  118745. /**
  118746. * 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.
  118747. * * 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.
  118748. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118749. * * 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.
  118750. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118751. * * 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
  118752. * * 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
  118753. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118758. * @param name defines the name of the mesh
  118759. * @param options defines the options used to create the mesh
  118760. * @param scene defines the hosting scene
  118761. * @returns the extruded shape mesh
  118762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118764. */
  118765. static ExtrudeShape(name: string, options: {
  118766. shape: Vector3[];
  118767. path: Vector3[];
  118768. scale?: number;
  118769. rotation?: number;
  118770. cap?: number;
  118771. updatable?: boolean;
  118772. sideOrientation?: number;
  118773. frontUVs?: Vector4;
  118774. backUVs?: Vector4;
  118775. instance?: Mesh;
  118776. invertUV?: boolean;
  118777. }, scene?: Nullable<Scene>): Mesh;
  118778. /**
  118779. * Creates an custom extruded shape mesh.
  118780. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118781. * * 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.
  118782. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118783. * * 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
  118784. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118785. * * 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
  118786. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118787. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118788. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118789. * * 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
  118790. * * 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
  118791. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118794. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118796. * @param name defines the name of the mesh
  118797. * @param options defines the options used to create the mesh
  118798. * @param scene defines the hosting scene
  118799. * @returns the custom extruded shape mesh
  118800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118801. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118803. */
  118804. static ExtrudeShapeCustom(name: string, options: {
  118805. shape: Vector3[];
  118806. path: Vector3[];
  118807. scaleFunction?: any;
  118808. rotationFunction?: any;
  118809. ribbonCloseArray?: boolean;
  118810. ribbonClosePath?: boolean;
  118811. cap?: number;
  118812. updatable?: boolean;
  118813. sideOrientation?: number;
  118814. frontUVs?: Vector4;
  118815. backUVs?: Vector4;
  118816. instance?: Mesh;
  118817. invertUV?: boolean;
  118818. }, scene?: Nullable<Scene>): Mesh;
  118819. private static _ExtrudeShapeGeneric;
  118820. }
  118821. }
  118822. declare module BABYLON {
  118823. /**
  118824. * AmmoJS Physics plugin
  118825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118826. * @see https://github.com/kripken/ammo.js/
  118827. */
  118828. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118829. private _useDeltaForWorldStep;
  118830. /**
  118831. * Reference to the Ammo library
  118832. */
  118833. bjsAMMO: any;
  118834. /**
  118835. * Created ammoJS world which physics bodies are added to
  118836. */
  118837. world: any;
  118838. /**
  118839. * Name of the plugin
  118840. */
  118841. name: string;
  118842. private _timeStep;
  118843. private _fixedTimeStep;
  118844. private _maxSteps;
  118845. private _tmpQuaternion;
  118846. private _tmpAmmoTransform;
  118847. private _tmpAmmoQuaternion;
  118848. private _tmpAmmoConcreteContactResultCallback;
  118849. private _collisionConfiguration;
  118850. private _dispatcher;
  118851. private _overlappingPairCache;
  118852. private _solver;
  118853. private _softBodySolver;
  118854. private _tmpAmmoVectorA;
  118855. private _tmpAmmoVectorB;
  118856. private _tmpAmmoVectorC;
  118857. private _tmpAmmoVectorD;
  118858. private _tmpContactCallbackResult;
  118859. private _tmpAmmoVectorRCA;
  118860. private _tmpAmmoVectorRCB;
  118861. private _raycastResult;
  118862. private static readonly DISABLE_COLLISION_FLAG;
  118863. private static readonly KINEMATIC_FLAG;
  118864. private static readonly DISABLE_DEACTIVATION_FLAG;
  118865. /**
  118866. * Initializes the ammoJS plugin
  118867. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118868. * @param ammoInjection can be used to inject your own ammo reference
  118869. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118870. */
  118871. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118872. /**
  118873. * Sets the gravity of the physics world (m/(s^2))
  118874. * @param gravity Gravity to set
  118875. */
  118876. setGravity(gravity: Vector3): void;
  118877. /**
  118878. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118879. * @param timeStep timestep to use in seconds
  118880. */
  118881. setTimeStep(timeStep: number): void;
  118882. /**
  118883. * 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)
  118884. * @param fixedTimeStep fixedTimeStep to use in seconds
  118885. */
  118886. setFixedTimeStep(fixedTimeStep: number): void;
  118887. /**
  118888. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118889. * @param maxSteps the maximum number of steps by the physics engine per frame
  118890. */
  118891. setMaxSteps(maxSteps: number): void;
  118892. /**
  118893. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118894. * @returns the current timestep in seconds
  118895. */
  118896. getTimeStep(): number;
  118897. private _isImpostorInContact;
  118898. private _isImpostorPairInContact;
  118899. private _stepSimulation;
  118900. /**
  118901. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118902. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118903. * After the step the babylon meshes are set to the position of the physics imposters
  118904. * @param delta amount of time to step forward
  118905. * @param impostors array of imposters to update before/after the step
  118906. */
  118907. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118908. /**
  118909. * Update babylon mesh to match physics world object
  118910. * @param impostor imposter to match
  118911. */
  118912. private _afterSoftStep;
  118913. /**
  118914. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118915. * @param impostor imposter to match
  118916. */
  118917. private _ropeStep;
  118918. /**
  118919. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118920. * @param impostor imposter to match
  118921. */
  118922. private _softbodyOrClothStep;
  118923. private _tmpVector;
  118924. private _tmpMatrix;
  118925. /**
  118926. * Applies an impulse on the imposter
  118927. * @param impostor imposter to apply impulse to
  118928. * @param force amount of force to be applied to the imposter
  118929. * @param contactPoint the location to apply the impulse on the imposter
  118930. */
  118931. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118932. /**
  118933. * Applies a force on the imposter
  118934. * @param impostor imposter to apply force
  118935. * @param force amount of force to be applied to the imposter
  118936. * @param contactPoint the location to apply the force on the imposter
  118937. */
  118938. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118939. /**
  118940. * Creates a physics body using the plugin
  118941. * @param impostor the imposter to create the physics body on
  118942. */
  118943. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118944. /**
  118945. * Removes the physics body from the imposter and disposes of the body's memory
  118946. * @param impostor imposter to remove the physics body from
  118947. */
  118948. removePhysicsBody(impostor: PhysicsImpostor): void;
  118949. /**
  118950. * Generates a joint
  118951. * @param impostorJoint the imposter joint to create the joint with
  118952. */
  118953. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118954. /**
  118955. * Removes a joint
  118956. * @param impostorJoint the imposter joint to remove the joint from
  118957. */
  118958. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118959. private _addMeshVerts;
  118960. /**
  118961. * Initialise the soft body vertices to match its object's (mesh) vertices
  118962. * Softbody vertices (nodes) are in world space and to match this
  118963. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118964. * @param impostor to create the softbody for
  118965. */
  118966. private _softVertexData;
  118967. /**
  118968. * Create an impostor's soft body
  118969. * @param impostor to create the softbody for
  118970. */
  118971. private _createSoftbody;
  118972. /**
  118973. * Create cloth for an impostor
  118974. * @param impostor to create the softbody for
  118975. */
  118976. private _createCloth;
  118977. /**
  118978. * Create rope for an impostor
  118979. * @param impostor to create the softbody for
  118980. */
  118981. private _createRope;
  118982. private _addHullVerts;
  118983. private _createShape;
  118984. /**
  118985. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118986. * @param impostor imposter containing the physics body and babylon object
  118987. */
  118988. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118989. /**
  118990. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118991. * @param impostor imposter containing the physics body and babylon object
  118992. * @param newPosition new position
  118993. * @param newRotation new rotation
  118994. */
  118995. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118996. /**
  118997. * If this plugin is supported
  118998. * @returns true if its supported
  118999. */
  119000. isSupported(): boolean;
  119001. /**
  119002. * Sets the linear velocity of the physics body
  119003. * @param impostor imposter to set the velocity on
  119004. * @param velocity velocity to set
  119005. */
  119006. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119007. /**
  119008. * Sets the angular velocity of the physics body
  119009. * @param impostor imposter to set the velocity on
  119010. * @param velocity velocity to set
  119011. */
  119012. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119013. /**
  119014. * gets the linear velocity
  119015. * @param impostor imposter to get linear velocity from
  119016. * @returns linear velocity
  119017. */
  119018. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119019. /**
  119020. * gets the angular velocity
  119021. * @param impostor imposter to get angular velocity from
  119022. * @returns angular velocity
  119023. */
  119024. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119025. /**
  119026. * Sets the mass of physics body
  119027. * @param impostor imposter to set the mass on
  119028. * @param mass mass to set
  119029. */
  119030. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119031. /**
  119032. * Gets the mass of the physics body
  119033. * @param impostor imposter to get the mass from
  119034. * @returns mass
  119035. */
  119036. getBodyMass(impostor: PhysicsImpostor): number;
  119037. /**
  119038. * Gets friction of the impostor
  119039. * @param impostor impostor to get friction from
  119040. * @returns friction value
  119041. */
  119042. getBodyFriction(impostor: PhysicsImpostor): number;
  119043. /**
  119044. * Sets friction of the impostor
  119045. * @param impostor impostor to set friction on
  119046. * @param friction friction value
  119047. */
  119048. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119049. /**
  119050. * Gets restitution of the impostor
  119051. * @param impostor impostor to get restitution from
  119052. * @returns restitution value
  119053. */
  119054. getBodyRestitution(impostor: PhysicsImpostor): number;
  119055. /**
  119056. * Sets resitution of the impostor
  119057. * @param impostor impostor to set resitution on
  119058. * @param restitution resitution value
  119059. */
  119060. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119061. /**
  119062. * Gets pressure inside the impostor
  119063. * @param impostor impostor to get pressure from
  119064. * @returns pressure value
  119065. */
  119066. getBodyPressure(impostor: PhysicsImpostor): number;
  119067. /**
  119068. * Sets pressure inside a soft body impostor
  119069. * Cloth and rope must remain 0 pressure
  119070. * @param impostor impostor to set pressure on
  119071. * @param pressure pressure value
  119072. */
  119073. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  119074. /**
  119075. * Gets stiffness of the impostor
  119076. * @param impostor impostor to get stiffness from
  119077. * @returns pressure value
  119078. */
  119079. getBodyStiffness(impostor: PhysicsImpostor): number;
  119080. /**
  119081. * Sets stiffness of the impostor
  119082. * @param impostor impostor to set stiffness on
  119083. * @param stiffness stiffness value from 0 to 1
  119084. */
  119085. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  119086. /**
  119087. * Gets velocityIterations of the impostor
  119088. * @param impostor impostor to get velocity iterations from
  119089. * @returns velocityIterations value
  119090. */
  119091. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  119092. /**
  119093. * Sets velocityIterations of the impostor
  119094. * @param impostor impostor to set velocity iterations on
  119095. * @param velocityIterations velocityIterations value
  119096. */
  119097. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  119098. /**
  119099. * Gets positionIterations of the impostor
  119100. * @param impostor impostor to get position iterations from
  119101. * @returns positionIterations value
  119102. */
  119103. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  119104. /**
  119105. * Sets positionIterations of the impostor
  119106. * @param impostor impostor to set position on
  119107. * @param positionIterations positionIterations value
  119108. */
  119109. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  119110. /**
  119111. * Append an anchor to a cloth object
  119112. * @param impostor is the cloth impostor to add anchor to
  119113. * @param otherImpostor is the rigid impostor to anchor to
  119114. * @param width ratio across width from 0 to 1
  119115. * @param height ratio up height from 0 to 1
  119116. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  119117. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119118. */
  119119. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119120. /**
  119121. * Append an hook to a rope object
  119122. * @param impostor is the rope impostor to add hook to
  119123. * @param otherImpostor is the rigid impostor to hook to
  119124. * @param length ratio along the rope from 0 to 1
  119125. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  119126. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119127. */
  119128. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119129. /**
  119130. * Sleeps the physics body and stops it from being active
  119131. * @param impostor impostor to sleep
  119132. */
  119133. sleepBody(impostor: PhysicsImpostor): void;
  119134. /**
  119135. * Activates the physics body
  119136. * @param impostor impostor to activate
  119137. */
  119138. wakeUpBody(impostor: PhysicsImpostor): void;
  119139. /**
  119140. * Updates the distance parameters of the joint
  119141. * @param joint joint to update
  119142. * @param maxDistance maximum distance of the joint
  119143. * @param minDistance minimum distance of the joint
  119144. */
  119145. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119146. /**
  119147. * Sets a motor on the joint
  119148. * @param joint joint to set motor on
  119149. * @param speed speed of the motor
  119150. * @param maxForce maximum force of the motor
  119151. * @param motorIndex index of the motor
  119152. */
  119153. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119154. /**
  119155. * Sets the motors limit
  119156. * @param joint joint to set limit on
  119157. * @param upperLimit upper limit
  119158. * @param lowerLimit lower limit
  119159. */
  119160. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119161. /**
  119162. * Syncs the position and rotation of a mesh with the impostor
  119163. * @param mesh mesh to sync
  119164. * @param impostor impostor to update the mesh with
  119165. */
  119166. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119167. /**
  119168. * Gets the radius of the impostor
  119169. * @param impostor impostor to get radius from
  119170. * @returns the radius
  119171. */
  119172. getRadius(impostor: PhysicsImpostor): number;
  119173. /**
  119174. * Gets the box size of the impostor
  119175. * @param impostor impostor to get box size from
  119176. * @param result the resulting box size
  119177. */
  119178. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119179. /**
  119180. * Disposes of the impostor
  119181. */
  119182. dispose(): void;
  119183. /**
  119184. * Does a raycast in the physics world
  119185. * @param from when should the ray start?
  119186. * @param to when should the ray end?
  119187. * @returns PhysicsRaycastResult
  119188. */
  119189. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119190. }
  119191. }
  119192. declare module BABYLON {
  119193. interface AbstractScene {
  119194. /**
  119195. * The list of reflection probes added to the scene
  119196. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119197. */
  119198. reflectionProbes: Array<ReflectionProbe>;
  119199. /**
  119200. * Removes the given reflection probe from this scene.
  119201. * @param toRemove The reflection probe to remove
  119202. * @returns The index of the removed reflection probe
  119203. */
  119204. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119205. /**
  119206. * Adds the given reflection probe to this scene.
  119207. * @param newReflectionProbe The reflection probe to add
  119208. */
  119209. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119210. }
  119211. /**
  119212. * Class used to generate realtime reflection / refraction cube textures
  119213. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119214. */
  119215. export class ReflectionProbe {
  119216. /** defines the name of the probe */
  119217. name: string;
  119218. private _scene;
  119219. private _renderTargetTexture;
  119220. private _projectionMatrix;
  119221. private _viewMatrix;
  119222. private _target;
  119223. private _add;
  119224. private _attachedMesh;
  119225. private _invertYAxis;
  119226. /** Gets or sets probe position (center of the cube map) */
  119227. position: Vector3;
  119228. /**
  119229. * Creates a new reflection probe
  119230. * @param name defines the name of the probe
  119231. * @param size defines the texture resolution (for each face)
  119232. * @param scene defines the hosting scene
  119233. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119234. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119235. */
  119236. constructor(
  119237. /** defines the name of the probe */
  119238. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119239. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119240. samples: number;
  119241. /** Gets or sets the refresh rate to use (on every frame by default) */
  119242. refreshRate: number;
  119243. /**
  119244. * Gets the hosting scene
  119245. * @returns a Scene
  119246. */
  119247. getScene(): Scene;
  119248. /** Gets the internal CubeTexture used to render to */
  119249. readonly cubeTexture: RenderTargetTexture;
  119250. /** Gets the list of meshes to render */
  119251. readonly renderList: Nullable<AbstractMesh[]>;
  119252. /**
  119253. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119254. * @param mesh defines the mesh to attach to
  119255. */
  119256. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119257. /**
  119258. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119259. * @param renderingGroupId The rendering group id corresponding to its index
  119260. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119261. */
  119262. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119263. /**
  119264. * Clean all associated resources
  119265. */
  119266. dispose(): void;
  119267. /**
  119268. * Converts the reflection probe information to a readable string for debug purpose.
  119269. * @param fullDetails Supports for multiple levels of logging within scene loading
  119270. * @returns the human readable reflection probe info
  119271. */
  119272. toString(fullDetails?: boolean): string;
  119273. /**
  119274. * Get the class name of the relfection probe.
  119275. * @returns "ReflectionProbe"
  119276. */
  119277. getClassName(): string;
  119278. /**
  119279. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119280. * @returns The JSON representation of the texture
  119281. */
  119282. serialize(): any;
  119283. /**
  119284. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119285. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119286. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119287. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119288. * @returns The parsed reflection probe if successful
  119289. */
  119290. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119291. }
  119292. }
  119293. declare module BABYLON {
  119294. /** @hidden */
  119295. export var _BabylonLoaderRegistered: boolean;
  119296. }
  119297. declare module BABYLON {
  119298. /**
  119299. * The Physically based simple base material of BJS.
  119300. *
  119301. * This enables better naming and convention enforcements on top of the pbrMaterial.
  119302. * It is used as the base class for both the specGloss and metalRough conventions.
  119303. */
  119304. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  119305. /**
  119306. * Number of Simultaneous lights allowed on the material.
  119307. */
  119308. maxSimultaneousLights: number;
  119309. /**
  119310. * If sets to true, disables all the lights affecting the material.
  119311. */
  119312. disableLighting: boolean;
  119313. /**
  119314. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119315. */
  119316. environmentTexture: BaseTexture;
  119317. /**
  119318. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119319. */
  119320. invertNormalMapX: boolean;
  119321. /**
  119322. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119323. */
  119324. invertNormalMapY: boolean;
  119325. /**
  119326. * Normal map used in the model.
  119327. */
  119328. normalTexture: BaseTexture;
  119329. /**
  119330. * Emissivie color used to self-illuminate the model.
  119331. */
  119332. emissiveColor: Color3;
  119333. /**
  119334. * Emissivie texture used to self-illuminate the model.
  119335. */
  119336. emissiveTexture: BaseTexture;
  119337. /**
  119338. * Occlusion Channel Strenght.
  119339. */
  119340. occlusionStrength: number;
  119341. /**
  119342. * Occlusion Texture of the material (adding extra occlusion effects).
  119343. */
  119344. occlusionTexture: BaseTexture;
  119345. /**
  119346. * Defines the alpha limits in alpha test mode.
  119347. */
  119348. alphaCutOff: number;
  119349. /**
  119350. * Gets the current double sided mode.
  119351. */
  119352. /**
  119353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119354. */
  119355. doubleSided: boolean;
  119356. /**
  119357. * Stores the pre-calculated light information of a mesh in a texture.
  119358. */
  119359. lightmapTexture: BaseTexture;
  119360. /**
  119361. * If true, the light map contains occlusion information instead of lighting info.
  119362. */
  119363. useLightmapAsShadowmap: boolean;
  119364. /**
  119365. * Instantiates a new PBRMaterial instance.
  119366. *
  119367. * @param name The material name
  119368. * @param scene The scene the material will be use in.
  119369. */
  119370. constructor(name: string, scene: Scene);
  119371. getClassName(): string;
  119372. }
  119373. }
  119374. declare module BABYLON {
  119375. /**
  119376. * The PBR material of BJS following the metal roughness convention.
  119377. *
  119378. * This fits to the PBR convention in the GLTF definition:
  119379. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119380. */
  119381. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119382. /**
  119383. * The base color has two different interpretations depending on the value of metalness.
  119384. * When the material is a metal, the base color is the specific measured reflectance value
  119385. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119386. * of the material.
  119387. */
  119388. baseColor: Color3;
  119389. /**
  119390. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119391. * well as opacity information in the alpha channel.
  119392. */
  119393. baseTexture: BaseTexture;
  119394. /**
  119395. * Specifies the metallic scalar value of the material.
  119396. * Can also be used to scale the metalness values of the metallic texture.
  119397. */
  119398. metallic: number;
  119399. /**
  119400. * Specifies the roughness scalar value of the material.
  119401. * Can also be used to scale the roughness values of the metallic texture.
  119402. */
  119403. roughness: number;
  119404. /**
  119405. * Texture containing both the metallic value in the B channel and the
  119406. * roughness value in the G channel to keep better precision.
  119407. */
  119408. metallicRoughnessTexture: BaseTexture;
  119409. /**
  119410. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119411. *
  119412. * @param name The material name
  119413. * @param scene The scene the material will be use in.
  119414. */
  119415. constructor(name: string, scene: Scene);
  119416. /**
  119417. * Return the currrent class name of the material.
  119418. */
  119419. getClassName(): string;
  119420. /**
  119421. * Makes a duplicate of the current material.
  119422. * @param name - name to use for the new material.
  119423. */
  119424. clone(name: string): PBRMetallicRoughnessMaterial;
  119425. /**
  119426. * Serialize the material to a parsable JSON object.
  119427. */
  119428. serialize(): any;
  119429. /**
  119430. * Parses a JSON object correponding to the serialize function.
  119431. */
  119432. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119433. }
  119434. }
  119435. declare module BABYLON {
  119436. /**
  119437. * The PBR material of BJS following the specular glossiness convention.
  119438. *
  119439. * This fits to the PBR convention in the GLTF definition:
  119440. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119441. */
  119442. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119443. /**
  119444. * Specifies the diffuse color of the material.
  119445. */
  119446. diffuseColor: Color3;
  119447. /**
  119448. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119449. * channel.
  119450. */
  119451. diffuseTexture: BaseTexture;
  119452. /**
  119453. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119454. */
  119455. specularColor: Color3;
  119456. /**
  119457. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119458. */
  119459. glossiness: number;
  119460. /**
  119461. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119462. */
  119463. specularGlossinessTexture: BaseTexture;
  119464. /**
  119465. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119466. *
  119467. * @param name The material name
  119468. * @param scene The scene the material will be use in.
  119469. */
  119470. constructor(name: string, scene: Scene);
  119471. /**
  119472. * Return the currrent class name of the material.
  119473. */
  119474. getClassName(): string;
  119475. /**
  119476. * Makes a duplicate of the current material.
  119477. * @param name - name to use for the new material.
  119478. */
  119479. clone(name: string): PBRSpecularGlossinessMaterial;
  119480. /**
  119481. * Serialize the material to a parsable JSON object.
  119482. */
  119483. serialize(): any;
  119484. /**
  119485. * Parses a JSON object correponding to the serialize function.
  119486. */
  119487. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119488. }
  119489. }
  119490. declare module BABYLON {
  119491. /**
  119492. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119493. * It can help converting any input color in a desired output one. This can then be used to create effects
  119494. * from sepia, black and white to sixties or futuristic rendering...
  119495. *
  119496. * The only supported format is currently 3dl.
  119497. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119498. */
  119499. export class ColorGradingTexture extends BaseTexture {
  119500. /**
  119501. * The current texture matrix. (will always be identity in color grading texture)
  119502. */
  119503. private _textureMatrix;
  119504. /**
  119505. * The texture URL.
  119506. */
  119507. url: string;
  119508. /**
  119509. * Empty line regex stored for GC.
  119510. */
  119511. private static _noneEmptyLineRegex;
  119512. private _engine;
  119513. /**
  119514. * Instantiates a ColorGradingTexture from the following parameters.
  119515. *
  119516. * @param url The location of the color gradind data (currently only supporting 3dl)
  119517. * @param scene The scene the texture will be used in
  119518. */
  119519. constructor(url: string, scene: Scene);
  119520. /**
  119521. * Returns the texture matrix used in most of the material.
  119522. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119523. */
  119524. getTextureMatrix(): Matrix;
  119525. /**
  119526. * Occurs when the file being loaded is a .3dl LUT file.
  119527. */
  119528. private load3dlTexture;
  119529. /**
  119530. * Starts the loading process of the texture.
  119531. */
  119532. private loadTexture;
  119533. /**
  119534. * Clones the color gradind texture.
  119535. */
  119536. clone(): ColorGradingTexture;
  119537. /**
  119538. * Called during delayed load for textures.
  119539. */
  119540. delayLoad(): void;
  119541. /**
  119542. * Parses a color grading texture serialized by Babylon.
  119543. * @param parsedTexture The texture information being parsedTexture
  119544. * @param scene The scene to load the texture in
  119545. * @param rootUrl The root url of the data assets to load
  119546. * @return A color gradind texture
  119547. */
  119548. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119549. /**
  119550. * Serializes the LUT texture to json format.
  119551. */
  119552. serialize(): any;
  119553. }
  119554. }
  119555. declare module BABYLON {
  119556. /**
  119557. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119558. */
  119559. export class EquiRectangularCubeTexture extends BaseTexture {
  119560. /** The six faces of the cube. */
  119561. private static _FacesMapping;
  119562. private _noMipmap;
  119563. private _onLoad;
  119564. private _onError;
  119565. /** The size of the cubemap. */
  119566. private _size;
  119567. /** The buffer of the image. */
  119568. private _buffer;
  119569. /** The width of the input image. */
  119570. private _width;
  119571. /** The height of the input image. */
  119572. private _height;
  119573. /** The URL to the image. */
  119574. url: string;
  119575. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119576. coordinatesMode: number;
  119577. /**
  119578. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119579. * @param url The location of the image
  119580. * @param scene The scene the texture will be used in
  119581. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119582. * @param noMipmap Forces to not generate the mipmap if true
  119583. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119584. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119585. * @param onLoad — defines a callback called when texture is loaded
  119586. * @param onError — defines a callback called if there is an error
  119587. */
  119588. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119589. /**
  119590. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119591. */
  119592. private loadImage;
  119593. /**
  119594. * Convert the image buffer into a cubemap and create a CubeTexture.
  119595. */
  119596. private loadTexture;
  119597. /**
  119598. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119599. * @param buffer The ArrayBuffer that should be converted.
  119600. * @returns The buffer as Float32Array.
  119601. */
  119602. private getFloat32ArrayFromArrayBuffer;
  119603. /**
  119604. * Get the current class name of the texture useful for serialization or dynamic coding.
  119605. * @returns "EquiRectangularCubeTexture"
  119606. */
  119607. getClassName(): string;
  119608. /**
  119609. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119610. * @returns A clone of the current EquiRectangularCubeTexture.
  119611. */
  119612. clone(): EquiRectangularCubeTexture;
  119613. }
  119614. }
  119615. declare module BABYLON {
  119616. /**
  119617. * Based on jsTGALoader - Javascript loader for TGA file
  119618. * By Vincent Thibault
  119619. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119620. */
  119621. export class TGATools {
  119622. private static _TYPE_INDEXED;
  119623. private static _TYPE_RGB;
  119624. private static _TYPE_GREY;
  119625. private static _TYPE_RLE_INDEXED;
  119626. private static _TYPE_RLE_RGB;
  119627. private static _TYPE_RLE_GREY;
  119628. private static _ORIGIN_MASK;
  119629. private static _ORIGIN_SHIFT;
  119630. private static _ORIGIN_BL;
  119631. private static _ORIGIN_BR;
  119632. private static _ORIGIN_UL;
  119633. private static _ORIGIN_UR;
  119634. /**
  119635. * Gets the header of a TGA file
  119636. * @param data defines the TGA data
  119637. * @returns the header
  119638. */
  119639. static GetTGAHeader(data: Uint8Array): any;
  119640. /**
  119641. * Uploads TGA content to a Babylon Texture
  119642. * @hidden
  119643. */
  119644. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119645. /** @hidden */
  119646. 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;
  119647. /** @hidden */
  119648. 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;
  119649. /** @hidden */
  119650. 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;
  119651. /** @hidden */
  119652. 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;
  119653. /** @hidden */
  119654. 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;
  119655. /** @hidden */
  119656. 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;
  119657. }
  119658. }
  119659. declare module BABYLON {
  119660. /**
  119661. * Implementation of the TGA Texture Loader.
  119662. * @hidden
  119663. */
  119664. export class _TGATextureLoader implements IInternalTextureLoader {
  119665. /**
  119666. * Defines wether the loader supports cascade loading the different faces.
  119667. */
  119668. readonly supportCascades: boolean;
  119669. /**
  119670. * This returns if the loader support the current file information.
  119671. * @param extension defines the file extension of the file being loaded
  119672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119673. * @param fallback defines the fallback internal texture if any
  119674. * @param isBase64 defines whether the texture is encoded as a base64
  119675. * @param isBuffer defines whether the texture data are stored as a buffer
  119676. * @returns true if the loader can load the specified file
  119677. */
  119678. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119679. /**
  119680. * Transform the url before loading if required.
  119681. * @param rootUrl the url of the texture
  119682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119683. * @returns the transformed texture
  119684. */
  119685. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119686. /**
  119687. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119688. * @param rootUrl the url of the texture
  119689. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119690. * @returns the fallback texture
  119691. */
  119692. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119693. /**
  119694. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119695. * @param data contains the texture data
  119696. * @param texture defines the BabylonJS internal texture
  119697. * @param createPolynomials will be true if polynomials have been requested
  119698. * @param onLoad defines the callback to trigger once the texture is ready
  119699. * @param onError defines the callback to trigger in case of error
  119700. */
  119701. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119702. /**
  119703. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119704. * @param data contains the texture data
  119705. * @param texture defines the BabylonJS internal texture
  119706. * @param callback defines the method to call once ready to upload
  119707. */
  119708. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119709. }
  119710. }
  119711. declare module BABYLON {
  119712. /**
  119713. * Info about the .basis files
  119714. */
  119715. class BasisFileInfo {
  119716. /**
  119717. * If the file has alpha
  119718. */
  119719. hasAlpha: boolean;
  119720. /**
  119721. * Info about each image of the basis file
  119722. */
  119723. images: Array<{
  119724. levels: Array<{
  119725. width: number;
  119726. height: number;
  119727. transcodedPixels: ArrayBufferView;
  119728. }>;
  119729. }>;
  119730. }
  119731. /**
  119732. * Result of transcoding a basis file
  119733. */
  119734. class TranscodeResult {
  119735. /**
  119736. * Info about the .basis file
  119737. */
  119738. fileInfo: BasisFileInfo;
  119739. /**
  119740. * Format to use when loading the file
  119741. */
  119742. format: number;
  119743. }
  119744. /**
  119745. * Configuration options for the Basis transcoder
  119746. */
  119747. export class BasisTranscodeConfiguration {
  119748. /**
  119749. * Supported compression formats used to determine the supported output format of the transcoder
  119750. */
  119751. supportedCompressionFormats?: {
  119752. /**
  119753. * etc1 compression format
  119754. */
  119755. etc1?: boolean;
  119756. /**
  119757. * s3tc compression format
  119758. */
  119759. s3tc?: boolean;
  119760. /**
  119761. * pvrtc compression format
  119762. */
  119763. pvrtc?: boolean;
  119764. /**
  119765. * etc2 compression format
  119766. */
  119767. etc2?: boolean;
  119768. };
  119769. /**
  119770. * If mipmap levels should be loaded for transcoded images (Default: true)
  119771. */
  119772. loadMipmapLevels?: boolean;
  119773. /**
  119774. * Index of a single image to load (Default: all images)
  119775. */
  119776. loadSingleImage?: number;
  119777. }
  119778. /**
  119779. * Used to load .Basis files
  119780. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119781. */
  119782. export class BasisTools {
  119783. private static _IgnoreSupportedFormats;
  119784. /**
  119785. * URL to use when loading the basis transcoder
  119786. */
  119787. static JSModuleURL: string;
  119788. /**
  119789. * URL to use when loading the wasm module for the transcoder
  119790. */
  119791. static WasmModuleURL: string;
  119792. /**
  119793. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119794. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119795. * @returns internal format corresponding to the Basis format
  119796. */
  119797. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119798. private static _WorkerPromise;
  119799. private static _Worker;
  119800. private static _actionId;
  119801. private static _CreateWorkerAsync;
  119802. /**
  119803. * Transcodes a loaded image file to compressed pixel data
  119804. * @param imageData image data to transcode
  119805. * @param config configuration options for the transcoding
  119806. * @returns a promise resulting in the transcoded image
  119807. */
  119808. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119809. /**
  119810. * Loads a texture from the transcode result
  119811. * @param texture texture load to
  119812. * @param transcodeResult the result of transcoding the basis file to load from
  119813. */
  119814. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119815. }
  119816. }
  119817. declare module BABYLON {
  119818. /**
  119819. * Loader for .basis file format
  119820. */
  119821. export class _BasisTextureLoader implements IInternalTextureLoader {
  119822. /**
  119823. * Defines whether the loader supports cascade loading the different faces.
  119824. */
  119825. readonly supportCascades: boolean;
  119826. /**
  119827. * This returns if the loader support the current file information.
  119828. * @param extension defines the file extension of the file being loaded
  119829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119830. * @param fallback defines the fallback internal texture if any
  119831. * @param isBase64 defines whether the texture is encoded as a base64
  119832. * @param isBuffer defines whether the texture data are stored as a buffer
  119833. * @returns true if the loader can load the specified file
  119834. */
  119835. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119836. /**
  119837. * Transform the url before loading if required.
  119838. * @param rootUrl the url of the texture
  119839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119840. * @returns the transformed texture
  119841. */
  119842. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119843. /**
  119844. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119845. * @param rootUrl the url of the texture
  119846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119847. * @returns the fallback texture
  119848. */
  119849. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119850. /**
  119851. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119852. * @param data contains the texture data
  119853. * @param texture defines the BabylonJS internal texture
  119854. * @param createPolynomials will be true if polynomials have been requested
  119855. * @param onLoad defines the callback to trigger once the texture is ready
  119856. * @param onError defines the callback to trigger in case of error
  119857. */
  119858. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119859. /**
  119860. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119861. * @param data contains the texture data
  119862. * @param texture defines the BabylonJS internal texture
  119863. * @param callback defines the method to call once ready to upload
  119864. */
  119865. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119866. }
  119867. }
  119868. declare module BABYLON {
  119869. /**
  119870. * 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.
  119871. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119872. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119873. */
  119874. export class CustomProceduralTexture extends ProceduralTexture {
  119875. private _animate;
  119876. private _time;
  119877. private _config;
  119878. private _texturePath;
  119879. /**
  119880. * Instantiates a new Custom Procedural Texture.
  119881. * 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.
  119882. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119883. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119884. * @param name Define the name of the texture
  119885. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119886. * @param size Define the size of the texture to create
  119887. * @param scene Define the scene the texture belongs to
  119888. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119889. * @param generateMipMaps Define if the texture should creates mip maps or not
  119890. */
  119891. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119892. private _loadJson;
  119893. /**
  119894. * Is the texture ready to be used ? (rendered at least once)
  119895. * @returns true if ready, otherwise, false.
  119896. */
  119897. isReady(): boolean;
  119898. /**
  119899. * Render the texture to its associated render target.
  119900. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119901. */
  119902. render(useCameraPostProcess?: boolean): void;
  119903. /**
  119904. * Update the list of dependant textures samplers in the shader.
  119905. */
  119906. updateTextures(): void;
  119907. /**
  119908. * Update the uniform values of the procedural texture in the shader.
  119909. */
  119910. updateShaderUniforms(): void;
  119911. /**
  119912. * Define if the texture animates or not.
  119913. */
  119914. animate: boolean;
  119915. }
  119916. }
  119917. declare module BABYLON {
  119918. /** @hidden */
  119919. export var noisePixelShader: {
  119920. name: string;
  119921. shader: string;
  119922. };
  119923. }
  119924. declare module BABYLON {
  119925. /**
  119926. * Class used to generate noise procedural textures
  119927. */
  119928. export class NoiseProceduralTexture extends ProceduralTexture {
  119929. private _time;
  119930. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119931. brightness: number;
  119932. /** Defines the number of octaves to process */
  119933. octaves: number;
  119934. /** Defines the level of persistence (0.8 by default) */
  119935. persistence: number;
  119936. /** Gets or sets animation speed factor (default is 1) */
  119937. animationSpeedFactor: number;
  119938. /**
  119939. * Creates a new NoiseProceduralTexture
  119940. * @param name defines the name fo the texture
  119941. * @param size defines the size of the texture (default is 256)
  119942. * @param scene defines the hosting scene
  119943. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119944. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119945. */
  119946. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119947. private _updateShaderUniforms;
  119948. protected _getDefines(): string;
  119949. /** Generate the current state of the procedural texture */
  119950. render(useCameraPostProcess?: boolean): void;
  119951. /**
  119952. * Serializes this noise procedural texture
  119953. * @returns a serialized noise procedural texture object
  119954. */
  119955. serialize(): any;
  119956. /**
  119957. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119958. * @param parsedTexture defines parsed texture data
  119959. * @param scene defines the current scene
  119960. * @param rootUrl defines the root URL containing noise procedural texture information
  119961. * @returns a parsed NoiseProceduralTexture
  119962. */
  119963. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119964. }
  119965. }
  119966. declare module BABYLON {
  119967. /**
  119968. * Raw cube texture where the raw buffers are passed in
  119969. */
  119970. export class RawCubeTexture extends CubeTexture {
  119971. /**
  119972. * Creates a cube texture where the raw buffers are passed in.
  119973. * @param scene defines the scene the texture is attached to
  119974. * @param data defines the array of data to use to create each face
  119975. * @param size defines the size of the textures
  119976. * @param format defines the format of the data
  119977. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119978. * @param generateMipMaps defines if the engine should generate the mip levels
  119979. * @param invertY defines if data must be stored with Y axis inverted
  119980. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119981. * @param compression defines the compression used (null by default)
  119982. */
  119983. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119984. /**
  119985. * Updates the raw cube texture.
  119986. * @param data defines the data to store
  119987. * @param format defines the data format
  119988. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119989. * @param invertY defines if data must be stored with Y axis inverted
  119990. * @param compression defines the compression used (null by default)
  119991. * @param level defines which level of the texture to update
  119992. */
  119993. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119994. /**
  119995. * Updates a raw cube texture with RGBD encoded data.
  119996. * @param data defines the array of data [mipmap][face] to use to create each face
  119997. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119998. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119999. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120000. * @returns a promsie that resolves when the operation is complete
  120001. */
  120002. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  120003. /**
  120004. * Clones the raw cube texture.
  120005. * @return a new cube texture
  120006. */
  120007. clone(): CubeTexture;
  120008. /** @hidden */
  120009. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120010. }
  120011. }
  120012. declare module BABYLON {
  120013. /**
  120014. * Class used to store 3D textures containing user data
  120015. */
  120016. export class RawTexture3D extends Texture {
  120017. /** Gets or sets the texture format to use */
  120018. format: number;
  120019. private _engine;
  120020. /**
  120021. * Create a new RawTexture3D
  120022. * @param data defines the data of the texture
  120023. * @param width defines the width of the texture
  120024. * @param height defines the height of the texture
  120025. * @param depth defines the depth of the texture
  120026. * @param format defines the texture format to use
  120027. * @param scene defines the hosting scene
  120028. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  120029. * @param invertY defines if texture must be stored with Y axis inverted
  120030. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120031. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  120032. */
  120033. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  120034. /** Gets or sets the texture format to use */
  120035. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  120036. /**
  120037. * Update the texture with new data
  120038. * @param data defines the data to store in the texture
  120039. */
  120040. update(data: ArrayBufferView): void;
  120041. }
  120042. }
  120043. declare module BABYLON {
  120044. /**
  120045. * Creates a refraction texture used by refraction channel of the standard material.
  120046. * It is like a mirror but to see through a material.
  120047. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120048. */
  120049. export class RefractionTexture extends RenderTargetTexture {
  120050. /**
  120051. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  120052. * 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.
  120053. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120054. */
  120055. refractionPlane: Plane;
  120056. /**
  120057. * Define how deep under the surface we should see.
  120058. */
  120059. depth: number;
  120060. /**
  120061. * Creates a refraction texture used by refraction channel of the standard material.
  120062. * It is like a mirror but to see through a material.
  120063. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120064. * @param name Define the texture name
  120065. * @param size Define the size of the underlying texture
  120066. * @param scene Define the scene the refraction belongs to
  120067. * @param generateMipMaps Define if we need to generate mips level for the refraction
  120068. */
  120069. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  120070. /**
  120071. * Clone the refraction texture.
  120072. * @returns the cloned texture
  120073. */
  120074. clone(): RefractionTexture;
  120075. /**
  120076. * Serialize the texture to a JSON representation you could use in Parse later on
  120077. * @returns the serialized JSON representation
  120078. */
  120079. serialize(): any;
  120080. }
  120081. }
  120082. declare module BABYLON {
  120083. /**
  120084. * Defines the options related to the creation of an HtmlElementTexture
  120085. */
  120086. export interface IHtmlElementTextureOptions {
  120087. /**
  120088. * Defines wether mip maps should be created or not.
  120089. */
  120090. generateMipMaps?: boolean;
  120091. /**
  120092. * Defines the sampling mode of the texture.
  120093. */
  120094. samplingMode?: number;
  120095. /**
  120096. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  120097. */
  120098. engine: Nullable<ThinEngine>;
  120099. /**
  120100. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  120101. */
  120102. scene: Nullable<Scene>;
  120103. }
  120104. /**
  120105. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  120106. * To be as efficient as possible depending on your constraints nothing aside the first upload
  120107. * is automatically managed.
  120108. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  120109. * in your application.
  120110. *
  120111. * As the update is not automatic, you need to call them manually.
  120112. */
  120113. export class HtmlElementTexture extends BaseTexture {
  120114. /**
  120115. * The texture URL.
  120116. */
  120117. element: HTMLVideoElement | HTMLCanvasElement;
  120118. private static readonly DefaultOptions;
  120119. private _textureMatrix;
  120120. private _engine;
  120121. private _isVideo;
  120122. private _generateMipMaps;
  120123. private _samplingMode;
  120124. /**
  120125. * Instantiates a HtmlElementTexture from the following parameters.
  120126. *
  120127. * @param name Defines the name of the texture
  120128. * @param element Defines the video or canvas the texture is filled with
  120129. * @param options Defines the other none mandatory texture creation options
  120130. */
  120131. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  120132. private _createInternalTexture;
  120133. /**
  120134. * Returns the texture matrix used in most of the material.
  120135. */
  120136. getTextureMatrix(): Matrix;
  120137. /**
  120138. * Updates the content of the texture.
  120139. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  120140. */
  120141. update(invertY?: Nullable<boolean>): void;
  120142. }
  120143. }
  120144. declare module BABYLON {
  120145. /**
  120146. * Enum used to define the target of a block
  120147. */
  120148. export enum NodeMaterialBlockTargets {
  120149. /** Vertex shader */
  120150. Vertex = 1,
  120151. /** Fragment shader */
  120152. Fragment = 2,
  120153. /** Neutral */
  120154. Neutral = 4,
  120155. /** Vertex and Fragment */
  120156. VertexAndFragment = 3
  120157. }
  120158. }
  120159. declare module BABYLON {
  120160. /**
  120161. * Defines the kind of connection point for node based material
  120162. */
  120163. export enum NodeMaterialBlockConnectionPointTypes {
  120164. /** Float */
  120165. Float = 1,
  120166. /** Int */
  120167. Int = 2,
  120168. /** Vector2 */
  120169. Vector2 = 4,
  120170. /** Vector3 */
  120171. Vector3 = 8,
  120172. /** Vector4 */
  120173. Vector4 = 16,
  120174. /** Color3 */
  120175. Color3 = 32,
  120176. /** Color4 */
  120177. Color4 = 64,
  120178. /** Matrix */
  120179. Matrix = 128,
  120180. /** Detect type based on connection */
  120181. AutoDetect = 1024,
  120182. /** Output type that will be defined by input type */
  120183. BasedOnInput = 2048
  120184. }
  120185. }
  120186. declare module BABYLON {
  120187. /**
  120188. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120189. */
  120190. export enum NodeMaterialBlockConnectionPointMode {
  120191. /** Value is an uniform */
  120192. Uniform = 0,
  120193. /** Value is a mesh attribute */
  120194. Attribute = 1,
  120195. /** Value is a varying between vertex and fragment shaders */
  120196. Varying = 2,
  120197. /** Mode is undefined */
  120198. Undefined = 3
  120199. }
  120200. }
  120201. declare module BABYLON {
  120202. /**
  120203. * Enum used to define system values e.g. values automatically provided by the system
  120204. */
  120205. export enum NodeMaterialSystemValues {
  120206. /** World */
  120207. World = 1,
  120208. /** View */
  120209. View = 2,
  120210. /** Projection */
  120211. Projection = 3,
  120212. /** ViewProjection */
  120213. ViewProjection = 4,
  120214. /** WorldView */
  120215. WorldView = 5,
  120216. /** WorldViewProjection */
  120217. WorldViewProjection = 6,
  120218. /** CameraPosition */
  120219. CameraPosition = 7,
  120220. /** Fog Color */
  120221. FogColor = 8,
  120222. /** Delta time */
  120223. DeltaTime = 9
  120224. }
  120225. }
  120226. declare module BABYLON {
  120227. /**
  120228. * Root class for all node material optimizers
  120229. */
  120230. export class NodeMaterialOptimizer {
  120231. /**
  120232. * Function used to optimize a NodeMaterial graph
  120233. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  120234. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  120235. */
  120236. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  120237. }
  120238. }
  120239. declare module BABYLON {
  120240. /**
  120241. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  120242. */
  120243. export class TransformBlock extends NodeMaterialBlock {
  120244. /**
  120245. * Defines the value to use to complement W value to transform it to a Vector4
  120246. */
  120247. complementW: number;
  120248. /**
  120249. * Defines the value to use to complement z value to transform it to a Vector4
  120250. */
  120251. complementZ: number;
  120252. /**
  120253. * Creates a new TransformBlock
  120254. * @param name defines the block name
  120255. */
  120256. constructor(name: string);
  120257. /**
  120258. * Gets the current class name
  120259. * @returns the class name
  120260. */
  120261. getClassName(): string;
  120262. /**
  120263. * Gets the vector input
  120264. */
  120265. readonly vector: NodeMaterialConnectionPoint;
  120266. /**
  120267. * Gets the output component
  120268. */
  120269. readonly output: NodeMaterialConnectionPoint;
  120270. /**
  120271. * Gets the matrix transform input
  120272. */
  120273. readonly transform: NodeMaterialConnectionPoint;
  120274. protected _buildBlock(state: NodeMaterialBuildState): this;
  120275. serialize(): any;
  120276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120277. protected _dumpPropertiesCode(): string;
  120278. }
  120279. }
  120280. declare module BABYLON {
  120281. /**
  120282. * Block used to output the vertex position
  120283. */
  120284. export class VertexOutputBlock extends NodeMaterialBlock {
  120285. /**
  120286. * Creates a new VertexOutputBlock
  120287. * @param name defines the block name
  120288. */
  120289. constructor(name: string);
  120290. /**
  120291. * Gets the current class name
  120292. * @returns the class name
  120293. */
  120294. getClassName(): string;
  120295. /**
  120296. * Gets the vector input component
  120297. */
  120298. readonly vector: NodeMaterialConnectionPoint;
  120299. protected _buildBlock(state: NodeMaterialBuildState): this;
  120300. }
  120301. }
  120302. declare module BABYLON {
  120303. /**
  120304. * Block used to output the final color
  120305. */
  120306. export class FragmentOutputBlock extends NodeMaterialBlock {
  120307. /**
  120308. * Create a new FragmentOutputBlock
  120309. * @param name defines the block name
  120310. */
  120311. constructor(name: string);
  120312. /**
  120313. * Gets the current class name
  120314. * @returns the class name
  120315. */
  120316. getClassName(): string;
  120317. /**
  120318. * Gets the rgba input component
  120319. */
  120320. readonly rgba: NodeMaterialConnectionPoint;
  120321. /**
  120322. * Gets the rgb input component
  120323. */
  120324. readonly rgb: NodeMaterialConnectionPoint;
  120325. /**
  120326. * Gets the a input component
  120327. */
  120328. readonly a: NodeMaterialConnectionPoint;
  120329. protected _buildBlock(state: NodeMaterialBuildState): this;
  120330. }
  120331. }
  120332. declare module BABYLON {
  120333. /**
  120334. * Block used to read a reflection texture from a sampler
  120335. */
  120336. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120337. private _define3DName;
  120338. private _defineCubicName;
  120339. private _defineExplicitName;
  120340. private _defineProjectionName;
  120341. private _defineLocalCubicName;
  120342. private _defineSphericalName;
  120343. private _definePlanarName;
  120344. private _defineEquirectangularName;
  120345. private _defineMirroredEquirectangularFixedName;
  120346. private _defineEquirectangularFixedName;
  120347. private _defineSkyboxName;
  120348. private _cubeSamplerName;
  120349. private _2DSamplerName;
  120350. private _positionUVWName;
  120351. private _directionWName;
  120352. private _reflectionCoordsName;
  120353. private _reflection2DCoordsName;
  120354. private _reflectionColorName;
  120355. private _reflectionMatrixName;
  120356. /**
  120357. * Gets or sets the texture associated with the node
  120358. */
  120359. texture: Nullable<BaseTexture>;
  120360. /**
  120361. * Create a new TextureBlock
  120362. * @param name defines the block name
  120363. */
  120364. constructor(name: string);
  120365. /**
  120366. * Gets the current class name
  120367. * @returns the class name
  120368. */
  120369. getClassName(): string;
  120370. /**
  120371. * Gets the world position input component
  120372. */
  120373. readonly position: NodeMaterialConnectionPoint;
  120374. /**
  120375. * Gets the world position input component
  120376. */
  120377. readonly worldPosition: NodeMaterialConnectionPoint;
  120378. /**
  120379. * Gets the world normal input component
  120380. */
  120381. readonly worldNormal: NodeMaterialConnectionPoint;
  120382. /**
  120383. * Gets the world input component
  120384. */
  120385. readonly world: NodeMaterialConnectionPoint;
  120386. /**
  120387. * Gets the camera (or eye) position component
  120388. */
  120389. readonly cameraPosition: NodeMaterialConnectionPoint;
  120390. /**
  120391. * Gets the view input component
  120392. */
  120393. readonly view: NodeMaterialConnectionPoint;
  120394. /**
  120395. * Gets the rgb output component
  120396. */
  120397. readonly rgb: NodeMaterialConnectionPoint;
  120398. /**
  120399. * Gets the r output component
  120400. */
  120401. readonly r: NodeMaterialConnectionPoint;
  120402. /**
  120403. * Gets the g output component
  120404. */
  120405. readonly g: NodeMaterialConnectionPoint;
  120406. /**
  120407. * Gets the b output component
  120408. */
  120409. readonly b: NodeMaterialConnectionPoint;
  120410. autoConfigure(material: NodeMaterial): void;
  120411. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120412. isReady(): boolean;
  120413. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120414. private _injectVertexCode;
  120415. private _writeOutput;
  120416. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120417. serialize(): any;
  120418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120419. }
  120420. }
  120421. declare module BABYLON {
  120422. /**
  120423. * Interface used to configure the node material editor
  120424. */
  120425. export interface INodeMaterialEditorOptions {
  120426. /** Define the URl to load node editor script */
  120427. editorURL?: string;
  120428. }
  120429. /** @hidden */
  120430. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120431. /** BONES */
  120432. NUM_BONE_INFLUENCERS: number;
  120433. BonesPerMesh: number;
  120434. BONETEXTURE: boolean;
  120435. /** MORPH TARGETS */
  120436. MORPHTARGETS: boolean;
  120437. MORPHTARGETS_NORMAL: boolean;
  120438. MORPHTARGETS_TANGENT: boolean;
  120439. MORPHTARGETS_UV: boolean;
  120440. NUM_MORPH_INFLUENCERS: number;
  120441. /** IMAGE PROCESSING */
  120442. IMAGEPROCESSING: boolean;
  120443. VIGNETTE: boolean;
  120444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120445. VIGNETTEBLENDMODEOPAQUE: boolean;
  120446. TONEMAPPING: boolean;
  120447. TONEMAPPING_ACES: boolean;
  120448. CONTRAST: boolean;
  120449. EXPOSURE: boolean;
  120450. COLORCURVES: boolean;
  120451. COLORGRADING: boolean;
  120452. COLORGRADING3D: boolean;
  120453. SAMPLER3DGREENDEPTH: boolean;
  120454. SAMPLER3DBGRMAP: boolean;
  120455. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120456. /** MISC. */
  120457. BUMPDIRECTUV: number;
  120458. constructor();
  120459. setValue(name: string, value: boolean): void;
  120460. }
  120461. /**
  120462. * Class used to configure NodeMaterial
  120463. */
  120464. export interface INodeMaterialOptions {
  120465. /**
  120466. * Defines if blocks should emit comments
  120467. */
  120468. emitComments: boolean;
  120469. }
  120470. /**
  120471. * Class used to create a node based material built by assembling shader blocks
  120472. */
  120473. export class NodeMaterial extends PushMaterial {
  120474. private static _BuildIdGenerator;
  120475. private _options;
  120476. private _vertexCompilationState;
  120477. private _fragmentCompilationState;
  120478. private _sharedData;
  120479. private _buildId;
  120480. private _buildWasSuccessful;
  120481. private _cachedWorldViewMatrix;
  120482. private _cachedWorldViewProjectionMatrix;
  120483. private _optimizers;
  120484. private _animationFrame;
  120485. /** Define the URl to load node editor script */
  120486. static EditorURL: string;
  120487. private BJSNODEMATERIALEDITOR;
  120488. /** Get the inspector from bundle or global */
  120489. private _getGlobalNodeMaterialEditor;
  120490. /**
  120491. * 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)
  120492. */
  120493. ignoreAlpha: boolean;
  120494. /**
  120495. * Defines the maximum number of lights that can be used in the material
  120496. */
  120497. maxSimultaneousLights: number;
  120498. /**
  120499. * Observable raised when the material is built
  120500. */
  120501. onBuildObservable: Observable<NodeMaterial>;
  120502. /**
  120503. * Gets or sets the root nodes of the material vertex shader
  120504. */
  120505. _vertexOutputNodes: NodeMaterialBlock[];
  120506. /**
  120507. * Gets or sets the root nodes of the material fragment (pixel) shader
  120508. */
  120509. _fragmentOutputNodes: NodeMaterialBlock[];
  120510. /** Gets or sets options to control the node material overall behavior */
  120511. options: INodeMaterialOptions;
  120512. /**
  120513. * Default configuration related to image processing available in the standard Material.
  120514. */
  120515. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120516. /**
  120517. * Gets the image processing configuration used either in this material.
  120518. */
  120519. /**
  120520. * Sets the Default image processing configuration used either in the this material.
  120521. *
  120522. * If sets to null, the scene one is in use.
  120523. */
  120524. imageProcessingConfiguration: ImageProcessingConfiguration;
  120525. /**
  120526. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120527. */
  120528. attachedBlocks: NodeMaterialBlock[];
  120529. /**
  120530. * Create a new node based material
  120531. * @param name defines the material name
  120532. * @param scene defines the hosting scene
  120533. * @param options defines creation option
  120534. */
  120535. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120536. /**
  120537. * Gets the current class name of the material e.g. "NodeMaterial"
  120538. * @returns the class name
  120539. */
  120540. getClassName(): string;
  120541. /**
  120542. * Keep track of the image processing observer to allow dispose and replace.
  120543. */
  120544. private _imageProcessingObserver;
  120545. /**
  120546. * Attaches a new image processing configuration to the Standard Material.
  120547. * @param configuration
  120548. */
  120549. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120550. /**
  120551. * Get a block by its name
  120552. * @param name defines the name of the block to retrieve
  120553. * @returns the required block or null if not found
  120554. */
  120555. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120556. /**
  120557. * Get a block by its name
  120558. * @param predicate defines the predicate used to find the good candidate
  120559. * @returns the required block or null if not found
  120560. */
  120561. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120562. /**
  120563. * Get an input block by its name
  120564. * @param predicate defines the predicate used to find the good candidate
  120565. * @returns the required input block or null if not found
  120566. */
  120567. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120568. /**
  120569. * Gets the list of input blocks attached to this material
  120570. * @returns an array of InputBlocks
  120571. */
  120572. getInputBlocks(): InputBlock[];
  120573. /**
  120574. * Adds a new optimizer to the list of optimizers
  120575. * @param optimizer defines the optimizers to add
  120576. * @returns the current material
  120577. */
  120578. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120579. /**
  120580. * Remove an optimizer from the list of optimizers
  120581. * @param optimizer defines the optimizers to remove
  120582. * @returns the current material
  120583. */
  120584. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120585. /**
  120586. * Add a new block to the list of output nodes
  120587. * @param node defines the node to add
  120588. * @returns the current material
  120589. */
  120590. addOutputNode(node: NodeMaterialBlock): this;
  120591. /**
  120592. * Remove a block from the list of root nodes
  120593. * @param node defines the node to remove
  120594. * @returns the current material
  120595. */
  120596. removeOutputNode(node: NodeMaterialBlock): this;
  120597. private _addVertexOutputNode;
  120598. private _removeVertexOutputNode;
  120599. private _addFragmentOutputNode;
  120600. private _removeFragmentOutputNode;
  120601. /**
  120602. * Specifies if the material will require alpha blending
  120603. * @returns a boolean specifying if alpha blending is needed
  120604. */
  120605. needAlphaBlending(): boolean;
  120606. /**
  120607. * Specifies if this material should be rendered in alpha test mode
  120608. * @returns a boolean specifying if an alpha test is needed.
  120609. */
  120610. needAlphaTesting(): boolean;
  120611. private _initializeBlock;
  120612. private _resetDualBlocks;
  120613. /**
  120614. * Build the material and generates the inner effect
  120615. * @param verbose defines if the build should log activity
  120616. */
  120617. build(verbose?: boolean): void;
  120618. /**
  120619. * Runs an otpimization phase to try to improve the shader code
  120620. */
  120621. optimize(): void;
  120622. private _prepareDefinesForAttributes;
  120623. /**
  120624. * Get if the submesh is ready to be used and all its information available.
  120625. * Child classes can use it to update shaders
  120626. * @param mesh defines the mesh to check
  120627. * @param subMesh defines which submesh to check
  120628. * @param useInstances specifies that instances should be used
  120629. * @returns a boolean indicating that the submesh is ready or not
  120630. */
  120631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120632. /**
  120633. * Get a string representing the shaders built by the current node graph
  120634. */
  120635. readonly compiledShaders: string;
  120636. /**
  120637. * Binds the world matrix to the material
  120638. * @param world defines the world transformation matrix
  120639. */
  120640. bindOnlyWorldMatrix(world: Matrix): void;
  120641. /**
  120642. * Binds the submesh to this material by preparing the effect and shader to draw
  120643. * @param world defines the world transformation matrix
  120644. * @param mesh defines the mesh containing the submesh
  120645. * @param subMesh defines the submesh to bind the material to
  120646. */
  120647. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120648. /**
  120649. * Gets the active textures from the material
  120650. * @returns an array of textures
  120651. */
  120652. getActiveTextures(): BaseTexture[];
  120653. /**
  120654. * Gets the list of texture blocks
  120655. * @returns an array of texture blocks
  120656. */
  120657. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  120658. /**
  120659. * Specifies if the material uses a texture
  120660. * @param texture defines the texture to check against the material
  120661. * @returns a boolean specifying if the material uses the texture
  120662. */
  120663. hasTexture(texture: BaseTexture): boolean;
  120664. /**
  120665. * Disposes the material
  120666. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  120667. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  120668. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  120669. */
  120670. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  120671. /** Creates the node editor window. */
  120672. private _createNodeEditor;
  120673. /**
  120674. * Launch the node material editor
  120675. * @param config Define the configuration of the editor
  120676. * @return a promise fulfilled when the node editor is visible
  120677. */
  120678. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  120679. /**
  120680. * Clear the current material
  120681. */
  120682. clear(): void;
  120683. /**
  120684. * Clear the current material and set it to a default state
  120685. */
  120686. setToDefault(): void;
  120687. /**
  120688. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  120689. * @param url defines the url to load from
  120690. * @returns a promise that will fullfil when the material is fully loaded
  120691. */
  120692. loadAsync(url: string): Promise<void>;
  120693. private _gatherBlocks;
  120694. /**
  120695. * Generate a string containing the code declaration required to create an equivalent of this material
  120696. * @returns a string
  120697. */
  120698. generateCode(): string;
  120699. /**
  120700. * Serializes this material in a JSON representation
  120701. * @returns the serialized material object
  120702. */
  120703. serialize(): any;
  120704. private _restoreConnections;
  120705. /**
  120706. * Clear the current graph and load a new one from a serialization object
  120707. * @param source defines the JSON representation of the material
  120708. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120709. */
  120710. loadFromSerialization(source: any, rootUrl?: string): void;
  120711. /**
  120712. * Creates a node material from parsed material data
  120713. * @param source defines the JSON representation of the material
  120714. * @param scene defines the hosting scene
  120715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120716. * @returns a new node material
  120717. */
  120718. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  120719. /**
  120720. * Creates a new node material set to default basic configuration
  120721. * @param name defines the name of the material
  120722. * @param scene defines the hosting scene
  120723. * @returns a new NodeMaterial
  120724. */
  120725. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  120726. }
  120727. }
  120728. declare module BABYLON {
  120729. /**
  120730. * Block used to read a texture from a sampler
  120731. */
  120732. export class TextureBlock extends NodeMaterialBlock {
  120733. private _defineName;
  120734. private _linearDefineName;
  120735. private _samplerName;
  120736. private _transformedUVName;
  120737. private _textureTransformName;
  120738. private _textureInfoName;
  120739. private _mainUVName;
  120740. private _mainUVDefineName;
  120741. /**
  120742. * Gets or sets the texture associated with the node
  120743. */
  120744. texture: Nullable<Texture>;
  120745. /**
  120746. * Create a new TextureBlock
  120747. * @param name defines the block name
  120748. */
  120749. constructor(name: string);
  120750. /**
  120751. * Gets the current class name
  120752. * @returns the class name
  120753. */
  120754. getClassName(): string;
  120755. /**
  120756. * Gets the uv input component
  120757. */
  120758. readonly uv: NodeMaterialConnectionPoint;
  120759. /**
  120760. * Gets the rgba output component
  120761. */
  120762. readonly rgba: NodeMaterialConnectionPoint;
  120763. /**
  120764. * Gets the rgb output component
  120765. */
  120766. readonly rgb: NodeMaterialConnectionPoint;
  120767. /**
  120768. * Gets the r output component
  120769. */
  120770. readonly r: NodeMaterialConnectionPoint;
  120771. /**
  120772. * Gets the g output component
  120773. */
  120774. readonly g: NodeMaterialConnectionPoint;
  120775. /**
  120776. * Gets the b output component
  120777. */
  120778. readonly b: NodeMaterialConnectionPoint;
  120779. /**
  120780. * Gets the a output component
  120781. */
  120782. readonly a: NodeMaterialConnectionPoint;
  120783. readonly target: NodeMaterialBlockTargets;
  120784. autoConfigure(material: NodeMaterial): void;
  120785. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120787. isReady(): boolean;
  120788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120789. private readonly _isMixed;
  120790. private _injectVertexCode;
  120791. private _writeOutput;
  120792. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120793. protected _dumpPropertiesCode(): string;
  120794. serialize(): any;
  120795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120796. }
  120797. }
  120798. declare module BABYLON {
  120799. /**
  120800. * Class used to store shared data between 2 NodeMaterialBuildState
  120801. */
  120802. export class NodeMaterialBuildStateSharedData {
  120803. /**
  120804. * Gets the list of emitted varyings
  120805. */
  120806. temps: string[];
  120807. /**
  120808. * Gets the list of emitted varyings
  120809. */
  120810. varyings: string[];
  120811. /**
  120812. * Gets the varying declaration string
  120813. */
  120814. varyingDeclaration: string;
  120815. /**
  120816. * Input blocks
  120817. */
  120818. inputBlocks: InputBlock[];
  120819. /**
  120820. * Input blocks
  120821. */
  120822. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120823. /**
  120824. * Bindable blocks (Blocks that need to set data to the effect)
  120825. */
  120826. bindableBlocks: NodeMaterialBlock[];
  120827. /**
  120828. * List of blocks that can provide a compilation fallback
  120829. */
  120830. blocksWithFallbacks: NodeMaterialBlock[];
  120831. /**
  120832. * List of blocks that can provide a define update
  120833. */
  120834. blocksWithDefines: NodeMaterialBlock[];
  120835. /**
  120836. * List of blocks that can provide a repeatable content
  120837. */
  120838. repeatableContentBlocks: NodeMaterialBlock[];
  120839. /**
  120840. * List of blocks that can provide a dynamic list of uniforms
  120841. */
  120842. dynamicUniformBlocks: NodeMaterialBlock[];
  120843. /**
  120844. * List of blocks that can block the isReady function for the material
  120845. */
  120846. blockingBlocks: NodeMaterialBlock[];
  120847. /**
  120848. * Gets the list of animated inputs
  120849. */
  120850. animatedInputs: InputBlock[];
  120851. /**
  120852. * Build Id used to avoid multiple recompilations
  120853. */
  120854. buildId: number;
  120855. /** List of emitted variables */
  120856. variableNames: {
  120857. [key: string]: number;
  120858. };
  120859. /** List of emitted defines */
  120860. defineNames: {
  120861. [key: string]: number;
  120862. };
  120863. /** Should emit comments? */
  120864. emitComments: boolean;
  120865. /** Emit build activity */
  120866. verbose: boolean;
  120867. /** Gets or sets the hosting scene */
  120868. scene: Scene;
  120869. /**
  120870. * Gets the compilation hints emitted at compilation time
  120871. */
  120872. hints: {
  120873. needWorldViewMatrix: boolean;
  120874. needWorldViewProjectionMatrix: boolean;
  120875. needAlphaBlending: boolean;
  120876. needAlphaTesting: boolean;
  120877. };
  120878. /**
  120879. * List of compilation checks
  120880. */
  120881. checks: {
  120882. emitVertex: boolean;
  120883. emitFragment: boolean;
  120884. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120885. };
  120886. /** Creates a new shared data */
  120887. constructor();
  120888. /**
  120889. * Emits console errors and exceptions if there is a failing check
  120890. */
  120891. emitErrors(): void;
  120892. }
  120893. }
  120894. declare module BABYLON {
  120895. /**
  120896. * Class used to store node based material build state
  120897. */
  120898. export class NodeMaterialBuildState {
  120899. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120900. supportUniformBuffers: boolean;
  120901. /**
  120902. * Gets the list of emitted attributes
  120903. */
  120904. attributes: string[];
  120905. /**
  120906. * Gets the list of emitted uniforms
  120907. */
  120908. uniforms: string[];
  120909. /**
  120910. * Gets the list of emitted constants
  120911. */
  120912. constants: string[];
  120913. /**
  120914. * Gets the list of emitted samplers
  120915. */
  120916. samplers: string[];
  120917. /**
  120918. * Gets the list of emitted functions
  120919. */
  120920. functions: {
  120921. [key: string]: string;
  120922. };
  120923. /**
  120924. * Gets the list of emitted extensions
  120925. */
  120926. extensions: {
  120927. [key: string]: string;
  120928. };
  120929. /**
  120930. * Gets the target of the compilation state
  120931. */
  120932. target: NodeMaterialBlockTargets;
  120933. /**
  120934. * Gets the list of emitted counters
  120935. */
  120936. counters: {
  120937. [key: string]: number;
  120938. };
  120939. /**
  120940. * Shared data between multiple NodeMaterialBuildState instances
  120941. */
  120942. sharedData: NodeMaterialBuildStateSharedData;
  120943. /** @hidden */
  120944. _vertexState: NodeMaterialBuildState;
  120945. /** @hidden */
  120946. _attributeDeclaration: string;
  120947. /** @hidden */
  120948. _uniformDeclaration: string;
  120949. /** @hidden */
  120950. _constantDeclaration: string;
  120951. /** @hidden */
  120952. _samplerDeclaration: string;
  120953. /** @hidden */
  120954. _varyingTransfer: string;
  120955. private _repeatableContentAnchorIndex;
  120956. /** @hidden */
  120957. _builtCompilationString: string;
  120958. /**
  120959. * Gets the emitted compilation strings
  120960. */
  120961. compilationString: string;
  120962. /**
  120963. * Finalize the compilation strings
  120964. * @param state defines the current compilation state
  120965. */
  120966. finalize(state: NodeMaterialBuildState): void;
  120967. /** @hidden */
  120968. readonly _repeatableContentAnchor: string;
  120969. /** @hidden */
  120970. _getFreeVariableName(prefix: string): string;
  120971. /** @hidden */
  120972. _getFreeDefineName(prefix: string): string;
  120973. /** @hidden */
  120974. _excludeVariableName(name: string): void;
  120975. /** @hidden */
  120976. _emit2DSampler(name: string): void;
  120977. /** @hidden */
  120978. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120979. /** @hidden */
  120980. _emitExtension(name: string, extension: string): void;
  120981. /** @hidden */
  120982. _emitFunction(name: string, code: string, comments: string): void;
  120983. /** @hidden */
  120984. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120985. replaceStrings?: {
  120986. search: RegExp;
  120987. replace: string;
  120988. }[];
  120989. repeatKey?: string;
  120990. }): string;
  120991. /** @hidden */
  120992. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120993. repeatKey?: string;
  120994. removeAttributes?: boolean;
  120995. removeUniforms?: boolean;
  120996. removeVaryings?: boolean;
  120997. removeIfDef?: boolean;
  120998. replaceStrings?: {
  120999. search: RegExp;
  121000. replace: string;
  121001. }[];
  121002. }, storeKey?: string): void;
  121003. /** @hidden */
  121004. _registerTempVariable(name: string): boolean;
  121005. /** @hidden */
  121006. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  121007. /** @hidden */
  121008. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  121009. /** @hidden */
  121010. _emitFloat(value: number): string;
  121011. }
  121012. }
  121013. declare module BABYLON {
  121014. /**
  121015. * Defines a block that can be used inside a node based material
  121016. */
  121017. export class NodeMaterialBlock {
  121018. private _buildId;
  121019. private _buildTarget;
  121020. private _target;
  121021. private _isFinalMerger;
  121022. private _isInput;
  121023. /** @hidden */
  121024. _codeVariableName: string;
  121025. /** @hidden */
  121026. _inputs: NodeMaterialConnectionPoint[];
  121027. /** @hidden */
  121028. _outputs: NodeMaterialConnectionPoint[];
  121029. /** @hidden */
  121030. _preparationId: number;
  121031. /**
  121032. * Gets or sets the name of the block
  121033. */
  121034. name: string;
  121035. /**
  121036. * Gets or sets the unique id of the node
  121037. */
  121038. uniqueId: number;
  121039. /**
  121040. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  121041. */
  121042. readonly isFinalMerger: boolean;
  121043. /**
  121044. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  121045. */
  121046. readonly isInput: boolean;
  121047. /**
  121048. * Gets or sets the build Id
  121049. */
  121050. buildId: number;
  121051. /**
  121052. * Gets or sets the target of the block
  121053. */
  121054. target: NodeMaterialBlockTargets;
  121055. /**
  121056. * Gets the list of input points
  121057. */
  121058. readonly inputs: NodeMaterialConnectionPoint[];
  121059. /** Gets the list of output points */
  121060. readonly outputs: NodeMaterialConnectionPoint[];
  121061. /**
  121062. * Find an input by its name
  121063. * @param name defines the name of the input to look for
  121064. * @returns the input or null if not found
  121065. */
  121066. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121067. /**
  121068. * Find an output by its name
  121069. * @param name defines the name of the outputto look for
  121070. * @returns the output or null if not found
  121071. */
  121072. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121073. /**
  121074. * Creates a new NodeMaterialBlock
  121075. * @param name defines the block name
  121076. * @param target defines the target of that block (Vertex by default)
  121077. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  121078. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  121079. */
  121080. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  121081. /**
  121082. * Initialize the block and prepare the context for build
  121083. * @param state defines the state that will be used for the build
  121084. */
  121085. initialize(state: NodeMaterialBuildState): void;
  121086. /**
  121087. * Bind data to effect. Will only be called for blocks with isBindable === true
  121088. * @param effect defines the effect to bind data to
  121089. * @param nodeMaterial defines the hosting NodeMaterial
  121090. * @param mesh defines the mesh that will be rendered
  121091. */
  121092. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121093. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  121094. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  121095. protected _writeFloat(value: number): string;
  121096. /**
  121097. * Gets the current class name e.g. "NodeMaterialBlock"
  121098. * @returns the class name
  121099. */
  121100. getClassName(): string;
  121101. /**
  121102. * Register a new input. Must be called inside a block constructor
  121103. * @param name defines the connection point name
  121104. * @param type defines the connection point type
  121105. * @param isOptional defines a boolean indicating that this input can be omitted
  121106. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121107. * @returns the current block
  121108. */
  121109. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  121110. /**
  121111. * Register a new output. Must be called inside a block constructor
  121112. * @param name defines the connection point name
  121113. * @param type defines the connection point type
  121114. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121115. * @returns the current block
  121116. */
  121117. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  121118. /**
  121119. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  121120. * @param forOutput defines an optional connection point to check compatibility with
  121121. * @returns the first available input or null
  121122. */
  121123. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  121124. /**
  121125. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  121126. * @param forBlock defines an optional block to check compatibility with
  121127. * @returns the first available input or null
  121128. */
  121129. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  121130. /**
  121131. * Gets the sibling of the given output
  121132. * @param current defines the current output
  121133. * @returns the next output in the list or null
  121134. */
  121135. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  121136. /**
  121137. * Connect current block with another block
  121138. * @param other defines the block to connect with
  121139. * @param options define the various options to help pick the right connections
  121140. * @returns the current block
  121141. */
  121142. connectTo(other: NodeMaterialBlock, options?: {
  121143. input?: string;
  121144. output?: string;
  121145. outputSwizzle?: string;
  121146. }): this | undefined;
  121147. protected _buildBlock(state: NodeMaterialBuildState): void;
  121148. /**
  121149. * Add uniforms, samplers and uniform buffers at compilation time
  121150. * @param state defines the state to update
  121151. * @param nodeMaterial defines the node material requesting the update
  121152. * @param defines defines the material defines to update
  121153. * @param uniformBuffers defines the list of uniform buffer names
  121154. */
  121155. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121156. /**
  121157. * Add potential fallbacks if shader compilation fails
  121158. * @param mesh defines the mesh to be rendered
  121159. * @param fallbacks defines the current prioritized list of fallbacks
  121160. */
  121161. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121162. /**
  121163. * Initialize defines for shader compilation
  121164. * @param mesh defines the mesh to be rendered
  121165. * @param nodeMaterial defines the node material requesting the update
  121166. * @param defines defines the material defines to update
  121167. * @param useInstances specifies that instances should be used
  121168. */
  121169. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121170. /**
  121171. * Update defines for shader compilation
  121172. * @param mesh defines the mesh to be rendered
  121173. * @param nodeMaterial defines the node material requesting the update
  121174. * @param defines defines the material defines to update
  121175. * @param useInstances specifies that instances should be used
  121176. */
  121177. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121178. /**
  121179. * Lets the block try to connect some inputs automatically
  121180. * @param material defines the hosting NodeMaterial
  121181. */
  121182. autoConfigure(material: NodeMaterial): void;
  121183. /**
  121184. * Function called when a block is declared as repeatable content generator
  121185. * @param vertexShaderState defines the current compilation state for the vertex shader
  121186. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121187. * @param mesh defines the mesh to be rendered
  121188. * @param defines defines the material defines to update
  121189. */
  121190. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121191. /**
  121192. * Checks if the block is ready
  121193. * @param mesh defines the mesh to be rendered
  121194. * @param nodeMaterial defines the node material requesting the update
  121195. * @param defines defines the material defines to update
  121196. * @param useInstances specifies that instances should be used
  121197. * @returns true if the block is ready
  121198. */
  121199. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121200. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121201. private _processBuild;
  121202. /**
  121203. * Compile the current node and generate the shader code
  121204. * @param state defines the current compilation state (uniforms, samplers, current string)
  121205. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121206. * @returns true if already built
  121207. */
  121208. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121209. protected _inputRename(name: string): string;
  121210. protected _outputRename(name: string): string;
  121211. protected _dumpPropertiesCode(): string;
  121212. /** @hidden */
  121213. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121214. /**
  121215. * Clone the current block to a new identical block
  121216. * @param scene defines the hosting scene
  121217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121218. * @returns a copy of the current block
  121219. */
  121220. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121221. /**
  121222. * Serializes this block in a JSON representation
  121223. * @returns the serialized block object
  121224. */
  121225. serialize(): any;
  121226. /** @hidden */
  121227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121228. /**
  121229. * Release resources
  121230. */
  121231. dispose(): void;
  121232. }
  121233. }
  121234. declare module BABYLON {
  121235. /**
  121236. * Enum defining the type of animations supported by InputBlock
  121237. */
  121238. export enum AnimatedInputBlockTypes {
  121239. /** No animation */
  121240. None = 0,
  121241. /** Time based animation. Will only work for floats */
  121242. Time = 1
  121243. }
  121244. }
  121245. declare module BABYLON {
  121246. /**
  121247. * Block used to expose an input value
  121248. */
  121249. export class InputBlock extends NodeMaterialBlock {
  121250. private _mode;
  121251. private _associatedVariableName;
  121252. private _storedValue;
  121253. private _valueCallback;
  121254. private _type;
  121255. private _animationType;
  121256. /** Gets or set a value used to limit the range of float values */
  121257. min: number;
  121258. /** Gets or set a value used to limit the range of float values */
  121259. max: number;
  121260. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  121261. matrixMode: number;
  121262. /** @hidden */
  121263. _systemValue: Nullable<NodeMaterialSystemValues>;
  121264. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  121265. visibleInInspector: boolean;
  121266. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  121267. isConstant: boolean;
  121268. /**
  121269. * Gets or sets the connection point type (default is float)
  121270. */
  121271. readonly type: NodeMaterialBlockConnectionPointTypes;
  121272. /**
  121273. * Creates a new InputBlock
  121274. * @param name defines the block name
  121275. * @param target defines the target of that block (Vertex by default)
  121276. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  121277. */
  121278. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  121279. /**
  121280. * Gets the output component
  121281. */
  121282. readonly output: NodeMaterialConnectionPoint;
  121283. /**
  121284. * Set the source of this connection point to a vertex attribute
  121285. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  121286. * @returns the current connection point
  121287. */
  121288. setAsAttribute(attributeName?: string): InputBlock;
  121289. /**
  121290. * Set the source of this connection point to a system value
  121291. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  121292. * @returns the current connection point
  121293. */
  121294. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  121295. /**
  121296. * Gets or sets the value of that point.
  121297. * Please note that this value will be ignored if valueCallback is defined
  121298. */
  121299. value: any;
  121300. /**
  121301. * Gets or sets a callback used to get the value of that point.
  121302. * Please note that setting this value will force the connection point to ignore the value property
  121303. */
  121304. valueCallback: () => any;
  121305. /**
  121306. * Gets or sets the associated variable name in the shader
  121307. */
  121308. associatedVariableName: string;
  121309. /** Gets or sets the type of animation applied to the input */
  121310. animationType: AnimatedInputBlockTypes;
  121311. /**
  121312. * Gets a boolean indicating that this connection point not defined yet
  121313. */
  121314. readonly isUndefined: boolean;
  121315. /**
  121316. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121317. * In this case the connection point name must be the name of the uniform to use.
  121318. * Can only be set on inputs
  121319. */
  121320. isUniform: boolean;
  121321. /**
  121322. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121323. * In this case the connection point name must be the name of the attribute to use
  121324. * Can only be set on inputs
  121325. */
  121326. isAttribute: boolean;
  121327. /**
  121328. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121329. * Can only be set on exit points
  121330. */
  121331. isVarying: boolean;
  121332. /**
  121333. * Gets a boolean indicating that the current connection point is a system value
  121334. */
  121335. readonly isSystemValue: boolean;
  121336. /**
  121337. * Gets or sets the current well known value or null if not defined as a system value
  121338. */
  121339. systemValue: Nullable<NodeMaterialSystemValues>;
  121340. /**
  121341. * Gets the current class name
  121342. * @returns the class name
  121343. */
  121344. getClassName(): string;
  121345. /**
  121346. * Animate the input if animationType !== None
  121347. * @param scene defines the rendering scene
  121348. */
  121349. animate(scene: Scene): void;
  121350. private _emitDefine;
  121351. initialize(state: NodeMaterialBuildState): void;
  121352. /**
  121353. * Set the input block to its default value (based on its type)
  121354. */
  121355. setDefaultValue(): void;
  121356. private _emitConstant;
  121357. private _emit;
  121358. /** @hidden */
  121359. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121360. /** @hidden */
  121361. _transmit(effect: Effect, scene: Scene): void;
  121362. protected _buildBlock(state: NodeMaterialBuildState): void;
  121363. protected _dumpPropertiesCode(): string;
  121364. serialize(): any;
  121365. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121366. }
  121367. }
  121368. declare module BABYLON {
  121369. /**
  121370. * Defines a connection point for a block
  121371. */
  121372. export class NodeMaterialConnectionPoint {
  121373. /** @hidden */
  121374. _ownerBlock: NodeMaterialBlock;
  121375. /** @hidden */
  121376. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121377. private _endpoints;
  121378. private _associatedVariableName;
  121379. /** @hidden */
  121380. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121381. /** @hidden */
  121382. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121383. private _type;
  121384. /** @hidden */
  121385. _enforceAssociatedVariableName: boolean;
  121386. /**
  121387. * Gets or sets the additional types supported by this connection point
  121388. */
  121389. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121390. /**
  121391. * Gets or sets the additional types excluded by this connection point
  121392. */
  121393. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121394. /**
  121395. * Observable triggered when this point is connected
  121396. */
  121397. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  121398. /**
  121399. * Gets or sets the associated variable name in the shader
  121400. */
  121401. associatedVariableName: string;
  121402. /**
  121403. * Gets or sets the connection point type (default is float)
  121404. */
  121405. type: NodeMaterialBlockConnectionPointTypes;
  121406. /**
  121407. * Gets or sets the connection point name
  121408. */
  121409. name: string;
  121410. /**
  121411. * Gets or sets a boolean indicating that this connection point can be omitted
  121412. */
  121413. isOptional: boolean;
  121414. /**
  121415. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121416. */
  121417. define: string;
  121418. /** @hidden */
  121419. _prioritizeVertex: boolean;
  121420. private _target;
  121421. /** Gets or sets the target of that connection point */
  121422. target: NodeMaterialBlockTargets;
  121423. /**
  121424. * Gets a boolean indicating that the current point is connected
  121425. */
  121426. readonly isConnected: boolean;
  121427. /**
  121428. * Gets a boolean indicating that the current point is connected to an input block
  121429. */
  121430. readonly isConnectedToInputBlock: boolean;
  121431. /**
  121432. * Gets a the connected input block (if any)
  121433. */
  121434. readonly connectInputBlock: Nullable<InputBlock>;
  121435. /** Get the other side of the connection (if any) */
  121436. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121437. /** Get the block that owns this connection point */
  121438. readonly ownerBlock: NodeMaterialBlock;
  121439. /** Get the block connected on the other side of this connection (if any) */
  121440. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121441. /** Get the block connected on the endpoints of this connection (if any) */
  121442. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121443. /** Gets the list of connected endpoints */
  121444. readonly endpoints: NodeMaterialConnectionPoint[];
  121445. /** Gets a boolean indicating if that output point is connected to at least one input */
  121446. readonly hasEndpoints: boolean;
  121447. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121448. readonly isConnectedInVertexShader: boolean;
  121449. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121450. readonly isConnectedInFragmentShader: boolean;
  121451. /**
  121452. * Creates a new connection point
  121453. * @param name defines the connection point name
  121454. * @param ownerBlock defines the block hosting this connection point
  121455. */
  121456. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121457. /**
  121458. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121459. * @returns the class name
  121460. */
  121461. getClassName(): string;
  121462. /**
  121463. * Gets an boolean indicating if the current point can be connected to another point
  121464. * @param connectionPoint defines the other connection point
  121465. * @returns true if the connection is possible
  121466. */
  121467. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121468. /**
  121469. * Connect this point to another connection point
  121470. * @param connectionPoint defines the other connection point
  121471. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121472. * @returns the current connection point
  121473. */
  121474. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121475. /**
  121476. * Disconnect this point from one of his endpoint
  121477. * @param endpoint defines the other connection point
  121478. * @returns the current connection point
  121479. */
  121480. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121481. /**
  121482. * Serializes this point in a JSON representation
  121483. * @returns the serialized point object
  121484. */
  121485. serialize(): any;
  121486. /**
  121487. * Release resources
  121488. */
  121489. dispose(): void;
  121490. }
  121491. }
  121492. declare module BABYLON {
  121493. /**
  121494. * Block used to add support for vertex skinning (bones)
  121495. */
  121496. export class BonesBlock extends NodeMaterialBlock {
  121497. /**
  121498. * Creates a new BonesBlock
  121499. * @param name defines the block name
  121500. */
  121501. constructor(name: string);
  121502. /**
  121503. * Initialize the block and prepare the context for build
  121504. * @param state defines the state that will be used for the build
  121505. */
  121506. initialize(state: NodeMaterialBuildState): void;
  121507. /**
  121508. * Gets the current class name
  121509. * @returns the class name
  121510. */
  121511. getClassName(): string;
  121512. /**
  121513. * Gets the matrix indices input component
  121514. */
  121515. readonly matricesIndices: NodeMaterialConnectionPoint;
  121516. /**
  121517. * Gets the matrix weights input component
  121518. */
  121519. readonly matricesWeights: NodeMaterialConnectionPoint;
  121520. /**
  121521. * Gets the extra matrix indices input component
  121522. */
  121523. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121524. /**
  121525. * Gets the extra matrix weights input component
  121526. */
  121527. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121528. /**
  121529. * Gets the world input component
  121530. */
  121531. readonly world: NodeMaterialConnectionPoint;
  121532. /**
  121533. * Gets the output component
  121534. */
  121535. readonly output: NodeMaterialConnectionPoint;
  121536. autoConfigure(material: NodeMaterial): void;
  121537. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121540. protected _buildBlock(state: NodeMaterialBuildState): this;
  121541. }
  121542. }
  121543. declare module BABYLON {
  121544. /**
  121545. * Block used to add support for instances
  121546. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121547. */
  121548. export class InstancesBlock extends NodeMaterialBlock {
  121549. /**
  121550. * Creates a new InstancesBlock
  121551. * @param name defines the block name
  121552. */
  121553. constructor(name: string);
  121554. /**
  121555. * Gets the current class name
  121556. * @returns the class name
  121557. */
  121558. getClassName(): string;
  121559. /**
  121560. * Gets the first world row input component
  121561. */
  121562. readonly world0: NodeMaterialConnectionPoint;
  121563. /**
  121564. * Gets the second world row input component
  121565. */
  121566. readonly world1: NodeMaterialConnectionPoint;
  121567. /**
  121568. * Gets the third world row input component
  121569. */
  121570. readonly world2: NodeMaterialConnectionPoint;
  121571. /**
  121572. * Gets the forth world row input component
  121573. */
  121574. readonly world3: NodeMaterialConnectionPoint;
  121575. /**
  121576. * Gets the world input component
  121577. */
  121578. readonly world: NodeMaterialConnectionPoint;
  121579. /**
  121580. * Gets the output component
  121581. */
  121582. readonly output: NodeMaterialConnectionPoint;
  121583. autoConfigure(material: NodeMaterial): void;
  121584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121585. protected _buildBlock(state: NodeMaterialBuildState): this;
  121586. }
  121587. }
  121588. declare module BABYLON {
  121589. /**
  121590. * Block used to add morph targets support to vertex shader
  121591. */
  121592. export class MorphTargetsBlock extends NodeMaterialBlock {
  121593. private _repeatableContentAnchor;
  121594. private _repeatebleContentGenerated;
  121595. /**
  121596. * Create a new MorphTargetsBlock
  121597. * @param name defines the block name
  121598. */
  121599. constructor(name: string);
  121600. /**
  121601. * Gets the current class name
  121602. * @returns the class name
  121603. */
  121604. getClassName(): string;
  121605. /**
  121606. * Gets the position input component
  121607. */
  121608. readonly position: NodeMaterialConnectionPoint;
  121609. /**
  121610. * Gets the normal input component
  121611. */
  121612. readonly normal: NodeMaterialConnectionPoint;
  121613. /**
  121614. * Gets the tangent input component
  121615. */
  121616. readonly tangent: NodeMaterialConnectionPoint;
  121617. /**
  121618. * Gets the tangent input component
  121619. */
  121620. readonly uv: NodeMaterialConnectionPoint;
  121621. /**
  121622. * Gets the position output component
  121623. */
  121624. readonly positionOutput: NodeMaterialConnectionPoint;
  121625. /**
  121626. * Gets the normal output component
  121627. */
  121628. readonly normalOutput: NodeMaterialConnectionPoint;
  121629. /**
  121630. * Gets the tangent output component
  121631. */
  121632. readonly tangentOutput: NodeMaterialConnectionPoint;
  121633. /**
  121634. * Gets the tangent output component
  121635. */
  121636. readonly uvOutput: NodeMaterialConnectionPoint;
  121637. initialize(state: NodeMaterialBuildState): void;
  121638. autoConfigure(material: NodeMaterial): void;
  121639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121641. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121642. protected _buildBlock(state: NodeMaterialBuildState): this;
  121643. }
  121644. }
  121645. declare module BABYLON {
  121646. /**
  121647. * Block used to get data information from a light
  121648. */
  121649. export class LightInformationBlock extends NodeMaterialBlock {
  121650. private _lightDataUniformName;
  121651. private _lightColorUniformName;
  121652. private _lightTypeDefineName;
  121653. /**
  121654. * Gets or sets the light associated with this block
  121655. */
  121656. light: Nullable<Light>;
  121657. /**
  121658. * Creates a new LightInformationBlock
  121659. * @param name defines the block name
  121660. */
  121661. constructor(name: string);
  121662. /**
  121663. * Gets the current class name
  121664. * @returns the class name
  121665. */
  121666. getClassName(): string;
  121667. /**
  121668. * Gets the world position input component
  121669. */
  121670. readonly worldPosition: NodeMaterialConnectionPoint;
  121671. /**
  121672. * Gets the direction output component
  121673. */
  121674. readonly direction: NodeMaterialConnectionPoint;
  121675. /**
  121676. * Gets the direction output component
  121677. */
  121678. readonly color: NodeMaterialConnectionPoint;
  121679. /**
  121680. * Gets the direction output component
  121681. */
  121682. readonly intensity: NodeMaterialConnectionPoint;
  121683. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121685. protected _buildBlock(state: NodeMaterialBuildState): this;
  121686. serialize(): any;
  121687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121688. }
  121689. }
  121690. declare module BABYLON {
  121691. /**
  121692. * Block used to add image processing support to fragment shader
  121693. */
  121694. export class ImageProcessingBlock extends NodeMaterialBlock {
  121695. /**
  121696. * Create a new ImageProcessingBlock
  121697. * @param name defines the block name
  121698. */
  121699. constructor(name: string);
  121700. /**
  121701. * Gets the current class name
  121702. * @returns the class name
  121703. */
  121704. getClassName(): string;
  121705. /**
  121706. * Gets the color input component
  121707. */
  121708. readonly color: NodeMaterialConnectionPoint;
  121709. /**
  121710. * Gets the output component
  121711. */
  121712. readonly output: NodeMaterialConnectionPoint;
  121713. /**
  121714. * Initialize the block and prepare the context for build
  121715. * @param state defines the state that will be used for the build
  121716. */
  121717. initialize(state: NodeMaterialBuildState): void;
  121718. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  121719. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121720. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121721. protected _buildBlock(state: NodeMaterialBuildState): this;
  121722. }
  121723. }
  121724. declare module BABYLON {
  121725. /**
  121726. * Block used to pertub normals based on a normal map
  121727. */
  121728. export class PerturbNormalBlock extends NodeMaterialBlock {
  121729. private _tangentSpaceParameterName;
  121730. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  121731. invertX: boolean;
  121732. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  121733. invertY: boolean;
  121734. /**
  121735. * Create a new PerturbNormalBlock
  121736. * @param name defines the block name
  121737. */
  121738. constructor(name: string);
  121739. /**
  121740. * Gets the current class name
  121741. * @returns the class name
  121742. */
  121743. getClassName(): string;
  121744. /**
  121745. * Gets the world position input component
  121746. */
  121747. readonly worldPosition: NodeMaterialConnectionPoint;
  121748. /**
  121749. * Gets the world normal input component
  121750. */
  121751. readonly worldNormal: NodeMaterialConnectionPoint;
  121752. /**
  121753. * Gets the uv input component
  121754. */
  121755. readonly uv: NodeMaterialConnectionPoint;
  121756. /**
  121757. * Gets the normal map color input component
  121758. */
  121759. readonly normalMapColor: NodeMaterialConnectionPoint;
  121760. /**
  121761. * Gets the strength input component
  121762. */
  121763. readonly strength: NodeMaterialConnectionPoint;
  121764. /**
  121765. * Gets the output component
  121766. */
  121767. readonly output: NodeMaterialConnectionPoint;
  121768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121770. autoConfigure(material: NodeMaterial): void;
  121771. protected _buildBlock(state: NodeMaterialBuildState): this;
  121772. protected _dumpPropertiesCode(): string;
  121773. serialize(): any;
  121774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121775. }
  121776. }
  121777. declare module BABYLON {
  121778. /**
  121779. * Block used to discard a pixel if a value is smaller than a cutoff
  121780. */
  121781. export class DiscardBlock extends NodeMaterialBlock {
  121782. /**
  121783. * Create a new DiscardBlock
  121784. * @param name defines the block name
  121785. */
  121786. constructor(name: string);
  121787. /**
  121788. * Gets the current class name
  121789. * @returns the class name
  121790. */
  121791. getClassName(): string;
  121792. /**
  121793. * Gets the color input component
  121794. */
  121795. readonly value: NodeMaterialConnectionPoint;
  121796. /**
  121797. * Gets the cutoff input component
  121798. */
  121799. readonly cutoff: NodeMaterialConnectionPoint;
  121800. protected _buildBlock(state: NodeMaterialBuildState): this;
  121801. }
  121802. }
  121803. declare module BABYLON {
  121804. /**
  121805. * Block used to add support for scene fog
  121806. */
  121807. export class FogBlock extends NodeMaterialBlock {
  121808. private _fogDistanceName;
  121809. private _fogParameters;
  121810. /**
  121811. * Create a new FogBlock
  121812. * @param name defines the block name
  121813. */
  121814. constructor(name: string);
  121815. /**
  121816. * Gets the current class name
  121817. * @returns the class name
  121818. */
  121819. getClassName(): string;
  121820. /**
  121821. * Gets the world position input component
  121822. */
  121823. readonly worldPosition: NodeMaterialConnectionPoint;
  121824. /**
  121825. * Gets the view input component
  121826. */
  121827. readonly view: NodeMaterialConnectionPoint;
  121828. /**
  121829. * Gets the color input component
  121830. */
  121831. readonly input: NodeMaterialConnectionPoint;
  121832. /**
  121833. * Gets the fog color input component
  121834. */
  121835. readonly fogColor: NodeMaterialConnectionPoint;
  121836. /**
  121837. * Gets the output component
  121838. */
  121839. readonly output: NodeMaterialConnectionPoint;
  121840. autoConfigure(material: NodeMaterial): void;
  121841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121843. protected _buildBlock(state: NodeMaterialBuildState): this;
  121844. }
  121845. }
  121846. declare module BABYLON {
  121847. /**
  121848. * Block used to add light in the fragment shader
  121849. */
  121850. export class LightBlock extends NodeMaterialBlock {
  121851. private _lightId;
  121852. /**
  121853. * Gets or sets the light associated with this block
  121854. */
  121855. light: Nullable<Light>;
  121856. /**
  121857. * Create a new LightBlock
  121858. * @param name defines the block name
  121859. */
  121860. constructor(name: string);
  121861. /**
  121862. * Gets the current class name
  121863. * @returns the class name
  121864. */
  121865. getClassName(): string;
  121866. /**
  121867. * Gets the world position input component
  121868. */
  121869. readonly worldPosition: NodeMaterialConnectionPoint;
  121870. /**
  121871. * Gets the world normal input component
  121872. */
  121873. readonly worldNormal: NodeMaterialConnectionPoint;
  121874. /**
  121875. * Gets the camera (or eye) position component
  121876. */
  121877. readonly cameraPosition: NodeMaterialConnectionPoint;
  121878. /**
  121879. * Gets the glossiness component
  121880. */
  121881. readonly glossiness: NodeMaterialConnectionPoint;
  121882. /**
  121883. * Gets the glossinness power component
  121884. */
  121885. readonly glossPower: NodeMaterialConnectionPoint;
  121886. /**
  121887. * Gets the diffuse color component
  121888. */
  121889. readonly diffuseColor: NodeMaterialConnectionPoint;
  121890. /**
  121891. * Gets the specular color component
  121892. */
  121893. readonly specularColor: NodeMaterialConnectionPoint;
  121894. /**
  121895. * Gets the diffuse output component
  121896. */
  121897. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121898. /**
  121899. * Gets the specular output component
  121900. */
  121901. readonly specularOutput: NodeMaterialConnectionPoint;
  121902. autoConfigure(material: NodeMaterial): void;
  121903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121904. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121906. private _injectVertexCode;
  121907. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121908. serialize(): any;
  121909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121910. }
  121911. }
  121912. declare module BABYLON {
  121913. /**
  121914. * Block used to multiply 2 values
  121915. */
  121916. export class MultiplyBlock extends NodeMaterialBlock {
  121917. /**
  121918. * Creates a new MultiplyBlock
  121919. * @param name defines the block name
  121920. */
  121921. constructor(name: string);
  121922. /**
  121923. * Gets the current class name
  121924. * @returns the class name
  121925. */
  121926. getClassName(): string;
  121927. /**
  121928. * Gets the left operand input component
  121929. */
  121930. readonly left: NodeMaterialConnectionPoint;
  121931. /**
  121932. * Gets the right operand input component
  121933. */
  121934. readonly right: NodeMaterialConnectionPoint;
  121935. /**
  121936. * Gets the output component
  121937. */
  121938. readonly output: NodeMaterialConnectionPoint;
  121939. protected _buildBlock(state: NodeMaterialBuildState): this;
  121940. }
  121941. }
  121942. declare module BABYLON {
  121943. /**
  121944. * Block used to add 2 vectors
  121945. */
  121946. export class AddBlock extends NodeMaterialBlock {
  121947. /**
  121948. * Creates a new AddBlock
  121949. * @param name defines the block name
  121950. */
  121951. constructor(name: string);
  121952. /**
  121953. * Gets the current class name
  121954. * @returns the class name
  121955. */
  121956. getClassName(): string;
  121957. /**
  121958. * Gets the left operand input component
  121959. */
  121960. readonly left: NodeMaterialConnectionPoint;
  121961. /**
  121962. * Gets the right operand input component
  121963. */
  121964. readonly right: NodeMaterialConnectionPoint;
  121965. /**
  121966. * Gets the output component
  121967. */
  121968. readonly output: NodeMaterialConnectionPoint;
  121969. protected _buildBlock(state: NodeMaterialBuildState): this;
  121970. }
  121971. }
  121972. declare module BABYLON {
  121973. /**
  121974. * Block used to scale a vector by a float
  121975. */
  121976. export class ScaleBlock extends NodeMaterialBlock {
  121977. /**
  121978. * Creates a new ScaleBlock
  121979. * @param name defines the block name
  121980. */
  121981. constructor(name: string);
  121982. /**
  121983. * Gets the current class name
  121984. * @returns the class name
  121985. */
  121986. getClassName(): string;
  121987. /**
  121988. * Gets the input component
  121989. */
  121990. readonly input: NodeMaterialConnectionPoint;
  121991. /**
  121992. * Gets the factor input component
  121993. */
  121994. readonly factor: NodeMaterialConnectionPoint;
  121995. /**
  121996. * Gets the output component
  121997. */
  121998. readonly output: NodeMaterialConnectionPoint;
  121999. protected _buildBlock(state: NodeMaterialBuildState): this;
  122000. }
  122001. }
  122002. declare module BABYLON {
  122003. /**
  122004. * Block used to clamp a float
  122005. */
  122006. export class ClampBlock extends NodeMaterialBlock {
  122007. /** Gets or sets the minimum range */
  122008. minimum: number;
  122009. /** Gets or sets the maximum range */
  122010. maximum: number;
  122011. /**
  122012. * Creates a new ClampBlock
  122013. * @param name defines the block name
  122014. */
  122015. constructor(name: string);
  122016. /**
  122017. * Gets the current class name
  122018. * @returns the class name
  122019. */
  122020. getClassName(): string;
  122021. /**
  122022. * Gets the value input component
  122023. */
  122024. readonly value: NodeMaterialConnectionPoint;
  122025. /**
  122026. * Gets the output component
  122027. */
  122028. readonly output: NodeMaterialConnectionPoint;
  122029. protected _buildBlock(state: NodeMaterialBuildState): this;
  122030. protected _dumpPropertiesCode(): string;
  122031. serialize(): any;
  122032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. /**
  122037. * Block used to apply a cross product between 2 vectors
  122038. */
  122039. export class CrossBlock extends NodeMaterialBlock {
  122040. /**
  122041. * Creates a new CrossBlock
  122042. * @param name defines the block name
  122043. */
  122044. constructor(name: string);
  122045. /**
  122046. * Gets the current class name
  122047. * @returns the class name
  122048. */
  122049. getClassName(): string;
  122050. /**
  122051. * Gets the left operand input component
  122052. */
  122053. readonly left: NodeMaterialConnectionPoint;
  122054. /**
  122055. * Gets the right operand input component
  122056. */
  122057. readonly right: NodeMaterialConnectionPoint;
  122058. /**
  122059. * Gets the output component
  122060. */
  122061. readonly output: NodeMaterialConnectionPoint;
  122062. protected _buildBlock(state: NodeMaterialBuildState): this;
  122063. }
  122064. }
  122065. declare module BABYLON {
  122066. /**
  122067. * Block used to apply a dot product between 2 vectors
  122068. */
  122069. export class DotBlock extends NodeMaterialBlock {
  122070. /**
  122071. * Creates a new DotBlock
  122072. * @param name defines the block name
  122073. */
  122074. constructor(name: string);
  122075. /**
  122076. * Gets the current class name
  122077. * @returns the class name
  122078. */
  122079. getClassName(): string;
  122080. /**
  122081. * Gets the left operand input component
  122082. */
  122083. readonly left: NodeMaterialConnectionPoint;
  122084. /**
  122085. * Gets the right operand input component
  122086. */
  122087. readonly right: NodeMaterialConnectionPoint;
  122088. /**
  122089. * Gets the output component
  122090. */
  122091. readonly output: NodeMaterialConnectionPoint;
  122092. protected _buildBlock(state: NodeMaterialBuildState): this;
  122093. }
  122094. }
  122095. declare module BABYLON {
  122096. /**
  122097. * Block used to remap a float from a range to a new one
  122098. */
  122099. export class RemapBlock extends NodeMaterialBlock {
  122100. /**
  122101. * Gets or sets the source range
  122102. */
  122103. sourceRange: Vector2;
  122104. /**
  122105. * Gets or sets the target range
  122106. */
  122107. targetRange: Vector2;
  122108. /**
  122109. * Creates a new RemapBlock
  122110. * @param name defines the block name
  122111. */
  122112. constructor(name: string);
  122113. /**
  122114. * Gets the current class name
  122115. * @returns the class name
  122116. */
  122117. getClassName(): string;
  122118. /**
  122119. * Gets the input component
  122120. */
  122121. readonly input: NodeMaterialConnectionPoint;
  122122. /**
  122123. * Gets the source min input component
  122124. */
  122125. readonly sourceMin: NodeMaterialConnectionPoint;
  122126. /**
  122127. * Gets the source max input component
  122128. */
  122129. readonly sourceMax: NodeMaterialConnectionPoint;
  122130. /**
  122131. * Gets the target min input component
  122132. */
  122133. readonly targetMin: NodeMaterialConnectionPoint;
  122134. /**
  122135. * Gets the target max input component
  122136. */
  122137. readonly targetMax: NodeMaterialConnectionPoint;
  122138. /**
  122139. * Gets the output component
  122140. */
  122141. readonly output: NodeMaterialConnectionPoint;
  122142. protected _buildBlock(state: NodeMaterialBuildState): this;
  122143. protected _dumpPropertiesCode(): string;
  122144. serialize(): any;
  122145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122146. }
  122147. }
  122148. declare module BABYLON {
  122149. /**
  122150. * Block used to normalize a vector
  122151. */
  122152. export class NormalizeBlock extends NodeMaterialBlock {
  122153. /**
  122154. * Creates a new NormalizeBlock
  122155. * @param name defines the block name
  122156. */
  122157. constructor(name: string);
  122158. /**
  122159. * Gets the current class name
  122160. * @returns the class name
  122161. */
  122162. getClassName(): string;
  122163. /**
  122164. * Gets the input component
  122165. */
  122166. readonly input: NodeMaterialConnectionPoint;
  122167. /**
  122168. * Gets the output component
  122169. */
  122170. readonly output: NodeMaterialConnectionPoint;
  122171. protected _buildBlock(state: NodeMaterialBuildState): this;
  122172. }
  122173. }
  122174. declare module BABYLON {
  122175. /**
  122176. * Operations supported by the Trigonometry block
  122177. */
  122178. export enum TrigonometryBlockOperations {
  122179. /** Cos */
  122180. Cos = 0,
  122181. /** Sin */
  122182. Sin = 1,
  122183. /** Abs */
  122184. Abs = 2,
  122185. /** Exp */
  122186. Exp = 3,
  122187. /** Exp2 */
  122188. Exp2 = 4,
  122189. /** Round */
  122190. Round = 5,
  122191. /** Floor */
  122192. Floor = 6,
  122193. /** Ceiling */
  122194. Ceiling = 7,
  122195. /** Square root */
  122196. Sqrt = 8,
  122197. /** Log */
  122198. Log = 9,
  122199. /** Tangent */
  122200. Tan = 10,
  122201. /** Arc tangent */
  122202. ArcTan = 11,
  122203. /** Arc cosinus */
  122204. ArcCos = 12,
  122205. /** Arc sinus */
  122206. ArcSin = 13,
  122207. /** Fraction */
  122208. Fract = 14,
  122209. /** Sign */
  122210. Sign = 15,
  122211. /** To radians (from degrees) */
  122212. Radians = 16,
  122213. /** To degrees (from radians) */
  122214. Degrees = 17
  122215. }
  122216. /**
  122217. * Block used to apply trigonometry operation to floats
  122218. */
  122219. export class TrigonometryBlock extends NodeMaterialBlock {
  122220. /**
  122221. * Gets or sets the operation applied by the block
  122222. */
  122223. operation: TrigonometryBlockOperations;
  122224. /**
  122225. * Creates a new TrigonometryBlock
  122226. * @param name defines the block name
  122227. */
  122228. constructor(name: string);
  122229. /**
  122230. * Gets the current class name
  122231. * @returns the class name
  122232. */
  122233. getClassName(): string;
  122234. /**
  122235. * Gets the input component
  122236. */
  122237. readonly input: NodeMaterialConnectionPoint;
  122238. /**
  122239. * Gets the output component
  122240. */
  122241. readonly output: NodeMaterialConnectionPoint;
  122242. protected _buildBlock(state: NodeMaterialBuildState): this;
  122243. serialize(): any;
  122244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122245. }
  122246. }
  122247. declare module BABYLON {
  122248. /**
  122249. * Block used to create a Color3/4 out of individual inputs (one for each component)
  122250. */
  122251. export class ColorMergerBlock extends NodeMaterialBlock {
  122252. /**
  122253. * Create a new ColorMergerBlock
  122254. * @param name defines the block name
  122255. */
  122256. constructor(name: string);
  122257. /**
  122258. * Gets the current class name
  122259. * @returns the class name
  122260. */
  122261. getClassName(): string;
  122262. /**
  122263. * Gets the r component (input)
  122264. */
  122265. readonly r: NodeMaterialConnectionPoint;
  122266. /**
  122267. * Gets the g component (input)
  122268. */
  122269. readonly g: NodeMaterialConnectionPoint;
  122270. /**
  122271. * Gets the b component (input)
  122272. */
  122273. readonly b: NodeMaterialConnectionPoint;
  122274. /**
  122275. * Gets the a component (input)
  122276. */
  122277. readonly a: NodeMaterialConnectionPoint;
  122278. /**
  122279. * Gets the rgba component (output)
  122280. */
  122281. readonly rgba: NodeMaterialConnectionPoint;
  122282. /**
  122283. * Gets the rgb component (output)
  122284. */
  122285. readonly rgb: NodeMaterialConnectionPoint;
  122286. protected _buildBlock(state: NodeMaterialBuildState): this;
  122287. }
  122288. }
  122289. declare module BABYLON {
  122290. /**
  122291. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  122292. */
  122293. export class VectorMergerBlock extends NodeMaterialBlock {
  122294. /**
  122295. * Create a new VectorMergerBlock
  122296. * @param name defines the block name
  122297. */
  122298. constructor(name: string);
  122299. /**
  122300. * Gets the current class name
  122301. * @returns the class name
  122302. */
  122303. getClassName(): string;
  122304. /**
  122305. * Gets the x component (input)
  122306. */
  122307. readonly x: NodeMaterialConnectionPoint;
  122308. /**
  122309. * Gets the y component (input)
  122310. */
  122311. readonly y: NodeMaterialConnectionPoint;
  122312. /**
  122313. * Gets the z component (input)
  122314. */
  122315. readonly z: NodeMaterialConnectionPoint;
  122316. /**
  122317. * Gets the w component (input)
  122318. */
  122319. readonly w: NodeMaterialConnectionPoint;
  122320. /**
  122321. * Gets the xyzw component (output)
  122322. */
  122323. readonly xyzw: NodeMaterialConnectionPoint;
  122324. /**
  122325. * Gets the xyz component (output)
  122326. */
  122327. readonly xyz: NodeMaterialConnectionPoint;
  122328. /**
  122329. * Gets the xy component (output)
  122330. */
  122331. readonly xy: NodeMaterialConnectionPoint;
  122332. protected _buildBlock(state: NodeMaterialBuildState): this;
  122333. }
  122334. }
  122335. declare module BABYLON {
  122336. /**
  122337. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122338. */
  122339. export class ColorSplitterBlock extends NodeMaterialBlock {
  122340. /**
  122341. * Create a new ColorSplitterBlock
  122342. * @param name defines the block name
  122343. */
  122344. constructor(name: string);
  122345. /**
  122346. * Gets the current class name
  122347. * @returns the class name
  122348. */
  122349. getClassName(): string;
  122350. /**
  122351. * Gets the rgba component (input)
  122352. */
  122353. readonly rgba: NodeMaterialConnectionPoint;
  122354. /**
  122355. * Gets the rgb component (input)
  122356. */
  122357. readonly rgbIn: NodeMaterialConnectionPoint;
  122358. /**
  122359. * Gets the rgb component (output)
  122360. */
  122361. readonly rgbOut: NodeMaterialConnectionPoint;
  122362. /**
  122363. * Gets the r component (output)
  122364. */
  122365. readonly r: NodeMaterialConnectionPoint;
  122366. /**
  122367. * Gets the g component (output)
  122368. */
  122369. readonly g: NodeMaterialConnectionPoint;
  122370. /**
  122371. * Gets the b component (output)
  122372. */
  122373. readonly b: NodeMaterialConnectionPoint;
  122374. /**
  122375. * Gets the a component (output)
  122376. */
  122377. readonly a: NodeMaterialConnectionPoint;
  122378. protected _inputRename(name: string): string;
  122379. protected _outputRename(name: string): string;
  122380. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122381. }
  122382. }
  122383. declare module BABYLON {
  122384. /**
  122385. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122386. */
  122387. export class VectorSplitterBlock extends NodeMaterialBlock {
  122388. /**
  122389. * Create a new VectorSplitterBlock
  122390. * @param name defines the block name
  122391. */
  122392. constructor(name: string);
  122393. /**
  122394. * Gets the current class name
  122395. * @returns the class name
  122396. */
  122397. getClassName(): string;
  122398. /**
  122399. * Gets the xyzw component (input)
  122400. */
  122401. readonly xyzw: NodeMaterialConnectionPoint;
  122402. /**
  122403. * Gets the xyz component (input)
  122404. */
  122405. readonly xyzIn: NodeMaterialConnectionPoint;
  122406. /**
  122407. * Gets the xy component (input)
  122408. */
  122409. readonly xyIn: NodeMaterialConnectionPoint;
  122410. /**
  122411. * Gets the xyz component (output)
  122412. */
  122413. readonly xyzOut: NodeMaterialConnectionPoint;
  122414. /**
  122415. * Gets the xy component (output)
  122416. */
  122417. readonly xyOut: NodeMaterialConnectionPoint;
  122418. /**
  122419. * Gets the x component (output)
  122420. */
  122421. readonly x: NodeMaterialConnectionPoint;
  122422. /**
  122423. * Gets the y component (output)
  122424. */
  122425. readonly y: NodeMaterialConnectionPoint;
  122426. /**
  122427. * Gets the z component (output)
  122428. */
  122429. readonly z: NodeMaterialConnectionPoint;
  122430. /**
  122431. * Gets the w component (output)
  122432. */
  122433. readonly w: NodeMaterialConnectionPoint;
  122434. protected _inputRename(name: string): string;
  122435. protected _outputRename(name: string): string;
  122436. protected _buildBlock(state: NodeMaterialBuildState): this;
  122437. }
  122438. }
  122439. declare module BABYLON {
  122440. /**
  122441. * Block used to lerp between 2 values
  122442. */
  122443. export class LerpBlock extends NodeMaterialBlock {
  122444. /**
  122445. * Creates a new LerpBlock
  122446. * @param name defines the block name
  122447. */
  122448. constructor(name: string);
  122449. /**
  122450. * Gets the current class name
  122451. * @returns the class name
  122452. */
  122453. getClassName(): string;
  122454. /**
  122455. * Gets the left operand input component
  122456. */
  122457. readonly left: NodeMaterialConnectionPoint;
  122458. /**
  122459. * Gets the right operand input component
  122460. */
  122461. readonly right: NodeMaterialConnectionPoint;
  122462. /**
  122463. * Gets the gradient operand input component
  122464. */
  122465. readonly gradient: NodeMaterialConnectionPoint;
  122466. /**
  122467. * Gets the output component
  122468. */
  122469. readonly output: NodeMaterialConnectionPoint;
  122470. protected _buildBlock(state: NodeMaterialBuildState): this;
  122471. }
  122472. }
  122473. declare module BABYLON {
  122474. /**
  122475. * Block used to divide 2 vectors
  122476. */
  122477. export class DivideBlock extends NodeMaterialBlock {
  122478. /**
  122479. * Creates a new DivideBlock
  122480. * @param name defines the block name
  122481. */
  122482. constructor(name: string);
  122483. /**
  122484. * Gets the current class name
  122485. * @returns the class name
  122486. */
  122487. getClassName(): string;
  122488. /**
  122489. * Gets the left operand input component
  122490. */
  122491. readonly left: NodeMaterialConnectionPoint;
  122492. /**
  122493. * Gets the right operand input component
  122494. */
  122495. readonly right: NodeMaterialConnectionPoint;
  122496. /**
  122497. * Gets the output component
  122498. */
  122499. readonly output: NodeMaterialConnectionPoint;
  122500. protected _buildBlock(state: NodeMaterialBuildState): this;
  122501. }
  122502. }
  122503. declare module BABYLON {
  122504. /**
  122505. * Block used to subtract 2 vectors
  122506. */
  122507. export class SubtractBlock extends NodeMaterialBlock {
  122508. /**
  122509. * Creates a new SubtractBlock
  122510. * @param name defines the block name
  122511. */
  122512. constructor(name: string);
  122513. /**
  122514. * Gets the current class name
  122515. * @returns the class name
  122516. */
  122517. getClassName(): string;
  122518. /**
  122519. * Gets the left operand input component
  122520. */
  122521. readonly left: NodeMaterialConnectionPoint;
  122522. /**
  122523. * Gets the right operand input component
  122524. */
  122525. readonly right: NodeMaterialConnectionPoint;
  122526. /**
  122527. * Gets the output component
  122528. */
  122529. readonly output: NodeMaterialConnectionPoint;
  122530. protected _buildBlock(state: NodeMaterialBuildState): this;
  122531. }
  122532. }
  122533. declare module BABYLON {
  122534. /**
  122535. * Block used to step a value
  122536. */
  122537. export class StepBlock extends NodeMaterialBlock {
  122538. /**
  122539. * Creates a new StepBlock
  122540. * @param name defines the block name
  122541. */
  122542. constructor(name: string);
  122543. /**
  122544. * Gets the current class name
  122545. * @returns the class name
  122546. */
  122547. getClassName(): string;
  122548. /**
  122549. * Gets the value operand input component
  122550. */
  122551. readonly value: NodeMaterialConnectionPoint;
  122552. /**
  122553. * Gets the edge operand input component
  122554. */
  122555. readonly edge: NodeMaterialConnectionPoint;
  122556. /**
  122557. * Gets the output component
  122558. */
  122559. readonly output: NodeMaterialConnectionPoint;
  122560. protected _buildBlock(state: NodeMaterialBuildState): this;
  122561. }
  122562. }
  122563. declare module BABYLON {
  122564. /**
  122565. * Block used to get the opposite (1 - x) of a value
  122566. */
  122567. export class OneMinusBlock extends NodeMaterialBlock {
  122568. /**
  122569. * Creates a new OneMinusBlock
  122570. * @param name defines the block name
  122571. */
  122572. constructor(name: string);
  122573. /**
  122574. * Gets the current class name
  122575. * @returns the class name
  122576. */
  122577. getClassName(): string;
  122578. /**
  122579. * Gets the input component
  122580. */
  122581. readonly input: NodeMaterialConnectionPoint;
  122582. /**
  122583. * Gets the output component
  122584. */
  122585. readonly output: NodeMaterialConnectionPoint;
  122586. protected _buildBlock(state: NodeMaterialBuildState): this;
  122587. }
  122588. }
  122589. declare module BABYLON {
  122590. /**
  122591. * Block used to get the view direction
  122592. */
  122593. export class ViewDirectionBlock extends NodeMaterialBlock {
  122594. /**
  122595. * Creates a new ViewDirectionBlock
  122596. * @param name defines the block name
  122597. */
  122598. constructor(name: string);
  122599. /**
  122600. * Gets the current class name
  122601. * @returns the class name
  122602. */
  122603. getClassName(): string;
  122604. /**
  122605. * Gets the world position component
  122606. */
  122607. readonly worldPosition: NodeMaterialConnectionPoint;
  122608. /**
  122609. * Gets the camera position component
  122610. */
  122611. readonly cameraPosition: NodeMaterialConnectionPoint;
  122612. /**
  122613. * Gets the output component
  122614. */
  122615. readonly output: NodeMaterialConnectionPoint;
  122616. autoConfigure(material: NodeMaterial): void;
  122617. protected _buildBlock(state: NodeMaterialBuildState): this;
  122618. }
  122619. }
  122620. declare module BABYLON {
  122621. /**
  122622. * Block used to compute fresnel value
  122623. */
  122624. export class FresnelBlock extends NodeMaterialBlock {
  122625. /**
  122626. * Create a new FresnelBlock
  122627. * @param name defines the block name
  122628. */
  122629. constructor(name: string);
  122630. /**
  122631. * Gets the current class name
  122632. * @returns the class name
  122633. */
  122634. getClassName(): string;
  122635. /**
  122636. * Gets the world normal input component
  122637. */
  122638. readonly worldNormal: NodeMaterialConnectionPoint;
  122639. /**
  122640. * Gets the view direction input component
  122641. */
  122642. readonly viewDirection: NodeMaterialConnectionPoint;
  122643. /**
  122644. * Gets the bias input component
  122645. */
  122646. readonly bias: NodeMaterialConnectionPoint;
  122647. /**
  122648. * Gets the camera (or eye) position component
  122649. */
  122650. readonly power: NodeMaterialConnectionPoint;
  122651. /**
  122652. * Gets the fresnel output component
  122653. */
  122654. readonly fresnel: NodeMaterialConnectionPoint;
  122655. autoConfigure(material: NodeMaterial): void;
  122656. protected _buildBlock(state: NodeMaterialBuildState): this;
  122657. }
  122658. }
  122659. declare module BABYLON {
  122660. /**
  122661. * Block used to get the max of 2 values
  122662. */
  122663. export class MaxBlock extends NodeMaterialBlock {
  122664. /**
  122665. * Creates a new MaxBlock
  122666. * @param name defines the block name
  122667. */
  122668. constructor(name: string);
  122669. /**
  122670. * Gets the current class name
  122671. * @returns the class name
  122672. */
  122673. getClassName(): string;
  122674. /**
  122675. * Gets the left operand input component
  122676. */
  122677. readonly left: NodeMaterialConnectionPoint;
  122678. /**
  122679. * Gets the right operand input component
  122680. */
  122681. readonly right: NodeMaterialConnectionPoint;
  122682. /**
  122683. * Gets the output component
  122684. */
  122685. readonly output: NodeMaterialConnectionPoint;
  122686. protected _buildBlock(state: NodeMaterialBuildState): this;
  122687. }
  122688. }
  122689. declare module BABYLON {
  122690. /**
  122691. * Block used to get the min of 2 values
  122692. */
  122693. export class MinBlock extends NodeMaterialBlock {
  122694. /**
  122695. * Creates a new MinBlock
  122696. * @param name defines the block name
  122697. */
  122698. constructor(name: string);
  122699. /**
  122700. * Gets the current class name
  122701. * @returns the class name
  122702. */
  122703. getClassName(): string;
  122704. /**
  122705. * Gets the left operand input component
  122706. */
  122707. readonly left: NodeMaterialConnectionPoint;
  122708. /**
  122709. * Gets the right operand input component
  122710. */
  122711. readonly right: NodeMaterialConnectionPoint;
  122712. /**
  122713. * Gets the output component
  122714. */
  122715. readonly output: NodeMaterialConnectionPoint;
  122716. protected _buildBlock(state: NodeMaterialBuildState): this;
  122717. }
  122718. }
  122719. declare module BABYLON {
  122720. /**
  122721. * Block used to get the distance between 2 values
  122722. */
  122723. export class DistanceBlock extends NodeMaterialBlock {
  122724. /**
  122725. * Creates a new DistanceBlock
  122726. * @param name defines the block name
  122727. */
  122728. constructor(name: string);
  122729. /**
  122730. * Gets the current class name
  122731. * @returns the class name
  122732. */
  122733. getClassName(): string;
  122734. /**
  122735. * Gets the left operand input component
  122736. */
  122737. readonly left: NodeMaterialConnectionPoint;
  122738. /**
  122739. * Gets the right operand input component
  122740. */
  122741. readonly right: NodeMaterialConnectionPoint;
  122742. /**
  122743. * Gets the output component
  122744. */
  122745. readonly output: NodeMaterialConnectionPoint;
  122746. protected _buildBlock(state: NodeMaterialBuildState): this;
  122747. }
  122748. }
  122749. declare module BABYLON {
  122750. /**
  122751. * Block used to get the length of a vector
  122752. */
  122753. export class LengthBlock extends NodeMaterialBlock {
  122754. /**
  122755. * Creates a new LengthBlock
  122756. * @param name defines the block name
  122757. */
  122758. constructor(name: string);
  122759. /**
  122760. * Gets the current class name
  122761. * @returns the class name
  122762. */
  122763. getClassName(): string;
  122764. /**
  122765. * Gets the value input component
  122766. */
  122767. readonly value: NodeMaterialConnectionPoint;
  122768. /**
  122769. * Gets the output component
  122770. */
  122771. readonly output: NodeMaterialConnectionPoint;
  122772. protected _buildBlock(state: NodeMaterialBuildState): this;
  122773. }
  122774. }
  122775. declare module BABYLON {
  122776. /**
  122777. * Block used to get negative version of a value (i.e. x * -1)
  122778. */
  122779. export class NegateBlock extends NodeMaterialBlock {
  122780. /**
  122781. * Creates a new NegateBlock
  122782. * @param name defines the block name
  122783. */
  122784. constructor(name: string);
  122785. /**
  122786. * Gets the current class name
  122787. * @returns the class name
  122788. */
  122789. getClassName(): string;
  122790. /**
  122791. * Gets the value input component
  122792. */
  122793. readonly value: NodeMaterialConnectionPoint;
  122794. /**
  122795. * Gets the output component
  122796. */
  122797. readonly output: NodeMaterialConnectionPoint;
  122798. protected _buildBlock(state: NodeMaterialBuildState): this;
  122799. }
  122800. }
  122801. declare module BABYLON {
  122802. /**
  122803. * Block used to get the value of the first parameter raised to the power of the second
  122804. */
  122805. export class PowBlock extends NodeMaterialBlock {
  122806. /**
  122807. * Creates a new PowBlock
  122808. * @param name defines the block name
  122809. */
  122810. constructor(name: string);
  122811. /**
  122812. * Gets the current class name
  122813. * @returns the class name
  122814. */
  122815. getClassName(): string;
  122816. /**
  122817. * Gets the value operand input component
  122818. */
  122819. readonly value: NodeMaterialConnectionPoint;
  122820. /**
  122821. * Gets the power operand input component
  122822. */
  122823. readonly power: NodeMaterialConnectionPoint;
  122824. /**
  122825. * Gets the output component
  122826. */
  122827. readonly output: NodeMaterialConnectionPoint;
  122828. protected _buildBlock(state: NodeMaterialBuildState): this;
  122829. }
  122830. }
  122831. declare module BABYLON {
  122832. /**
  122833. * Block used to get a random number
  122834. */
  122835. export class RandomNumberBlock extends NodeMaterialBlock {
  122836. /**
  122837. * Creates a new RandomNumberBlock
  122838. * @param name defines the block name
  122839. */
  122840. constructor(name: string);
  122841. /**
  122842. * Gets the current class name
  122843. * @returns the class name
  122844. */
  122845. getClassName(): string;
  122846. /**
  122847. * Gets the seed input component
  122848. */
  122849. readonly seed: NodeMaterialConnectionPoint;
  122850. /**
  122851. * Gets the output component
  122852. */
  122853. readonly output: NodeMaterialConnectionPoint;
  122854. protected _buildBlock(state: NodeMaterialBuildState): this;
  122855. }
  122856. }
  122857. declare module BABYLON {
  122858. /**
  122859. * Block used to compute arc tangent of 2 values
  122860. */
  122861. export class ArcTan2Block extends NodeMaterialBlock {
  122862. /**
  122863. * Creates a new ArcTan2Block
  122864. * @param name defines the block name
  122865. */
  122866. constructor(name: string);
  122867. /**
  122868. * Gets the current class name
  122869. * @returns the class name
  122870. */
  122871. getClassName(): string;
  122872. /**
  122873. * Gets the x operand input component
  122874. */
  122875. readonly x: NodeMaterialConnectionPoint;
  122876. /**
  122877. * Gets the y operand input component
  122878. */
  122879. readonly y: NodeMaterialConnectionPoint;
  122880. /**
  122881. * Gets the output component
  122882. */
  122883. readonly output: NodeMaterialConnectionPoint;
  122884. protected _buildBlock(state: NodeMaterialBuildState): this;
  122885. }
  122886. }
  122887. declare module BABYLON {
  122888. /**
  122889. * Block used to smooth step a value
  122890. */
  122891. export class SmoothStepBlock extends NodeMaterialBlock {
  122892. /**
  122893. * Creates a new SmoothStepBlock
  122894. * @param name defines the block name
  122895. */
  122896. constructor(name: string);
  122897. /**
  122898. * Gets the current class name
  122899. * @returns the class name
  122900. */
  122901. getClassName(): string;
  122902. /**
  122903. * Gets the value operand input component
  122904. */
  122905. readonly value: NodeMaterialConnectionPoint;
  122906. /**
  122907. * Gets the first edge operand input component
  122908. */
  122909. readonly edge0: NodeMaterialConnectionPoint;
  122910. /**
  122911. * Gets the second edge operand input component
  122912. */
  122913. readonly edge1: NodeMaterialConnectionPoint;
  122914. /**
  122915. * Gets the output component
  122916. */
  122917. readonly output: NodeMaterialConnectionPoint;
  122918. protected _buildBlock(state: NodeMaterialBuildState): this;
  122919. }
  122920. }
  122921. declare module BABYLON {
  122922. /**
  122923. * Block used to get the reciprocal (1 / x) of a value
  122924. */
  122925. export class ReciprocalBlock extends NodeMaterialBlock {
  122926. /**
  122927. * Creates a new ReciprocalBlock
  122928. * @param name defines the block name
  122929. */
  122930. constructor(name: string);
  122931. /**
  122932. * Gets the current class name
  122933. * @returns the class name
  122934. */
  122935. getClassName(): string;
  122936. /**
  122937. * Gets the input component
  122938. */
  122939. readonly input: NodeMaterialConnectionPoint;
  122940. /**
  122941. * Gets the output component
  122942. */
  122943. readonly output: NodeMaterialConnectionPoint;
  122944. protected _buildBlock(state: NodeMaterialBuildState): this;
  122945. }
  122946. }
  122947. declare module BABYLON {
  122948. /**
  122949. * Block used to replace a color by another one
  122950. */
  122951. export class ReplaceColorBlock extends NodeMaterialBlock {
  122952. /**
  122953. * Creates a new ReplaceColorBlock
  122954. * @param name defines the block name
  122955. */
  122956. constructor(name: string);
  122957. /**
  122958. * Gets the current class name
  122959. * @returns the class name
  122960. */
  122961. getClassName(): string;
  122962. /**
  122963. * Gets the value input component
  122964. */
  122965. readonly value: NodeMaterialConnectionPoint;
  122966. /**
  122967. * Gets the reference input component
  122968. */
  122969. readonly reference: NodeMaterialConnectionPoint;
  122970. /**
  122971. * Gets the distance input component
  122972. */
  122973. readonly distance: NodeMaterialConnectionPoint;
  122974. /**
  122975. * Gets the replacement input component
  122976. */
  122977. readonly replacement: NodeMaterialConnectionPoint;
  122978. /**
  122979. * Gets the output component
  122980. */
  122981. readonly output: NodeMaterialConnectionPoint;
  122982. protected _buildBlock(state: NodeMaterialBuildState): this;
  122983. }
  122984. }
  122985. declare module BABYLON {
  122986. /**
  122987. * Block used to posterize a value
  122988. * @see https://en.wikipedia.org/wiki/Posterization
  122989. */
  122990. export class PosterizeBlock extends NodeMaterialBlock {
  122991. /**
  122992. * Creates a new PosterizeBlock
  122993. * @param name defines the block name
  122994. */
  122995. constructor(name: string);
  122996. /**
  122997. * Gets the current class name
  122998. * @returns the class name
  122999. */
  123000. getClassName(): string;
  123001. /**
  123002. * Gets the value input component
  123003. */
  123004. readonly value: NodeMaterialConnectionPoint;
  123005. /**
  123006. * Gets the steps input component
  123007. */
  123008. readonly steps: NodeMaterialConnectionPoint;
  123009. /**
  123010. * Gets the output component
  123011. */
  123012. readonly output: NodeMaterialConnectionPoint;
  123013. protected _buildBlock(state: NodeMaterialBuildState): this;
  123014. }
  123015. }
  123016. declare module BABYLON {
  123017. /**
  123018. * Operations supported by the Wave block
  123019. */
  123020. export enum WaveBlockKind {
  123021. /** SawTooth */
  123022. SawTooth = 0,
  123023. /** Square */
  123024. Square = 1,
  123025. /** Triangle */
  123026. Triangle = 2
  123027. }
  123028. /**
  123029. * Block used to apply wave operation to floats
  123030. */
  123031. export class WaveBlock extends NodeMaterialBlock {
  123032. /**
  123033. * Gets or sets the kibnd of wave to be applied by the block
  123034. */
  123035. kind: WaveBlockKind;
  123036. /**
  123037. * Creates a new WaveBlock
  123038. * @param name defines the block name
  123039. */
  123040. constructor(name: string);
  123041. /**
  123042. * Gets the current class name
  123043. * @returns the class name
  123044. */
  123045. getClassName(): string;
  123046. /**
  123047. * Gets the input component
  123048. */
  123049. readonly input: NodeMaterialConnectionPoint;
  123050. /**
  123051. * Gets the output component
  123052. */
  123053. readonly output: NodeMaterialConnectionPoint;
  123054. protected _buildBlock(state: NodeMaterialBuildState): this;
  123055. serialize(): any;
  123056. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123057. }
  123058. }
  123059. declare module BABYLON {
  123060. /**
  123061. * Class used to store a color step for the GradientBlock
  123062. */
  123063. export class GradientBlockColorStep {
  123064. /**
  123065. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123066. */
  123067. step: number;
  123068. /**
  123069. * Gets or sets the color associated with this step
  123070. */
  123071. color: Color3;
  123072. /**
  123073. * Creates a new GradientBlockColorStep
  123074. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  123075. * @param color defines the color associated with this step
  123076. */
  123077. constructor(
  123078. /**
  123079. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123080. */
  123081. step: number,
  123082. /**
  123083. * Gets or sets the color associated with this step
  123084. */
  123085. color: Color3);
  123086. }
  123087. /**
  123088. * Block used to return a color from a gradient based on an input value between 0 and 1
  123089. */
  123090. export class GradientBlock extends NodeMaterialBlock {
  123091. /**
  123092. * Gets or sets the list of color steps
  123093. */
  123094. colorSteps: GradientBlockColorStep[];
  123095. /**
  123096. * Creates a new GradientBlock
  123097. * @param name defines the block name
  123098. */
  123099. constructor(name: string);
  123100. /**
  123101. * Gets the current class name
  123102. * @returns the class name
  123103. */
  123104. getClassName(): string;
  123105. /**
  123106. * Gets the gradient input component
  123107. */
  123108. readonly gradient: NodeMaterialConnectionPoint;
  123109. /**
  123110. * Gets the output component
  123111. */
  123112. readonly output: NodeMaterialConnectionPoint;
  123113. private _writeColorConstant;
  123114. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123115. serialize(): any;
  123116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123117. protected _dumpPropertiesCode(): string;
  123118. }
  123119. }
  123120. declare module BABYLON {
  123121. /**
  123122. * Block used to normalize lerp between 2 values
  123123. */
  123124. export class NLerpBlock extends NodeMaterialBlock {
  123125. /**
  123126. * Creates a new NLerpBlock
  123127. * @param name defines the block name
  123128. */
  123129. constructor(name: string);
  123130. /**
  123131. * Gets the current class name
  123132. * @returns the class name
  123133. */
  123134. getClassName(): string;
  123135. /**
  123136. * Gets the left operand input component
  123137. */
  123138. readonly left: NodeMaterialConnectionPoint;
  123139. /**
  123140. * Gets the right operand input component
  123141. */
  123142. readonly right: NodeMaterialConnectionPoint;
  123143. /**
  123144. * Gets the gradient operand input component
  123145. */
  123146. readonly gradient: NodeMaterialConnectionPoint;
  123147. /**
  123148. * Gets the output component
  123149. */
  123150. readonly output: NodeMaterialConnectionPoint;
  123151. protected _buildBlock(state: NodeMaterialBuildState): this;
  123152. }
  123153. }
  123154. declare module BABYLON {
  123155. /**
  123156. * Block used to test if the fragment shader is front facing
  123157. */
  123158. export class FrontFacingBlock extends NodeMaterialBlock {
  123159. /**
  123160. * Creates a new FrontFacingBlock
  123161. * @param name defines the block name
  123162. */
  123163. constructor(name: string);
  123164. /**
  123165. * Gets the current class name
  123166. * @returns the class name
  123167. */
  123168. getClassName(): string;
  123169. /**
  123170. * Gets the world normal component
  123171. */
  123172. readonly worldNormal: NodeMaterialConnectionPoint;
  123173. /**
  123174. * Gets the view direction input component
  123175. */
  123176. readonly viewDirection: NodeMaterialConnectionPoint;
  123177. /**
  123178. * Gets the output component
  123179. */
  123180. readonly output: NodeMaterialConnectionPoint;
  123181. autoConfigure(material: NodeMaterial): void;
  123182. protected _buildBlock(state: NodeMaterialBuildState): this;
  123183. }
  123184. }
  123185. declare module BABYLON {
  123186. /**
  123187. * Effect Render Options
  123188. */
  123189. export interface IEffectRendererOptions {
  123190. /**
  123191. * Defines the vertices positions.
  123192. */
  123193. positions?: number[];
  123194. /**
  123195. * Defines the indices.
  123196. */
  123197. indices?: number[];
  123198. }
  123199. /**
  123200. * Helper class to render one or more effects
  123201. */
  123202. export class EffectRenderer {
  123203. private engine;
  123204. private static _DefaultOptions;
  123205. private _vertexBuffers;
  123206. private _indexBuffer;
  123207. private _ringBufferIndex;
  123208. private _ringScreenBuffer;
  123209. private _fullscreenViewport;
  123210. private _getNextFrameBuffer;
  123211. /**
  123212. * Creates an effect renderer
  123213. * @param engine the engine to use for rendering
  123214. * @param options defines the options of the effect renderer
  123215. */
  123216. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123217. /**
  123218. * Sets the current viewport in normalized coordinates 0-1
  123219. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123220. */
  123221. setViewport(viewport?: Viewport): void;
  123222. /**
  123223. * Binds the embedded attributes buffer to the effect.
  123224. * @param effect Defines the effect to bind the attributes for
  123225. */
  123226. bindBuffers(effect: Effect): void;
  123227. /**
  123228. * Sets the current effect wrapper to use during draw.
  123229. * The effect needs to be ready before calling this api.
  123230. * This also sets the default full screen position attribute.
  123231. * @param effectWrapper Defines the effect to draw with
  123232. */
  123233. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  123234. /**
  123235. * Draws a full screen quad.
  123236. */
  123237. draw(): void;
  123238. /**
  123239. * renders one or more effects to a specified texture
  123240. * @param effectWrappers list of effects to renderer
  123241. * @param outputTexture texture to draw to, if null it will render to the screen
  123242. */
  123243. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  123244. /**
  123245. * Disposes of the effect renderer
  123246. */
  123247. dispose(): void;
  123248. }
  123249. /**
  123250. * Options to create an EffectWrapper
  123251. */
  123252. interface EffectWrapperCreationOptions {
  123253. /**
  123254. * Engine to use to create the effect
  123255. */
  123256. engine: ThinEngine;
  123257. /**
  123258. * Fragment shader for the effect
  123259. */
  123260. fragmentShader: string;
  123261. /**
  123262. * Vertex shader for the effect
  123263. */
  123264. vertexShader?: string;
  123265. /**
  123266. * Attributes to use in the shader
  123267. */
  123268. attributeNames?: Array<string>;
  123269. /**
  123270. * Uniforms to use in the shader
  123271. */
  123272. uniformNames?: Array<string>;
  123273. /**
  123274. * Texture sampler names to use in the shader
  123275. */
  123276. samplerNames?: Array<string>;
  123277. /**
  123278. * The friendly name of the effect displayed in Spector.
  123279. */
  123280. name?: string;
  123281. }
  123282. /**
  123283. * Wraps an effect to be used for rendering
  123284. */
  123285. export class EffectWrapper {
  123286. /**
  123287. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  123288. */
  123289. onApplyObservable: Observable<{}>;
  123290. /**
  123291. * The underlying effect
  123292. */
  123293. effect: Effect;
  123294. /**
  123295. * Creates an effect to be renderer
  123296. * @param creationOptions options to create the effect
  123297. */
  123298. constructor(creationOptions: EffectWrapperCreationOptions);
  123299. /**
  123300. * Disposes of the effect wrapper
  123301. */
  123302. dispose(): void;
  123303. }
  123304. }
  123305. declare module BABYLON {
  123306. /**
  123307. * Helper class to push actions to a pool of workers.
  123308. */
  123309. export class WorkerPool implements IDisposable {
  123310. private _workerInfos;
  123311. private _pendingActions;
  123312. /**
  123313. * Constructor
  123314. * @param workers Array of workers to use for actions
  123315. */
  123316. constructor(workers: Array<Worker>);
  123317. /**
  123318. * Terminates all workers and clears any pending actions.
  123319. */
  123320. dispose(): void;
  123321. /**
  123322. * Pushes an action to the worker pool. If all the workers are active, the action will be
  123323. * pended until a worker has completed its action.
  123324. * @param action The action to perform. Call onComplete when the action is complete.
  123325. */
  123326. push(action: (worker: Worker, onComplete: () => void) => void): void;
  123327. private _execute;
  123328. }
  123329. }
  123330. declare module BABYLON {
  123331. /**
  123332. * Configuration for Draco compression
  123333. */
  123334. export interface IDracoCompressionConfiguration {
  123335. /**
  123336. * Configuration for the decoder.
  123337. */
  123338. decoder: {
  123339. /**
  123340. * The url to the WebAssembly module.
  123341. */
  123342. wasmUrl?: string;
  123343. /**
  123344. * The url to the WebAssembly binary.
  123345. */
  123346. wasmBinaryUrl?: string;
  123347. /**
  123348. * The url to the fallback JavaScript module.
  123349. */
  123350. fallbackUrl?: string;
  123351. };
  123352. }
  123353. /**
  123354. * Draco compression (https://google.github.io/draco/)
  123355. *
  123356. * This class wraps the Draco module.
  123357. *
  123358. * **Encoder**
  123359. *
  123360. * The encoder is not currently implemented.
  123361. *
  123362. * **Decoder**
  123363. *
  123364. * 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.
  123365. *
  123366. * To update the configuration, use the following code:
  123367. * ```javascript
  123368. * DracoCompression.Configuration = {
  123369. * decoder: {
  123370. * wasmUrl: "<url to the WebAssembly library>",
  123371. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123372. * fallbackUrl: "<url to the fallback JavaScript library>",
  123373. * }
  123374. * };
  123375. * ```
  123376. *
  123377. * 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.
  123378. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123379. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123380. *
  123381. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123382. * ```javascript
  123383. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123384. * ```
  123385. *
  123386. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123387. */
  123388. export class DracoCompression implements IDisposable {
  123389. private _workerPoolPromise?;
  123390. private _decoderModulePromise?;
  123391. /**
  123392. * The configuration. Defaults to the following urls:
  123393. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123394. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123395. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123396. */
  123397. static Configuration: IDracoCompressionConfiguration;
  123398. /**
  123399. * Returns true if the decoder configuration is available.
  123400. */
  123401. static readonly DecoderAvailable: boolean;
  123402. /**
  123403. * Default number of workers to create when creating the draco compression object.
  123404. */
  123405. static DefaultNumWorkers: number;
  123406. private static GetDefaultNumWorkers;
  123407. private static _Default;
  123408. /**
  123409. * Default instance for the draco compression object.
  123410. */
  123411. static readonly Default: DracoCompression;
  123412. /**
  123413. * Constructor
  123414. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123415. */
  123416. constructor(numWorkers?: number);
  123417. /**
  123418. * Stop all async operations and release resources.
  123419. */
  123420. dispose(): void;
  123421. /**
  123422. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123423. * @returns a promise that resolves when ready
  123424. */
  123425. whenReadyAsync(): Promise<void>;
  123426. /**
  123427. * Decode Draco compressed mesh data to vertex data.
  123428. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123429. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123430. * @returns A promise that resolves with the decoded vertex data
  123431. */
  123432. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123433. [kind: string]: number;
  123434. }): Promise<VertexData>;
  123435. }
  123436. }
  123437. declare module BABYLON {
  123438. /**
  123439. * Class for building Constructive Solid Geometry
  123440. */
  123441. export class CSG {
  123442. private polygons;
  123443. /**
  123444. * The world matrix
  123445. */
  123446. matrix: Matrix;
  123447. /**
  123448. * Stores the position
  123449. */
  123450. position: Vector3;
  123451. /**
  123452. * Stores the rotation
  123453. */
  123454. rotation: Vector3;
  123455. /**
  123456. * Stores the rotation quaternion
  123457. */
  123458. rotationQuaternion: Nullable<Quaternion>;
  123459. /**
  123460. * Stores the scaling vector
  123461. */
  123462. scaling: Vector3;
  123463. /**
  123464. * Convert the Mesh to CSG
  123465. * @param mesh The Mesh to convert to CSG
  123466. * @returns A new CSG from the Mesh
  123467. */
  123468. static FromMesh(mesh: Mesh): CSG;
  123469. /**
  123470. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123471. * @param polygons Polygons used to construct a CSG solid
  123472. */
  123473. private static FromPolygons;
  123474. /**
  123475. * Clones, or makes a deep copy, of the CSG
  123476. * @returns A new CSG
  123477. */
  123478. clone(): CSG;
  123479. /**
  123480. * Unions this CSG with another CSG
  123481. * @param csg The CSG to union against this CSG
  123482. * @returns The unioned CSG
  123483. */
  123484. union(csg: CSG): CSG;
  123485. /**
  123486. * Unions this CSG with another CSG in place
  123487. * @param csg The CSG to union against this CSG
  123488. */
  123489. unionInPlace(csg: CSG): void;
  123490. /**
  123491. * Subtracts this CSG with another CSG
  123492. * @param csg The CSG to subtract against this CSG
  123493. * @returns A new CSG
  123494. */
  123495. subtract(csg: CSG): CSG;
  123496. /**
  123497. * Subtracts this CSG with another CSG in place
  123498. * @param csg The CSG to subtact against this CSG
  123499. */
  123500. subtractInPlace(csg: CSG): void;
  123501. /**
  123502. * Intersect this CSG with another CSG
  123503. * @param csg The CSG to intersect against this CSG
  123504. * @returns A new CSG
  123505. */
  123506. intersect(csg: CSG): CSG;
  123507. /**
  123508. * Intersects this CSG with another CSG in place
  123509. * @param csg The CSG to intersect against this CSG
  123510. */
  123511. intersectInPlace(csg: CSG): void;
  123512. /**
  123513. * Return a new CSG solid with solid and empty space switched. This solid is
  123514. * not modified.
  123515. * @returns A new CSG solid with solid and empty space switched
  123516. */
  123517. inverse(): CSG;
  123518. /**
  123519. * Inverses the CSG in place
  123520. */
  123521. inverseInPlace(): void;
  123522. /**
  123523. * This is used to keep meshes transformations so they can be restored
  123524. * when we build back a Babylon Mesh
  123525. * NB : All CSG operations are performed in world coordinates
  123526. * @param csg The CSG to copy the transform attributes from
  123527. * @returns This CSG
  123528. */
  123529. copyTransformAttributes(csg: CSG): CSG;
  123530. /**
  123531. * Build Raw mesh from CSG
  123532. * Coordinates here are in world space
  123533. * @param name The name of the mesh geometry
  123534. * @param scene The Scene
  123535. * @param keepSubMeshes Specifies if the submeshes should be kept
  123536. * @returns A new Mesh
  123537. */
  123538. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123539. /**
  123540. * Build Mesh from CSG taking material and transforms into account
  123541. * @param name The name of the Mesh
  123542. * @param material The material of the Mesh
  123543. * @param scene The Scene
  123544. * @param keepSubMeshes Specifies if submeshes should be kept
  123545. * @returns The new Mesh
  123546. */
  123547. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123548. }
  123549. }
  123550. declare module BABYLON {
  123551. /**
  123552. * Class used to create a trail following a mesh
  123553. */
  123554. export class TrailMesh extends Mesh {
  123555. private _generator;
  123556. private _autoStart;
  123557. private _running;
  123558. private _diameter;
  123559. private _length;
  123560. private _sectionPolygonPointsCount;
  123561. private _sectionVectors;
  123562. private _sectionNormalVectors;
  123563. private _beforeRenderObserver;
  123564. /**
  123565. * @constructor
  123566. * @param name The value used by scene.getMeshByName() to do a lookup.
  123567. * @param generator The mesh to generate a trail.
  123568. * @param scene The scene to add this mesh to.
  123569. * @param diameter Diameter of trailing mesh. Default is 1.
  123570. * @param length Length of trailing mesh. Default is 60.
  123571. * @param autoStart Automatically start trailing mesh. Default true.
  123572. */
  123573. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123574. /**
  123575. * "TrailMesh"
  123576. * @returns "TrailMesh"
  123577. */
  123578. getClassName(): string;
  123579. private _createMesh;
  123580. /**
  123581. * Start trailing mesh.
  123582. */
  123583. start(): void;
  123584. /**
  123585. * Stop trailing mesh.
  123586. */
  123587. stop(): void;
  123588. /**
  123589. * Update trailing mesh geometry.
  123590. */
  123591. update(): void;
  123592. /**
  123593. * Returns a new TrailMesh object.
  123594. * @param name is a string, the name given to the new mesh
  123595. * @param newGenerator use new generator object for cloned trail mesh
  123596. * @returns a new mesh
  123597. */
  123598. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123599. /**
  123600. * Serializes this trail mesh
  123601. * @param serializationObject object to write serialization to
  123602. */
  123603. serialize(serializationObject: any): void;
  123604. /**
  123605. * Parses a serialized trail mesh
  123606. * @param parsedMesh the serialized mesh
  123607. * @param scene the scene to create the trail mesh in
  123608. * @returns the created trail mesh
  123609. */
  123610. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123611. }
  123612. }
  123613. declare module BABYLON {
  123614. /**
  123615. * Class containing static functions to help procedurally build meshes
  123616. */
  123617. export class TiledBoxBuilder {
  123618. /**
  123619. * Creates a box mesh
  123620. * 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)
  123621. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123625. * @param name defines the name of the mesh
  123626. * @param options defines the options used to create the mesh
  123627. * @param scene defines the hosting scene
  123628. * @returns the box mesh
  123629. */
  123630. static CreateTiledBox(name: string, options: {
  123631. pattern?: number;
  123632. width?: number;
  123633. height?: number;
  123634. depth?: number;
  123635. tileSize?: number;
  123636. tileWidth?: number;
  123637. tileHeight?: number;
  123638. alignHorizontal?: number;
  123639. alignVertical?: number;
  123640. faceUV?: Vector4[];
  123641. faceColors?: Color4[];
  123642. sideOrientation?: number;
  123643. updatable?: boolean;
  123644. }, scene?: Nullable<Scene>): Mesh;
  123645. }
  123646. }
  123647. declare module BABYLON {
  123648. /**
  123649. * Class containing static functions to help procedurally build meshes
  123650. */
  123651. export class TorusKnotBuilder {
  123652. /**
  123653. * Creates a torus knot mesh
  123654. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123655. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123656. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123657. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123661. * @param name defines the name of the mesh
  123662. * @param options defines the options used to create the mesh
  123663. * @param scene defines the hosting scene
  123664. * @returns the torus knot mesh
  123665. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123666. */
  123667. static CreateTorusKnot(name: string, options: {
  123668. radius?: number;
  123669. tube?: number;
  123670. radialSegments?: number;
  123671. tubularSegments?: number;
  123672. p?: number;
  123673. q?: number;
  123674. updatable?: boolean;
  123675. sideOrientation?: number;
  123676. frontUVs?: Vector4;
  123677. backUVs?: Vector4;
  123678. }, scene: any): Mesh;
  123679. }
  123680. }
  123681. declare module BABYLON {
  123682. /**
  123683. * Polygon
  123684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  123685. */
  123686. export class Polygon {
  123687. /**
  123688. * Creates a rectangle
  123689. * @param xmin bottom X coord
  123690. * @param ymin bottom Y coord
  123691. * @param xmax top X coord
  123692. * @param ymax top Y coord
  123693. * @returns points that make the resulting rectation
  123694. */
  123695. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  123696. /**
  123697. * Creates a circle
  123698. * @param radius radius of circle
  123699. * @param cx scale in x
  123700. * @param cy scale in y
  123701. * @param numberOfSides number of sides that make up the circle
  123702. * @returns points that make the resulting circle
  123703. */
  123704. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  123705. /**
  123706. * Creates a polygon from input string
  123707. * @param input Input polygon data
  123708. * @returns the parsed points
  123709. */
  123710. static Parse(input: string): Vector2[];
  123711. /**
  123712. * Starts building a polygon from x and y coordinates
  123713. * @param x x coordinate
  123714. * @param y y coordinate
  123715. * @returns the started path2
  123716. */
  123717. static StartingAt(x: number, y: number): Path2;
  123718. }
  123719. /**
  123720. * Builds a polygon
  123721. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  123722. */
  123723. export class PolygonMeshBuilder {
  123724. private _points;
  123725. private _outlinepoints;
  123726. private _holes;
  123727. private _name;
  123728. private _scene;
  123729. private _epoints;
  123730. private _eholes;
  123731. private _addToepoint;
  123732. /**
  123733. * Babylon reference to the earcut plugin.
  123734. */
  123735. bjsEarcut: any;
  123736. /**
  123737. * Creates a PolygonMeshBuilder
  123738. * @param name name of the builder
  123739. * @param contours Path of the polygon
  123740. * @param scene scene to add to when creating the mesh
  123741. * @param earcutInjection can be used to inject your own earcut reference
  123742. */
  123743. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  123744. /**
  123745. * Adds a whole within the polygon
  123746. * @param hole Array of points defining the hole
  123747. * @returns this
  123748. */
  123749. addHole(hole: Vector2[]): PolygonMeshBuilder;
  123750. /**
  123751. * Creates the polygon
  123752. * @param updatable If the mesh should be updatable
  123753. * @param depth The depth of the mesh created
  123754. * @returns the created mesh
  123755. */
  123756. build(updatable?: boolean, depth?: number): Mesh;
  123757. /**
  123758. * Creates the polygon
  123759. * @param depth The depth of the mesh created
  123760. * @returns the created VertexData
  123761. */
  123762. buildVertexData(depth?: number): VertexData;
  123763. /**
  123764. * Adds a side to the polygon
  123765. * @param positions points that make the polygon
  123766. * @param normals normals of the polygon
  123767. * @param uvs uvs of the polygon
  123768. * @param indices indices of the polygon
  123769. * @param bounds bounds of the polygon
  123770. * @param points points of the polygon
  123771. * @param depth depth of the polygon
  123772. * @param flip flip of the polygon
  123773. */
  123774. private addSide;
  123775. }
  123776. }
  123777. declare module BABYLON {
  123778. /**
  123779. * Class containing static functions to help procedurally build meshes
  123780. */
  123781. export class PolygonBuilder {
  123782. /**
  123783. * Creates a polygon mesh
  123784. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123785. * * 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
  123786. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123789. * * Remember you can only change the shape positions, not their number when updating a polygon
  123790. * @param name defines the name of the mesh
  123791. * @param options defines the options used to create the mesh
  123792. * @param scene defines the hosting scene
  123793. * @param earcutInjection can be used to inject your own earcut reference
  123794. * @returns the polygon mesh
  123795. */
  123796. static CreatePolygon(name: string, options: {
  123797. shape: Vector3[];
  123798. holes?: Vector3[][];
  123799. depth?: number;
  123800. faceUV?: Vector4[];
  123801. faceColors?: Color4[];
  123802. updatable?: boolean;
  123803. sideOrientation?: number;
  123804. frontUVs?: Vector4;
  123805. backUVs?: Vector4;
  123806. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123807. /**
  123808. * Creates an extruded polygon mesh, with depth in the Y direction.
  123809. * * 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)
  123810. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123811. * @param name defines the name of the mesh
  123812. * @param options defines the options used to create the mesh
  123813. * @param scene defines the hosting scene
  123814. * @param earcutInjection can be used to inject your own earcut reference
  123815. * @returns the polygon mesh
  123816. */
  123817. static ExtrudePolygon(name: string, options: {
  123818. shape: Vector3[];
  123819. holes?: Vector3[][];
  123820. depth?: number;
  123821. faceUV?: Vector4[];
  123822. faceColors?: Color4[];
  123823. updatable?: boolean;
  123824. sideOrientation?: number;
  123825. frontUVs?: Vector4;
  123826. backUVs?: Vector4;
  123827. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123828. }
  123829. }
  123830. declare module BABYLON {
  123831. /**
  123832. * Class containing static functions to help procedurally build meshes
  123833. */
  123834. export class LatheBuilder {
  123835. /**
  123836. * Creates lathe mesh.
  123837. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123838. * * 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
  123839. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123840. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123841. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123842. * * 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
  123843. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123844. * * 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
  123845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123847. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123849. * @param name defines the name of the mesh
  123850. * @param options defines the options used to create the mesh
  123851. * @param scene defines the hosting scene
  123852. * @returns the lathe mesh
  123853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123854. */
  123855. static CreateLathe(name: string, options: {
  123856. shape: Vector3[];
  123857. radius?: number;
  123858. tessellation?: number;
  123859. clip?: number;
  123860. arc?: number;
  123861. closed?: boolean;
  123862. updatable?: boolean;
  123863. sideOrientation?: number;
  123864. frontUVs?: Vector4;
  123865. backUVs?: Vector4;
  123866. cap?: number;
  123867. invertUV?: boolean;
  123868. }, scene?: Nullable<Scene>): Mesh;
  123869. }
  123870. }
  123871. declare module BABYLON {
  123872. /**
  123873. * Class containing static functions to help procedurally build meshes
  123874. */
  123875. export class TiledPlaneBuilder {
  123876. /**
  123877. * Creates a tiled plane mesh
  123878. * * The parameter `pattern` will, depending on value, do nothing or
  123879. * * * flip (reflect about central vertical) alternate tiles across and up
  123880. * * * flip every tile on alternate rows
  123881. * * * rotate (180 degs) alternate tiles across and up
  123882. * * * rotate every tile on alternate rows
  123883. * * * flip and rotate alternate tiles across and up
  123884. * * * flip and rotate every tile on alternate rows
  123885. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123886. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123888. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123889. * * 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)
  123890. * * 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)
  123891. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123892. * @param name defines the name of the mesh
  123893. * @param options defines the options used to create the mesh
  123894. * @param scene defines the hosting scene
  123895. * @returns the box mesh
  123896. */
  123897. static CreateTiledPlane(name: string, options: {
  123898. pattern?: number;
  123899. tileSize?: number;
  123900. tileWidth?: number;
  123901. tileHeight?: number;
  123902. size?: number;
  123903. width?: number;
  123904. height?: number;
  123905. alignHorizontal?: number;
  123906. alignVertical?: number;
  123907. sideOrientation?: number;
  123908. frontUVs?: Vector4;
  123909. backUVs?: Vector4;
  123910. updatable?: boolean;
  123911. }, scene?: Nullable<Scene>): Mesh;
  123912. }
  123913. }
  123914. declare module BABYLON {
  123915. /**
  123916. * Class containing static functions to help procedurally build meshes
  123917. */
  123918. export class TubeBuilder {
  123919. /**
  123920. * Creates a tube mesh.
  123921. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123922. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123923. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123924. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123925. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123926. * * 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)
  123927. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123928. * * 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
  123929. * * 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
  123930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123934. * @param name defines the name of the mesh
  123935. * @param options defines the options used to create the mesh
  123936. * @param scene defines the hosting scene
  123937. * @returns the tube mesh
  123938. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123939. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123940. */
  123941. static CreateTube(name: string, options: {
  123942. path: Vector3[];
  123943. radius?: number;
  123944. tessellation?: number;
  123945. radiusFunction?: {
  123946. (i: number, distance: number): number;
  123947. };
  123948. cap?: number;
  123949. arc?: number;
  123950. updatable?: boolean;
  123951. sideOrientation?: number;
  123952. frontUVs?: Vector4;
  123953. backUVs?: Vector4;
  123954. instance?: Mesh;
  123955. invertUV?: boolean;
  123956. }, scene?: Nullable<Scene>): Mesh;
  123957. }
  123958. }
  123959. declare module BABYLON {
  123960. /**
  123961. * Class containing static functions to help procedurally build meshes
  123962. */
  123963. export class IcoSphereBuilder {
  123964. /**
  123965. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123966. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123967. * * 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`)
  123968. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123969. * * 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
  123970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123973. * @param name defines the name of the mesh
  123974. * @param options defines the options used to create the mesh
  123975. * @param scene defines the hosting scene
  123976. * @returns the icosahedron mesh
  123977. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123978. */
  123979. static CreateIcoSphere(name: string, options: {
  123980. radius?: number;
  123981. radiusX?: number;
  123982. radiusY?: number;
  123983. radiusZ?: number;
  123984. flat?: boolean;
  123985. subdivisions?: number;
  123986. sideOrientation?: number;
  123987. frontUVs?: Vector4;
  123988. backUVs?: Vector4;
  123989. updatable?: boolean;
  123990. }, scene?: Nullable<Scene>): Mesh;
  123991. }
  123992. }
  123993. declare module BABYLON {
  123994. /**
  123995. * Class containing static functions to help procedurally build meshes
  123996. */
  123997. export class DecalBuilder {
  123998. /**
  123999. * Creates a decal mesh.
  124000. * 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
  124001. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124002. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124003. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124004. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124005. * @param name defines the name of the mesh
  124006. * @param sourceMesh defines the mesh where the decal must be applied
  124007. * @param options defines the options used to create the mesh
  124008. * @param scene defines the hosting scene
  124009. * @returns the decal mesh
  124010. * @see https://doc.babylonjs.com/how_to/decals
  124011. */
  124012. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124013. position?: Vector3;
  124014. normal?: Vector3;
  124015. size?: Vector3;
  124016. angle?: number;
  124017. }): Mesh;
  124018. }
  124019. }
  124020. declare module BABYLON {
  124021. /**
  124022. * Class containing static functions to help procedurally build meshes
  124023. */
  124024. export class MeshBuilder {
  124025. /**
  124026. * Creates a box mesh
  124027. * * The parameter `size` sets the size (float) of each box side (default 1)
  124028. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  124029. * * 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)
  124030. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124034. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124035. * @param name defines the name of the mesh
  124036. * @param options defines the options used to create the mesh
  124037. * @param scene defines the hosting scene
  124038. * @returns the box mesh
  124039. */
  124040. static CreateBox(name: string, options: {
  124041. size?: number;
  124042. width?: number;
  124043. height?: number;
  124044. depth?: number;
  124045. faceUV?: Vector4[];
  124046. faceColors?: Color4[];
  124047. sideOrientation?: number;
  124048. frontUVs?: Vector4;
  124049. backUVs?: Vector4;
  124050. updatable?: boolean;
  124051. }, scene?: Nullable<Scene>): Mesh;
  124052. /**
  124053. * Creates a tiled box mesh
  124054. * * faceTiles sets the pattern, tile size and number of tiles for a face
  124055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124056. * @param name defines the name of the mesh
  124057. * @param options defines the options used to create the mesh
  124058. * @param scene defines the hosting scene
  124059. * @returns the tiled box mesh
  124060. */
  124061. static CreateTiledBox(name: string, options: {
  124062. pattern?: number;
  124063. size?: number;
  124064. width?: number;
  124065. height?: number;
  124066. depth: number;
  124067. tileSize?: number;
  124068. tileWidth?: number;
  124069. tileHeight?: number;
  124070. faceUV?: Vector4[];
  124071. faceColors?: Color4[];
  124072. alignHorizontal?: number;
  124073. alignVertical?: number;
  124074. sideOrientation?: number;
  124075. updatable?: boolean;
  124076. }, scene?: Nullable<Scene>): Mesh;
  124077. /**
  124078. * Creates a sphere mesh
  124079. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124080. * * 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`)
  124081. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124082. * * 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
  124083. * * 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)
  124084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124087. * @param name defines the name of the mesh
  124088. * @param options defines the options used to create the mesh
  124089. * @param scene defines the hosting scene
  124090. * @returns the sphere mesh
  124091. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124092. */
  124093. static CreateSphere(name: string, options: {
  124094. segments?: number;
  124095. diameter?: number;
  124096. diameterX?: number;
  124097. diameterY?: number;
  124098. diameterZ?: number;
  124099. arc?: number;
  124100. slice?: number;
  124101. sideOrientation?: number;
  124102. frontUVs?: Vector4;
  124103. backUVs?: Vector4;
  124104. updatable?: boolean;
  124105. }, scene?: Nullable<Scene>): Mesh;
  124106. /**
  124107. * Creates a plane polygonal mesh. By default, this is a disc
  124108. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  124109. * * 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
  124110. * * 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
  124111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124114. * @param name defines the name of the mesh
  124115. * @param options defines the options used to create the mesh
  124116. * @param scene defines the hosting scene
  124117. * @returns the plane polygonal mesh
  124118. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  124119. */
  124120. static CreateDisc(name: string, options: {
  124121. radius?: number;
  124122. tessellation?: number;
  124123. arc?: number;
  124124. updatable?: boolean;
  124125. sideOrientation?: number;
  124126. frontUVs?: Vector4;
  124127. backUVs?: Vector4;
  124128. }, scene?: Nullable<Scene>): Mesh;
  124129. /**
  124130. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124131. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124132. * * 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`)
  124133. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124134. * * 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
  124135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124138. * @param name defines the name of the mesh
  124139. * @param options defines the options used to create the mesh
  124140. * @param scene defines the hosting scene
  124141. * @returns the icosahedron mesh
  124142. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124143. */
  124144. static CreateIcoSphere(name: string, options: {
  124145. radius?: number;
  124146. radiusX?: number;
  124147. radiusY?: number;
  124148. radiusZ?: number;
  124149. flat?: boolean;
  124150. subdivisions?: number;
  124151. sideOrientation?: number;
  124152. frontUVs?: Vector4;
  124153. backUVs?: Vector4;
  124154. updatable?: boolean;
  124155. }, scene?: Nullable<Scene>): Mesh;
  124156. /**
  124157. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124158. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124159. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124160. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124161. * * 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
  124162. * * 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
  124163. * * 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
  124164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124167. * * 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
  124168. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124169. * * 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
  124170. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124172. * @param name defines the name of the mesh
  124173. * @param options defines the options used to create the mesh
  124174. * @param scene defines the hosting scene
  124175. * @returns the ribbon mesh
  124176. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124178. */
  124179. static CreateRibbon(name: string, options: {
  124180. pathArray: Vector3[][];
  124181. closeArray?: boolean;
  124182. closePath?: boolean;
  124183. offset?: number;
  124184. updatable?: boolean;
  124185. sideOrientation?: number;
  124186. frontUVs?: Vector4;
  124187. backUVs?: Vector4;
  124188. instance?: Mesh;
  124189. invertUV?: boolean;
  124190. uvs?: Vector2[];
  124191. colors?: Color4[];
  124192. }, scene?: Nullable<Scene>): Mesh;
  124193. /**
  124194. * Creates a cylinder or a cone mesh
  124195. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124196. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124197. * * 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.
  124198. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124199. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124200. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124201. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124202. * * 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).
  124203. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124204. * * 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).
  124205. * * 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
  124206. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124207. * * 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
  124208. * * 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.
  124209. * * If `enclose` is false, a ring surface is one element.
  124210. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124211. * * 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
  124212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124215. * @param name defines the name of the mesh
  124216. * @param options defines the options used to create the mesh
  124217. * @param scene defines the hosting scene
  124218. * @returns the cylinder mesh
  124219. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124220. */
  124221. static CreateCylinder(name: string, options: {
  124222. height?: number;
  124223. diameterTop?: number;
  124224. diameterBottom?: number;
  124225. diameter?: number;
  124226. tessellation?: number;
  124227. subdivisions?: number;
  124228. arc?: number;
  124229. faceColors?: Color4[];
  124230. faceUV?: Vector4[];
  124231. updatable?: boolean;
  124232. hasRings?: boolean;
  124233. enclose?: boolean;
  124234. cap?: number;
  124235. sideOrientation?: number;
  124236. frontUVs?: Vector4;
  124237. backUVs?: Vector4;
  124238. }, scene?: Nullable<Scene>): Mesh;
  124239. /**
  124240. * Creates a torus mesh
  124241. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124242. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124243. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124247. * @param name defines the name of the mesh
  124248. * @param options defines the options used to create the mesh
  124249. * @param scene defines the hosting scene
  124250. * @returns the torus mesh
  124251. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124252. */
  124253. static CreateTorus(name: string, options: {
  124254. diameter?: number;
  124255. thickness?: number;
  124256. tessellation?: number;
  124257. updatable?: boolean;
  124258. sideOrientation?: number;
  124259. frontUVs?: Vector4;
  124260. backUVs?: Vector4;
  124261. }, scene?: Nullable<Scene>): Mesh;
  124262. /**
  124263. * Creates a torus knot mesh
  124264. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124265. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124266. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124267. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124271. * @param name defines the name of the mesh
  124272. * @param options defines the options used to create the mesh
  124273. * @param scene defines the hosting scene
  124274. * @returns the torus knot mesh
  124275. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124276. */
  124277. static CreateTorusKnot(name: string, options: {
  124278. radius?: number;
  124279. tube?: number;
  124280. radialSegments?: number;
  124281. tubularSegments?: number;
  124282. p?: number;
  124283. q?: number;
  124284. updatable?: boolean;
  124285. sideOrientation?: number;
  124286. frontUVs?: Vector4;
  124287. backUVs?: Vector4;
  124288. }, scene?: Nullable<Scene>): Mesh;
  124289. /**
  124290. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124291. * * 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
  124292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124293. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124294. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124295. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124296. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124297. * * 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
  124298. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124301. * @param name defines the name of the new line system
  124302. * @param options defines the options used to create the line system
  124303. * @param scene defines the hosting scene
  124304. * @returns a new line system mesh
  124305. */
  124306. static CreateLineSystem(name: string, options: {
  124307. lines: Vector3[][];
  124308. updatable?: boolean;
  124309. instance?: Nullable<LinesMesh>;
  124310. colors?: Nullable<Color4[][]>;
  124311. useVertexAlpha?: boolean;
  124312. }, scene: Nullable<Scene>): LinesMesh;
  124313. /**
  124314. * Creates a line mesh
  124315. * 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
  124316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124317. * * The parameter `points` is an array successive Vector3
  124318. * * 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
  124319. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124321. * * When updating an instance, remember that only point positions can change, not the number of points
  124322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124324. * @param name defines the name of the new line system
  124325. * @param options defines the options used to create the line system
  124326. * @param scene defines the hosting scene
  124327. * @returns a new line mesh
  124328. */
  124329. static CreateLines(name: string, options: {
  124330. points: Vector3[];
  124331. updatable?: boolean;
  124332. instance?: Nullable<LinesMesh>;
  124333. colors?: Color4[];
  124334. useVertexAlpha?: boolean;
  124335. }, scene?: Nullable<Scene>): LinesMesh;
  124336. /**
  124337. * Creates a dashed line mesh
  124338. * * 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
  124339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124340. * * The parameter `points` is an array successive Vector3
  124341. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124342. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124343. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124344. * * 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
  124345. * * When updating an instance, remember that only point positions can change, not the number of points
  124346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124347. * @param name defines the name of the mesh
  124348. * @param options defines the options used to create the mesh
  124349. * @param scene defines the hosting scene
  124350. * @returns the dashed line mesh
  124351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124352. */
  124353. static CreateDashedLines(name: string, options: {
  124354. points: Vector3[];
  124355. dashSize?: number;
  124356. gapSize?: number;
  124357. dashNb?: number;
  124358. updatable?: boolean;
  124359. instance?: LinesMesh;
  124360. }, scene?: Nullable<Scene>): LinesMesh;
  124361. /**
  124362. * 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.
  124363. * * 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.
  124364. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124365. * * 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.
  124366. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124367. * * 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
  124368. * * 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
  124369. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124374. * @param name defines the name of the mesh
  124375. * @param options defines the options used to create the mesh
  124376. * @param scene defines the hosting scene
  124377. * @returns the extruded shape mesh
  124378. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124380. */
  124381. static ExtrudeShape(name: string, options: {
  124382. shape: Vector3[];
  124383. path: Vector3[];
  124384. scale?: number;
  124385. rotation?: number;
  124386. cap?: number;
  124387. updatable?: boolean;
  124388. sideOrientation?: number;
  124389. frontUVs?: Vector4;
  124390. backUVs?: Vector4;
  124391. instance?: Mesh;
  124392. invertUV?: boolean;
  124393. }, scene?: Nullable<Scene>): Mesh;
  124394. /**
  124395. * Creates an custom extruded shape mesh.
  124396. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124397. * * 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.
  124398. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124399. * * 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
  124400. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124401. * * 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
  124402. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124403. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124404. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124405. * * 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
  124406. * * 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
  124407. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124412. * @param name defines the name of the mesh
  124413. * @param options defines the options used to create the mesh
  124414. * @param scene defines the hosting scene
  124415. * @returns the custom extruded shape mesh
  124416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124419. */
  124420. static ExtrudeShapeCustom(name: string, options: {
  124421. shape: Vector3[];
  124422. path: Vector3[];
  124423. scaleFunction?: any;
  124424. rotationFunction?: any;
  124425. ribbonCloseArray?: boolean;
  124426. ribbonClosePath?: boolean;
  124427. cap?: number;
  124428. updatable?: boolean;
  124429. sideOrientation?: number;
  124430. frontUVs?: Vector4;
  124431. backUVs?: Vector4;
  124432. instance?: Mesh;
  124433. invertUV?: boolean;
  124434. }, scene?: Nullable<Scene>): Mesh;
  124435. /**
  124436. * Creates lathe mesh.
  124437. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124438. * * 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
  124439. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124440. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124441. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124442. * * 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
  124443. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124444. * * 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
  124445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124449. * @param name defines the name of the mesh
  124450. * @param options defines the options used to create the mesh
  124451. * @param scene defines the hosting scene
  124452. * @returns the lathe mesh
  124453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124454. */
  124455. static CreateLathe(name: string, options: {
  124456. shape: Vector3[];
  124457. radius?: number;
  124458. tessellation?: number;
  124459. clip?: number;
  124460. arc?: number;
  124461. closed?: boolean;
  124462. updatable?: boolean;
  124463. sideOrientation?: number;
  124464. frontUVs?: Vector4;
  124465. backUVs?: Vector4;
  124466. cap?: number;
  124467. invertUV?: boolean;
  124468. }, scene?: Nullable<Scene>): Mesh;
  124469. /**
  124470. * Creates a tiled plane mesh
  124471. * * You can set a limited pattern arrangement with the tiles
  124472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124475. * @param name defines the name of the mesh
  124476. * @param options defines the options used to create the mesh
  124477. * @param scene defines the hosting scene
  124478. * @returns the plane mesh
  124479. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124480. */
  124481. static CreateTiledPlane(name: string, options: {
  124482. pattern?: number;
  124483. tileSize?: number;
  124484. tileWidth?: number;
  124485. tileHeight?: number;
  124486. size?: number;
  124487. width?: number;
  124488. height?: number;
  124489. alignHorizontal?: number;
  124490. alignVertical?: number;
  124491. sideOrientation?: number;
  124492. frontUVs?: Vector4;
  124493. backUVs?: Vector4;
  124494. updatable?: boolean;
  124495. }, scene?: Nullable<Scene>): Mesh;
  124496. /**
  124497. * Creates a plane mesh
  124498. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124499. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124500. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124504. * @param name defines the name of the mesh
  124505. * @param options defines the options used to create the mesh
  124506. * @param scene defines the hosting scene
  124507. * @returns the plane mesh
  124508. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124509. */
  124510. static CreatePlane(name: string, options: {
  124511. size?: number;
  124512. width?: number;
  124513. height?: number;
  124514. sideOrientation?: number;
  124515. frontUVs?: Vector4;
  124516. backUVs?: Vector4;
  124517. updatable?: boolean;
  124518. sourcePlane?: Plane;
  124519. }, scene?: Nullable<Scene>): Mesh;
  124520. /**
  124521. * Creates a ground mesh
  124522. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124523. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124525. * @param name defines the name of the mesh
  124526. * @param options defines the options used to create the mesh
  124527. * @param scene defines the hosting scene
  124528. * @returns the ground mesh
  124529. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124530. */
  124531. static CreateGround(name: string, options: {
  124532. width?: number;
  124533. height?: number;
  124534. subdivisions?: number;
  124535. subdivisionsX?: number;
  124536. subdivisionsY?: number;
  124537. updatable?: boolean;
  124538. }, scene?: Nullable<Scene>): Mesh;
  124539. /**
  124540. * Creates a tiled ground mesh
  124541. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124542. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124543. * * 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
  124544. * * 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
  124545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124546. * @param name defines the name of the mesh
  124547. * @param options defines the options used to create the mesh
  124548. * @param scene defines the hosting scene
  124549. * @returns the tiled ground mesh
  124550. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124551. */
  124552. static CreateTiledGround(name: string, options: {
  124553. xmin: number;
  124554. zmin: number;
  124555. xmax: number;
  124556. zmax: number;
  124557. subdivisions?: {
  124558. w: number;
  124559. h: number;
  124560. };
  124561. precision?: {
  124562. w: number;
  124563. h: number;
  124564. };
  124565. updatable?: boolean;
  124566. }, scene?: Nullable<Scene>): Mesh;
  124567. /**
  124568. * Creates a ground mesh from a height map
  124569. * * The parameter `url` sets the URL of the height map image resource.
  124570. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124571. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124572. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124573. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124574. * * 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.
  124575. * * 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).
  124576. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124578. * @param name defines the name of the mesh
  124579. * @param url defines the url to the height map
  124580. * @param options defines the options used to create the mesh
  124581. * @param scene defines the hosting scene
  124582. * @returns the ground mesh
  124583. * @see https://doc.babylonjs.com/babylon101/height_map
  124584. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124585. */
  124586. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124587. width?: number;
  124588. height?: number;
  124589. subdivisions?: number;
  124590. minHeight?: number;
  124591. maxHeight?: number;
  124592. colorFilter?: Color3;
  124593. alphaFilter?: number;
  124594. updatable?: boolean;
  124595. onReady?: (mesh: GroundMesh) => void;
  124596. }, scene?: Nullable<Scene>): GroundMesh;
  124597. /**
  124598. * Creates a polygon mesh
  124599. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124600. * * 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
  124601. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124604. * * Remember you can only change the shape positions, not their number when updating a polygon
  124605. * @param name defines the name of the mesh
  124606. * @param options defines the options used to create the mesh
  124607. * @param scene defines the hosting scene
  124608. * @param earcutInjection can be used to inject your own earcut reference
  124609. * @returns the polygon mesh
  124610. */
  124611. static CreatePolygon(name: string, options: {
  124612. shape: Vector3[];
  124613. holes?: Vector3[][];
  124614. depth?: number;
  124615. faceUV?: Vector4[];
  124616. faceColors?: Color4[];
  124617. updatable?: boolean;
  124618. sideOrientation?: number;
  124619. frontUVs?: Vector4;
  124620. backUVs?: Vector4;
  124621. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124622. /**
  124623. * Creates an extruded polygon mesh, with depth in the Y direction.
  124624. * * 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)
  124625. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124626. * @param name defines the name of the mesh
  124627. * @param options defines the options used to create the mesh
  124628. * @param scene defines the hosting scene
  124629. * @param earcutInjection can be used to inject your own earcut reference
  124630. * @returns the polygon mesh
  124631. */
  124632. static ExtrudePolygon(name: string, options: {
  124633. shape: Vector3[];
  124634. holes?: Vector3[][];
  124635. depth?: number;
  124636. faceUV?: Vector4[];
  124637. faceColors?: Color4[];
  124638. updatable?: boolean;
  124639. sideOrientation?: number;
  124640. frontUVs?: Vector4;
  124641. backUVs?: Vector4;
  124642. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124643. /**
  124644. * Creates a tube mesh.
  124645. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124646. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124647. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124648. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124649. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124650. * * 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)
  124651. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124652. * * 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
  124653. * * 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
  124654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124656. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124658. * @param name defines the name of the mesh
  124659. * @param options defines the options used to create the mesh
  124660. * @param scene defines the hosting scene
  124661. * @returns the tube mesh
  124662. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124663. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124664. */
  124665. static CreateTube(name: string, options: {
  124666. path: Vector3[];
  124667. radius?: number;
  124668. tessellation?: number;
  124669. radiusFunction?: {
  124670. (i: number, distance: number): number;
  124671. };
  124672. cap?: number;
  124673. arc?: number;
  124674. updatable?: boolean;
  124675. sideOrientation?: number;
  124676. frontUVs?: Vector4;
  124677. backUVs?: Vector4;
  124678. instance?: Mesh;
  124679. invertUV?: boolean;
  124680. }, scene?: Nullable<Scene>): Mesh;
  124681. /**
  124682. * Creates a polyhedron mesh
  124683. * * 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
  124684. * * The parameter `size` (positive float, default 1) sets the polygon size
  124685. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124686. * * 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`
  124687. * * 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
  124688. * * 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)`)
  124689. * * 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
  124690. * * 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
  124691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124694. * @param name defines the name of the mesh
  124695. * @param options defines the options used to create the mesh
  124696. * @param scene defines the hosting scene
  124697. * @returns the polyhedron mesh
  124698. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124699. */
  124700. static CreatePolyhedron(name: string, options: {
  124701. type?: number;
  124702. size?: number;
  124703. sizeX?: number;
  124704. sizeY?: number;
  124705. sizeZ?: number;
  124706. custom?: any;
  124707. faceUV?: Vector4[];
  124708. faceColors?: Color4[];
  124709. flat?: boolean;
  124710. updatable?: boolean;
  124711. sideOrientation?: number;
  124712. frontUVs?: Vector4;
  124713. backUVs?: Vector4;
  124714. }, scene?: Nullable<Scene>): Mesh;
  124715. /**
  124716. * Creates a decal mesh.
  124717. * 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
  124718. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124719. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124720. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124721. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124722. * @param name defines the name of the mesh
  124723. * @param sourceMesh defines the mesh where the decal must be applied
  124724. * @param options defines the options used to create the mesh
  124725. * @param scene defines the hosting scene
  124726. * @returns the decal mesh
  124727. * @see https://doc.babylonjs.com/how_to/decals
  124728. */
  124729. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124730. position?: Vector3;
  124731. normal?: Vector3;
  124732. size?: Vector3;
  124733. angle?: number;
  124734. }): Mesh;
  124735. }
  124736. }
  124737. declare module BABYLON {
  124738. /**
  124739. * A simplifier interface for future simplification implementations
  124740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124741. */
  124742. export interface ISimplifier {
  124743. /**
  124744. * Simplification of a given mesh according to the given settings.
  124745. * Since this requires computation, it is assumed that the function runs async.
  124746. * @param settings The settings of the simplification, including quality and distance
  124747. * @param successCallback A callback that will be called after the mesh was simplified.
  124748. * @param errorCallback in case of an error, this callback will be called. optional.
  124749. */
  124750. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  124751. }
  124752. /**
  124753. * Expected simplification settings.
  124754. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  124755. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124756. */
  124757. export interface ISimplificationSettings {
  124758. /**
  124759. * Gets or sets the expected quality
  124760. */
  124761. quality: number;
  124762. /**
  124763. * Gets or sets the distance when this optimized version should be used
  124764. */
  124765. distance: number;
  124766. /**
  124767. * Gets an already optimized mesh
  124768. */
  124769. optimizeMesh?: boolean;
  124770. }
  124771. /**
  124772. * Class used to specify simplification options
  124773. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124774. */
  124775. export class SimplificationSettings implements ISimplificationSettings {
  124776. /** expected quality */
  124777. quality: number;
  124778. /** distance when this optimized version should be used */
  124779. distance: number;
  124780. /** already optimized mesh */
  124781. optimizeMesh?: boolean | undefined;
  124782. /**
  124783. * Creates a SimplificationSettings
  124784. * @param quality expected quality
  124785. * @param distance distance when this optimized version should be used
  124786. * @param optimizeMesh already optimized mesh
  124787. */
  124788. constructor(
  124789. /** expected quality */
  124790. quality: number,
  124791. /** distance when this optimized version should be used */
  124792. distance: number,
  124793. /** already optimized mesh */
  124794. optimizeMesh?: boolean | undefined);
  124795. }
  124796. /**
  124797. * Interface used to define a simplification task
  124798. */
  124799. export interface ISimplificationTask {
  124800. /**
  124801. * Array of settings
  124802. */
  124803. settings: Array<ISimplificationSettings>;
  124804. /**
  124805. * Simplification type
  124806. */
  124807. simplificationType: SimplificationType;
  124808. /**
  124809. * Mesh to simplify
  124810. */
  124811. mesh: Mesh;
  124812. /**
  124813. * Callback called on success
  124814. */
  124815. successCallback?: () => void;
  124816. /**
  124817. * Defines if parallel processing can be used
  124818. */
  124819. parallelProcessing: boolean;
  124820. }
  124821. /**
  124822. * Queue used to order the simplification tasks
  124823. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124824. */
  124825. export class SimplificationQueue {
  124826. private _simplificationArray;
  124827. /**
  124828. * Gets a boolean indicating that the process is still running
  124829. */
  124830. running: boolean;
  124831. /**
  124832. * Creates a new queue
  124833. */
  124834. constructor();
  124835. /**
  124836. * Adds a new simplification task
  124837. * @param task defines a task to add
  124838. */
  124839. addTask(task: ISimplificationTask): void;
  124840. /**
  124841. * Execute next task
  124842. */
  124843. executeNext(): void;
  124844. /**
  124845. * Execute a simplification task
  124846. * @param task defines the task to run
  124847. */
  124848. runSimplification(task: ISimplificationTask): void;
  124849. private getSimplifier;
  124850. }
  124851. /**
  124852. * The implemented types of simplification
  124853. * At the moment only Quadratic Error Decimation is implemented
  124854. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124855. */
  124856. export enum SimplificationType {
  124857. /** Quadratic error decimation */
  124858. QUADRATIC = 0
  124859. }
  124860. }
  124861. declare module BABYLON {
  124862. interface Scene {
  124863. /** @hidden (Backing field) */
  124864. _simplificationQueue: SimplificationQueue;
  124865. /**
  124866. * Gets or sets the simplification queue attached to the scene
  124867. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124868. */
  124869. simplificationQueue: SimplificationQueue;
  124870. }
  124871. interface Mesh {
  124872. /**
  124873. * Simplify the mesh according to the given array of settings.
  124874. * Function will return immediately and will simplify async
  124875. * @param settings a collection of simplification settings
  124876. * @param parallelProcessing should all levels calculate parallel or one after the other
  124877. * @param simplificationType the type of simplification to run
  124878. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124879. * @returns the current mesh
  124880. */
  124881. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124882. }
  124883. /**
  124884. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124885. * created in a scene
  124886. */
  124887. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124888. /**
  124889. * The component name helpfull to identify the component in the list of scene components.
  124890. */
  124891. readonly name: string;
  124892. /**
  124893. * The scene the component belongs to.
  124894. */
  124895. scene: Scene;
  124896. /**
  124897. * Creates a new instance of the component for the given scene
  124898. * @param scene Defines the scene to register the component in
  124899. */
  124900. constructor(scene: Scene);
  124901. /**
  124902. * Registers the component in a given scene
  124903. */
  124904. register(): void;
  124905. /**
  124906. * Rebuilds the elements related to this component in case of
  124907. * context lost for instance.
  124908. */
  124909. rebuild(): void;
  124910. /**
  124911. * Disposes the component and the associated ressources
  124912. */
  124913. dispose(): void;
  124914. private _beforeCameraUpdate;
  124915. }
  124916. }
  124917. declare module BABYLON {
  124918. /**
  124919. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124920. */
  124921. export interface INavigationEnginePlugin {
  124922. /**
  124923. * plugin name
  124924. */
  124925. name: string;
  124926. /**
  124927. * Creates a navigation mesh
  124928. * @param meshes array of all the geometry used to compute the navigatio mesh
  124929. * @param parameters bunch of parameters used to filter geometry
  124930. */
  124931. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124932. /**
  124933. * Create a navigation mesh debug mesh
  124934. * @param scene is where the mesh will be added
  124935. * @returns debug display mesh
  124936. */
  124937. createDebugNavMesh(scene: Scene): Mesh;
  124938. /**
  124939. * Get a navigation mesh constrained position, closest to the parameter position
  124940. * @param position world position
  124941. * @returns the closest point to position constrained by the navigation mesh
  124942. */
  124943. getClosestPoint(position: Vector3): Vector3;
  124944. /**
  124945. * Get a navigation mesh constrained position, within a particular radius
  124946. * @param position world position
  124947. * @param maxRadius the maximum distance to the constrained world position
  124948. * @returns the closest point to position constrained by the navigation mesh
  124949. */
  124950. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124951. /**
  124952. * Compute the final position from a segment made of destination-position
  124953. * @param position world position
  124954. * @param destination world position
  124955. * @returns the resulting point along the navmesh
  124956. */
  124957. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124958. /**
  124959. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124960. * @param start world position
  124961. * @param end world position
  124962. * @returns array containing world position composing the path
  124963. */
  124964. computePath(start: Vector3, end: Vector3): Vector3[];
  124965. /**
  124966. * If this plugin is supported
  124967. * @returns true if plugin is supported
  124968. */
  124969. isSupported(): boolean;
  124970. /**
  124971. * Create a new Crowd so you can add agents
  124972. * @param maxAgents the maximum agent count in the crowd
  124973. * @param maxAgentRadius the maximum radius an agent can have
  124974. * @param scene to attach the crowd to
  124975. * @returns the crowd you can add agents to
  124976. */
  124977. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124978. /**
  124979. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124980. * The queries will try to find a solution within those bounds
  124981. * default is (1,1,1)
  124982. * @param extent x,y,z value that define the extent around the queries point of reference
  124983. */
  124984. setDefaultQueryExtent(extent: Vector3): void;
  124985. /**
  124986. * Get the Bounding box extent specified by setDefaultQueryExtent
  124987. * @returns the box extent values
  124988. */
  124989. getDefaultQueryExtent(): Vector3;
  124990. /**
  124991. * Release all resources
  124992. */
  124993. dispose(): void;
  124994. }
  124995. /**
  124996. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124997. */
  124998. export interface ICrowd {
  124999. /**
  125000. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125001. * You can attach anything to that node. The node position is updated in the scene update tick.
  125002. * @param pos world position that will be constrained by the navigation mesh
  125003. * @param parameters agent parameters
  125004. * @param transform hooked to the agent that will be update by the scene
  125005. * @returns agent index
  125006. */
  125007. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125008. /**
  125009. * Returns the agent position in world space
  125010. * @param index agent index returned by addAgent
  125011. * @returns world space position
  125012. */
  125013. getAgentPosition(index: number): Vector3;
  125014. /**
  125015. * Gets the agent velocity in world space
  125016. * @param index agent index returned by addAgent
  125017. * @returns world space velocity
  125018. */
  125019. getAgentVelocity(index: number): Vector3;
  125020. /**
  125021. * remove a particular agent previously created
  125022. * @param index agent index returned by addAgent
  125023. */
  125024. removeAgent(index: number): void;
  125025. /**
  125026. * get the list of all agents attached to this crowd
  125027. * @returns list of agent indices
  125028. */
  125029. getAgents(): number[];
  125030. /**
  125031. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125032. * @param deltaTime in seconds
  125033. */
  125034. update(deltaTime: number): void;
  125035. /**
  125036. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125037. * @param index agent index returned by addAgent
  125038. * @param destination targeted world position
  125039. */
  125040. agentGoto(index: number, destination: Vector3): void;
  125041. /**
  125042. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125043. * The queries will try to find a solution within those bounds
  125044. * default is (1,1,1)
  125045. * @param extent x,y,z value that define the extent around the queries point of reference
  125046. */
  125047. setDefaultQueryExtent(extent: Vector3): void;
  125048. /**
  125049. * Get the Bounding box extent specified by setDefaultQueryExtent
  125050. * @returns the box extent values
  125051. */
  125052. getDefaultQueryExtent(): Vector3;
  125053. /**
  125054. * Release all resources
  125055. */
  125056. dispose(): void;
  125057. }
  125058. /**
  125059. * Configures an agent
  125060. */
  125061. export interface IAgentParameters {
  125062. /**
  125063. * Agent radius. [Limit: >= 0]
  125064. */
  125065. radius: number;
  125066. /**
  125067. * Agent height. [Limit: > 0]
  125068. */
  125069. height: number;
  125070. /**
  125071. * Maximum allowed acceleration. [Limit: >= 0]
  125072. */
  125073. maxAcceleration: number;
  125074. /**
  125075. * Maximum allowed speed. [Limit: >= 0]
  125076. */
  125077. maxSpeed: number;
  125078. /**
  125079. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  125080. */
  125081. collisionQueryRange: number;
  125082. /**
  125083. * The path visibility optimization range. [Limit: > 0]
  125084. */
  125085. pathOptimizationRange: number;
  125086. /**
  125087. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  125088. */
  125089. separationWeight: number;
  125090. }
  125091. /**
  125092. * Configures the navigation mesh creation
  125093. */
  125094. export interface INavMeshParameters {
  125095. /**
  125096. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  125097. */
  125098. cs: number;
  125099. /**
  125100. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  125101. */
  125102. ch: number;
  125103. /**
  125104. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  125105. */
  125106. walkableSlopeAngle: number;
  125107. /**
  125108. * Minimum floor to 'ceiling' height that will still allow the floor area to
  125109. * be considered walkable. [Limit: >= 3] [Units: vx]
  125110. */
  125111. walkableHeight: number;
  125112. /**
  125113. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  125114. */
  125115. walkableClimb: number;
  125116. /**
  125117. * The distance to erode/shrink the walkable area of the heightfield away from
  125118. * obstructions. [Limit: >=0] [Units: vx]
  125119. */
  125120. walkableRadius: number;
  125121. /**
  125122. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  125123. */
  125124. maxEdgeLen: number;
  125125. /**
  125126. * The maximum distance a simplfied contour's border edges should deviate
  125127. * the original raw contour. [Limit: >=0] [Units: vx]
  125128. */
  125129. maxSimplificationError: number;
  125130. /**
  125131. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  125132. */
  125133. minRegionArea: number;
  125134. /**
  125135. * Any regions with a span count smaller than this value will, if possible,
  125136. * be merged with larger regions. [Limit: >=0] [Units: vx]
  125137. */
  125138. mergeRegionArea: number;
  125139. /**
  125140. * The maximum number of vertices allowed for polygons generated during the
  125141. * contour to polygon conversion process. [Limit: >= 3]
  125142. */
  125143. maxVertsPerPoly: number;
  125144. /**
  125145. * Sets the sampling distance to use when generating the detail mesh.
  125146. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  125147. */
  125148. detailSampleDist: number;
  125149. /**
  125150. * The maximum distance the detail mesh surface should deviate from heightfield
  125151. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  125152. */
  125153. detailSampleMaxError: number;
  125154. }
  125155. }
  125156. declare module BABYLON {
  125157. /**
  125158. * RecastJS navigation plugin
  125159. */
  125160. export class RecastJSPlugin implements INavigationEnginePlugin {
  125161. /**
  125162. * Reference to the Recast library
  125163. */
  125164. bjsRECAST: any;
  125165. /**
  125166. * plugin name
  125167. */
  125168. name: string;
  125169. /**
  125170. * the first navmesh created. We might extend this to support multiple navmeshes
  125171. */
  125172. navMesh: any;
  125173. /**
  125174. * Initializes the recastJS plugin
  125175. * @param recastInjection can be used to inject your own recast reference
  125176. */
  125177. constructor(recastInjection?: any);
  125178. /**
  125179. * Creates a navigation mesh
  125180. * @param meshes array of all the geometry used to compute the navigatio mesh
  125181. * @param parameters bunch of parameters used to filter geometry
  125182. */
  125183. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125184. /**
  125185. * Create a navigation mesh debug mesh
  125186. * @param scene is where the mesh will be added
  125187. * @returns debug display mesh
  125188. */
  125189. createDebugNavMesh(scene: Scene): Mesh;
  125190. /**
  125191. * Get a navigation mesh constrained position, closest to the parameter position
  125192. * @param position world position
  125193. * @returns the closest point to position constrained by the navigation mesh
  125194. */
  125195. getClosestPoint(position: Vector3): Vector3;
  125196. /**
  125197. * Get a navigation mesh constrained position, within a particular radius
  125198. * @param position world position
  125199. * @param maxRadius the maximum distance to the constrained world position
  125200. * @returns the closest point to position constrained by the navigation mesh
  125201. */
  125202. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125203. /**
  125204. * Compute the final position from a segment made of destination-position
  125205. * @param position world position
  125206. * @param destination world position
  125207. * @returns the resulting point along the navmesh
  125208. */
  125209. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125210. /**
  125211. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125212. * @param start world position
  125213. * @param end world position
  125214. * @returns array containing world position composing the path
  125215. */
  125216. computePath(start: Vector3, end: Vector3): Vector3[];
  125217. /**
  125218. * Create a new Crowd so you can add agents
  125219. * @param maxAgents the maximum agent count in the crowd
  125220. * @param maxAgentRadius the maximum radius an agent can have
  125221. * @param scene to attach the crowd to
  125222. * @returns the crowd you can add agents to
  125223. */
  125224. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125225. /**
  125226. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125227. * The queries will try to find a solution within those bounds
  125228. * default is (1,1,1)
  125229. * @param extent x,y,z value that define the extent around the queries point of reference
  125230. */
  125231. setDefaultQueryExtent(extent: Vector3): void;
  125232. /**
  125233. * Get the Bounding box extent specified by setDefaultQueryExtent
  125234. * @returns the box extent values
  125235. */
  125236. getDefaultQueryExtent(): Vector3;
  125237. /**
  125238. * Disposes
  125239. */
  125240. dispose(): void;
  125241. /**
  125242. * If this plugin is supported
  125243. * @returns true if plugin is supported
  125244. */
  125245. isSupported(): boolean;
  125246. }
  125247. /**
  125248. * Recast detour crowd implementation
  125249. */
  125250. export class RecastJSCrowd implements ICrowd {
  125251. /**
  125252. * Recast/detour plugin
  125253. */
  125254. bjsRECASTPlugin: RecastJSPlugin;
  125255. /**
  125256. * Link to the detour crowd
  125257. */
  125258. recastCrowd: any;
  125259. /**
  125260. * One transform per agent
  125261. */
  125262. transforms: TransformNode[];
  125263. /**
  125264. * All agents created
  125265. */
  125266. agents: number[];
  125267. /**
  125268. * Link to the scene is kept to unregister the crowd from the scene
  125269. */
  125270. private _scene;
  125271. /**
  125272. * Observer for crowd updates
  125273. */
  125274. private _onBeforeAnimationsObserver;
  125275. /**
  125276. * Constructor
  125277. * @param plugin recastJS plugin
  125278. * @param maxAgents the maximum agent count in the crowd
  125279. * @param maxAgentRadius the maximum radius an agent can have
  125280. * @param scene to attach the crowd to
  125281. * @returns the crowd you can add agents to
  125282. */
  125283. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  125284. /**
  125285. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125286. * You can attach anything to that node. The node position is updated in the scene update tick.
  125287. * @param pos world position that will be constrained by the navigation mesh
  125288. * @param parameters agent parameters
  125289. * @param transform hooked to the agent that will be update by the scene
  125290. * @returns agent index
  125291. */
  125292. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125293. /**
  125294. * Returns the agent position in world space
  125295. * @param index agent index returned by addAgent
  125296. * @returns world space position
  125297. */
  125298. getAgentPosition(index: number): Vector3;
  125299. /**
  125300. * Returns the agent velocity in world space
  125301. * @param index agent index returned by addAgent
  125302. * @returns world space velocity
  125303. */
  125304. getAgentVelocity(index: number): Vector3;
  125305. /**
  125306. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125307. * @param index agent index returned by addAgent
  125308. * @param destination targeted world position
  125309. */
  125310. agentGoto(index: number, destination: Vector3): void;
  125311. /**
  125312. * remove a particular agent previously created
  125313. * @param index agent index returned by addAgent
  125314. */
  125315. removeAgent(index: number): void;
  125316. /**
  125317. * get the list of all agents attached to this crowd
  125318. * @returns list of agent indices
  125319. */
  125320. getAgents(): number[];
  125321. /**
  125322. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125323. * @param deltaTime in seconds
  125324. */
  125325. update(deltaTime: number): void;
  125326. /**
  125327. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125328. * The queries will try to find a solution within those bounds
  125329. * default is (1,1,1)
  125330. * @param extent x,y,z value that define the extent around the queries point of reference
  125331. */
  125332. setDefaultQueryExtent(extent: Vector3): void;
  125333. /**
  125334. * Get the Bounding box extent specified by setDefaultQueryExtent
  125335. * @returns the box extent values
  125336. */
  125337. getDefaultQueryExtent(): Vector3;
  125338. /**
  125339. * Release all resources
  125340. */
  125341. dispose(): void;
  125342. }
  125343. }
  125344. declare module BABYLON {
  125345. /**
  125346. * Class used to enable access to IndexedDB
  125347. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125348. */
  125349. export class Database implements IOfflineProvider {
  125350. private _callbackManifestChecked;
  125351. private _currentSceneUrl;
  125352. private _db;
  125353. private _enableSceneOffline;
  125354. private _enableTexturesOffline;
  125355. private _manifestVersionFound;
  125356. private _mustUpdateRessources;
  125357. private _hasReachedQuota;
  125358. private _isSupported;
  125359. private _idbFactory;
  125360. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125361. private static IsUASupportingBlobStorage;
  125362. /**
  125363. * Gets a boolean indicating if Database storate is enabled (off by default)
  125364. */
  125365. static IDBStorageEnabled: boolean;
  125366. /**
  125367. * Gets a boolean indicating if scene must be saved in the database
  125368. */
  125369. readonly enableSceneOffline: boolean;
  125370. /**
  125371. * Gets a boolean indicating if textures must be saved in the database
  125372. */
  125373. readonly enableTexturesOffline: boolean;
  125374. /**
  125375. * Creates a new Database
  125376. * @param urlToScene defines the url to load the scene
  125377. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125378. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125379. */
  125380. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125381. private static _ParseURL;
  125382. private static _ReturnFullUrlLocation;
  125383. private _checkManifestFile;
  125384. /**
  125385. * Open the database and make it available
  125386. * @param successCallback defines the callback to call on success
  125387. * @param errorCallback defines the callback to call on error
  125388. */
  125389. open(successCallback: () => void, errorCallback: () => void): void;
  125390. /**
  125391. * Loads an image from the database
  125392. * @param url defines the url to load from
  125393. * @param image defines the target DOM image
  125394. */
  125395. loadImage(url: string, image: HTMLImageElement): void;
  125396. private _loadImageFromDBAsync;
  125397. private _saveImageIntoDBAsync;
  125398. private _checkVersionFromDB;
  125399. private _loadVersionFromDBAsync;
  125400. private _saveVersionIntoDBAsync;
  125401. /**
  125402. * Loads a file from database
  125403. * @param url defines the URL to load from
  125404. * @param sceneLoaded defines a callback to call on success
  125405. * @param progressCallBack defines a callback to call when progress changed
  125406. * @param errorCallback defines a callback to call on error
  125407. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125408. */
  125409. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125410. private _loadFileAsync;
  125411. private _saveFileAsync;
  125412. /**
  125413. * Validates if xhr data is correct
  125414. * @param xhr defines the request to validate
  125415. * @param dataType defines the expected data type
  125416. * @returns true if data is correct
  125417. */
  125418. private static _ValidateXHRData;
  125419. }
  125420. }
  125421. declare module BABYLON {
  125422. /** @hidden */
  125423. export var gpuUpdateParticlesPixelShader: {
  125424. name: string;
  125425. shader: string;
  125426. };
  125427. }
  125428. declare module BABYLON {
  125429. /** @hidden */
  125430. export var gpuUpdateParticlesVertexShader: {
  125431. name: string;
  125432. shader: string;
  125433. };
  125434. }
  125435. declare module BABYLON {
  125436. /** @hidden */
  125437. export var clipPlaneFragmentDeclaration2: {
  125438. name: string;
  125439. shader: string;
  125440. };
  125441. }
  125442. declare module BABYLON {
  125443. /** @hidden */
  125444. export var gpuRenderParticlesPixelShader: {
  125445. name: string;
  125446. shader: string;
  125447. };
  125448. }
  125449. declare module BABYLON {
  125450. /** @hidden */
  125451. export var clipPlaneVertexDeclaration2: {
  125452. name: string;
  125453. shader: string;
  125454. };
  125455. }
  125456. declare module BABYLON {
  125457. /** @hidden */
  125458. export var gpuRenderParticlesVertexShader: {
  125459. name: string;
  125460. shader: string;
  125461. };
  125462. }
  125463. declare module BABYLON {
  125464. /**
  125465. * This represents a GPU particle system in Babylon
  125466. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125467. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125468. */
  125469. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125470. /**
  125471. * The layer mask we are rendering the particles through.
  125472. */
  125473. layerMask: number;
  125474. private _capacity;
  125475. private _activeCount;
  125476. private _currentActiveCount;
  125477. private _accumulatedCount;
  125478. private _renderEffect;
  125479. private _updateEffect;
  125480. private _buffer0;
  125481. private _buffer1;
  125482. private _spriteBuffer;
  125483. private _updateVAO;
  125484. private _renderVAO;
  125485. private _targetIndex;
  125486. private _sourceBuffer;
  125487. private _targetBuffer;
  125488. private _engine;
  125489. private _currentRenderId;
  125490. private _started;
  125491. private _stopped;
  125492. private _timeDelta;
  125493. private _randomTexture;
  125494. private _randomTexture2;
  125495. private _attributesStrideSize;
  125496. private _updateEffectOptions;
  125497. private _randomTextureSize;
  125498. private _actualFrame;
  125499. private readonly _rawTextureWidth;
  125500. /**
  125501. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125502. */
  125503. static readonly IsSupported: boolean;
  125504. /**
  125505. * An event triggered when the system is disposed.
  125506. */
  125507. onDisposeObservable: Observable<GPUParticleSystem>;
  125508. /**
  125509. * Gets the maximum number of particles active at the same time.
  125510. * @returns The max number of active particles.
  125511. */
  125512. getCapacity(): number;
  125513. /**
  125514. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125515. * to override the particles.
  125516. */
  125517. forceDepthWrite: boolean;
  125518. /**
  125519. * Gets or set the number of active particles
  125520. */
  125521. activeParticleCount: number;
  125522. private _preWarmDone;
  125523. /**
  125524. * Is this system ready to be used/rendered
  125525. * @return true if the system is ready
  125526. */
  125527. isReady(): boolean;
  125528. /**
  125529. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125530. * @returns True if it has been started, otherwise false.
  125531. */
  125532. isStarted(): boolean;
  125533. /**
  125534. * Starts the particle system and begins to emit
  125535. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125536. */
  125537. start(delay?: number): void;
  125538. /**
  125539. * Stops the particle system.
  125540. */
  125541. stop(): void;
  125542. /**
  125543. * Remove all active particles
  125544. */
  125545. reset(): void;
  125546. /**
  125547. * Returns the string "GPUParticleSystem"
  125548. * @returns a string containing the class name
  125549. */
  125550. getClassName(): string;
  125551. private _colorGradientsTexture;
  125552. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125553. /**
  125554. * Adds a new color gradient
  125555. * @param gradient defines the gradient to use (between 0 and 1)
  125556. * @param color1 defines the color to affect to the specified gradient
  125557. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125558. * @returns the current particle system
  125559. */
  125560. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125561. /**
  125562. * Remove a specific color gradient
  125563. * @param gradient defines the gradient to remove
  125564. * @returns the current particle system
  125565. */
  125566. removeColorGradient(gradient: number): GPUParticleSystem;
  125567. private _angularSpeedGradientsTexture;
  125568. private _sizeGradientsTexture;
  125569. private _velocityGradientsTexture;
  125570. private _limitVelocityGradientsTexture;
  125571. private _dragGradientsTexture;
  125572. private _addFactorGradient;
  125573. /**
  125574. * Adds a new size gradient
  125575. * @param gradient defines the gradient to use (between 0 and 1)
  125576. * @param factor defines the size factor to affect to the specified gradient
  125577. * @returns the current particle system
  125578. */
  125579. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125580. /**
  125581. * Remove a specific size gradient
  125582. * @param gradient defines the gradient to remove
  125583. * @returns the current particle system
  125584. */
  125585. removeSizeGradient(gradient: number): GPUParticleSystem;
  125586. /**
  125587. * Adds a new angular speed gradient
  125588. * @param gradient defines the gradient to use (between 0 and 1)
  125589. * @param factor defines the angular speed to affect to the specified gradient
  125590. * @returns the current particle system
  125591. */
  125592. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125593. /**
  125594. * Remove a specific angular speed gradient
  125595. * @param gradient defines the gradient to remove
  125596. * @returns the current particle system
  125597. */
  125598. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125599. /**
  125600. * Adds a new velocity gradient
  125601. * @param gradient defines the gradient to use (between 0 and 1)
  125602. * @param factor defines the velocity to affect to the specified gradient
  125603. * @returns the current particle system
  125604. */
  125605. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125606. /**
  125607. * Remove a specific velocity gradient
  125608. * @param gradient defines the gradient to remove
  125609. * @returns the current particle system
  125610. */
  125611. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125612. /**
  125613. * Adds a new limit velocity gradient
  125614. * @param gradient defines the gradient to use (between 0 and 1)
  125615. * @param factor defines the limit velocity value to affect to the specified gradient
  125616. * @returns the current particle system
  125617. */
  125618. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125619. /**
  125620. * Remove a specific limit velocity gradient
  125621. * @param gradient defines the gradient to remove
  125622. * @returns the current particle system
  125623. */
  125624. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125625. /**
  125626. * Adds a new drag gradient
  125627. * @param gradient defines the gradient to use (between 0 and 1)
  125628. * @param factor defines the drag value to affect to the specified gradient
  125629. * @returns the current particle system
  125630. */
  125631. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125632. /**
  125633. * Remove a specific drag gradient
  125634. * @param gradient defines the gradient to remove
  125635. * @returns the current particle system
  125636. */
  125637. removeDragGradient(gradient: number): GPUParticleSystem;
  125638. /**
  125639. * Not supported by GPUParticleSystem
  125640. * @param gradient defines the gradient to use (between 0 and 1)
  125641. * @param factor defines the emit rate value to affect to the specified gradient
  125642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125643. * @returns the current particle system
  125644. */
  125645. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125646. /**
  125647. * Not supported by GPUParticleSystem
  125648. * @param gradient defines the gradient to remove
  125649. * @returns the current particle system
  125650. */
  125651. removeEmitRateGradient(gradient: number): IParticleSystem;
  125652. /**
  125653. * Not supported by GPUParticleSystem
  125654. * @param gradient defines the gradient to use (between 0 and 1)
  125655. * @param factor defines the start size value to affect to the specified gradient
  125656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125657. * @returns the current particle system
  125658. */
  125659. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125660. /**
  125661. * Not supported by GPUParticleSystem
  125662. * @param gradient defines the gradient to remove
  125663. * @returns the current particle system
  125664. */
  125665. removeStartSizeGradient(gradient: number): IParticleSystem;
  125666. /**
  125667. * Not supported by GPUParticleSystem
  125668. * @param gradient defines the gradient to use (between 0 and 1)
  125669. * @param min defines the color remap minimal range
  125670. * @param max defines the color remap maximal range
  125671. * @returns the current particle system
  125672. */
  125673. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125674. /**
  125675. * Not supported by GPUParticleSystem
  125676. * @param gradient defines the gradient to remove
  125677. * @returns the current particle system
  125678. */
  125679. removeColorRemapGradient(): IParticleSystem;
  125680. /**
  125681. * Not supported by GPUParticleSystem
  125682. * @param gradient defines the gradient to use (between 0 and 1)
  125683. * @param min defines the alpha remap minimal range
  125684. * @param max defines the alpha remap maximal range
  125685. * @returns the current particle system
  125686. */
  125687. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125688. /**
  125689. * Not supported by GPUParticleSystem
  125690. * @param gradient defines the gradient to remove
  125691. * @returns the current particle system
  125692. */
  125693. removeAlphaRemapGradient(): IParticleSystem;
  125694. /**
  125695. * Not supported by GPUParticleSystem
  125696. * @param gradient defines the gradient to use (between 0 and 1)
  125697. * @param color defines the color to affect to the specified gradient
  125698. * @returns the current particle system
  125699. */
  125700. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  125701. /**
  125702. * Not supported by GPUParticleSystem
  125703. * @param gradient defines the gradient to remove
  125704. * @returns the current particle system
  125705. */
  125706. removeRampGradient(): IParticleSystem;
  125707. /**
  125708. * Not supported by GPUParticleSystem
  125709. * @returns the list of ramp gradients
  125710. */
  125711. getRampGradients(): Nullable<Array<Color3Gradient>>;
  125712. /**
  125713. * Not supported by GPUParticleSystem
  125714. * Gets or sets a boolean indicating that ramp gradients must be used
  125715. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  125716. */
  125717. useRampGradients: boolean;
  125718. /**
  125719. * Not supported by GPUParticleSystem
  125720. * @param gradient defines the gradient to use (between 0 and 1)
  125721. * @param factor defines the life time factor to affect to the specified gradient
  125722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125723. * @returns the current particle system
  125724. */
  125725. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125726. /**
  125727. * Not supported by GPUParticleSystem
  125728. * @param gradient defines the gradient to remove
  125729. * @returns the current particle system
  125730. */
  125731. removeLifeTimeGradient(gradient: number): IParticleSystem;
  125732. /**
  125733. * Instantiates a GPU particle system.
  125734. * 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.
  125735. * @param name The name of the particle system
  125736. * @param options The options used to create the system
  125737. * @param scene The scene the particle system belongs to
  125738. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  125739. */
  125740. constructor(name: string, options: Partial<{
  125741. capacity: number;
  125742. randomTextureSize: number;
  125743. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  125744. protected _reset(): void;
  125745. private _createUpdateVAO;
  125746. private _createRenderVAO;
  125747. private _initialize;
  125748. /** @hidden */
  125749. _recreateUpdateEffect(): void;
  125750. /** @hidden */
  125751. _recreateRenderEffect(): void;
  125752. /**
  125753. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  125754. * @param preWarm defines if we are in the pre-warmimg phase
  125755. */
  125756. animate(preWarm?: boolean): void;
  125757. private _createFactorGradientTexture;
  125758. private _createSizeGradientTexture;
  125759. private _createAngularSpeedGradientTexture;
  125760. private _createVelocityGradientTexture;
  125761. private _createLimitVelocityGradientTexture;
  125762. private _createDragGradientTexture;
  125763. private _createColorGradientTexture;
  125764. /**
  125765. * Renders the particle system in its current state
  125766. * @param preWarm defines if the system should only update the particles but not render them
  125767. * @returns the current number of particles
  125768. */
  125769. render(preWarm?: boolean): number;
  125770. /**
  125771. * Rebuilds the particle system
  125772. */
  125773. rebuild(): void;
  125774. private _releaseBuffers;
  125775. private _releaseVAOs;
  125776. /**
  125777. * Disposes the particle system and free the associated resources
  125778. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  125779. */
  125780. dispose(disposeTexture?: boolean): void;
  125781. /**
  125782. * Clones the particle system.
  125783. * @param name The name of the cloned object
  125784. * @param newEmitter The new emitter to use
  125785. * @returns the cloned particle system
  125786. */
  125787. clone(name: string, newEmitter: any): GPUParticleSystem;
  125788. /**
  125789. * Serializes the particle system to a JSON object.
  125790. * @returns the JSON object
  125791. */
  125792. serialize(): any;
  125793. /**
  125794. * Parses a JSON object to create a GPU particle system.
  125795. * @param parsedParticleSystem The JSON object to parse
  125796. * @param scene The scene to create the particle system in
  125797. * @param rootUrl The root url to use to load external dependencies like texture
  125798. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  125799. * @returns the parsed GPU particle system
  125800. */
  125801. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  125802. }
  125803. }
  125804. declare module BABYLON {
  125805. /**
  125806. * Represents a set of particle systems working together to create a specific effect
  125807. */
  125808. export class ParticleSystemSet implements IDisposable {
  125809. /**
  125810. * Gets or sets base Assets URL
  125811. */
  125812. static BaseAssetsUrl: string;
  125813. private _emitterCreationOptions;
  125814. private _emitterNode;
  125815. /**
  125816. * Gets the particle system list
  125817. */
  125818. systems: IParticleSystem[];
  125819. /**
  125820. * Gets the emitter node used with this set
  125821. */
  125822. readonly emitterNode: Nullable<TransformNode>;
  125823. /**
  125824. * Creates a new emitter mesh as a sphere
  125825. * @param options defines the options used to create the sphere
  125826. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125827. * @param scene defines the hosting scene
  125828. */
  125829. setEmitterAsSphere(options: {
  125830. diameter: number;
  125831. segments: number;
  125832. color: Color3;
  125833. }, renderingGroupId: number, scene: Scene): void;
  125834. /**
  125835. * Starts all particle systems of the set
  125836. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125837. */
  125838. start(emitter?: AbstractMesh): void;
  125839. /**
  125840. * Release all associated resources
  125841. */
  125842. dispose(): void;
  125843. /**
  125844. * Serialize the set into a JSON compatible object
  125845. * @returns a JSON compatible representation of the set
  125846. */
  125847. serialize(): any;
  125848. /**
  125849. * Parse a new ParticleSystemSet from a serialized source
  125850. * @param data defines a JSON compatible representation of the set
  125851. * @param scene defines the hosting scene
  125852. * @param gpu defines if we want GPU particles or CPU particles
  125853. * @returns a new ParticleSystemSet
  125854. */
  125855. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125856. }
  125857. }
  125858. declare module BABYLON {
  125859. /**
  125860. * This class is made for on one-liner static method to help creating particle system set.
  125861. */
  125862. export class ParticleHelper {
  125863. /**
  125864. * Gets or sets base Assets URL
  125865. */
  125866. static BaseAssetsUrl: string;
  125867. /**
  125868. * Create a default particle system that you can tweak
  125869. * @param emitter defines the emitter to use
  125870. * @param capacity defines the system capacity (default is 500 particles)
  125871. * @param scene defines the hosting scene
  125872. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125873. * @returns the new Particle system
  125874. */
  125875. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125876. /**
  125877. * This is the main static method (one-liner) of this helper to create different particle systems
  125878. * @param type This string represents the type to the particle system to create
  125879. * @param scene The scene where the particle system should live
  125880. * @param gpu If the system will use gpu
  125881. * @returns the ParticleSystemSet created
  125882. */
  125883. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125884. /**
  125885. * Static function used to export a particle system to a ParticleSystemSet variable.
  125886. * Please note that the emitter shape is not exported
  125887. * @param systems defines the particle systems to export
  125888. * @returns the created particle system set
  125889. */
  125890. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125891. }
  125892. }
  125893. declare module BABYLON {
  125894. interface Engine {
  125895. /**
  125896. * Create an effect to use with particle systems.
  125897. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125898. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125899. * @param uniformsNames defines a list of attribute names
  125900. * @param samplers defines an array of string used to represent textures
  125901. * @param defines defines the string containing the defines to use to compile the shaders
  125902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125903. * @param onCompiled defines a function to call when the effect creation is successful
  125904. * @param onError defines a function to call when the effect creation has failed
  125905. * @returns the new Effect
  125906. */
  125907. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125908. }
  125909. interface Mesh {
  125910. /**
  125911. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125912. * @returns an array of IParticleSystem
  125913. */
  125914. getEmittedParticleSystems(): IParticleSystem[];
  125915. /**
  125916. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125917. * @returns an array of IParticleSystem
  125918. */
  125919. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125920. }
  125921. /**
  125922. * @hidden
  125923. */
  125924. export var _IDoNeedToBeInTheBuild: number;
  125925. }
  125926. declare module BABYLON {
  125927. /** Defines the 4 color options */
  125928. export enum PointColor {
  125929. /** color value */
  125930. Color = 2,
  125931. /** uv value */
  125932. UV = 1,
  125933. /** random value */
  125934. Random = 0,
  125935. /** stated value */
  125936. Stated = 3
  125937. }
  125938. /**
  125939. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  125940. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  125941. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  125942. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125943. *
  125944. * Full documentation here : TO BE ENTERED
  125945. */
  125946. export class PointsCloudSystem implements IDisposable {
  125947. /**
  125948. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  125949. * Example : var p = SPS.particles[i];
  125950. */
  125951. particles: CloudPoint[];
  125952. /**
  125953. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  125954. */
  125955. nbParticles: number;
  125956. /**
  125957. * This a counter for your own usage. It's not set by any SPS functions.
  125958. */
  125959. counter: number;
  125960. /**
  125961. * The PCS name. This name is also given to the underlying mesh.
  125962. */
  125963. name: string;
  125964. /**
  125965. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  125966. */
  125967. mesh: Mesh;
  125968. /**
  125969. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  125970. * Please read :
  125971. */
  125972. vars: any;
  125973. /**
  125974. * @hidden
  125975. */
  125976. _size: number;
  125977. private _scene;
  125978. private _promises;
  125979. private _positions;
  125980. private _indices;
  125981. private _normals;
  125982. private _colors;
  125983. private _uvs;
  125984. private _indices32;
  125985. private _positions32;
  125986. private _colors32;
  125987. private _uvs32;
  125988. private _updatable;
  125989. private _isVisibilityBoxLocked;
  125990. private _alwaysVisible;
  125991. private _groups;
  125992. private _groupCounter;
  125993. private _computeParticleColor;
  125994. private _computeParticleTexture;
  125995. private _computeParticleRotation;
  125996. private _computeBoundingBox;
  125997. private _isReady;
  125998. /**
  125999. * Creates a PCS (Points Cloud System) object
  126000. * @param name (String) is the PCS name, this will be the underlying mesh name
  126001. * @param pointSize (number) is the size for each point
  126002. * @param scene (Scene) is the scene in which the PCS is added
  126003. * @param options defines the options of the PCS e.g.
  126004. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  126005. */
  126006. constructor(name: string, pointSize: number, scene: Scene, options?: {
  126007. updatable?: boolean;
  126008. });
  126009. /**
  126010. * Builds the PCS underlying mesh. Returns a standard Mesh.
  126011. * If no points were added to the PCS, the returned mesh is just a single point.
  126012. * @returns a promise for the created mesh
  126013. */
  126014. buildMeshAsync(): Promise<Mesh>;
  126015. /**
  126016. * @hidden
  126017. */
  126018. private _buildMesh;
  126019. private _addParticle;
  126020. private _randomUnitVector;
  126021. private _getColorIndicesForCoord;
  126022. private _setPointsColorOrUV;
  126023. private _colorFromTexture;
  126024. private _calculateDensity;
  126025. /**
  126026. * Adds points to the PCS in random positions within a unit sphere
  126027. * @param nb (positive integer) the number of particles to be created from this model
  126028. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  126029. * @returns the number of groups in the system
  126030. */
  126031. addPoints(nb: number, pointFunction?: any): number;
  126032. /**
  126033. * Adds points to the PCS from the surface of the model shape
  126034. * @param mesh is any Mesh object that will be used as a surface model for the points
  126035. * @param nb (positive integer) the number of particles to be created from this model
  126036. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  126037. * @param color (color3) to be used when colorWith is stated
  126038. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126039. * @returns the number of groups in the system
  126040. */
  126041. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126042. /**
  126043. * Adds points to the PCS inside the model shape
  126044. * @param mesh is any Mesh object that will be used as a surface model for the points
  126045. * @param nb (positive integer) the number of particles to be created from this model
  126046. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  126047. * @param color (color4) to be used when colorWith is stated
  126048. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126049. * @returns the number of groups in the system
  126050. */
  126051. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126052. /**
  126053. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  126054. * This method calls `updateParticle()` for each particle of the SPS.
  126055. * For an animated SPS, it is usually called within the render loop.
  126056. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  126057. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  126058. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  126059. * @returns the PCS.
  126060. */
  126061. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  126062. /**
  126063. * Disposes the PCS.
  126064. */
  126065. dispose(): void;
  126066. /**
  126067. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  126068. * doc :
  126069. * @returns the PCS.
  126070. */
  126071. refreshVisibleSize(): PointsCloudSystem;
  126072. /**
  126073. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  126074. * @param size the size (float) of the visibility box
  126075. * note : this doesn't lock the PCS mesh bounding box.
  126076. * doc :
  126077. */
  126078. setVisibilityBox(size: number): void;
  126079. /**
  126080. * Gets whether the PCS is always visible or not
  126081. * doc :
  126082. */
  126083. /**
  126084. * Sets the PCS as always visible or not
  126085. * doc :
  126086. */
  126087. isAlwaysVisible: boolean;
  126088. /**
  126089. * Tells to `setParticles()` to compute the particle rotations or not
  126090. * Default value : false. The PCS is faster when it's set to false
  126091. * Note : particle rotations are only applied to parent particles
  126092. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  126093. */
  126094. computeParticleRotation: boolean;
  126095. /**
  126096. * Tells to `setParticles()` to compute the particle colors or not.
  126097. * Default value : true. The PCS is faster when it's set to false.
  126098. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126099. */
  126100. /**
  126101. * Gets if `setParticles()` computes the particle colors or not.
  126102. * Default value : false. The PCS is faster when it's set to false.
  126103. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126104. */
  126105. computeParticleColor: boolean;
  126106. /**
  126107. * Gets if `setParticles()` computes the particle textures or not.
  126108. * Default value : false. The PCS is faster when it's set to false.
  126109. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  126110. */
  126111. computeParticleTexture: boolean;
  126112. /**
  126113. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126114. */
  126115. /**
  126116. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126117. */
  126118. computeBoundingBox: boolean;
  126119. /**
  126120. * This function does nothing. It may be overwritten to set all the particle first values.
  126121. * The PCS doesn't call this function, you may have to call it by your own.
  126122. * doc :
  126123. */
  126124. initParticles(): void;
  126125. /**
  126126. * This function does nothing. It may be overwritten to recycle a particle
  126127. * The PCS doesn't call this function, you can to call it
  126128. * doc :
  126129. * @param particle The particle to recycle
  126130. * @returns the recycled particle
  126131. */
  126132. recycleParticle(particle: CloudPoint): CloudPoint;
  126133. /**
  126134. * Updates a particle : this function should be overwritten by the user.
  126135. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126136. * doc :
  126137. * @example : just set a particle position or velocity and recycle conditions
  126138. * @param particle The particle to update
  126139. * @returns the updated particle
  126140. */
  126141. updateParticle(particle: CloudPoint): CloudPoint;
  126142. /**
  126143. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126144. * This does nothing and may be overwritten by the user.
  126145. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126146. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126147. * @param update the boolean update value actually passed to setParticles()
  126148. */
  126149. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126150. /**
  126151. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126152. * This will be passed three parameters.
  126153. * This does nothing and may be overwritten by the user.
  126154. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126155. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126156. * @param update the boolean update value actually passed to setParticles()
  126157. */
  126158. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126159. }
  126160. }
  126161. declare module BABYLON {
  126162. /**
  126163. * Represents one particle of a points cloud system.
  126164. */
  126165. export class CloudPoint {
  126166. /**
  126167. * particle global index
  126168. */
  126169. idx: number;
  126170. /**
  126171. * The color of the particle
  126172. */
  126173. color: Nullable<Color4>;
  126174. /**
  126175. * The world space position of the particle.
  126176. */
  126177. position: Vector3;
  126178. /**
  126179. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  126180. */
  126181. rotation: Vector3;
  126182. /**
  126183. * The world space rotation quaternion of the particle.
  126184. */
  126185. rotationQuaternion: Nullable<Quaternion>;
  126186. /**
  126187. * The uv of the particle.
  126188. */
  126189. uv: Nullable<Vector2>;
  126190. /**
  126191. * The current speed of the particle.
  126192. */
  126193. velocity: Vector3;
  126194. /**
  126195. * The pivot point in the particle local space.
  126196. */
  126197. pivot: Vector3;
  126198. /**
  126199. * Must the particle be translated from its pivot point in its local space ?
  126200. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  126201. * Default : false
  126202. */
  126203. translateFromPivot: boolean;
  126204. /**
  126205. * Index of this particle in the global "positions" array (Internal use)
  126206. * @hidden
  126207. */
  126208. _pos: number;
  126209. /**
  126210. * @hidden Index of this particle in the global "indices" array (Internal use)
  126211. */
  126212. _ind: number;
  126213. /**
  126214. * Group this particle belongs to
  126215. */
  126216. _group: PointsGroup;
  126217. /**
  126218. * Group id of this particle
  126219. */
  126220. groupId: number;
  126221. /**
  126222. * Index of the particle in its group id (Internal use)
  126223. */
  126224. idxInGroup: number;
  126225. /**
  126226. * @hidden Particle BoundingInfo object (Internal use)
  126227. */
  126228. _boundingInfo: BoundingInfo;
  126229. /**
  126230. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  126231. */
  126232. _pcs: PointsCloudSystem;
  126233. /**
  126234. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  126235. */
  126236. _stillInvisible: boolean;
  126237. /**
  126238. * @hidden Last computed particle rotation matrix
  126239. */
  126240. _rotationMatrix: number[];
  126241. /**
  126242. * Parent particle Id, if any.
  126243. * Default null.
  126244. */
  126245. parentId: Nullable<number>;
  126246. /**
  126247. * @hidden Internal global position in the PCS.
  126248. */
  126249. _globalPosition: Vector3;
  126250. /**
  126251. * Creates a Point Cloud object.
  126252. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  126253. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  126254. * @param group (PointsGroup) is the group the particle belongs to
  126255. * @param groupId (integer) is the group identifier in the PCS.
  126256. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  126257. * @param pcs defines the PCS it is associated to
  126258. */
  126259. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  126260. /**
  126261. * get point size
  126262. */
  126263. /**
  126264. * Set point size
  126265. */
  126266. size: Vector3;
  126267. /**
  126268. * Legacy support, changed quaternion to rotationQuaternion
  126269. */
  126270. /**
  126271. * Legacy support, changed quaternion to rotationQuaternion
  126272. */
  126273. quaternion: Nullable<Quaternion>;
  126274. /**
  126275. * Returns a boolean. True if the particle intersects a mesh, else false
  126276. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  126277. * @param target is the object (point or mesh) what the intersection is computed against
  126278. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  126279. * @returns true if it intersects
  126280. */
  126281. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  126282. /**
  126283. * get the rotation matrix of the particle
  126284. * @hidden
  126285. */
  126286. getRotationMatrix(m: Matrix): void;
  126287. }
  126288. /**
  126289. * Represents a group of points in a points cloud system
  126290. * * PCS internal tool, don't use it manually.
  126291. */
  126292. export class PointsGroup {
  126293. /**
  126294. * The group id
  126295. * @hidden
  126296. */
  126297. groupID: number;
  126298. /**
  126299. * image data for group (internal use)
  126300. * @hidden
  126301. */
  126302. _groupImageData: Nullable<ArrayBufferView>;
  126303. /**
  126304. * Image Width (internal use)
  126305. * @hidden
  126306. */
  126307. _groupImgWidth: number;
  126308. /**
  126309. * Image Height (internal use)
  126310. * @hidden
  126311. */
  126312. _groupImgHeight: number;
  126313. /**
  126314. * Custom position function (internal use)
  126315. * @hidden
  126316. */
  126317. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  126318. /**
  126319. * density per facet for surface points
  126320. * @hidden
  126321. */
  126322. _groupDensity: number[];
  126323. /**
  126324. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  126325. * PCS internal tool, don't use it manually.
  126326. * @hidden
  126327. */
  126328. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  126329. }
  126330. }
  126331. declare module BABYLON {
  126332. interface Scene {
  126333. /** @hidden (Backing field) */
  126334. _physicsEngine: Nullable<IPhysicsEngine>;
  126335. /**
  126336. * Gets the current physics engine
  126337. * @returns a IPhysicsEngine or null if none attached
  126338. */
  126339. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  126340. /**
  126341. * Enables physics to the current scene
  126342. * @param gravity defines the scene's gravity for the physics engine
  126343. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  126344. * @return a boolean indicating if the physics engine was initialized
  126345. */
  126346. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  126347. /**
  126348. * Disables and disposes the physics engine associated with the scene
  126349. */
  126350. disablePhysicsEngine(): void;
  126351. /**
  126352. * Gets a boolean indicating if there is an active physics engine
  126353. * @returns a boolean indicating if there is an active physics engine
  126354. */
  126355. isPhysicsEnabled(): boolean;
  126356. /**
  126357. * Deletes a physics compound impostor
  126358. * @param compound defines the compound to delete
  126359. */
  126360. deleteCompoundImpostor(compound: any): void;
  126361. /**
  126362. * An event triggered when physic simulation is about to be run
  126363. */
  126364. onBeforePhysicsObservable: Observable<Scene>;
  126365. /**
  126366. * An event triggered when physic simulation has been done
  126367. */
  126368. onAfterPhysicsObservable: Observable<Scene>;
  126369. }
  126370. interface AbstractMesh {
  126371. /** @hidden */
  126372. _physicsImpostor: Nullable<PhysicsImpostor>;
  126373. /**
  126374. * Gets or sets impostor used for physic simulation
  126375. * @see http://doc.babylonjs.com/features/physics_engine
  126376. */
  126377. physicsImpostor: Nullable<PhysicsImpostor>;
  126378. /**
  126379. * Gets the current physics impostor
  126380. * @see http://doc.babylonjs.com/features/physics_engine
  126381. * @returns a physics impostor or null
  126382. */
  126383. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126384. /** Apply a physic impulse to the mesh
  126385. * @param force defines the force to apply
  126386. * @param contactPoint defines where to apply the force
  126387. * @returns the current mesh
  126388. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126389. */
  126390. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126391. /**
  126392. * Creates a physic joint between two meshes
  126393. * @param otherMesh defines the other mesh to use
  126394. * @param pivot1 defines the pivot to use on this mesh
  126395. * @param pivot2 defines the pivot to use on the other mesh
  126396. * @param options defines additional options (can be plugin dependent)
  126397. * @returns the current mesh
  126398. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126399. */
  126400. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126401. /** @hidden */
  126402. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126403. }
  126404. /**
  126405. * Defines the physics engine scene component responsible to manage a physics engine
  126406. */
  126407. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126408. /**
  126409. * The component name helpful to identify the component in the list of scene components.
  126410. */
  126411. readonly name: string;
  126412. /**
  126413. * The scene the component belongs to.
  126414. */
  126415. scene: Scene;
  126416. /**
  126417. * Creates a new instance of the component for the given scene
  126418. * @param scene Defines the scene to register the component in
  126419. */
  126420. constructor(scene: Scene);
  126421. /**
  126422. * Registers the component in a given scene
  126423. */
  126424. register(): void;
  126425. /**
  126426. * Rebuilds the elements related to this component in case of
  126427. * context lost for instance.
  126428. */
  126429. rebuild(): void;
  126430. /**
  126431. * Disposes the component and the associated ressources
  126432. */
  126433. dispose(): void;
  126434. }
  126435. }
  126436. declare module BABYLON {
  126437. /**
  126438. * A helper for physics simulations
  126439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126440. */
  126441. export class PhysicsHelper {
  126442. private _scene;
  126443. private _physicsEngine;
  126444. /**
  126445. * Initializes the Physics helper
  126446. * @param scene Babylon.js scene
  126447. */
  126448. constructor(scene: Scene);
  126449. /**
  126450. * Applies a radial explosion impulse
  126451. * @param origin the origin of the explosion
  126452. * @param radiusOrEventOptions the radius or the options of radial explosion
  126453. * @param strength the explosion strength
  126454. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126455. * @returns A physics radial explosion event, or null
  126456. */
  126457. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126458. /**
  126459. * Applies a radial explosion force
  126460. * @param origin the origin of the explosion
  126461. * @param radiusOrEventOptions the radius or the options of radial explosion
  126462. * @param strength the explosion strength
  126463. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126464. * @returns A physics radial explosion event, or null
  126465. */
  126466. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126467. /**
  126468. * Creates a gravitational field
  126469. * @param origin the origin of the explosion
  126470. * @param radiusOrEventOptions the radius or the options of radial explosion
  126471. * @param strength the explosion strength
  126472. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126473. * @returns A physics gravitational field event, or null
  126474. */
  126475. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126476. /**
  126477. * Creates a physics updraft event
  126478. * @param origin the origin of the updraft
  126479. * @param radiusOrEventOptions the radius or the options of the updraft
  126480. * @param strength the strength of the updraft
  126481. * @param height the height of the updraft
  126482. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126483. * @returns A physics updraft event, or null
  126484. */
  126485. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126486. /**
  126487. * Creates a physics vortex event
  126488. * @param origin the of the vortex
  126489. * @param radiusOrEventOptions the radius or the options of the vortex
  126490. * @param strength the strength of the vortex
  126491. * @param height the height of the vortex
  126492. * @returns a Physics vortex event, or null
  126493. * A physics vortex event or null
  126494. */
  126495. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126496. }
  126497. /**
  126498. * Represents a physics radial explosion event
  126499. */
  126500. class PhysicsRadialExplosionEvent {
  126501. private _scene;
  126502. private _options;
  126503. private _sphere;
  126504. private _dataFetched;
  126505. /**
  126506. * Initializes a radial explosioin event
  126507. * @param _scene BabylonJS scene
  126508. * @param _options The options for the vortex event
  126509. */
  126510. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126511. /**
  126512. * Returns the data related to the radial explosion event (sphere).
  126513. * @returns The radial explosion event data
  126514. */
  126515. getData(): PhysicsRadialExplosionEventData;
  126516. /**
  126517. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126518. * @param impostor A physics imposter
  126519. * @param origin the origin of the explosion
  126520. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126521. */
  126522. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126523. /**
  126524. * Triggers affecterd impostors callbacks
  126525. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126526. */
  126527. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126528. /**
  126529. * Disposes the sphere.
  126530. * @param force Specifies if the sphere should be disposed by force
  126531. */
  126532. dispose(force?: boolean): void;
  126533. /*** Helpers ***/
  126534. private _prepareSphere;
  126535. private _intersectsWithSphere;
  126536. }
  126537. /**
  126538. * Represents a gravitational field event
  126539. */
  126540. class PhysicsGravitationalFieldEvent {
  126541. private _physicsHelper;
  126542. private _scene;
  126543. private _origin;
  126544. private _options;
  126545. private _tickCallback;
  126546. private _sphere;
  126547. private _dataFetched;
  126548. /**
  126549. * Initializes the physics gravitational field event
  126550. * @param _physicsHelper A physics helper
  126551. * @param _scene BabylonJS scene
  126552. * @param _origin The origin position of the gravitational field event
  126553. * @param _options The options for the vortex event
  126554. */
  126555. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126556. /**
  126557. * Returns the data related to the gravitational field event (sphere).
  126558. * @returns A gravitational field event
  126559. */
  126560. getData(): PhysicsGravitationalFieldEventData;
  126561. /**
  126562. * Enables the gravitational field.
  126563. */
  126564. enable(): void;
  126565. /**
  126566. * Disables the gravitational field.
  126567. */
  126568. disable(): void;
  126569. /**
  126570. * Disposes the sphere.
  126571. * @param force The force to dispose from the gravitational field event
  126572. */
  126573. dispose(force?: boolean): void;
  126574. private _tick;
  126575. }
  126576. /**
  126577. * Represents a physics updraft event
  126578. */
  126579. class PhysicsUpdraftEvent {
  126580. private _scene;
  126581. private _origin;
  126582. private _options;
  126583. private _physicsEngine;
  126584. private _originTop;
  126585. private _originDirection;
  126586. private _tickCallback;
  126587. private _cylinder;
  126588. private _cylinderPosition;
  126589. private _dataFetched;
  126590. /**
  126591. * Initializes the physics updraft event
  126592. * @param _scene BabylonJS scene
  126593. * @param _origin The origin position of the updraft
  126594. * @param _options The options for the updraft event
  126595. */
  126596. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126597. /**
  126598. * Returns the data related to the updraft event (cylinder).
  126599. * @returns A physics updraft event
  126600. */
  126601. getData(): PhysicsUpdraftEventData;
  126602. /**
  126603. * Enables the updraft.
  126604. */
  126605. enable(): void;
  126606. /**
  126607. * Disables the updraft.
  126608. */
  126609. disable(): void;
  126610. /**
  126611. * Disposes the cylinder.
  126612. * @param force Specifies if the updraft should be disposed by force
  126613. */
  126614. dispose(force?: boolean): void;
  126615. private getImpostorHitData;
  126616. private _tick;
  126617. /*** Helpers ***/
  126618. private _prepareCylinder;
  126619. private _intersectsWithCylinder;
  126620. }
  126621. /**
  126622. * Represents a physics vortex event
  126623. */
  126624. class PhysicsVortexEvent {
  126625. private _scene;
  126626. private _origin;
  126627. private _options;
  126628. private _physicsEngine;
  126629. private _originTop;
  126630. private _tickCallback;
  126631. private _cylinder;
  126632. private _cylinderPosition;
  126633. private _dataFetched;
  126634. /**
  126635. * Initializes the physics vortex event
  126636. * @param _scene The BabylonJS scene
  126637. * @param _origin The origin position of the vortex
  126638. * @param _options The options for the vortex event
  126639. */
  126640. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126641. /**
  126642. * Returns the data related to the vortex event (cylinder).
  126643. * @returns The physics vortex event data
  126644. */
  126645. getData(): PhysicsVortexEventData;
  126646. /**
  126647. * Enables the vortex.
  126648. */
  126649. enable(): void;
  126650. /**
  126651. * Disables the cortex.
  126652. */
  126653. disable(): void;
  126654. /**
  126655. * Disposes the sphere.
  126656. * @param force
  126657. */
  126658. dispose(force?: boolean): void;
  126659. private getImpostorHitData;
  126660. private _tick;
  126661. /*** Helpers ***/
  126662. private _prepareCylinder;
  126663. private _intersectsWithCylinder;
  126664. }
  126665. /**
  126666. * Options fot the radial explosion event
  126667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126668. */
  126669. export class PhysicsRadialExplosionEventOptions {
  126670. /**
  126671. * The radius of the sphere for the radial explosion.
  126672. */
  126673. radius: number;
  126674. /**
  126675. * The strenth of the explosion.
  126676. */
  126677. strength: number;
  126678. /**
  126679. * The strenght of the force in correspondence to the distance of the affected object
  126680. */
  126681. falloff: PhysicsRadialImpulseFalloff;
  126682. /**
  126683. * Sphere options for the radial explosion.
  126684. */
  126685. sphere: {
  126686. segments: number;
  126687. diameter: number;
  126688. };
  126689. /**
  126690. * Sphere options for the radial explosion.
  126691. */
  126692. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  126693. }
  126694. /**
  126695. * Options fot the updraft event
  126696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126697. */
  126698. export class PhysicsUpdraftEventOptions {
  126699. /**
  126700. * The radius of the cylinder for the vortex
  126701. */
  126702. radius: number;
  126703. /**
  126704. * The strenth of the updraft.
  126705. */
  126706. strength: number;
  126707. /**
  126708. * The height of the cylinder for the updraft.
  126709. */
  126710. height: number;
  126711. /**
  126712. * The mode for the the updraft.
  126713. */
  126714. updraftMode: PhysicsUpdraftMode;
  126715. }
  126716. /**
  126717. * Options fot the vortex event
  126718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126719. */
  126720. export class PhysicsVortexEventOptions {
  126721. /**
  126722. * The radius of the cylinder for the vortex
  126723. */
  126724. radius: number;
  126725. /**
  126726. * The strenth of the vortex.
  126727. */
  126728. strength: number;
  126729. /**
  126730. * The height of the cylinder for the vortex.
  126731. */
  126732. height: number;
  126733. /**
  126734. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  126735. */
  126736. centripetalForceThreshold: number;
  126737. /**
  126738. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  126739. */
  126740. centripetalForceMultiplier: number;
  126741. /**
  126742. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  126743. */
  126744. centrifugalForceMultiplier: number;
  126745. /**
  126746. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  126747. */
  126748. updraftForceMultiplier: number;
  126749. }
  126750. /**
  126751. * The strenght of the force in correspondence to the distance of the affected object
  126752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126753. */
  126754. export enum PhysicsRadialImpulseFalloff {
  126755. /** Defines that impulse is constant in strength across it's whole radius */
  126756. Constant = 0,
  126757. /** Defines that impulse gets weaker if it's further from the origin */
  126758. Linear = 1
  126759. }
  126760. /**
  126761. * The strength of the force in correspondence to the distance of the affected object
  126762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126763. */
  126764. export enum PhysicsUpdraftMode {
  126765. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  126766. Center = 0,
  126767. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  126768. Perpendicular = 1
  126769. }
  126770. /**
  126771. * Interface for a physics hit data
  126772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126773. */
  126774. export interface PhysicsHitData {
  126775. /**
  126776. * The force applied at the contact point
  126777. */
  126778. force: Vector3;
  126779. /**
  126780. * The contact point
  126781. */
  126782. contactPoint: Vector3;
  126783. /**
  126784. * The distance from the origin to the contact point
  126785. */
  126786. distanceFromOrigin: number;
  126787. }
  126788. /**
  126789. * Interface for radial explosion event data
  126790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126791. */
  126792. export interface PhysicsRadialExplosionEventData {
  126793. /**
  126794. * A sphere used for the radial explosion event
  126795. */
  126796. sphere: Mesh;
  126797. }
  126798. /**
  126799. * Interface for gravitational field event data
  126800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126801. */
  126802. export interface PhysicsGravitationalFieldEventData {
  126803. /**
  126804. * A sphere mesh used for the gravitational field event
  126805. */
  126806. sphere: Mesh;
  126807. }
  126808. /**
  126809. * Interface for updraft event data
  126810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126811. */
  126812. export interface PhysicsUpdraftEventData {
  126813. /**
  126814. * A cylinder used for the updraft event
  126815. */
  126816. cylinder: Mesh;
  126817. }
  126818. /**
  126819. * Interface for vortex event data
  126820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126821. */
  126822. export interface PhysicsVortexEventData {
  126823. /**
  126824. * A cylinder used for the vortex event
  126825. */
  126826. cylinder: Mesh;
  126827. }
  126828. /**
  126829. * Interface for an affected physics impostor
  126830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126831. */
  126832. export interface PhysicsAffectedImpostorWithData {
  126833. /**
  126834. * The impostor affected by the effect
  126835. */
  126836. impostor: PhysicsImpostor;
  126837. /**
  126838. * The data about the hit/horce from the explosion
  126839. */
  126840. hitData: PhysicsHitData;
  126841. }
  126842. }
  126843. declare module BABYLON {
  126844. /** @hidden */
  126845. export var blackAndWhitePixelShader: {
  126846. name: string;
  126847. shader: string;
  126848. };
  126849. }
  126850. declare module BABYLON {
  126851. /**
  126852. * Post process used to render in black and white
  126853. */
  126854. export class BlackAndWhitePostProcess extends PostProcess {
  126855. /**
  126856. * Linear about to convert he result to black and white (default: 1)
  126857. */
  126858. degree: number;
  126859. /**
  126860. * Creates a black and white post process
  126861. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  126862. * @param name The name of the effect.
  126863. * @param options The required width/height ratio to downsize to before computing the render pass.
  126864. * @param camera The camera to apply the render pass to.
  126865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126866. * @param engine The engine which the post process will be applied. (default: current engine)
  126867. * @param reusable If the post process can be reused on the same frame. (default: false)
  126868. */
  126869. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126870. }
  126871. }
  126872. declare module BABYLON {
  126873. /**
  126874. * This represents a set of one or more post processes in Babylon.
  126875. * A post process can be used to apply a shader to a texture after it is rendered.
  126876. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126877. */
  126878. export class PostProcessRenderEffect {
  126879. private _postProcesses;
  126880. private _getPostProcesses;
  126881. private _singleInstance;
  126882. private _cameras;
  126883. private _indicesForCamera;
  126884. /**
  126885. * Name of the effect
  126886. * @hidden
  126887. */
  126888. _name: string;
  126889. /**
  126890. * Instantiates a post process render effect.
  126891. * A post process can be used to apply a shader to a texture after it is rendered.
  126892. * @param engine The engine the effect is tied to
  126893. * @param name The name of the effect
  126894. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  126895. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  126896. */
  126897. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  126898. /**
  126899. * Checks if all the post processes in the effect are supported.
  126900. */
  126901. readonly isSupported: boolean;
  126902. /**
  126903. * Updates the current state of the effect
  126904. * @hidden
  126905. */
  126906. _update(): void;
  126907. /**
  126908. * Attaches the effect on cameras
  126909. * @param cameras The camera to attach to.
  126910. * @hidden
  126911. */
  126912. _attachCameras(cameras: Camera): void;
  126913. /**
  126914. * Attaches the effect on cameras
  126915. * @param cameras The camera to attach to.
  126916. * @hidden
  126917. */
  126918. _attachCameras(cameras: Camera[]): void;
  126919. /**
  126920. * Detaches the effect on cameras
  126921. * @param cameras The camera to detatch from.
  126922. * @hidden
  126923. */
  126924. _detachCameras(cameras: Camera): void;
  126925. /**
  126926. * Detatches the effect on cameras
  126927. * @param cameras The camera to detatch from.
  126928. * @hidden
  126929. */
  126930. _detachCameras(cameras: Camera[]): void;
  126931. /**
  126932. * Enables the effect on given cameras
  126933. * @param cameras The camera to enable.
  126934. * @hidden
  126935. */
  126936. _enable(cameras: Camera): void;
  126937. /**
  126938. * Enables the effect on given cameras
  126939. * @param cameras The camera to enable.
  126940. * @hidden
  126941. */
  126942. _enable(cameras: Nullable<Camera[]>): void;
  126943. /**
  126944. * Disables the effect on the given cameras
  126945. * @param cameras The camera to disable.
  126946. * @hidden
  126947. */
  126948. _disable(cameras: Camera): void;
  126949. /**
  126950. * Disables the effect on the given cameras
  126951. * @param cameras The camera to disable.
  126952. * @hidden
  126953. */
  126954. _disable(cameras: Nullable<Camera[]>): void;
  126955. /**
  126956. * Gets a list of the post processes contained in the effect.
  126957. * @param camera The camera to get the post processes on.
  126958. * @returns The list of the post processes in the effect.
  126959. */
  126960. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  126961. }
  126962. }
  126963. declare module BABYLON {
  126964. /** @hidden */
  126965. export var extractHighlightsPixelShader: {
  126966. name: string;
  126967. shader: string;
  126968. };
  126969. }
  126970. declare module BABYLON {
  126971. /**
  126972. * 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.
  126973. */
  126974. export class ExtractHighlightsPostProcess extends PostProcess {
  126975. /**
  126976. * The luminance threshold, pixels below this value will be set to black.
  126977. */
  126978. threshold: number;
  126979. /** @hidden */
  126980. _exposure: number;
  126981. /**
  126982. * Post process which has the input texture to be used when performing highlight extraction
  126983. * @hidden
  126984. */
  126985. _inputPostProcess: Nullable<PostProcess>;
  126986. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126987. }
  126988. }
  126989. declare module BABYLON {
  126990. /** @hidden */
  126991. export var bloomMergePixelShader: {
  126992. name: string;
  126993. shader: string;
  126994. };
  126995. }
  126996. declare module BABYLON {
  126997. /**
  126998. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126999. */
  127000. export class BloomMergePostProcess extends PostProcess {
  127001. /** Weight of the bloom to be added to the original input. */
  127002. weight: number;
  127003. /**
  127004. * Creates a new instance of @see BloomMergePostProcess
  127005. * @param name The name of the effect.
  127006. * @param originalFromInput Post process which's input will be used for the merge.
  127007. * @param blurred Blurred highlights post process which's output will be used.
  127008. * @param weight Weight of the bloom to be added to the original input.
  127009. * @param options The required width/height ratio to downsize to before computing the render pass.
  127010. * @param camera The camera to apply the render pass to.
  127011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127012. * @param engine The engine which the post process will be applied. (default: current engine)
  127013. * @param reusable If the post process can be reused on the same frame. (default: false)
  127014. * @param textureType Type of textures used when performing the post process. (default: 0)
  127015. * @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)
  127016. */
  127017. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  127018. /** Weight of the bloom to be added to the original input. */
  127019. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127020. }
  127021. }
  127022. declare module BABYLON {
  127023. /**
  127024. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  127025. */
  127026. export class BloomEffect extends PostProcessRenderEffect {
  127027. private bloomScale;
  127028. /**
  127029. * @hidden Internal
  127030. */
  127031. _effects: Array<PostProcess>;
  127032. /**
  127033. * @hidden Internal
  127034. */
  127035. _downscale: ExtractHighlightsPostProcess;
  127036. private _blurX;
  127037. private _blurY;
  127038. private _merge;
  127039. /**
  127040. * The luminance threshold to find bright areas of the image to bloom.
  127041. */
  127042. threshold: number;
  127043. /**
  127044. * The strength of the bloom.
  127045. */
  127046. weight: number;
  127047. /**
  127048. * Specifies the size of the bloom blur kernel, relative to the final output size
  127049. */
  127050. kernel: number;
  127051. /**
  127052. * Creates a new instance of @see BloomEffect
  127053. * @param scene The scene the effect belongs to.
  127054. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  127055. * @param bloomKernel The size of the kernel to be used when applying the blur.
  127056. * @param bloomWeight The the strength of bloom.
  127057. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127058. * @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)
  127059. */
  127060. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  127061. /**
  127062. * Disposes each of the internal effects for a given camera.
  127063. * @param camera The camera to dispose the effect on.
  127064. */
  127065. disposeEffects(camera: Camera): void;
  127066. /**
  127067. * @hidden Internal
  127068. */
  127069. _updateEffects(): void;
  127070. /**
  127071. * Internal
  127072. * @returns if all the contained post processes are ready.
  127073. * @hidden
  127074. */
  127075. _isReady(): boolean;
  127076. }
  127077. }
  127078. declare module BABYLON {
  127079. /** @hidden */
  127080. export var chromaticAberrationPixelShader: {
  127081. name: string;
  127082. shader: string;
  127083. };
  127084. }
  127085. declare module BABYLON {
  127086. /**
  127087. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  127088. */
  127089. export class ChromaticAberrationPostProcess extends PostProcess {
  127090. /**
  127091. * The amount of seperation of rgb channels (default: 30)
  127092. */
  127093. aberrationAmount: number;
  127094. /**
  127095. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  127096. */
  127097. radialIntensity: number;
  127098. /**
  127099. * 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))
  127100. */
  127101. direction: Vector2;
  127102. /**
  127103. * 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))
  127104. */
  127105. centerPosition: Vector2;
  127106. /**
  127107. * Creates a new instance ChromaticAberrationPostProcess
  127108. * @param name The name of the effect.
  127109. * @param screenWidth The width of the screen to apply the effect on.
  127110. * @param screenHeight The height of the screen to apply the effect on.
  127111. * @param options The required width/height ratio to downsize to before computing the render pass.
  127112. * @param camera The camera to apply the render pass to.
  127113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127114. * @param engine The engine which the post process will be applied. (default: current engine)
  127115. * @param reusable If the post process can be reused on the same frame. (default: false)
  127116. * @param textureType Type of textures used when performing the post process. (default: 0)
  127117. * @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)
  127118. */
  127119. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127120. }
  127121. }
  127122. declare module BABYLON {
  127123. /** @hidden */
  127124. export var circleOfConfusionPixelShader: {
  127125. name: string;
  127126. shader: string;
  127127. };
  127128. }
  127129. declare module BABYLON {
  127130. /**
  127131. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  127132. */
  127133. export class CircleOfConfusionPostProcess extends PostProcess {
  127134. /**
  127135. * 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.
  127136. */
  127137. lensSize: number;
  127138. /**
  127139. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127140. */
  127141. fStop: number;
  127142. /**
  127143. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127144. */
  127145. focusDistance: number;
  127146. /**
  127147. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  127148. */
  127149. focalLength: number;
  127150. private _depthTexture;
  127151. /**
  127152. * Creates a new instance CircleOfConfusionPostProcess
  127153. * @param name The name of the effect.
  127154. * @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.
  127155. * @param options The required width/height ratio to downsize to before computing the render pass.
  127156. * @param camera The camera to apply the render pass to.
  127157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127158. * @param engine The engine which the post process will be applied. (default: current engine)
  127159. * @param reusable If the post process can be reused on the same frame. (default: false)
  127160. * @param textureType Type of textures used when performing the post process. (default: 0)
  127161. * @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)
  127162. */
  127163. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127164. /**
  127165. * 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.
  127166. */
  127167. depthTexture: RenderTargetTexture;
  127168. }
  127169. }
  127170. declare module BABYLON {
  127171. /** @hidden */
  127172. export var colorCorrectionPixelShader: {
  127173. name: string;
  127174. shader: string;
  127175. };
  127176. }
  127177. declare module BABYLON {
  127178. /**
  127179. *
  127180. * This post-process allows the modification of rendered colors by using
  127181. * a 'look-up table' (LUT). This effect is also called Color Grading.
  127182. *
  127183. * The object needs to be provided an url to a texture containing the color
  127184. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  127185. * Use an image editing software to tweak the LUT to match your needs.
  127186. *
  127187. * For an example of a color LUT, see here:
  127188. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  127189. * For explanations on color grading, see here:
  127190. * @see http://udn.epicgames.com/Three/ColorGrading.html
  127191. *
  127192. */
  127193. export class ColorCorrectionPostProcess extends PostProcess {
  127194. private _colorTableTexture;
  127195. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127196. }
  127197. }
  127198. declare module BABYLON {
  127199. /** @hidden */
  127200. export var convolutionPixelShader: {
  127201. name: string;
  127202. shader: string;
  127203. };
  127204. }
  127205. declare module BABYLON {
  127206. /**
  127207. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127208. * input texture to perform effects such as edge detection or sharpening
  127209. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127210. */
  127211. export class ConvolutionPostProcess extends PostProcess {
  127212. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127213. kernel: number[];
  127214. /**
  127215. * Creates a new instance ConvolutionPostProcess
  127216. * @param name The name of the effect.
  127217. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127218. * @param options The required width/height ratio to downsize to before computing the render pass.
  127219. * @param camera The camera to apply the render pass to.
  127220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127221. * @param engine The engine which the post process will be applied. (default: current engine)
  127222. * @param reusable If the post process can be reused on the same frame. (default: false)
  127223. * @param textureType Type of textures used when performing the post process. (default: 0)
  127224. */
  127225. constructor(name: string,
  127226. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127227. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127228. /**
  127229. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127230. */
  127231. static EdgeDetect0Kernel: number[];
  127232. /**
  127233. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127234. */
  127235. static EdgeDetect1Kernel: number[];
  127236. /**
  127237. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127238. */
  127239. static EdgeDetect2Kernel: number[];
  127240. /**
  127241. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127242. */
  127243. static SharpenKernel: number[];
  127244. /**
  127245. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127246. */
  127247. static EmbossKernel: number[];
  127248. /**
  127249. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127250. */
  127251. static GaussianKernel: number[];
  127252. }
  127253. }
  127254. declare module BABYLON {
  127255. /**
  127256. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  127257. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  127258. * based on samples that have a large difference in distance than the center pixel.
  127259. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  127260. */
  127261. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  127262. direction: Vector2;
  127263. /**
  127264. * Creates a new instance CircleOfConfusionPostProcess
  127265. * @param name The name of the effect.
  127266. * @param scene The scene the effect belongs to.
  127267. * @param direction The direction the blur should be applied.
  127268. * @param kernel The size of the kernel used to blur.
  127269. * @param options The required width/height ratio to downsize to before computing the render pass.
  127270. * @param camera The camera to apply the render pass to.
  127271. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  127272. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  127273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127274. * @param engine The engine which the post process will be applied. (default: current engine)
  127275. * @param reusable If the post process can be reused on the same frame. (default: false)
  127276. * @param textureType Type of textures used when performing the post process. (default: 0)
  127277. * @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)
  127278. */
  127279. 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);
  127280. }
  127281. }
  127282. declare module BABYLON {
  127283. /** @hidden */
  127284. export var depthOfFieldMergePixelShader: {
  127285. name: string;
  127286. shader: string;
  127287. };
  127288. }
  127289. declare module BABYLON {
  127290. /**
  127291. * Options to be set when merging outputs from the default pipeline.
  127292. */
  127293. export class DepthOfFieldMergePostProcessOptions {
  127294. /**
  127295. * The original image to merge on top of
  127296. */
  127297. originalFromInput: PostProcess;
  127298. /**
  127299. * Parameters to perform the merge of the depth of field effect
  127300. */
  127301. depthOfField?: {
  127302. circleOfConfusion: PostProcess;
  127303. blurSteps: Array<PostProcess>;
  127304. };
  127305. /**
  127306. * Parameters to perform the merge of bloom effect
  127307. */
  127308. bloom?: {
  127309. blurred: PostProcess;
  127310. weight: number;
  127311. };
  127312. }
  127313. /**
  127314. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127315. */
  127316. export class DepthOfFieldMergePostProcess extends PostProcess {
  127317. private blurSteps;
  127318. /**
  127319. * Creates a new instance of DepthOfFieldMergePostProcess
  127320. * @param name The name of the effect.
  127321. * @param originalFromInput Post process which's input will be used for the merge.
  127322. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  127323. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  127324. * @param options The required width/height ratio to downsize to before computing the render pass.
  127325. * @param camera The camera to apply the render pass to.
  127326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127327. * @param engine The engine which the post process will be applied. (default: current engine)
  127328. * @param reusable If the post process can be reused on the same frame. (default: false)
  127329. * @param textureType Type of textures used when performing the post process. (default: 0)
  127330. * @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)
  127331. */
  127332. 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);
  127333. /**
  127334. * Updates the effect with the current post process compile time values and recompiles the shader.
  127335. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  127336. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  127337. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  127338. * @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
  127339. * @param onCompiled Called when the shader has been compiled.
  127340. * @param onError Called if there is an error when compiling a shader.
  127341. */
  127342. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  127343. }
  127344. }
  127345. declare module BABYLON {
  127346. /**
  127347. * Specifies the level of max blur that should be applied when using the depth of field effect
  127348. */
  127349. export enum DepthOfFieldEffectBlurLevel {
  127350. /**
  127351. * Subtle blur
  127352. */
  127353. Low = 0,
  127354. /**
  127355. * Medium blur
  127356. */
  127357. Medium = 1,
  127358. /**
  127359. * Large blur
  127360. */
  127361. High = 2
  127362. }
  127363. /**
  127364. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127365. */
  127366. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127367. private _circleOfConfusion;
  127368. /**
  127369. * @hidden Internal, blurs from high to low
  127370. */
  127371. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127372. private _depthOfFieldBlurY;
  127373. private _dofMerge;
  127374. /**
  127375. * @hidden Internal post processes in depth of field effect
  127376. */
  127377. _effects: Array<PostProcess>;
  127378. /**
  127379. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127380. */
  127381. focalLength: number;
  127382. /**
  127383. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127384. */
  127385. fStop: number;
  127386. /**
  127387. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127388. */
  127389. focusDistance: number;
  127390. /**
  127391. * 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.
  127392. */
  127393. lensSize: number;
  127394. /**
  127395. * Creates a new instance DepthOfFieldEffect
  127396. * @param scene The scene the effect belongs to.
  127397. * @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.
  127398. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127399. * @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)
  127400. */
  127401. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127402. /**
  127403. * Get the current class name of the current effet
  127404. * @returns "DepthOfFieldEffect"
  127405. */
  127406. getClassName(): string;
  127407. /**
  127408. * 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.
  127409. */
  127410. depthTexture: RenderTargetTexture;
  127411. /**
  127412. * Disposes each of the internal effects for a given camera.
  127413. * @param camera The camera to dispose the effect on.
  127414. */
  127415. disposeEffects(camera: Camera): void;
  127416. /**
  127417. * @hidden Internal
  127418. */
  127419. _updateEffects(): void;
  127420. /**
  127421. * Internal
  127422. * @returns if all the contained post processes are ready.
  127423. * @hidden
  127424. */
  127425. _isReady(): boolean;
  127426. }
  127427. }
  127428. declare module BABYLON {
  127429. /** @hidden */
  127430. export var displayPassPixelShader: {
  127431. name: string;
  127432. shader: string;
  127433. };
  127434. }
  127435. declare module BABYLON {
  127436. /**
  127437. * DisplayPassPostProcess which produces an output the same as it's input
  127438. */
  127439. export class DisplayPassPostProcess extends PostProcess {
  127440. /**
  127441. * Creates the DisplayPassPostProcess
  127442. * @param name The name of the effect.
  127443. * @param options The required width/height ratio to downsize to before computing the render pass.
  127444. * @param camera The camera to apply the render pass to.
  127445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127446. * @param engine The engine which the post process will be applied. (default: current engine)
  127447. * @param reusable If the post process can be reused on the same frame. (default: false)
  127448. */
  127449. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127450. }
  127451. }
  127452. declare module BABYLON {
  127453. /** @hidden */
  127454. export var filterPixelShader: {
  127455. name: string;
  127456. shader: string;
  127457. };
  127458. }
  127459. declare module BABYLON {
  127460. /**
  127461. * Applies a kernel filter to the image
  127462. */
  127463. export class FilterPostProcess extends PostProcess {
  127464. /** The matrix to be applied to the image */
  127465. kernelMatrix: Matrix;
  127466. /**
  127467. *
  127468. * @param name The name of the effect.
  127469. * @param kernelMatrix The matrix to be applied to the image
  127470. * @param options The required width/height ratio to downsize to before computing the render pass.
  127471. * @param camera The camera to apply the render pass to.
  127472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127473. * @param engine The engine which the post process will be applied. (default: current engine)
  127474. * @param reusable If the post process can be reused on the same frame. (default: false)
  127475. */
  127476. constructor(name: string,
  127477. /** The matrix to be applied to the image */
  127478. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127479. }
  127480. }
  127481. declare module BABYLON {
  127482. /** @hidden */
  127483. export var fxaaPixelShader: {
  127484. name: string;
  127485. shader: string;
  127486. };
  127487. }
  127488. declare module BABYLON {
  127489. /** @hidden */
  127490. export var fxaaVertexShader: {
  127491. name: string;
  127492. shader: string;
  127493. };
  127494. }
  127495. declare module BABYLON {
  127496. /**
  127497. * Fxaa post process
  127498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127499. */
  127500. export class FxaaPostProcess extends PostProcess {
  127501. /** @hidden */
  127502. texelWidth: number;
  127503. /** @hidden */
  127504. texelHeight: number;
  127505. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127506. private _getDefines;
  127507. }
  127508. }
  127509. declare module BABYLON {
  127510. /** @hidden */
  127511. export var grainPixelShader: {
  127512. name: string;
  127513. shader: string;
  127514. };
  127515. }
  127516. declare module BABYLON {
  127517. /**
  127518. * The GrainPostProcess adds noise to the image at mid luminance levels
  127519. */
  127520. export class GrainPostProcess extends PostProcess {
  127521. /**
  127522. * The intensity of the grain added (default: 30)
  127523. */
  127524. intensity: number;
  127525. /**
  127526. * If the grain should be randomized on every frame
  127527. */
  127528. animated: boolean;
  127529. /**
  127530. * Creates a new instance of @see GrainPostProcess
  127531. * @param name The name of the effect.
  127532. * @param options The required width/height ratio to downsize to before computing the render pass.
  127533. * @param camera The camera to apply the render pass to.
  127534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127535. * @param engine The engine which the post process will be applied. (default: current engine)
  127536. * @param reusable If the post process can be reused on the same frame. (default: false)
  127537. * @param textureType Type of textures used when performing the post process. (default: 0)
  127538. * @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)
  127539. */
  127540. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127541. }
  127542. }
  127543. declare module BABYLON {
  127544. /** @hidden */
  127545. export var highlightsPixelShader: {
  127546. name: string;
  127547. shader: string;
  127548. };
  127549. }
  127550. declare module BABYLON {
  127551. /**
  127552. * Extracts highlights from the image
  127553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127554. */
  127555. export class HighlightsPostProcess extends PostProcess {
  127556. /**
  127557. * Extracts highlights from the image
  127558. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127559. * @param name The name of the effect.
  127560. * @param options The required width/height ratio to downsize to before computing the render pass.
  127561. * @param camera The camera to apply the render pass to.
  127562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127563. * @param engine The engine which the post process will be applied. (default: current engine)
  127564. * @param reusable If the post process can be reused on the same frame. (default: false)
  127565. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127566. */
  127567. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127568. }
  127569. }
  127570. declare module BABYLON {
  127571. /** @hidden */
  127572. export var mrtFragmentDeclaration: {
  127573. name: string;
  127574. shader: string;
  127575. };
  127576. }
  127577. declare module BABYLON {
  127578. /** @hidden */
  127579. export var geometryPixelShader: {
  127580. name: string;
  127581. shader: string;
  127582. };
  127583. }
  127584. declare module BABYLON {
  127585. /** @hidden */
  127586. export var geometryVertexShader: {
  127587. name: string;
  127588. shader: string;
  127589. };
  127590. }
  127591. declare module BABYLON {
  127592. /** @hidden */
  127593. interface ISavedTransformationMatrix {
  127594. world: Matrix;
  127595. viewProjection: Matrix;
  127596. }
  127597. /**
  127598. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127599. */
  127600. export class GeometryBufferRenderer {
  127601. /**
  127602. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127603. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127604. */
  127605. static readonly POSITION_TEXTURE_TYPE: number;
  127606. /**
  127607. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127608. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127609. */
  127610. static readonly VELOCITY_TEXTURE_TYPE: number;
  127611. /**
  127612. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127613. * in order to compute objects velocities when enableVelocity is set to "true"
  127614. * @hidden
  127615. */
  127616. _previousTransformationMatrices: {
  127617. [index: number]: ISavedTransformationMatrix;
  127618. };
  127619. /**
  127620. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127621. * in order to compute objects velocities when enableVelocity is set to "true"
  127622. * @hidden
  127623. */
  127624. _previousBonesTransformationMatrices: {
  127625. [index: number]: Float32Array;
  127626. };
  127627. /**
  127628. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127629. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127630. */
  127631. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127632. private _scene;
  127633. private _multiRenderTarget;
  127634. private _ratio;
  127635. private _enablePosition;
  127636. private _enableVelocity;
  127637. private _positionIndex;
  127638. private _velocityIndex;
  127639. protected _effect: Effect;
  127640. protected _cachedDefines: string;
  127641. /**
  127642. * Set the render list (meshes to be rendered) used in the G buffer.
  127643. */
  127644. renderList: Mesh[];
  127645. /**
  127646. * Gets wether or not G buffer are supported by the running hardware.
  127647. * This requires draw buffer supports
  127648. */
  127649. readonly isSupported: boolean;
  127650. /**
  127651. * Returns the index of the given texture type in the G-Buffer textures array
  127652. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127653. * @returns the index of the given texture type in the G-Buffer textures array
  127654. */
  127655. getTextureIndex(textureType: number): number;
  127656. /**
  127657. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127658. */
  127659. /**
  127660. * Sets whether or not objects positions are enabled for the G buffer.
  127661. */
  127662. enablePosition: boolean;
  127663. /**
  127664. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127665. */
  127666. /**
  127667. * Sets wether or not objects velocities are enabled for the G buffer.
  127668. */
  127669. enableVelocity: boolean;
  127670. /**
  127671. * Gets the scene associated with the buffer.
  127672. */
  127673. readonly scene: Scene;
  127674. /**
  127675. * Gets the ratio used by the buffer during its creation.
  127676. * How big is the buffer related to the main canvas.
  127677. */
  127678. readonly ratio: number;
  127679. /** @hidden */
  127680. static _SceneComponentInitialization: (scene: Scene) => void;
  127681. /**
  127682. * Creates a new G Buffer for the scene
  127683. * @param scene The scene the buffer belongs to
  127684. * @param ratio How big is the buffer related to the main canvas.
  127685. */
  127686. constructor(scene: Scene, ratio?: number);
  127687. /**
  127688. * Checks wether everything is ready to render a submesh to the G buffer.
  127689. * @param subMesh the submesh to check readiness for
  127690. * @param useInstances is the mesh drawn using instance or not
  127691. * @returns true if ready otherwise false
  127692. */
  127693. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127694. /**
  127695. * Gets the current underlying G Buffer.
  127696. * @returns the buffer
  127697. */
  127698. getGBuffer(): MultiRenderTarget;
  127699. /**
  127700. * Gets the number of samples used to render the buffer (anti aliasing).
  127701. */
  127702. /**
  127703. * Sets the number of samples used to render the buffer (anti aliasing).
  127704. */
  127705. samples: number;
  127706. /**
  127707. * Disposes the renderer and frees up associated resources.
  127708. */
  127709. dispose(): void;
  127710. protected _createRenderTargets(): void;
  127711. private _copyBonesTransformationMatrices;
  127712. }
  127713. }
  127714. declare module BABYLON {
  127715. interface Scene {
  127716. /** @hidden (Backing field) */
  127717. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127718. /**
  127719. * Gets or Sets the current geometry buffer associated to the scene.
  127720. */
  127721. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127722. /**
  127723. * Enables a GeometryBufferRender and associates it with the scene
  127724. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  127725. * @returns the GeometryBufferRenderer
  127726. */
  127727. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  127728. /**
  127729. * Disables the GeometryBufferRender associated with the scene
  127730. */
  127731. disableGeometryBufferRenderer(): void;
  127732. }
  127733. /**
  127734. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127735. * in several rendering techniques.
  127736. */
  127737. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  127738. /**
  127739. * The component name helpful to identify the component in the list of scene components.
  127740. */
  127741. readonly name: string;
  127742. /**
  127743. * The scene the component belongs to.
  127744. */
  127745. scene: Scene;
  127746. /**
  127747. * Creates a new instance of the component for the given scene
  127748. * @param scene Defines the scene to register the component in
  127749. */
  127750. constructor(scene: Scene);
  127751. /**
  127752. * Registers the component in a given scene
  127753. */
  127754. register(): void;
  127755. /**
  127756. * Rebuilds the elements related to this component in case of
  127757. * context lost for instance.
  127758. */
  127759. rebuild(): void;
  127760. /**
  127761. * Disposes the component and the associated ressources
  127762. */
  127763. dispose(): void;
  127764. private _gatherRenderTargets;
  127765. }
  127766. }
  127767. declare module BABYLON {
  127768. /** @hidden */
  127769. export var motionBlurPixelShader: {
  127770. name: string;
  127771. shader: string;
  127772. };
  127773. }
  127774. declare module BABYLON {
  127775. /**
  127776. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  127777. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  127778. * As an example, all you have to do is to create the post-process:
  127779. * var mb = new BABYLON.MotionBlurPostProcess(
  127780. * 'mb', // The name of the effect.
  127781. * scene, // The scene containing the objects to blur according to their velocity.
  127782. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  127783. * camera // The camera to apply the render pass to.
  127784. * );
  127785. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  127786. */
  127787. export class MotionBlurPostProcess extends PostProcess {
  127788. /**
  127789. * Defines how much the image is blurred by the movement. Default value is equal to 1
  127790. */
  127791. motionStrength: number;
  127792. /**
  127793. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  127794. */
  127795. /**
  127796. * Sets the number of iterations to be used for motion blur quality
  127797. */
  127798. motionBlurSamples: number;
  127799. private _motionBlurSamples;
  127800. private _geometryBufferRenderer;
  127801. /**
  127802. * Creates a new instance MotionBlurPostProcess
  127803. * @param name The name of the effect.
  127804. * @param scene The scene containing the objects to blur according to their velocity.
  127805. * @param options The required width/height ratio to downsize to before computing the render pass.
  127806. * @param camera The camera to apply the render pass to.
  127807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127808. * @param engine The engine which the post process will be applied. (default: current engine)
  127809. * @param reusable If the post process can be reused on the same frame. (default: false)
  127810. * @param textureType Type of textures used when performing the post process. (default: 0)
  127811. * @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)
  127812. */
  127813. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127814. /**
  127815. * Excludes the given skinned mesh from computing bones velocities.
  127816. * 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.
  127817. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  127818. */
  127819. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127820. /**
  127821. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  127822. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  127823. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  127824. */
  127825. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127826. /**
  127827. * Disposes the post process.
  127828. * @param camera The camera to dispose the post process on.
  127829. */
  127830. dispose(camera?: Camera): void;
  127831. }
  127832. }
  127833. declare module BABYLON {
  127834. /** @hidden */
  127835. export var refractionPixelShader: {
  127836. name: string;
  127837. shader: string;
  127838. };
  127839. }
  127840. declare module BABYLON {
  127841. /**
  127842. * Post process which applies a refractin texture
  127843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127844. */
  127845. export class RefractionPostProcess extends PostProcess {
  127846. /** the base color of the refraction (used to taint the rendering) */
  127847. color: Color3;
  127848. /** simulated refraction depth */
  127849. depth: number;
  127850. /** the coefficient of the base color (0 to remove base color tainting) */
  127851. colorLevel: number;
  127852. private _refTexture;
  127853. private _ownRefractionTexture;
  127854. /**
  127855. * Gets or sets the refraction texture
  127856. * Please note that you are responsible for disposing the texture if you set it manually
  127857. */
  127858. refractionTexture: Texture;
  127859. /**
  127860. * Initializes the RefractionPostProcess
  127861. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127862. * @param name The name of the effect.
  127863. * @param refractionTextureUrl Url of the refraction texture to use
  127864. * @param color the base color of the refraction (used to taint the rendering)
  127865. * @param depth simulated refraction depth
  127866. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127867. * @param camera The camera to apply the render pass to.
  127868. * @param options The required width/height ratio to downsize to before computing the render pass.
  127869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127870. * @param engine The engine which the post process will be applied. (default: current engine)
  127871. * @param reusable If the post process can be reused on the same frame. (default: false)
  127872. */
  127873. constructor(name: string, refractionTextureUrl: string,
  127874. /** the base color of the refraction (used to taint the rendering) */
  127875. color: Color3,
  127876. /** simulated refraction depth */
  127877. depth: number,
  127878. /** the coefficient of the base color (0 to remove base color tainting) */
  127879. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127880. /**
  127881. * Disposes of the post process
  127882. * @param camera Camera to dispose post process on
  127883. */
  127884. dispose(camera: Camera): void;
  127885. }
  127886. }
  127887. declare module BABYLON {
  127888. /** @hidden */
  127889. export var sharpenPixelShader: {
  127890. name: string;
  127891. shader: string;
  127892. };
  127893. }
  127894. declare module BABYLON {
  127895. /**
  127896. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127897. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127898. */
  127899. export class SharpenPostProcess extends PostProcess {
  127900. /**
  127901. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127902. */
  127903. colorAmount: number;
  127904. /**
  127905. * How much sharpness should be applied (default: 0.3)
  127906. */
  127907. edgeAmount: number;
  127908. /**
  127909. * Creates a new instance ConvolutionPostProcess
  127910. * @param name The name of the effect.
  127911. * @param options The required width/height ratio to downsize to before computing the render pass.
  127912. * @param camera The camera to apply the render pass to.
  127913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127914. * @param engine The engine which the post process will be applied. (default: current engine)
  127915. * @param reusable If the post process can be reused on the same frame. (default: false)
  127916. * @param textureType Type of textures used when performing the post process. (default: 0)
  127917. * @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)
  127918. */
  127919. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127920. }
  127921. }
  127922. declare module BABYLON {
  127923. /**
  127924. * PostProcessRenderPipeline
  127925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127926. */
  127927. export class PostProcessRenderPipeline {
  127928. private engine;
  127929. private _renderEffects;
  127930. private _renderEffectsForIsolatedPass;
  127931. /**
  127932. * List of inspectable custom properties (used by the Inspector)
  127933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  127934. */
  127935. inspectableCustomProperties: IInspectable[];
  127936. /**
  127937. * @hidden
  127938. */
  127939. protected _cameras: Camera[];
  127940. /** @hidden */
  127941. _name: string;
  127942. /**
  127943. * Gets pipeline name
  127944. */
  127945. readonly name: string;
  127946. /**
  127947. * Initializes a PostProcessRenderPipeline
  127948. * @param engine engine to add the pipeline to
  127949. * @param name name of the pipeline
  127950. */
  127951. constructor(engine: Engine, name: string);
  127952. /**
  127953. * Gets the class name
  127954. * @returns "PostProcessRenderPipeline"
  127955. */
  127956. getClassName(): string;
  127957. /**
  127958. * If all the render effects in the pipeline are supported
  127959. */
  127960. readonly isSupported: boolean;
  127961. /**
  127962. * Adds an effect to the pipeline
  127963. * @param renderEffect the effect to add
  127964. */
  127965. addEffect(renderEffect: PostProcessRenderEffect): void;
  127966. /** @hidden */
  127967. _rebuild(): void;
  127968. /** @hidden */
  127969. _enableEffect(renderEffectName: string, cameras: Camera): void;
  127970. /** @hidden */
  127971. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  127972. /** @hidden */
  127973. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127974. /** @hidden */
  127975. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127976. /** @hidden */
  127977. _attachCameras(cameras: Camera, unique: boolean): void;
  127978. /** @hidden */
  127979. _attachCameras(cameras: Camera[], unique: boolean): void;
  127980. /** @hidden */
  127981. _detachCameras(cameras: Camera): void;
  127982. /** @hidden */
  127983. _detachCameras(cameras: Nullable<Camera[]>): void;
  127984. /** @hidden */
  127985. _update(): void;
  127986. /** @hidden */
  127987. _reset(): void;
  127988. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  127989. /**
  127990. * Disposes of the pipeline
  127991. */
  127992. dispose(): void;
  127993. }
  127994. }
  127995. declare module BABYLON {
  127996. /**
  127997. * PostProcessRenderPipelineManager class
  127998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127999. */
  128000. export class PostProcessRenderPipelineManager {
  128001. private _renderPipelines;
  128002. /**
  128003. * Initializes a PostProcessRenderPipelineManager
  128004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128005. */
  128006. constructor();
  128007. /**
  128008. * Gets the list of supported render pipelines
  128009. */
  128010. readonly supportedPipelines: PostProcessRenderPipeline[];
  128011. /**
  128012. * Adds a pipeline to the manager
  128013. * @param renderPipeline The pipeline to add
  128014. */
  128015. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  128016. /**
  128017. * Attaches a camera to the pipeline
  128018. * @param renderPipelineName The name of the pipeline to attach to
  128019. * @param cameras the camera to attach
  128020. * @param unique if the camera can be attached multiple times to the pipeline
  128021. */
  128022. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  128023. /**
  128024. * Detaches a camera from the pipeline
  128025. * @param renderPipelineName The name of the pipeline to detach from
  128026. * @param cameras the camera to detach
  128027. */
  128028. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  128029. /**
  128030. * Enables an effect by name on a pipeline
  128031. * @param renderPipelineName the name of the pipeline to enable the effect in
  128032. * @param renderEffectName the name of the effect to enable
  128033. * @param cameras the cameras that the effect should be enabled on
  128034. */
  128035. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128036. /**
  128037. * Disables an effect by name on a pipeline
  128038. * @param renderPipelineName the name of the pipeline to disable the effect in
  128039. * @param renderEffectName the name of the effect to disable
  128040. * @param cameras the cameras that the effect should be disabled on
  128041. */
  128042. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128043. /**
  128044. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  128045. */
  128046. update(): void;
  128047. /** @hidden */
  128048. _rebuild(): void;
  128049. /**
  128050. * Disposes of the manager and pipelines
  128051. */
  128052. dispose(): void;
  128053. }
  128054. }
  128055. declare module BABYLON {
  128056. interface Scene {
  128057. /** @hidden (Backing field) */
  128058. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128059. /**
  128060. * Gets the postprocess render pipeline manager
  128061. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128062. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128063. */
  128064. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128065. }
  128066. /**
  128067. * Defines the Render Pipeline scene component responsible to rendering pipelines
  128068. */
  128069. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  128070. /**
  128071. * The component name helpfull to identify the component in the list of scene components.
  128072. */
  128073. readonly name: string;
  128074. /**
  128075. * The scene the component belongs to.
  128076. */
  128077. scene: Scene;
  128078. /**
  128079. * Creates a new instance of the component for the given scene
  128080. * @param scene Defines the scene to register the component in
  128081. */
  128082. constructor(scene: Scene);
  128083. /**
  128084. * Registers the component in a given scene
  128085. */
  128086. register(): void;
  128087. /**
  128088. * Rebuilds the elements related to this component in case of
  128089. * context lost for instance.
  128090. */
  128091. rebuild(): void;
  128092. /**
  128093. * Disposes the component and the associated ressources
  128094. */
  128095. dispose(): void;
  128096. private _gatherRenderTargets;
  128097. }
  128098. }
  128099. declare module BABYLON {
  128100. /**
  128101. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  128102. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128103. */
  128104. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128105. private _scene;
  128106. private _camerasToBeAttached;
  128107. /**
  128108. * ID of the sharpen post process,
  128109. */
  128110. private readonly SharpenPostProcessId;
  128111. /**
  128112. * @ignore
  128113. * ID of the image processing post process;
  128114. */
  128115. readonly ImageProcessingPostProcessId: string;
  128116. /**
  128117. * @ignore
  128118. * ID of the Fast Approximate Anti-Aliasing post process;
  128119. */
  128120. readonly FxaaPostProcessId: string;
  128121. /**
  128122. * ID of the chromatic aberration post process,
  128123. */
  128124. private readonly ChromaticAberrationPostProcessId;
  128125. /**
  128126. * ID of the grain post process
  128127. */
  128128. private readonly GrainPostProcessId;
  128129. /**
  128130. * Sharpen post process which will apply a sharpen convolution to enhance edges
  128131. */
  128132. sharpen: SharpenPostProcess;
  128133. private _sharpenEffect;
  128134. private bloom;
  128135. /**
  128136. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  128137. */
  128138. depthOfField: DepthOfFieldEffect;
  128139. /**
  128140. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128141. */
  128142. fxaa: FxaaPostProcess;
  128143. /**
  128144. * Image post processing pass used to perform operations such as tone mapping or color grading.
  128145. */
  128146. imageProcessing: ImageProcessingPostProcess;
  128147. /**
  128148. * Chromatic aberration post process which will shift rgb colors in the image
  128149. */
  128150. chromaticAberration: ChromaticAberrationPostProcess;
  128151. private _chromaticAberrationEffect;
  128152. /**
  128153. * Grain post process which add noise to the image
  128154. */
  128155. grain: GrainPostProcess;
  128156. private _grainEffect;
  128157. /**
  128158. * Glow post process which adds a glow to emissive areas of the image
  128159. */
  128160. private _glowLayer;
  128161. /**
  128162. * Animations which can be used to tweak settings over a period of time
  128163. */
  128164. animations: Animation[];
  128165. private _imageProcessingConfigurationObserver;
  128166. private _sharpenEnabled;
  128167. private _bloomEnabled;
  128168. private _depthOfFieldEnabled;
  128169. private _depthOfFieldBlurLevel;
  128170. private _fxaaEnabled;
  128171. private _imageProcessingEnabled;
  128172. private _defaultPipelineTextureType;
  128173. private _bloomScale;
  128174. private _chromaticAberrationEnabled;
  128175. private _grainEnabled;
  128176. private _buildAllowed;
  128177. /**
  128178. * Gets active scene
  128179. */
  128180. readonly scene: Scene;
  128181. /**
  128182. * Enable or disable the sharpen process from the pipeline
  128183. */
  128184. sharpenEnabled: boolean;
  128185. private _resizeObserver;
  128186. private _hardwareScaleLevel;
  128187. private _bloomKernel;
  128188. /**
  128189. * Specifies the size of the bloom blur kernel, relative to the final output size
  128190. */
  128191. bloomKernel: number;
  128192. /**
  128193. * Specifies the weight of the bloom in the final rendering
  128194. */
  128195. private _bloomWeight;
  128196. /**
  128197. * Specifies the luma threshold for the area that will be blurred by the bloom
  128198. */
  128199. private _bloomThreshold;
  128200. private _hdr;
  128201. /**
  128202. * The strength of the bloom.
  128203. */
  128204. bloomWeight: number;
  128205. /**
  128206. * The strength of the bloom.
  128207. */
  128208. bloomThreshold: number;
  128209. /**
  128210. * The scale of the bloom, lower value will provide better performance.
  128211. */
  128212. bloomScale: number;
  128213. /**
  128214. * Enable or disable the bloom from the pipeline
  128215. */
  128216. bloomEnabled: boolean;
  128217. private _rebuildBloom;
  128218. /**
  128219. * If the depth of field is enabled.
  128220. */
  128221. depthOfFieldEnabled: boolean;
  128222. /**
  128223. * Blur level of the depth of field effect. (Higher blur will effect performance)
  128224. */
  128225. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  128226. /**
  128227. * If the anti aliasing is enabled.
  128228. */
  128229. fxaaEnabled: boolean;
  128230. private _samples;
  128231. /**
  128232. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128233. */
  128234. samples: number;
  128235. /**
  128236. * If image processing is enabled.
  128237. */
  128238. imageProcessingEnabled: boolean;
  128239. /**
  128240. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  128241. */
  128242. glowLayerEnabled: boolean;
  128243. /**
  128244. * Gets the glow layer (or null if not defined)
  128245. */
  128246. readonly glowLayer: Nullable<GlowLayer>;
  128247. /**
  128248. * Enable or disable the chromaticAberration process from the pipeline
  128249. */
  128250. chromaticAberrationEnabled: boolean;
  128251. /**
  128252. * Enable or disable the grain process from the pipeline
  128253. */
  128254. grainEnabled: boolean;
  128255. /**
  128256. * @constructor
  128257. * @param name - The rendering pipeline name (default: "")
  128258. * @param hdr - If high dynamic range textures should be used (default: true)
  128259. * @param scene - The scene linked to this pipeline (default: the last created scene)
  128260. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  128261. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  128262. */
  128263. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  128264. /**
  128265. * Get the class name
  128266. * @returns "DefaultRenderingPipeline"
  128267. */
  128268. getClassName(): string;
  128269. /**
  128270. * Force the compilation of the entire pipeline.
  128271. */
  128272. prepare(): void;
  128273. private _hasCleared;
  128274. private _prevPostProcess;
  128275. private _prevPrevPostProcess;
  128276. private _setAutoClearAndTextureSharing;
  128277. private _depthOfFieldSceneObserver;
  128278. private _buildPipeline;
  128279. private _disposePostProcesses;
  128280. /**
  128281. * Adds a camera to the pipeline
  128282. * @param camera the camera to be added
  128283. */
  128284. addCamera(camera: Camera): void;
  128285. /**
  128286. * Removes a camera from the pipeline
  128287. * @param camera the camera to remove
  128288. */
  128289. removeCamera(camera: Camera): void;
  128290. /**
  128291. * Dispose of the pipeline and stop all post processes
  128292. */
  128293. dispose(): void;
  128294. /**
  128295. * Serialize the rendering pipeline (Used when exporting)
  128296. * @returns the serialized object
  128297. */
  128298. serialize(): any;
  128299. /**
  128300. * Parse the serialized pipeline
  128301. * @param source Source pipeline.
  128302. * @param scene The scene to load the pipeline to.
  128303. * @param rootUrl The URL of the serialized pipeline.
  128304. * @returns An instantiated pipeline from the serialized object.
  128305. */
  128306. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  128307. }
  128308. }
  128309. declare module BABYLON {
  128310. /** @hidden */
  128311. export var lensHighlightsPixelShader: {
  128312. name: string;
  128313. shader: string;
  128314. };
  128315. }
  128316. declare module BABYLON {
  128317. /** @hidden */
  128318. export var depthOfFieldPixelShader: {
  128319. name: string;
  128320. shader: string;
  128321. };
  128322. }
  128323. declare module BABYLON {
  128324. /**
  128325. * BABYLON.JS Chromatic Aberration GLSL Shader
  128326. * Author: Olivier Guyot
  128327. * Separates very slightly R, G and B colors on the edges of the screen
  128328. * Inspired by Francois Tarlier & Martins Upitis
  128329. */
  128330. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  128331. /**
  128332. * @ignore
  128333. * The chromatic aberration PostProcess id in the pipeline
  128334. */
  128335. LensChromaticAberrationEffect: string;
  128336. /**
  128337. * @ignore
  128338. * The highlights enhancing PostProcess id in the pipeline
  128339. */
  128340. HighlightsEnhancingEffect: string;
  128341. /**
  128342. * @ignore
  128343. * The depth-of-field PostProcess id in the pipeline
  128344. */
  128345. LensDepthOfFieldEffect: string;
  128346. private _scene;
  128347. private _depthTexture;
  128348. private _grainTexture;
  128349. private _chromaticAberrationPostProcess;
  128350. private _highlightsPostProcess;
  128351. private _depthOfFieldPostProcess;
  128352. private _edgeBlur;
  128353. private _grainAmount;
  128354. private _chromaticAberration;
  128355. private _distortion;
  128356. private _highlightsGain;
  128357. private _highlightsThreshold;
  128358. private _dofDistance;
  128359. private _dofAperture;
  128360. private _dofDarken;
  128361. private _dofPentagon;
  128362. private _blurNoise;
  128363. /**
  128364. * @constructor
  128365. *
  128366. * Effect parameters are as follow:
  128367. * {
  128368. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128369. * edge_blur: number; // from 0 to x (1 for realism)
  128370. * distortion: number; // from 0 to x (1 for realism)
  128371. * grain_amount: number; // from 0 to 1
  128372. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128373. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128374. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128375. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128376. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128377. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128378. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128379. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128380. * }
  128381. * Note: if an effect parameter is unset, effect is disabled
  128382. *
  128383. * @param name The rendering pipeline name
  128384. * @param parameters - An object containing all parameters (see above)
  128385. * @param scene The scene linked to this pipeline
  128386. * @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)
  128387. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128388. */
  128389. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128390. /**
  128391. * Get the class name
  128392. * @returns "LensRenderingPipeline"
  128393. */
  128394. getClassName(): string;
  128395. /**
  128396. * Gets associated scene
  128397. */
  128398. readonly scene: Scene;
  128399. /**
  128400. * Gets or sets the edge blur
  128401. */
  128402. edgeBlur: number;
  128403. /**
  128404. * Gets or sets the grain amount
  128405. */
  128406. grainAmount: number;
  128407. /**
  128408. * Gets or sets the chromatic aberration amount
  128409. */
  128410. chromaticAberration: number;
  128411. /**
  128412. * Gets or sets the depth of field aperture
  128413. */
  128414. dofAperture: number;
  128415. /**
  128416. * Gets or sets the edge distortion
  128417. */
  128418. edgeDistortion: number;
  128419. /**
  128420. * Gets or sets the depth of field distortion
  128421. */
  128422. dofDistortion: number;
  128423. /**
  128424. * Gets or sets the darken out of focus amount
  128425. */
  128426. darkenOutOfFocus: number;
  128427. /**
  128428. * Gets or sets a boolean indicating if blur noise is enabled
  128429. */
  128430. blurNoise: boolean;
  128431. /**
  128432. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128433. */
  128434. pentagonBokeh: boolean;
  128435. /**
  128436. * Gets or sets the highlight grain amount
  128437. */
  128438. highlightsGain: number;
  128439. /**
  128440. * Gets or sets the highlight threshold
  128441. */
  128442. highlightsThreshold: number;
  128443. /**
  128444. * Sets the amount of blur at the edges
  128445. * @param amount blur amount
  128446. */
  128447. setEdgeBlur(amount: number): void;
  128448. /**
  128449. * Sets edge blur to 0
  128450. */
  128451. disableEdgeBlur(): void;
  128452. /**
  128453. * Sets the amout of grain
  128454. * @param amount Amount of grain
  128455. */
  128456. setGrainAmount(amount: number): void;
  128457. /**
  128458. * Set grain amount to 0
  128459. */
  128460. disableGrain(): void;
  128461. /**
  128462. * Sets the chromatic aberration amount
  128463. * @param amount amount of chromatic aberration
  128464. */
  128465. setChromaticAberration(amount: number): void;
  128466. /**
  128467. * Sets chromatic aberration amount to 0
  128468. */
  128469. disableChromaticAberration(): void;
  128470. /**
  128471. * Sets the EdgeDistortion amount
  128472. * @param amount amount of EdgeDistortion
  128473. */
  128474. setEdgeDistortion(amount: number): void;
  128475. /**
  128476. * Sets edge distortion to 0
  128477. */
  128478. disableEdgeDistortion(): void;
  128479. /**
  128480. * Sets the FocusDistance amount
  128481. * @param amount amount of FocusDistance
  128482. */
  128483. setFocusDistance(amount: number): void;
  128484. /**
  128485. * Disables depth of field
  128486. */
  128487. disableDepthOfField(): void;
  128488. /**
  128489. * Sets the Aperture amount
  128490. * @param amount amount of Aperture
  128491. */
  128492. setAperture(amount: number): void;
  128493. /**
  128494. * Sets the DarkenOutOfFocus amount
  128495. * @param amount amount of DarkenOutOfFocus
  128496. */
  128497. setDarkenOutOfFocus(amount: number): void;
  128498. private _pentagonBokehIsEnabled;
  128499. /**
  128500. * Creates a pentagon bokeh effect
  128501. */
  128502. enablePentagonBokeh(): void;
  128503. /**
  128504. * Disables the pentagon bokeh effect
  128505. */
  128506. disablePentagonBokeh(): void;
  128507. /**
  128508. * Enables noise blur
  128509. */
  128510. enableNoiseBlur(): void;
  128511. /**
  128512. * Disables noise blur
  128513. */
  128514. disableNoiseBlur(): void;
  128515. /**
  128516. * Sets the HighlightsGain amount
  128517. * @param amount amount of HighlightsGain
  128518. */
  128519. setHighlightsGain(amount: number): void;
  128520. /**
  128521. * Sets the HighlightsThreshold amount
  128522. * @param amount amount of HighlightsThreshold
  128523. */
  128524. setHighlightsThreshold(amount: number): void;
  128525. /**
  128526. * Disables highlights
  128527. */
  128528. disableHighlights(): void;
  128529. /**
  128530. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128531. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128532. */
  128533. dispose(disableDepthRender?: boolean): void;
  128534. private _createChromaticAberrationPostProcess;
  128535. private _createHighlightsPostProcess;
  128536. private _createDepthOfFieldPostProcess;
  128537. private _createGrainTexture;
  128538. }
  128539. }
  128540. declare module BABYLON {
  128541. /** @hidden */
  128542. export var ssao2PixelShader: {
  128543. name: string;
  128544. shader: string;
  128545. };
  128546. }
  128547. declare module BABYLON {
  128548. /** @hidden */
  128549. export var ssaoCombinePixelShader: {
  128550. name: string;
  128551. shader: string;
  128552. };
  128553. }
  128554. declare module BABYLON {
  128555. /**
  128556. * Render pipeline to produce ssao effect
  128557. */
  128558. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128559. /**
  128560. * @ignore
  128561. * The PassPostProcess id in the pipeline that contains the original scene color
  128562. */
  128563. SSAOOriginalSceneColorEffect: string;
  128564. /**
  128565. * @ignore
  128566. * The SSAO PostProcess id in the pipeline
  128567. */
  128568. SSAORenderEffect: string;
  128569. /**
  128570. * @ignore
  128571. * The horizontal blur PostProcess id in the pipeline
  128572. */
  128573. SSAOBlurHRenderEffect: string;
  128574. /**
  128575. * @ignore
  128576. * The vertical blur PostProcess id in the pipeline
  128577. */
  128578. SSAOBlurVRenderEffect: string;
  128579. /**
  128580. * @ignore
  128581. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128582. */
  128583. SSAOCombineRenderEffect: string;
  128584. /**
  128585. * The output strength of the SSAO post-process. Default value is 1.0.
  128586. */
  128587. totalStrength: number;
  128588. /**
  128589. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128590. */
  128591. maxZ: number;
  128592. /**
  128593. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128594. */
  128595. minZAspect: number;
  128596. private _samples;
  128597. /**
  128598. * Number of samples used for the SSAO calculations. Default value is 8
  128599. */
  128600. samples: number;
  128601. private _textureSamples;
  128602. /**
  128603. * Number of samples to use for antialiasing
  128604. */
  128605. textureSamples: number;
  128606. /**
  128607. * Ratio object used for SSAO ratio and blur ratio
  128608. */
  128609. private _ratio;
  128610. /**
  128611. * Dynamically generated sphere sampler.
  128612. */
  128613. private _sampleSphere;
  128614. /**
  128615. * Blur filter offsets
  128616. */
  128617. private _samplerOffsets;
  128618. private _expensiveBlur;
  128619. /**
  128620. * If bilateral blur should be used
  128621. */
  128622. expensiveBlur: boolean;
  128623. /**
  128624. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128625. */
  128626. radius: number;
  128627. /**
  128628. * The base color of the SSAO post-process
  128629. * The final result is "base + ssao" between [0, 1]
  128630. */
  128631. base: number;
  128632. /**
  128633. * Support test.
  128634. */
  128635. static readonly IsSupported: boolean;
  128636. private _scene;
  128637. private _depthTexture;
  128638. private _normalTexture;
  128639. private _randomTexture;
  128640. private _originalColorPostProcess;
  128641. private _ssaoPostProcess;
  128642. private _blurHPostProcess;
  128643. private _blurVPostProcess;
  128644. private _ssaoCombinePostProcess;
  128645. private _firstUpdate;
  128646. /**
  128647. * Gets active scene
  128648. */
  128649. readonly scene: Scene;
  128650. /**
  128651. * @constructor
  128652. * @param name The rendering pipeline name
  128653. * @param scene The scene linked to this pipeline
  128654. * @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 }
  128655. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128656. */
  128657. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128658. /**
  128659. * Get the class name
  128660. * @returns "SSAO2RenderingPipeline"
  128661. */
  128662. getClassName(): string;
  128663. /**
  128664. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128665. */
  128666. dispose(disableGeometryBufferRenderer?: boolean): void;
  128667. private _createBlurPostProcess;
  128668. /** @hidden */
  128669. _rebuild(): void;
  128670. private _bits;
  128671. private _radicalInverse_VdC;
  128672. private _hammersley;
  128673. private _hemisphereSample_uniform;
  128674. private _generateHemisphere;
  128675. private _createSSAOPostProcess;
  128676. private _createSSAOCombinePostProcess;
  128677. private _createRandomTexture;
  128678. /**
  128679. * Serialize the rendering pipeline (Used when exporting)
  128680. * @returns the serialized object
  128681. */
  128682. serialize(): any;
  128683. /**
  128684. * Parse the serialized pipeline
  128685. * @param source Source pipeline.
  128686. * @param scene The scene to load the pipeline to.
  128687. * @param rootUrl The URL of the serialized pipeline.
  128688. * @returns An instantiated pipeline from the serialized object.
  128689. */
  128690. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  128691. }
  128692. }
  128693. declare module BABYLON {
  128694. /** @hidden */
  128695. export var ssaoPixelShader: {
  128696. name: string;
  128697. shader: string;
  128698. };
  128699. }
  128700. declare module BABYLON {
  128701. /**
  128702. * Render pipeline to produce ssao effect
  128703. */
  128704. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  128705. /**
  128706. * @ignore
  128707. * The PassPostProcess id in the pipeline that contains the original scene color
  128708. */
  128709. SSAOOriginalSceneColorEffect: string;
  128710. /**
  128711. * @ignore
  128712. * The SSAO PostProcess id in the pipeline
  128713. */
  128714. SSAORenderEffect: string;
  128715. /**
  128716. * @ignore
  128717. * The horizontal blur PostProcess id in the pipeline
  128718. */
  128719. SSAOBlurHRenderEffect: string;
  128720. /**
  128721. * @ignore
  128722. * The vertical blur PostProcess id in the pipeline
  128723. */
  128724. SSAOBlurVRenderEffect: string;
  128725. /**
  128726. * @ignore
  128727. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128728. */
  128729. SSAOCombineRenderEffect: string;
  128730. /**
  128731. * The output strength of the SSAO post-process. Default value is 1.0.
  128732. */
  128733. totalStrength: number;
  128734. /**
  128735. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  128736. */
  128737. radius: number;
  128738. /**
  128739. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  128740. * Must not be equal to fallOff and superior to fallOff.
  128741. * Default value is 0.0075
  128742. */
  128743. area: number;
  128744. /**
  128745. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  128746. * Must not be equal to area and inferior to area.
  128747. * Default value is 0.000001
  128748. */
  128749. fallOff: number;
  128750. /**
  128751. * The base color of the SSAO post-process
  128752. * The final result is "base + ssao" between [0, 1]
  128753. */
  128754. base: number;
  128755. private _scene;
  128756. private _depthTexture;
  128757. private _randomTexture;
  128758. private _originalColorPostProcess;
  128759. private _ssaoPostProcess;
  128760. private _blurHPostProcess;
  128761. private _blurVPostProcess;
  128762. private _ssaoCombinePostProcess;
  128763. private _firstUpdate;
  128764. /**
  128765. * Gets active scene
  128766. */
  128767. readonly scene: Scene;
  128768. /**
  128769. * @constructor
  128770. * @param name - The rendering pipeline name
  128771. * @param scene - The scene linked to this pipeline
  128772. * @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 }
  128773. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  128774. */
  128775. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128776. /**
  128777. * Get the class name
  128778. * @returns "SSAORenderingPipeline"
  128779. */
  128780. getClassName(): string;
  128781. /**
  128782. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128783. */
  128784. dispose(disableDepthRender?: boolean): void;
  128785. private _createBlurPostProcess;
  128786. /** @hidden */
  128787. _rebuild(): void;
  128788. private _createSSAOPostProcess;
  128789. private _createSSAOCombinePostProcess;
  128790. private _createRandomTexture;
  128791. }
  128792. }
  128793. declare module BABYLON {
  128794. /** @hidden */
  128795. export var standardPixelShader: {
  128796. name: string;
  128797. shader: string;
  128798. };
  128799. }
  128800. declare module BABYLON {
  128801. /**
  128802. * Standard rendering pipeline
  128803. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128804. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  128805. */
  128806. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128807. /**
  128808. * Public members
  128809. */
  128810. /**
  128811. * Post-process which contains the original scene color before the pipeline applies all the effects
  128812. */
  128813. originalPostProcess: Nullable<PostProcess>;
  128814. /**
  128815. * Post-process used to down scale an image x4
  128816. */
  128817. downSampleX4PostProcess: Nullable<PostProcess>;
  128818. /**
  128819. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  128820. */
  128821. brightPassPostProcess: Nullable<PostProcess>;
  128822. /**
  128823. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  128824. */
  128825. blurHPostProcesses: PostProcess[];
  128826. /**
  128827. * Post-process array storing all the vertical blur post-processes used by the pipeline
  128828. */
  128829. blurVPostProcesses: PostProcess[];
  128830. /**
  128831. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  128832. */
  128833. textureAdderPostProcess: Nullable<PostProcess>;
  128834. /**
  128835. * Post-process used to create volumetric lighting effect
  128836. */
  128837. volumetricLightPostProcess: Nullable<PostProcess>;
  128838. /**
  128839. * Post-process used to smooth the previous volumetric light post-process on the X axis
  128840. */
  128841. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  128842. /**
  128843. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  128844. */
  128845. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  128846. /**
  128847. * Post-process used to merge the volumetric light effect and the real scene color
  128848. */
  128849. volumetricLightMergePostProces: Nullable<PostProcess>;
  128850. /**
  128851. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  128852. */
  128853. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  128854. /**
  128855. * Base post-process used to calculate the average luminance of the final image for HDR
  128856. */
  128857. luminancePostProcess: Nullable<PostProcess>;
  128858. /**
  128859. * Post-processes used to create down sample post-processes in order to get
  128860. * the average luminance of the final image for HDR
  128861. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  128862. */
  128863. luminanceDownSamplePostProcesses: PostProcess[];
  128864. /**
  128865. * Post-process used to create a HDR effect (light adaptation)
  128866. */
  128867. hdrPostProcess: Nullable<PostProcess>;
  128868. /**
  128869. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  128870. */
  128871. textureAdderFinalPostProcess: Nullable<PostProcess>;
  128872. /**
  128873. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  128874. */
  128875. lensFlareFinalPostProcess: Nullable<PostProcess>;
  128876. /**
  128877. * Post-process used to merge the final HDR post-process and the real scene color
  128878. */
  128879. hdrFinalPostProcess: Nullable<PostProcess>;
  128880. /**
  128881. * Post-process used to create a lens flare effect
  128882. */
  128883. lensFlarePostProcess: Nullable<PostProcess>;
  128884. /**
  128885. * Post-process that merges the result of the lens flare post-process and the real scene color
  128886. */
  128887. lensFlareComposePostProcess: Nullable<PostProcess>;
  128888. /**
  128889. * Post-process used to create a motion blur effect
  128890. */
  128891. motionBlurPostProcess: Nullable<PostProcess>;
  128892. /**
  128893. * Post-process used to create a depth of field effect
  128894. */
  128895. depthOfFieldPostProcess: Nullable<PostProcess>;
  128896. /**
  128897. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128898. */
  128899. fxaaPostProcess: Nullable<FxaaPostProcess>;
  128900. /**
  128901. * Represents the brightness threshold in order to configure the illuminated surfaces
  128902. */
  128903. brightThreshold: number;
  128904. /**
  128905. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  128906. */
  128907. blurWidth: number;
  128908. /**
  128909. * Sets if the blur for highlighted surfaces must be only horizontal
  128910. */
  128911. horizontalBlur: boolean;
  128912. /**
  128913. * Gets the overall exposure used by the pipeline
  128914. */
  128915. /**
  128916. * Sets the overall exposure used by the pipeline
  128917. */
  128918. exposure: number;
  128919. /**
  128920. * Texture used typically to simulate "dirty" on camera lens
  128921. */
  128922. lensTexture: Nullable<Texture>;
  128923. /**
  128924. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  128925. */
  128926. volumetricLightCoefficient: number;
  128927. /**
  128928. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  128929. */
  128930. volumetricLightPower: number;
  128931. /**
  128932. * Used the set the blur intensity to smooth the volumetric lights
  128933. */
  128934. volumetricLightBlurScale: number;
  128935. /**
  128936. * Light (spot or directional) used to generate the volumetric lights rays
  128937. * The source light must have a shadow generate so the pipeline can get its
  128938. * depth map
  128939. */
  128940. sourceLight: Nullable<SpotLight | DirectionalLight>;
  128941. /**
  128942. * For eye adaptation, represents the minimum luminance the eye can see
  128943. */
  128944. hdrMinimumLuminance: number;
  128945. /**
  128946. * For eye adaptation, represents the decrease luminance speed
  128947. */
  128948. hdrDecreaseRate: number;
  128949. /**
  128950. * For eye adaptation, represents the increase luminance speed
  128951. */
  128952. hdrIncreaseRate: number;
  128953. /**
  128954. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128955. */
  128956. /**
  128957. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128958. */
  128959. hdrAutoExposure: boolean;
  128960. /**
  128961. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  128962. */
  128963. lensColorTexture: Nullable<Texture>;
  128964. /**
  128965. * The overall strengh for the lens flare effect
  128966. */
  128967. lensFlareStrength: number;
  128968. /**
  128969. * Dispersion coefficient for lens flare ghosts
  128970. */
  128971. lensFlareGhostDispersal: number;
  128972. /**
  128973. * Main lens flare halo width
  128974. */
  128975. lensFlareHaloWidth: number;
  128976. /**
  128977. * Based on the lens distortion effect, defines how much the lens flare result
  128978. * is distorted
  128979. */
  128980. lensFlareDistortionStrength: number;
  128981. /**
  128982. * Configures the blur intensity used for for lens flare (halo)
  128983. */
  128984. lensFlareBlurWidth: number;
  128985. /**
  128986. * Lens star texture must be used to simulate rays on the flares and is available
  128987. * in the documentation
  128988. */
  128989. lensStarTexture: Nullable<Texture>;
  128990. /**
  128991. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  128992. * flare effect by taking account of the dirt texture
  128993. */
  128994. lensFlareDirtTexture: Nullable<Texture>;
  128995. /**
  128996. * Represents the focal length for the depth of field effect
  128997. */
  128998. depthOfFieldDistance: number;
  128999. /**
  129000. * Represents the blur intensity for the blurred part of the depth of field effect
  129001. */
  129002. depthOfFieldBlurWidth: number;
  129003. /**
  129004. * Gets how much the image is blurred by the movement while using the motion blur post-process
  129005. */
  129006. /**
  129007. * Sets how much the image is blurred by the movement while using the motion blur post-process
  129008. */
  129009. motionStrength: number;
  129010. /**
  129011. * Gets wether or not the motion blur post-process is object based or screen based.
  129012. */
  129013. /**
  129014. * Sets wether or not the motion blur post-process should be object based or screen based
  129015. */
  129016. objectBasedMotionBlur: boolean;
  129017. /**
  129018. * List of animations for the pipeline (IAnimatable implementation)
  129019. */
  129020. animations: Animation[];
  129021. /**
  129022. * Private members
  129023. */
  129024. private _scene;
  129025. private _currentDepthOfFieldSource;
  129026. private _basePostProcess;
  129027. private _fixedExposure;
  129028. private _currentExposure;
  129029. private _hdrAutoExposure;
  129030. private _hdrCurrentLuminance;
  129031. private _motionStrength;
  129032. private _isObjectBasedMotionBlur;
  129033. private _floatTextureType;
  129034. private _camerasToBeAttached;
  129035. private _ratio;
  129036. private _bloomEnabled;
  129037. private _depthOfFieldEnabled;
  129038. private _vlsEnabled;
  129039. private _lensFlareEnabled;
  129040. private _hdrEnabled;
  129041. private _motionBlurEnabled;
  129042. private _fxaaEnabled;
  129043. private _motionBlurSamples;
  129044. private _volumetricLightStepsCount;
  129045. private _samples;
  129046. /**
  129047. * @ignore
  129048. * Specifies if the bloom pipeline is enabled
  129049. */
  129050. BloomEnabled: boolean;
  129051. /**
  129052. * @ignore
  129053. * Specifies if the depth of field pipeline is enabed
  129054. */
  129055. DepthOfFieldEnabled: boolean;
  129056. /**
  129057. * @ignore
  129058. * Specifies if the lens flare pipeline is enabed
  129059. */
  129060. LensFlareEnabled: boolean;
  129061. /**
  129062. * @ignore
  129063. * Specifies if the HDR pipeline is enabled
  129064. */
  129065. HDREnabled: boolean;
  129066. /**
  129067. * @ignore
  129068. * Specifies if the volumetric lights scattering effect is enabled
  129069. */
  129070. VLSEnabled: boolean;
  129071. /**
  129072. * @ignore
  129073. * Specifies if the motion blur effect is enabled
  129074. */
  129075. MotionBlurEnabled: boolean;
  129076. /**
  129077. * Specifies if anti-aliasing is enabled
  129078. */
  129079. fxaaEnabled: boolean;
  129080. /**
  129081. * Specifies the number of steps used to calculate the volumetric lights
  129082. * Typically in interval [50, 200]
  129083. */
  129084. volumetricLightStepsCount: number;
  129085. /**
  129086. * Specifies the number of samples used for the motion blur effect
  129087. * Typically in interval [16, 64]
  129088. */
  129089. motionBlurSamples: number;
  129090. /**
  129091. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129092. */
  129093. samples: number;
  129094. /**
  129095. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129096. * @constructor
  129097. * @param name The rendering pipeline name
  129098. * @param scene The scene linked to this pipeline
  129099. * @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)
  129100. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  129101. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129102. */
  129103. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  129104. private _buildPipeline;
  129105. private _createDownSampleX4PostProcess;
  129106. private _createBrightPassPostProcess;
  129107. private _createBlurPostProcesses;
  129108. private _createTextureAdderPostProcess;
  129109. private _createVolumetricLightPostProcess;
  129110. private _createLuminancePostProcesses;
  129111. private _createHdrPostProcess;
  129112. private _createLensFlarePostProcess;
  129113. private _createDepthOfFieldPostProcess;
  129114. private _createMotionBlurPostProcess;
  129115. private _getDepthTexture;
  129116. private _disposePostProcesses;
  129117. /**
  129118. * Dispose of the pipeline and stop all post processes
  129119. */
  129120. dispose(): void;
  129121. /**
  129122. * Serialize the rendering pipeline (Used when exporting)
  129123. * @returns the serialized object
  129124. */
  129125. serialize(): any;
  129126. /**
  129127. * Parse the serialized pipeline
  129128. * @param source Source pipeline.
  129129. * @param scene The scene to load the pipeline to.
  129130. * @param rootUrl The URL of the serialized pipeline.
  129131. * @returns An instantiated pipeline from the serialized object.
  129132. */
  129133. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  129134. /**
  129135. * Luminance steps
  129136. */
  129137. static LuminanceSteps: number;
  129138. }
  129139. }
  129140. declare module BABYLON {
  129141. /** @hidden */
  129142. export var tonemapPixelShader: {
  129143. name: string;
  129144. shader: string;
  129145. };
  129146. }
  129147. declare module BABYLON {
  129148. /** Defines operator used for tonemapping */
  129149. export enum TonemappingOperator {
  129150. /** Hable */
  129151. Hable = 0,
  129152. /** Reinhard */
  129153. Reinhard = 1,
  129154. /** HejiDawson */
  129155. HejiDawson = 2,
  129156. /** Photographic */
  129157. Photographic = 3
  129158. }
  129159. /**
  129160. * Defines a post process to apply tone mapping
  129161. */
  129162. export class TonemapPostProcess extends PostProcess {
  129163. private _operator;
  129164. /** Defines the required exposure adjustement */
  129165. exposureAdjustment: number;
  129166. /**
  129167. * Creates a new TonemapPostProcess
  129168. * @param name defines the name of the postprocess
  129169. * @param _operator defines the operator to use
  129170. * @param exposureAdjustment defines the required exposure adjustement
  129171. * @param camera defines the camera to use (can be null)
  129172. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  129173. * @param engine defines the hosting engine (can be ignore if camera is set)
  129174. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129175. */
  129176. constructor(name: string, _operator: TonemappingOperator,
  129177. /** Defines the required exposure adjustement */
  129178. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  129179. }
  129180. }
  129181. declare module BABYLON {
  129182. /** @hidden */
  129183. export var depthVertexShader: {
  129184. name: string;
  129185. shader: string;
  129186. };
  129187. }
  129188. declare module BABYLON {
  129189. /** @hidden */
  129190. export var volumetricLightScatteringPixelShader: {
  129191. name: string;
  129192. shader: string;
  129193. };
  129194. }
  129195. declare module BABYLON {
  129196. /** @hidden */
  129197. export var volumetricLightScatteringPassVertexShader: {
  129198. name: string;
  129199. shader: string;
  129200. };
  129201. }
  129202. declare module BABYLON {
  129203. /** @hidden */
  129204. export var volumetricLightScatteringPassPixelShader: {
  129205. name: string;
  129206. shader: string;
  129207. };
  129208. }
  129209. declare module BABYLON {
  129210. /**
  129211. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129212. */
  129213. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129214. private _volumetricLightScatteringPass;
  129215. private _volumetricLightScatteringRTT;
  129216. private _viewPort;
  129217. private _screenCoordinates;
  129218. private _cachedDefines;
  129219. /**
  129220. * If not undefined, the mesh position is computed from the attached node position
  129221. */
  129222. attachedNode: {
  129223. position: Vector3;
  129224. };
  129225. /**
  129226. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  129227. */
  129228. customMeshPosition: Vector3;
  129229. /**
  129230. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  129231. */
  129232. useCustomMeshPosition: boolean;
  129233. /**
  129234. * If the post-process should inverse the light scattering direction
  129235. */
  129236. invert: boolean;
  129237. /**
  129238. * The internal mesh used by the post-process
  129239. */
  129240. mesh: Mesh;
  129241. /**
  129242. * @hidden
  129243. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  129244. */
  129245. useDiffuseColor: boolean;
  129246. /**
  129247. * Array containing the excluded meshes not rendered in the internal pass
  129248. */
  129249. excludedMeshes: AbstractMesh[];
  129250. /**
  129251. * Controls the overall intensity of the post-process
  129252. */
  129253. exposure: number;
  129254. /**
  129255. * Dissipates each sample's contribution in range [0, 1]
  129256. */
  129257. decay: number;
  129258. /**
  129259. * Controls the overall intensity of each sample
  129260. */
  129261. weight: number;
  129262. /**
  129263. * Controls the density of each sample
  129264. */
  129265. density: number;
  129266. /**
  129267. * @constructor
  129268. * @param name The post-process name
  129269. * @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)
  129270. * @param camera The camera that the post-process will be attached to
  129271. * @param mesh The mesh used to create the light scattering
  129272. * @param samples The post-process quality, default 100
  129273. * @param samplingModeThe post-process filtering mode
  129274. * @param engine The babylon engine
  129275. * @param reusable If the post-process is reusable
  129276. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  129277. */
  129278. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  129279. /**
  129280. * Returns the string "VolumetricLightScatteringPostProcess"
  129281. * @returns "VolumetricLightScatteringPostProcess"
  129282. */
  129283. getClassName(): string;
  129284. private _isReady;
  129285. /**
  129286. * Sets the new light position for light scattering effect
  129287. * @param position The new custom light position
  129288. */
  129289. setCustomMeshPosition(position: Vector3): void;
  129290. /**
  129291. * Returns the light position for light scattering effect
  129292. * @return Vector3 The custom light position
  129293. */
  129294. getCustomMeshPosition(): Vector3;
  129295. /**
  129296. * Disposes the internal assets and detaches the post-process from the camera
  129297. */
  129298. dispose(camera: Camera): void;
  129299. /**
  129300. * Returns the render target texture used by the post-process
  129301. * @return the render target texture used by the post-process
  129302. */
  129303. getPass(): RenderTargetTexture;
  129304. private _meshExcluded;
  129305. private _createPass;
  129306. private _updateMeshScreenCoordinates;
  129307. /**
  129308. * Creates a default mesh for the Volumeric Light Scattering post-process
  129309. * @param name The mesh name
  129310. * @param scene The scene where to create the mesh
  129311. * @return the default mesh
  129312. */
  129313. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  129314. }
  129315. }
  129316. declare module BABYLON {
  129317. interface Scene {
  129318. /** @hidden (Backing field) */
  129319. _boundingBoxRenderer: BoundingBoxRenderer;
  129320. /** @hidden (Backing field) */
  129321. _forceShowBoundingBoxes: boolean;
  129322. /**
  129323. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  129324. */
  129325. forceShowBoundingBoxes: boolean;
  129326. /**
  129327. * Gets the bounding box renderer associated with the scene
  129328. * @returns a BoundingBoxRenderer
  129329. */
  129330. getBoundingBoxRenderer(): BoundingBoxRenderer;
  129331. }
  129332. interface AbstractMesh {
  129333. /** @hidden (Backing field) */
  129334. _showBoundingBox: boolean;
  129335. /**
  129336. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  129337. */
  129338. showBoundingBox: boolean;
  129339. }
  129340. /**
  129341. * Component responsible of rendering the bounding box of the meshes in a scene.
  129342. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  129343. */
  129344. export class BoundingBoxRenderer implements ISceneComponent {
  129345. /**
  129346. * The component name helpfull to identify the component in the list of scene components.
  129347. */
  129348. readonly name: string;
  129349. /**
  129350. * The scene the component belongs to.
  129351. */
  129352. scene: Scene;
  129353. /**
  129354. * Color of the bounding box lines placed in front of an object
  129355. */
  129356. frontColor: Color3;
  129357. /**
  129358. * Color of the bounding box lines placed behind an object
  129359. */
  129360. backColor: Color3;
  129361. /**
  129362. * Defines if the renderer should show the back lines or not
  129363. */
  129364. showBackLines: boolean;
  129365. /**
  129366. * @hidden
  129367. */
  129368. renderList: SmartArray<BoundingBox>;
  129369. private _colorShader;
  129370. private _vertexBuffers;
  129371. private _indexBuffer;
  129372. private _fillIndexBuffer;
  129373. private _fillIndexData;
  129374. /**
  129375. * Instantiates a new bounding box renderer in a scene.
  129376. * @param scene the scene the renderer renders in
  129377. */
  129378. constructor(scene: Scene);
  129379. /**
  129380. * Registers the component in a given scene
  129381. */
  129382. register(): void;
  129383. private _evaluateSubMesh;
  129384. private _activeMesh;
  129385. private _prepareRessources;
  129386. private _createIndexBuffer;
  129387. /**
  129388. * Rebuilds the elements related to this component in case of
  129389. * context lost for instance.
  129390. */
  129391. rebuild(): void;
  129392. /**
  129393. * @hidden
  129394. */
  129395. reset(): void;
  129396. /**
  129397. * Render the bounding boxes of a specific rendering group
  129398. * @param renderingGroupId defines the rendering group to render
  129399. */
  129400. render(renderingGroupId: number): void;
  129401. /**
  129402. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129403. * @param mesh Define the mesh to render the occlusion bounding box for
  129404. */
  129405. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129406. /**
  129407. * Dispose and release the resources attached to this renderer.
  129408. */
  129409. dispose(): void;
  129410. }
  129411. }
  129412. declare module BABYLON {
  129413. /** @hidden */
  129414. export var depthPixelShader: {
  129415. name: string;
  129416. shader: string;
  129417. };
  129418. }
  129419. declare module BABYLON {
  129420. /**
  129421. * This represents a depth renderer in Babylon.
  129422. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129423. */
  129424. export class DepthRenderer {
  129425. private _scene;
  129426. private _depthMap;
  129427. private _effect;
  129428. private readonly _storeNonLinearDepth;
  129429. private readonly _clearColor;
  129430. /** Get if the depth renderer is using packed depth or not */
  129431. readonly isPacked: boolean;
  129432. private _cachedDefines;
  129433. private _camera;
  129434. /**
  129435. * Specifiess that the depth renderer will only be used within
  129436. * the camera it is created for.
  129437. * This can help forcing its rendering during the camera processing.
  129438. */
  129439. useOnlyInActiveCamera: boolean;
  129440. /** @hidden */
  129441. static _SceneComponentInitialization: (scene: Scene) => void;
  129442. /**
  129443. * Instantiates a depth renderer
  129444. * @param scene The scene the renderer belongs to
  129445. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129446. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129447. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129448. */
  129449. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129450. /**
  129451. * Creates the depth rendering effect and checks if the effect is ready.
  129452. * @param subMesh The submesh to be used to render the depth map of
  129453. * @param useInstances If multiple world instances should be used
  129454. * @returns if the depth renderer is ready to render the depth map
  129455. */
  129456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129457. /**
  129458. * Gets the texture which the depth map will be written to.
  129459. * @returns The depth map texture
  129460. */
  129461. getDepthMap(): RenderTargetTexture;
  129462. /**
  129463. * Disposes of the depth renderer.
  129464. */
  129465. dispose(): void;
  129466. }
  129467. }
  129468. declare module BABYLON {
  129469. interface Scene {
  129470. /** @hidden (Backing field) */
  129471. _depthRenderer: {
  129472. [id: string]: DepthRenderer;
  129473. };
  129474. /**
  129475. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129476. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129477. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129478. * @returns the created depth renderer
  129479. */
  129480. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129481. /**
  129482. * Disables a depth renderer for a given camera
  129483. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129484. */
  129485. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129486. }
  129487. /**
  129488. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129489. * in several rendering techniques.
  129490. */
  129491. export class DepthRendererSceneComponent implements ISceneComponent {
  129492. /**
  129493. * The component name helpfull to identify the component in the list of scene components.
  129494. */
  129495. readonly name: string;
  129496. /**
  129497. * The scene the component belongs to.
  129498. */
  129499. scene: Scene;
  129500. /**
  129501. * Creates a new instance of the component for the given scene
  129502. * @param scene Defines the scene to register the component in
  129503. */
  129504. constructor(scene: Scene);
  129505. /**
  129506. * Registers the component in a given scene
  129507. */
  129508. register(): void;
  129509. /**
  129510. * Rebuilds the elements related to this component in case of
  129511. * context lost for instance.
  129512. */
  129513. rebuild(): void;
  129514. /**
  129515. * Disposes the component and the associated ressources
  129516. */
  129517. dispose(): void;
  129518. private _gatherRenderTargets;
  129519. private _gatherActiveCameraRenderTargets;
  129520. }
  129521. }
  129522. declare module BABYLON {
  129523. /** @hidden */
  129524. export var outlinePixelShader: {
  129525. name: string;
  129526. shader: string;
  129527. };
  129528. }
  129529. declare module BABYLON {
  129530. /** @hidden */
  129531. export var outlineVertexShader: {
  129532. name: string;
  129533. shader: string;
  129534. };
  129535. }
  129536. declare module BABYLON {
  129537. interface Scene {
  129538. /** @hidden */
  129539. _outlineRenderer: OutlineRenderer;
  129540. /**
  129541. * Gets the outline renderer associated with the scene
  129542. * @returns a OutlineRenderer
  129543. */
  129544. getOutlineRenderer(): OutlineRenderer;
  129545. }
  129546. interface AbstractMesh {
  129547. /** @hidden (Backing field) */
  129548. _renderOutline: boolean;
  129549. /**
  129550. * Gets or sets a boolean indicating if the outline must be rendered as well
  129551. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129552. */
  129553. renderOutline: boolean;
  129554. /** @hidden (Backing field) */
  129555. _renderOverlay: boolean;
  129556. /**
  129557. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129558. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129559. */
  129560. renderOverlay: boolean;
  129561. }
  129562. /**
  129563. * This class is responsible to draw bothe outline/overlay of meshes.
  129564. * It should not be used directly but through the available method on mesh.
  129565. */
  129566. export class OutlineRenderer implements ISceneComponent {
  129567. /**
  129568. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129569. */
  129570. private static _StencilReference;
  129571. /**
  129572. * The name of the component. Each component must have a unique name.
  129573. */
  129574. name: string;
  129575. /**
  129576. * The scene the component belongs to.
  129577. */
  129578. scene: Scene;
  129579. /**
  129580. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129581. */
  129582. zOffset: number;
  129583. private _engine;
  129584. private _effect;
  129585. private _cachedDefines;
  129586. private _savedDepthWrite;
  129587. /**
  129588. * Instantiates a new outline renderer. (There could be only one per scene).
  129589. * @param scene Defines the scene it belongs to
  129590. */
  129591. constructor(scene: Scene);
  129592. /**
  129593. * Register the component to one instance of a scene.
  129594. */
  129595. register(): void;
  129596. /**
  129597. * Rebuilds the elements related to this component in case of
  129598. * context lost for instance.
  129599. */
  129600. rebuild(): void;
  129601. /**
  129602. * Disposes the component and the associated ressources.
  129603. */
  129604. dispose(): void;
  129605. /**
  129606. * Renders the outline in the canvas.
  129607. * @param subMesh Defines the sumesh to render
  129608. * @param batch Defines the batch of meshes in case of instances
  129609. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129610. */
  129611. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129612. /**
  129613. * Returns whether or not the outline renderer is ready for a given submesh.
  129614. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129615. * @param subMesh Defines the submesh to check readyness for
  129616. * @param useInstances Defines wheter wee are trying to render instances or not
  129617. * @returns true if ready otherwise false
  129618. */
  129619. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129620. private _beforeRenderingMesh;
  129621. private _afterRenderingMesh;
  129622. }
  129623. }
  129624. declare module BABYLON {
  129625. /**
  129626. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129627. * @see http://doc.babylonjs.com/babylon101/sprites
  129628. */
  129629. export class SpritePackedManager extends SpriteManager {
  129630. /** defines the packed manager's name */
  129631. name: string;
  129632. /**
  129633. * Creates a new sprite manager from a packed sprite sheet
  129634. * @param name defines the manager's name
  129635. * @param imgUrl defines the sprite sheet url
  129636. * @param capacity defines the maximum allowed number of sprites
  129637. * @param scene defines the hosting scene
  129638. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129639. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129640. * @param samplingMode defines the smapling mode to use with spritesheet
  129641. * @param fromPacked set to true; do not alter
  129642. */
  129643. constructor(
  129644. /** defines the packed manager's name */
  129645. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129646. }
  129647. }
  129648. declare module BABYLON {
  129649. /**
  129650. * Defines the list of states available for a task inside a AssetsManager
  129651. */
  129652. export enum AssetTaskState {
  129653. /**
  129654. * Initialization
  129655. */
  129656. INIT = 0,
  129657. /**
  129658. * Running
  129659. */
  129660. RUNNING = 1,
  129661. /**
  129662. * Done
  129663. */
  129664. DONE = 2,
  129665. /**
  129666. * Error
  129667. */
  129668. ERROR = 3
  129669. }
  129670. /**
  129671. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  129672. */
  129673. export abstract class AbstractAssetTask {
  129674. /**
  129675. * Task name
  129676. */ name: string;
  129677. /**
  129678. * Callback called when the task is successful
  129679. */
  129680. onSuccess: (task: any) => void;
  129681. /**
  129682. * Callback called when the task is not successful
  129683. */
  129684. onError: (task: any, message?: string, exception?: any) => void;
  129685. /**
  129686. * Creates a new AssetsManager
  129687. * @param name defines the name of the task
  129688. */
  129689. constructor(
  129690. /**
  129691. * Task name
  129692. */ name: string);
  129693. private _isCompleted;
  129694. private _taskState;
  129695. private _errorObject;
  129696. /**
  129697. * Get if the task is completed
  129698. */
  129699. readonly isCompleted: boolean;
  129700. /**
  129701. * Gets the current state of the task
  129702. */
  129703. readonly taskState: AssetTaskState;
  129704. /**
  129705. * Gets the current error object (if task is in error)
  129706. */
  129707. readonly errorObject: {
  129708. message?: string;
  129709. exception?: any;
  129710. };
  129711. /**
  129712. * Internal only
  129713. * @hidden
  129714. */
  129715. _setErrorObject(message?: string, exception?: any): void;
  129716. /**
  129717. * Execute the current task
  129718. * @param scene defines the scene where you want your assets to be loaded
  129719. * @param onSuccess is a callback called when the task is successfully executed
  129720. * @param onError is a callback called if an error occurs
  129721. */
  129722. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129723. /**
  129724. * Execute the current task
  129725. * @param scene defines the scene where you want your assets to be loaded
  129726. * @param onSuccess is a callback called when the task is successfully executed
  129727. * @param onError is a callback called if an error occurs
  129728. */
  129729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129730. /**
  129731. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  129732. * This can be used with failed tasks that have the reason for failure fixed.
  129733. */
  129734. reset(): void;
  129735. private onErrorCallback;
  129736. private onDoneCallback;
  129737. }
  129738. /**
  129739. * Define the interface used by progress events raised during assets loading
  129740. */
  129741. export interface IAssetsProgressEvent {
  129742. /**
  129743. * Defines the number of remaining tasks to process
  129744. */
  129745. remainingCount: number;
  129746. /**
  129747. * Defines the total number of tasks
  129748. */
  129749. totalCount: number;
  129750. /**
  129751. * Defines the task that was just processed
  129752. */
  129753. task: AbstractAssetTask;
  129754. }
  129755. /**
  129756. * Class used to share progress information about assets loading
  129757. */
  129758. export class AssetsProgressEvent implements IAssetsProgressEvent {
  129759. /**
  129760. * Defines the number of remaining tasks to process
  129761. */
  129762. remainingCount: number;
  129763. /**
  129764. * Defines the total number of tasks
  129765. */
  129766. totalCount: number;
  129767. /**
  129768. * Defines the task that was just processed
  129769. */
  129770. task: AbstractAssetTask;
  129771. /**
  129772. * Creates a AssetsProgressEvent
  129773. * @param remainingCount defines the number of remaining tasks to process
  129774. * @param totalCount defines the total number of tasks
  129775. * @param task defines the task that was just processed
  129776. */
  129777. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  129778. }
  129779. /**
  129780. * Define a task used by AssetsManager to load meshes
  129781. */
  129782. export class MeshAssetTask extends AbstractAssetTask {
  129783. /**
  129784. * Defines the name of the task
  129785. */
  129786. name: string;
  129787. /**
  129788. * Defines the list of mesh's names you want to load
  129789. */
  129790. meshesNames: any;
  129791. /**
  129792. * Defines the root url to use as a base to load your meshes and associated resources
  129793. */
  129794. rootUrl: string;
  129795. /**
  129796. * Defines the filename of the scene to load from
  129797. */
  129798. sceneFilename: string;
  129799. /**
  129800. * Gets the list of loaded meshes
  129801. */
  129802. loadedMeshes: Array<AbstractMesh>;
  129803. /**
  129804. * Gets the list of loaded particle systems
  129805. */
  129806. loadedParticleSystems: Array<IParticleSystem>;
  129807. /**
  129808. * Gets the list of loaded skeletons
  129809. */
  129810. loadedSkeletons: Array<Skeleton>;
  129811. /**
  129812. * Gets the list of loaded animation groups
  129813. */
  129814. loadedAnimationGroups: Array<AnimationGroup>;
  129815. /**
  129816. * Callback called when the task is successful
  129817. */
  129818. onSuccess: (task: MeshAssetTask) => void;
  129819. /**
  129820. * Callback called when the task is successful
  129821. */
  129822. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  129823. /**
  129824. * Creates a new MeshAssetTask
  129825. * @param name defines the name of the task
  129826. * @param meshesNames defines the list of mesh's names you want to load
  129827. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  129828. * @param sceneFilename defines the filename of the scene to load from
  129829. */
  129830. constructor(
  129831. /**
  129832. * Defines the name of the task
  129833. */
  129834. name: string,
  129835. /**
  129836. * Defines the list of mesh's names you want to load
  129837. */
  129838. meshesNames: any,
  129839. /**
  129840. * Defines the root url to use as a base to load your meshes and associated resources
  129841. */
  129842. rootUrl: string,
  129843. /**
  129844. * Defines the filename of the scene to load from
  129845. */
  129846. sceneFilename: string);
  129847. /**
  129848. * Execute the current task
  129849. * @param scene defines the scene where you want your assets to be loaded
  129850. * @param onSuccess is a callback called when the task is successfully executed
  129851. * @param onError is a callback called if an error occurs
  129852. */
  129853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129854. }
  129855. /**
  129856. * Define a task used by AssetsManager to load text content
  129857. */
  129858. export class TextFileAssetTask extends AbstractAssetTask {
  129859. /**
  129860. * Defines the name of the task
  129861. */
  129862. name: string;
  129863. /**
  129864. * Defines the location of the file to load
  129865. */
  129866. url: string;
  129867. /**
  129868. * Gets the loaded text string
  129869. */
  129870. text: string;
  129871. /**
  129872. * Callback called when the task is successful
  129873. */
  129874. onSuccess: (task: TextFileAssetTask) => void;
  129875. /**
  129876. * Callback called when the task is successful
  129877. */
  129878. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  129879. /**
  129880. * Creates a new TextFileAssetTask object
  129881. * @param name defines the name of the task
  129882. * @param url defines the location of the file to load
  129883. */
  129884. constructor(
  129885. /**
  129886. * Defines the name of the task
  129887. */
  129888. name: string,
  129889. /**
  129890. * Defines the location of the file to load
  129891. */
  129892. url: string);
  129893. /**
  129894. * Execute the current task
  129895. * @param scene defines the scene where you want your assets to be loaded
  129896. * @param onSuccess is a callback called when the task is successfully executed
  129897. * @param onError is a callback called if an error occurs
  129898. */
  129899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129900. }
  129901. /**
  129902. * Define a task used by AssetsManager to load binary data
  129903. */
  129904. export class BinaryFileAssetTask extends AbstractAssetTask {
  129905. /**
  129906. * Defines the name of the task
  129907. */
  129908. name: string;
  129909. /**
  129910. * Defines the location of the file to load
  129911. */
  129912. url: string;
  129913. /**
  129914. * Gets the lodaded data (as an array buffer)
  129915. */
  129916. data: ArrayBuffer;
  129917. /**
  129918. * Callback called when the task is successful
  129919. */
  129920. onSuccess: (task: BinaryFileAssetTask) => void;
  129921. /**
  129922. * Callback called when the task is successful
  129923. */
  129924. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  129925. /**
  129926. * Creates a new BinaryFileAssetTask object
  129927. * @param name defines the name of the new task
  129928. * @param url defines the location of the file to load
  129929. */
  129930. constructor(
  129931. /**
  129932. * Defines the name of the task
  129933. */
  129934. name: string,
  129935. /**
  129936. * Defines the location of the file to load
  129937. */
  129938. url: string);
  129939. /**
  129940. * Execute the current task
  129941. * @param scene defines the scene where you want your assets to be loaded
  129942. * @param onSuccess is a callback called when the task is successfully executed
  129943. * @param onError is a callback called if an error occurs
  129944. */
  129945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129946. }
  129947. /**
  129948. * Define a task used by AssetsManager to load images
  129949. */
  129950. export class ImageAssetTask extends AbstractAssetTask {
  129951. /**
  129952. * Defines the name of the task
  129953. */
  129954. name: string;
  129955. /**
  129956. * Defines the location of the image to load
  129957. */
  129958. url: string;
  129959. /**
  129960. * Gets the loaded images
  129961. */
  129962. image: HTMLImageElement;
  129963. /**
  129964. * Callback called when the task is successful
  129965. */
  129966. onSuccess: (task: ImageAssetTask) => void;
  129967. /**
  129968. * Callback called when the task is successful
  129969. */
  129970. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  129971. /**
  129972. * Creates a new ImageAssetTask
  129973. * @param name defines the name of the task
  129974. * @param url defines the location of the image to load
  129975. */
  129976. constructor(
  129977. /**
  129978. * Defines the name of the task
  129979. */
  129980. name: string,
  129981. /**
  129982. * Defines the location of the image to load
  129983. */
  129984. url: string);
  129985. /**
  129986. * Execute the current task
  129987. * @param scene defines the scene where you want your assets to be loaded
  129988. * @param onSuccess is a callback called when the task is successfully executed
  129989. * @param onError is a callback called if an error occurs
  129990. */
  129991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129992. }
  129993. /**
  129994. * Defines the interface used by texture loading tasks
  129995. */
  129996. export interface ITextureAssetTask<TEX extends BaseTexture> {
  129997. /**
  129998. * Gets the loaded texture
  129999. */
  130000. texture: TEX;
  130001. }
  130002. /**
  130003. * Define a task used by AssetsManager to load 2D textures
  130004. */
  130005. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  130006. /**
  130007. * Defines the name of the task
  130008. */
  130009. name: string;
  130010. /**
  130011. * Defines the location of the file to load
  130012. */
  130013. url: string;
  130014. /**
  130015. * Defines if mipmap should not be generated (default is false)
  130016. */
  130017. noMipmap?: boolean | undefined;
  130018. /**
  130019. * Defines if texture must be inverted on Y axis (default is false)
  130020. */
  130021. invertY?: boolean | undefined;
  130022. /**
  130023. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130024. */
  130025. samplingMode: number;
  130026. /**
  130027. * Gets the loaded texture
  130028. */
  130029. texture: Texture;
  130030. /**
  130031. * Callback called when the task is successful
  130032. */
  130033. onSuccess: (task: TextureAssetTask) => void;
  130034. /**
  130035. * Callback called when the task is successful
  130036. */
  130037. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  130038. /**
  130039. * Creates a new TextureAssetTask object
  130040. * @param name defines the name of the task
  130041. * @param url defines the location of the file to load
  130042. * @param noMipmap defines if mipmap should not be generated (default is false)
  130043. * @param invertY defines if texture must be inverted on Y axis (default is false)
  130044. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130045. */
  130046. constructor(
  130047. /**
  130048. * Defines the name of the task
  130049. */
  130050. name: string,
  130051. /**
  130052. * Defines the location of the file to load
  130053. */
  130054. url: string,
  130055. /**
  130056. * Defines if mipmap should not be generated (default is false)
  130057. */
  130058. noMipmap?: boolean | undefined,
  130059. /**
  130060. * Defines if texture must be inverted on Y axis (default is false)
  130061. */
  130062. invertY?: boolean | undefined,
  130063. /**
  130064. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130065. */
  130066. samplingMode?: number);
  130067. /**
  130068. * Execute the current task
  130069. * @param scene defines the scene where you want your assets to be loaded
  130070. * @param onSuccess is a callback called when the task is successfully executed
  130071. * @param onError is a callback called if an error occurs
  130072. */
  130073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130074. }
  130075. /**
  130076. * Define a task used by AssetsManager to load cube textures
  130077. */
  130078. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  130079. /**
  130080. * Defines the name of the task
  130081. */
  130082. name: string;
  130083. /**
  130084. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130085. */
  130086. url: string;
  130087. /**
  130088. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130089. */
  130090. extensions?: string[] | undefined;
  130091. /**
  130092. * Defines if mipmaps should not be generated (default is false)
  130093. */
  130094. noMipmap?: boolean | undefined;
  130095. /**
  130096. * Defines the explicit list of files (undefined by default)
  130097. */
  130098. files?: string[] | undefined;
  130099. /**
  130100. * Gets the loaded texture
  130101. */
  130102. texture: CubeTexture;
  130103. /**
  130104. * Callback called when the task is successful
  130105. */
  130106. onSuccess: (task: CubeTextureAssetTask) => void;
  130107. /**
  130108. * Callback called when the task is successful
  130109. */
  130110. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  130111. /**
  130112. * Creates a new CubeTextureAssetTask
  130113. * @param name defines the name of the task
  130114. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130115. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130116. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130117. * @param files defines the explicit list of files (undefined by default)
  130118. */
  130119. constructor(
  130120. /**
  130121. * Defines the name of the task
  130122. */
  130123. name: string,
  130124. /**
  130125. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130126. */
  130127. url: string,
  130128. /**
  130129. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130130. */
  130131. extensions?: string[] | undefined,
  130132. /**
  130133. * Defines if mipmaps should not be generated (default is false)
  130134. */
  130135. noMipmap?: boolean | undefined,
  130136. /**
  130137. * Defines the explicit list of files (undefined by default)
  130138. */
  130139. files?: string[] | undefined);
  130140. /**
  130141. * Execute the current task
  130142. * @param scene defines the scene where you want your assets to be loaded
  130143. * @param onSuccess is a callback called when the task is successfully executed
  130144. * @param onError is a callback called if an error occurs
  130145. */
  130146. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130147. }
  130148. /**
  130149. * Define a task used by AssetsManager to load HDR cube textures
  130150. */
  130151. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  130152. /**
  130153. * Defines the name of the task
  130154. */
  130155. name: string;
  130156. /**
  130157. * Defines the location of the file to load
  130158. */
  130159. url: string;
  130160. /**
  130161. * Defines the desired size (the more it increases the longer the generation will be)
  130162. */
  130163. size: number;
  130164. /**
  130165. * Defines if mipmaps should not be generated (default is false)
  130166. */
  130167. noMipmap: boolean;
  130168. /**
  130169. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130170. */
  130171. generateHarmonics: boolean;
  130172. /**
  130173. * 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)
  130174. */
  130175. gammaSpace: boolean;
  130176. /**
  130177. * Internal Use Only
  130178. */
  130179. reserved: boolean;
  130180. /**
  130181. * Gets the loaded texture
  130182. */
  130183. texture: HDRCubeTexture;
  130184. /**
  130185. * Callback called when the task is successful
  130186. */
  130187. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  130188. /**
  130189. * Callback called when the task is successful
  130190. */
  130191. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  130192. /**
  130193. * Creates a new HDRCubeTextureAssetTask object
  130194. * @param name defines the name of the task
  130195. * @param url defines the location of the file to load
  130196. * @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.
  130197. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130198. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130199. * @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)
  130200. * @param reserved Internal use only
  130201. */
  130202. constructor(
  130203. /**
  130204. * Defines the name of the task
  130205. */
  130206. name: string,
  130207. /**
  130208. * Defines the location of the file to load
  130209. */
  130210. url: string,
  130211. /**
  130212. * Defines the desired size (the more it increases the longer the generation will be)
  130213. */
  130214. size: number,
  130215. /**
  130216. * Defines if mipmaps should not be generated (default is false)
  130217. */
  130218. noMipmap?: boolean,
  130219. /**
  130220. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130221. */
  130222. generateHarmonics?: boolean,
  130223. /**
  130224. * 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)
  130225. */
  130226. gammaSpace?: boolean,
  130227. /**
  130228. * Internal Use Only
  130229. */
  130230. reserved?: boolean);
  130231. /**
  130232. * Execute the current task
  130233. * @param scene defines the scene where you want your assets to be loaded
  130234. * @param onSuccess is a callback called when the task is successfully executed
  130235. * @param onError is a callback called if an error occurs
  130236. */
  130237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130238. }
  130239. /**
  130240. * Define a task used by AssetsManager to load Equirectangular cube textures
  130241. */
  130242. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  130243. /**
  130244. * Defines the name of the task
  130245. */
  130246. name: string;
  130247. /**
  130248. * Defines the location of the file to load
  130249. */
  130250. url: string;
  130251. /**
  130252. * Defines the desired size (the more it increases the longer the generation will be)
  130253. */
  130254. size: number;
  130255. /**
  130256. * Defines if mipmaps should not be generated (default is false)
  130257. */
  130258. noMipmap: boolean;
  130259. /**
  130260. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130261. * but the standard material would require them in Gamma space) (default is true)
  130262. */
  130263. gammaSpace: boolean;
  130264. /**
  130265. * Gets the loaded texture
  130266. */
  130267. texture: EquiRectangularCubeTexture;
  130268. /**
  130269. * Callback called when the task is successful
  130270. */
  130271. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  130272. /**
  130273. * Callback called when the task is successful
  130274. */
  130275. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  130276. /**
  130277. * Creates a new EquiRectangularCubeTextureAssetTask object
  130278. * @param name defines the name of the task
  130279. * @param url defines the location of the file to load
  130280. * @param size defines the desired size (the more it increases the longer the generation will be)
  130281. * If the size is omitted this implies you are using a preprocessed cubemap.
  130282. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130283. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  130284. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  130285. * (default is true)
  130286. */
  130287. constructor(
  130288. /**
  130289. * Defines the name of the task
  130290. */
  130291. name: string,
  130292. /**
  130293. * Defines the location of the file to load
  130294. */
  130295. url: string,
  130296. /**
  130297. * Defines the desired size (the more it increases the longer the generation will be)
  130298. */
  130299. size: number,
  130300. /**
  130301. * Defines if mipmaps should not be generated (default is false)
  130302. */
  130303. noMipmap?: boolean,
  130304. /**
  130305. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130306. * but the standard material would require them in Gamma space) (default is true)
  130307. */
  130308. gammaSpace?: boolean);
  130309. /**
  130310. * Execute the current task
  130311. * @param scene defines the scene where you want your assets to be loaded
  130312. * @param onSuccess is a callback called when the task is successfully executed
  130313. * @param onError is a callback called if an error occurs
  130314. */
  130315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130316. }
  130317. /**
  130318. * This class can be used to easily import assets into a scene
  130319. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  130320. */
  130321. export class AssetsManager {
  130322. private _scene;
  130323. private _isLoading;
  130324. protected _tasks: AbstractAssetTask[];
  130325. protected _waitingTasksCount: number;
  130326. protected _totalTasksCount: number;
  130327. /**
  130328. * Callback called when all tasks are processed
  130329. */
  130330. onFinish: (tasks: AbstractAssetTask[]) => void;
  130331. /**
  130332. * Callback called when a task is successful
  130333. */
  130334. onTaskSuccess: (task: AbstractAssetTask) => void;
  130335. /**
  130336. * Callback called when a task had an error
  130337. */
  130338. onTaskError: (task: AbstractAssetTask) => void;
  130339. /**
  130340. * Callback called when a task is done (whatever the result is)
  130341. */
  130342. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  130343. /**
  130344. * Observable called when all tasks are processed
  130345. */
  130346. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  130347. /**
  130348. * Observable called when a task had an error
  130349. */
  130350. onTaskErrorObservable: Observable<AbstractAssetTask>;
  130351. /**
  130352. * Observable called when all tasks were executed
  130353. */
  130354. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  130355. /**
  130356. * Observable called when a task is done (whatever the result is)
  130357. */
  130358. onProgressObservable: Observable<IAssetsProgressEvent>;
  130359. /**
  130360. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  130361. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130362. */
  130363. useDefaultLoadingScreen: boolean;
  130364. /**
  130365. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130366. * when all assets have been downloaded.
  130367. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130368. */
  130369. autoHideLoadingUI: boolean;
  130370. /**
  130371. * Creates a new AssetsManager
  130372. * @param scene defines the scene to work on
  130373. */
  130374. constructor(scene: Scene);
  130375. /**
  130376. * Add a MeshAssetTask to the list of active tasks
  130377. * @param taskName defines the name of the new task
  130378. * @param meshesNames defines the name of meshes to load
  130379. * @param rootUrl defines the root url to use to locate files
  130380. * @param sceneFilename defines the filename of the scene file
  130381. * @returns a new MeshAssetTask object
  130382. */
  130383. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130384. /**
  130385. * Add a TextFileAssetTask to the list of active tasks
  130386. * @param taskName defines the name of the new task
  130387. * @param url defines the url of the file to load
  130388. * @returns a new TextFileAssetTask object
  130389. */
  130390. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130391. /**
  130392. * Add a BinaryFileAssetTask to the list of active tasks
  130393. * @param taskName defines the name of the new task
  130394. * @param url defines the url of the file to load
  130395. * @returns a new BinaryFileAssetTask object
  130396. */
  130397. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130398. /**
  130399. * Add a ImageAssetTask to the list of active tasks
  130400. * @param taskName defines the name of the new task
  130401. * @param url defines the url of the file to load
  130402. * @returns a new ImageAssetTask object
  130403. */
  130404. addImageTask(taskName: string, url: string): ImageAssetTask;
  130405. /**
  130406. * Add a TextureAssetTask to the list of active tasks
  130407. * @param taskName defines the name of the new task
  130408. * @param url defines the url of the file to load
  130409. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130410. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130411. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130412. * @returns a new TextureAssetTask object
  130413. */
  130414. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130415. /**
  130416. * Add a CubeTextureAssetTask to the list of active tasks
  130417. * @param taskName defines the name of the new task
  130418. * @param url defines the url of the file to load
  130419. * @param extensions defines the extension to use to load the cube map (can be null)
  130420. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130421. * @param files defines the list of files to load (can be null)
  130422. * @returns a new CubeTextureAssetTask object
  130423. */
  130424. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130425. /**
  130426. *
  130427. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130428. * @param taskName defines the name of the new task
  130429. * @param url defines the url of the file to load
  130430. * @param size defines the size you want for the cubemap (can be null)
  130431. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130432. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130433. * @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)
  130434. * @param reserved Internal use only
  130435. * @returns a new HDRCubeTextureAssetTask object
  130436. */
  130437. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130438. /**
  130439. *
  130440. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130441. * @param taskName defines the name of the new task
  130442. * @param url defines the url of the file to load
  130443. * @param size defines the size you want for the cubemap (can be null)
  130444. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130445. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130446. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130447. * @returns a new EquiRectangularCubeTextureAssetTask object
  130448. */
  130449. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130450. /**
  130451. * Remove a task from the assets manager.
  130452. * @param task the task to remove
  130453. */
  130454. removeTask(task: AbstractAssetTask): void;
  130455. private _decreaseWaitingTasksCount;
  130456. private _runTask;
  130457. /**
  130458. * Reset the AssetsManager and remove all tasks
  130459. * @return the current instance of the AssetsManager
  130460. */
  130461. reset(): AssetsManager;
  130462. /**
  130463. * Start the loading process
  130464. * @return the current instance of the AssetsManager
  130465. */
  130466. load(): AssetsManager;
  130467. /**
  130468. * Start the loading process as an async operation
  130469. * @return a promise returning the list of failed tasks
  130470. */
  130471. loadAsync(): Promise<void>;
  130472. }
  130473. }
  130474. declare module BABYLON {
  130475. /**
  130476. * Wrapper class for promise with external resolve and reject.
  130477. */
  130478. export class Deferred<T> {
  130479. /**
  130480. * The promise associated with this deferred object.
  130481. */
  130482. readonly promise: Promise<T>;
  130483. private _resolve;
  130484. private _reject;
  130485. /**
  130486. * The resolve method of the promise associated with this deferred object.
  130487. */
  130488. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130489. /**
  130490. * The reject method of the promise associated with this deferred object.
  130491. */
  130492. readonly reject: (reason?: any) => void;
  130493. /**
  130494. * Constructor for this deferred object.
  130495. */
  130496. constructor();
  130497. }
  130498. }
  130499. declare module BABYLON {
  130500. /**
  130501. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130502. */
  130503. export class MeshExploder {
  130504. private _centerMesh;
  130505. private _meshes;
  130506. private _meshesOrigins;
  130507. private _toCenterVectors;
  130508. private _scaledDirection;
  130509. private _newPosition;
  130510. private _centerPosition;
  130511. /**
  130512. * Explodes meshes from a center mesh.
  130513. * @param meshes The meshes to explode.
  130514. * @param centerMesh The mesh to be center of explosion.
  130515. */
  130516. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130517. private _setCenterMesh;
  130518. /**
  130519. * Get class name
  130520. * @returns "MeshExploder"
  130521. */
  130522. getClassName(): string;
  130523. /**
  130524. * "Exploded meshes"
  130525. * @returns Array of meshes with the centerMesh at index 0.
  130526. */
  130527. getMeshes(): Array<Mesh>;
  130528. /**
  130529. * Explodes meshes giving a specific direction
  130530. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130531. */
  130532. explode(direction?: number): void;
  130533. }
  130534. }
  130535. declare module BABYLON {
  130536. /**
  130537. * Class used to help managing file picking and drag'n'drop
  130538. */
  130539. export class FilesInput {
  130540. /**
  130541. * List of files ready to be loaded
  130542. */
  130543. static readonly FilesToLoad: {
  130544. [key: string]: File;
  130545. };
  130546. /**
  130547. * Callback called when a file is processed
  130548. */
  130549. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130550. private _engine;
  130551. private _currentScene;
  130552. private _sceneLoadedCallback;
  130553. private _progressCallback;
  130554. private _additionalRenderLoopLogicCallback;
  130555. private _textureLoadingCallback;
  130556. private _startingProcessingFilesCallback;
  130557. private _onReloadCallback;
  130558. private _errorCallback;
  130559. private _elementToMonitor;
  130560. private _sceneFileToLoad;
  130561. private _filesToLoad;
  130562. /**
  130563. * Creates a new FilesInput
  130564. * @param engine defines the rendering engine
  130565. * @param scene defines the hosting scene
  130566. * @param sceneLoadedCallback callback called when scene is loaded
  130567. * @param progressCallback callback called to track progress
  130568. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130569. * @param textureLoadingCallback callback called when a texture is loading
  130570. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130571. * @param onReloadCallback callback called when a reload is requested
  130572. * @param errorCallback callback call if an error occurs
  130573. */
  130574. 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);
  130575. private _dragEnterHandler;
  130576. private _dragOverHandler;
  130577. private _dropHandler;
  130578. /**
  130579. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130580. * @param elementToMonitor defines the DOM element to track
  130581. */
  130582. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130583. /**
  130584. * Release all associated resources
  130585. */
  130586. dispose(): void;
  130587. private renderFunction;
  130588. private drag;
  130589. private drop;
  130590. private _traverseFolder;
  130591. private _processFiles;
  130592. /**
  130593. * Load files from a drop event
  130594. * @param event defines the drop event to use as source
  130595. */
  130596. loadFiles(event: any): void;
  130597. private _processReload;
  130598. /**
  130599. * Reload the current scene from the loaded files
  130600. */
  130601. reload(): void;
  130602. }
  130603. }
  130604. declare module BABYLON {
  130605. /**
  130606. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130608. */
  130609. export class SceneOptimization {
  130610. /**
  130611. * Defines the priority of this optimization (0 by default which means first in the list)
  130612. */
  130613. priority: number;
  130614. /**
  130615. * Gets a string describing the action executed by the current optimization
  130616. * @returns description string
  130617. */
  130618. getDescription(): string;
  130619. /**
  130620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130621. * @param scene defines the current scene where to apply this optimization
  130622. * @param optimizer defines the current optimizer
  130623. * @returns true if everything that can be done was applied
  130624. */
  130625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130626. /**
  130627. * Creates the SceneOptimization object
  130628. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130629. * @param desc defines the description associated with the optimization
  130630. */
  130631. constructor(
  130632. /**
  130633. * Defines the priority of this optimization (0 by default which means first in the list)
  130634. */
  130635. priority?: number);
  130636. }
  130637. /**
  130638. * Defines an optimization used to reduce the size of render target textures
  130639. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130640. */
  130641. export class TextureOptimization extends SceneOptimization {
  130642. /**
  130643. * Defines the priority of this optimization (0 by default which means first in the list)
  130644. */
  130645. priority: number;
  130646. /**
  130647. * 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
  130648. */
  130649. maximumSize: number;
  130650. /**
  130651. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130652. */
  130653. step: number;
  130654. /**
  130655. * Gets a string describing the action executed by the current optimization
  130656. * @returns description string
  130657. */
  130658. getDescription(): string;
  130659. /**
  130660. * Creates the TextureOptimization object
  130661. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130662. * @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
  130663. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130664. */
  130665. constructor(
  130666. /**
  130667. * Defines the priority of this optimization (0 by default which means first in the list)
  130668. */
  130669. priority?: number,
  130670. /**
  130671. * 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
  130672. */
  130673. maximumSize?: number,
  130674. /**
  130675. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130676. */
  130677. step?: number);
  130678. /**
  130679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130680. * @param scene defines the current scene where to apply this optimization
  130681. * @param optimizer defines the current optimizer
  130682. * @returns true if everything that can be done was applied
  130683. */
  130684. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130685. }
  130686. /**
  130687. * Defines an optimization used to increase or decrease the rendering resolution
  130688. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130689. */
  130690. export class HardwareScalingOptimization extends SceneOptimization {
  130691. /**
  130692. * Defines the priority of this optimization (0 by default which means first in the list)
  130693. */
  130694. priority: number;
  130695. /**
  130696. * Defines the maximum scale to use (2 by default)
  130697. */
  130698. maximumScale: number;
  130699. /**
  130700. * Defines the step to use between two passes (0.5 by default)
  130701. */
  130702. step: number;
  130703. private _currentScale;
  130704. private _directionOffset;
  130705. /**
  130706. * Gets a string describing the action executed by the current optimization
  130707. * @return description string
  130708. */
  130709. getDescription(): string;
  130710. /**
  130711. * Creates the HardwareScalingOptimization object
  130712. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130713. * @param maximumScale defines the maximum scale to use (2 by default)
  130714. * @param step defines the step to use between two passes (0.5 by default)
  130715. */
  130716. constructor(
  130717. /**
  130718. * Defines the priority of this optimization (0 by default which means first in the list)
  130719. */
  130720. priority?: number,
  130721. /**
  130722. * Defines the maximum scale to use (2 by default)
  130723. */
  130724. maximumScale?: number,
  130725. /**
  130726. * Defines the step to use between two passes (0.5 by default)
  130727. */
  130728. step?: number);
  130729. /**
  130730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130731. * @param scene defines the current scene where to apply this optimization
  130732. * @param optimizer defines the current optimizer
  130733. * @returns true if everything that can be done was applied
  130734. */
  130735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130736. }
  130737. /**
  130738. * Defines an optimization used to remove shadows
  130739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130740. */
  130741. export class ShadowsOptimization extends SceneOptimization {
  130742. /**
  130743. * Gets a string describing the action executed by the current optimization
  130744. * @return description string
  130745. */
  130746. getDescription(): string;
  130747. /**
  130748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130749. * @param scene defines the current scene where to apply this optimization
  130750. * @param optimizer defines the current optimizer
  130751. * @returns true if everything that can be done was applied
  130752. */
  130753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130754. }
  130755. /**
  130756. * Defines an optimization used to turn post-processes off
  130757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130758. */
  130759. export class PostProcessesOptimization extends SceneOptimization {
  130760. /**
  130761. * Gets a string describing the action executed by the current optimization
  130762. * @return description string
  130763. */
  130764. getDescription(): string;
  130765. /**
  130766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130767. * @param scene defines the current scene where to apply this optimization
  130768. * @param optimizer defines the current optimizer
  130769. * @returns true if everything that can be done was applied
  130770. */
  130771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130772. }
  130773. /**
  130774. * Defines an optimization used to turn lens flares off
  130775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130776. */
  130777. export class LensFlaresOptimization extends SceneOptimization {
  130778. /**
  130779. * Gets a string describing the action executed by the current optimization
  130780. * @return description string
  130781. */
  130782. getDescription(): string;
  130783. /**
  130784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130785. * @param scene defines the current scene where to apply this optimization
  130786. * @param optimizer defines the current optimizer
  130787. * @returns true if everything that can be done was applied
  130788. */
  130789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130790. }
  130791. /**
  130792. * Defines an optimization based on user defined callback.
  130793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130794. */
  130795. export class CustomOptimization extends SceneOptimization {
  130796. /**
  130797. * Callback called to apply the custom optimization.
  130798. */
  130799. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  130800. /**
  130801. * Callback called to get custom description
  130802. */
  130803. onGetDescription: () => string;
  130804. /**
  130805. * Gets a string describing the action executed by the current optimization
  130806. * @returns description string
  130807. */
  130808. getDescription(): string;
  130809. /**
  130810. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130811. * @param scene defines the current scene where to apply this optimization
  130812. * @param optimizer defines the current optimizer
  130813. * @returns true if everything that can be done was applied
  130814. */
  130815. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130816. }
  130817. /**
  130818. * Defines an optimization used to turn particles off
  130819. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130820. */
  130821. export class ParticlesOptimization extends SceneOptimization {
  130822. /**
  130823. * Gets a string describing the action executed by the current optimization
  130824. * @return description string
  130825. */
  130826. getDescription(): string;
  130827. /**
  130828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130829. * @param scene defines the current scene where to apply this optimization
  130830. * @param optimizer defines the current optimizer
  130831. * @returns true if everything that can be done was applied
  130832. */
  130833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130834. }
  130835. /**
  130836. * Defines an optimization used to turn render targets off
  130837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130838. */
  130839. export class RenderTargetsOptimization extends SceneOptimization {
  130840. /**
  130841. * Gets a string describing the action executed by the current optimization
  130842. * @return description string
  130843. */
  130844. getDescription(): string;
  130845. /**
  130846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130847. * @param scene defines the current scene where to apply this optimization
  130848. * @param optimizer defines the current optimizer
  130849. * @returns true if everything that can be done was applied
  130850. */
  130851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130852. }
  130853. /**
  130854. * Defines an optimization used to merge meshes with compatible materials
  130855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130856. */
  130857. export class MergeMeshesOptimization extends SceneOptimization {
  130858. private static _UpdateSelectionTree;
  130859. /**
  130860. * Gets or sets a boolean which defines if optimization octree has to be updated
  130861. */
  130862. /**
  130863. * Gets or sets a boolean which defines if optimization octree has to be updated
  130864. */
  130865. static UpdateSelectionTree: boolean;
  130866. /**
  130867. * Gets a string describing the action executed by the current optimization
  130868. * @return description string
  130869. */
  130870. getDescription(): string;
  130871. private _canBeMerged;
  130872. /**
  130873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130874. * @param scene defines the current scene where to apply this optimization
  130875. * @param optimizer defines the current optimizer
  130876. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  130877. * @returns true if everything that can be done was applied
  130878. */
  130879. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  130880. }
  130881. /**
  130882. * Defines a list of options used by SceneOptimizer
  130883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130884. */
  130885. export class SceneOptimizerOptions {
  130886. /**
  130887. * Defines the target frame rate to reach (60 by default)
  130888. */
  130889. targetFrameRate: number;
  130890. /**
  130891. * Defines the interval between two checkes (2000ms by default)
  130892. */
  130893. trackerDuration: number;
  130894. /**
  130895. * Gets the list of optimizations to apply
  130896. */
  130897. optimizations: SceneOptimization[];
  130898. /**
  130899. * Creates a new list of options used by SceneOptimizer
  130900. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  130901. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  130902. */
  130903. constructor(
  130904. /**
  130905. * Defines the target frame rate to reach (60 by default)
  130906. */
  130907. targetFrameRate?: number,
  130908. /**
  130909. * Defines the interval between two checkes (2000ms by default)
  130910. */
  130911. trackerDuration?: number);
  130912. /**
  130913. * Add a new optimization
  130914. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  130915. * @returns the current SceneOptimizerOptions
  130916. */
  130917. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  130918. /**
  130919. * Add a new custom optimization
  130920. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  130921. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  130922. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130923. * @returns the current SceneOptimizerOptions
  130924. */
  130925. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  130926. /**
  130927. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  130928. * @param targetFrameRate defines the target frame rate (60 by default)
  130929. * @returns a SceneOptimizerOptions object
  130930. */
  130931. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130932. /**
  130933. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  130934. * @param targetFrameRate defines the target frame rate (60 by default)
  130935. * @returns a SceneOptimizerOptions object
  130936. */
  130937. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130938. /**
  130939. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  130940. * @param targetFrameRate defines the target frame rate (60 by default)
  130941. * @returns a SceneOptimizerOptions object
  130942. */
  130943. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130944. }
  130945. /**
  130946. * Class used to run optimizations in order to reach a target frame rate
  130947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130948. */
  130949. export class SceneOptimizer implements IDisposable {
  130950. private _isRunning;
  130951. private _options;
  130952. private _scene;
  130953. private _currentPriorityLevel;
  130954. private _targetFrameRate;
  130955. private _trackerDuration;
  130956. private _currentFrameRate;
  130957. private _sceneDisposeObserver;
  130958. private _improvementMode;
  130959. /**
  130960. * Defines an observable called when the optimizer reaches the target frame rate
  130961. */
  130962. onSuccessObservable: Observable<SceneOptimizer>;
  130963. /**
  130964. * Defines an observable called when the optimizer enables an optimization
  130965. */
  130966. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  130967. /**
  130968. * Defines an observable called when the optimizer is not able to reach the target frame rate
  130969. */
  130970. onFailureObservable: Observable<SceneOptimizer>;
  130971. /**
  130972. * Gets a boolean indicating if the optimizer is in improvement mode
  130973. */
  130974. readonly isInImprovementMode: boolean;
  130975. /**
  130976. * Gets the current priority level (0 at start)
  130977. */
  130978. readonly currentPriorityLevel: number;
  130979. /**
  130980. * Gets the current frame rate checked by the SceneOptimizer
  130981. */
  130982. readonly currentFrameRate: number;
  130983. /**
  130984. * Gets or sets the current target frame rate (60 by default)
  130985. */
  130986. /**
  130987. * Gets or sets the current target frame rate (60 by default)
  130988. */
  130989. targetFrameRate: number;
  130990. /**
  130991. * Gets or sets the current interval between two checks (every 2000ms by default)
  130992. */
  130993. /**
  130994. * Gets or sets the current interval between two checks (every 2000ms by default)
  130995. */
  130996. trackerDuration: number;
  130997. /**
  130998. * Gets the list of active optimizations
  130999. */
  131000. readonly optimizations: SceneOptimization[];
  131001. /**
  131002. * Creates a new SceneOptimizer
  131003. * @param scene defines the scene to work on
  131004. * @param options defines the options to use with the SceneOptimizer
  131005. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  131006. * @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)
  131007. */
  131008. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  131009. /**
  131010. * Stops the current optimizer
  131011. */
  131012. stop(): void;
  131013. /**
  131014. * Reset the optimizer to initial step (current priority level = 0)
  131015. */
  131016. reset(): void;
  131017. /**
  131018. * Start the optimizer. By default it will try to reach a specific framerate
  131019. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  131020. */
  131021. start(): void;
  131022. private _checkCurrentState;
  131023. /**
  131024. * Release all resources
  131025. */
  131026. dispose(): void;
  131027. /**
  131028. * Helper function to create a SceneOptimizer with one single line of code
  131029. * @param scene defines the scene to work on
  131030. * @param options defines the options to use with the SceneOptimizer
  131031. * @param onSuccess defines a callback to call on success
  131032. * @param onFailure defines a callback to call on failure
  131033. * @returns the new SceneOptimizer object
  131034. */
  131035. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  131036. }
  131037. }
  131038. declare module BABYLON {
  131039. /**
  131040. * Class used to serialize a scene into a string
  131041. */
  131042. export class SceneSerializer {
  131043. /**
  131044. * Clear cache used by a previous serialization
  131045. */
  131046. static ClearCache(): void;
  131047. /**
  131048. * Serialize a scene into a JSON compatible object
  131049. * @param scene defines the scene to serialize
  131050. * @returns a JSON compatible object
  131051. */
  131052. static Serialize(scene: Scene): any;
  131053. /**
  131054. * Serialize a mesh into a JSON compatible object
  131055. * @param toSerialize defines the mesh to serialize
  131056. * @param withParents defines if parents must be serialized as well
  131057. * @param withChildren defines if children must be serialized as well
  131058. * @returns a JSON compatible object
  131059. */
  131060. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  131061. }
  131062. }
  131063. declare module BABYLON {
  131064. /**
  131065. * Class used to host texture specific utilities
  131066. */
  131067. export class TextureTools {
  131068. /**
  131069. * Uses the GPU to create a copy texture rescaled at a given size
  131070. * @param texture Texture to copy from
  131071. * @param width defines the desired width
  131072. * @param height defines the desired height
  131073. * @param useBilinearMode defines if bilinear mode has to be used
  131074. * @return the generated texture
  131075. */
  131076. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  131077. }
  131078. }
  131079. declare module BABYLON {
  131080. /**
  131081. * This represents the different options available for the video capture.
  131082. */
  131083. export interface VideoRecorderOptions {
  131084. /** Defines the mime type of the video. */
  131085. mimeType: string;
  131086. /** Defines the FPS the video should be recorded at. */
  131087. fps: number;
  131088. /** Defines the chunk size for the recording data. */
  131089. recordChunckSize: number;
  131090. /** The audio tracks to attach to the recording. */
  131091. audioTracks?: MediaStreamTrack[];
  131092. }
  131093. /**
  131094. * This can help with recording videos from BabylonJS.
  131095. * This is based on the available WebRTC functionalities of the browser.
  131096. *
  131097. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  131098. */
  131099. export class VideoRecorder {
  131100. private static readonly _defaultOptions;
  131101. /**
  131102. * Returns whether or not the VideoRecorder is available in your browser.
  131103. * @param engine Defines the Babylon Engine.
  131104. * @returns true if supported otherwise false.
  131105. */
  131106. static IsSupported(engine: Engine): boolean;
  131107. private readonly _options;
  131108. private _canvas;
  131109. private _mediaRecorder;
  131110. private _recordedChunks;
  131111. private _fileName;
  131112. private _resolve;
  131113. private _reject;
  131114. /**
  131115. * True when a recording is already in progress.
  131116. */
  131117. readonly isRecording: boolean;
  131118. /**
  131119. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  131120. * @param engine Defines the BabylonJS Engine you wish to record.
  131121. * @param options Defines options that can be used to customize the capture.
  131122. */
  131123. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  131124. /**
  131125. * Stops the current recording before the default capture timeout passed in the startRecording function.
  131126. */
  131127. stopRecording(): void;
  131128. /**
  131129. * Starts recording the canvas for a max duration specified in parameters.
  131130. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  131131. * If null no automatic download will start and you can rely on the promise to get the data back.
  131132. * @param maxDuration Defines the maximum recording time in seconds.
  131133. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  131134. * @return A promise callback at the end of the recording with the video data in Blob.
  131135. */
  131136. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  131137. /**
  131138. * Releases internal resources used during the recording.
  131139. */
  131140. dispose(): void;
  131141. private _handleDataAvailable;
  131142. private _handleError;
  131143. private _handleStop;
  131144. }
  131145. }
  131146. declare module BABYLON {
  131147. /**
  131148. * Class containing a set of static utilities functions for screenshots
  131149. */
  131150. export class ScreenshotTools {
  131151. /**
  131152. * Captures a screenshot of the current rendering
  131153. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131154. * @param engine defines the rendering engine
  131155. * @param camera defines the source camera
  131156. * @param size This parameter can be set to a single number or to an object with the
  131157. * following (optional) properties: precision, width, height. If a single number is passed,
  131158. * it will be used for both width and height. If an object is passed, the screenshot size
  131159. * will be derived from the parameters. The precision property is a multiplier allowing
  131160. * rendering at a higher or lower resolution
  131161. * @param successCallback defines the callback receives a single parameter which contains the
  131162. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131163. * src parameter of an <img> to display it
  131164. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131165. * Check your browser for supported MIME types
  131166. */
  131167. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  131168. /**
  131169. * Captures a screenshot of the current rendering
  131170. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131171. * @param engine defines the rendering engine
  131172. * @param camera defines the source camera
  131173. * @param size This parameter can be set to a single number or to an object with the
  131174. * following (optional) properties: precision, width, height. If a single number is passed,
  131175. * it will be used for both width and height. If an object is passed, the screenshot size
  131176. * will be derived from the parameters. The precision property is a multiplier allowing
  131177. * rendering at a higher or lower resolution
  131178. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131179. * Check your browser for supported MIME types
  131180. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131181. * to the src parameter of an <img> to display it
  131182. */
  131183. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  131184. /**
  131185. * Generates an image screenshot from the specified camera.
  131186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131187. * @param engine The engine to use for rendering
  131188. * @param camera The camera to use for rendering
  131189. * @param size This parameter can be set to a single number or to an object with the
  131190. * following (optional) properties: precision, width, height. If a single number is passed,
  131191. * it will be used for both width and height. If an object is passed, the screenshot size
  131192. * will be derived from the parameters. The precision property is a multiplier allowing
  131193. * rendering at a higher or lower resolution
  131194. * @param successCallback The callback receives a single parameter which contains the
  131195. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131196. * src parameter of an <img> to display it
  131197. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131198. * Check your browser for supported MIME types
  131199. * @param samples Texture samples (default: 1)
  131200. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131201. * @param fileName A name for for the downloaded file.
  131202. */
  131203. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  131204. /**
  131205. * Generates an image screenshot from the specified camera.
  131206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131207. * @param engine The engine to use for rendering
  131208. * @param camera The camera to use for rendering
  131209. * @param size This parameter can be set to a single number or to an object with the
  131210. * following (optional) properties: precision, width, height. If a single number is passed,
  131211. * it will be used for both width and height. If an object is passed, the screenshot size
  131212. * will be derived from the parameters. The precision property is a multiplier allowing
  131213. * rendering at a higher or lower resolution
  131214. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131215. * Check your browser for supported MIME types
  131216. * @param samples Texture samples (default: 1)
  131217. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131218. * @param fileName A name for for the downloaded file.
  131219. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131220. * to the src parameter of an <img> to display it
  131221. */
  131222. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  131223. /**
  131224. * Gets height and width for screenshot size
  131225. * @private
  131226. */
  131227. private static _getScreenshotSize;
  131228. }
  131229. }
  131230. declare module BABYLON {
  131231. /**
  131232. * A cursor which tracks a point on a path
  131233. */
  131234. export class PathCursor {
  131235. private path;
  131236. /**
  131237. * Stores path cursor callbacks for when an onchange event is triggered
  131238. */
  131239. private _onchange;
  131240. /**
  131241. * The value of the path cursor
  131242. */
  131243. value: number;
  131244. /**
  131245. * The animation array of the path cursor
  131246. */
  131247. animations: Animation[];
  131248. /**
  131249. * Initializes the path cursor
  131250. * @param path The path to track
  131251. */
  131252. constructor(path: Path2);
  131253. /**
  131254. * Gets the cursor point on the path
  131255. * @returns A point on the path cursor at the cursor location
  131256. */
  131257. getPoint(): Vector3;
  131258. /**
  131259. * Moves the cursor ahead by the step amount
  131260. * @param step The amount to move the cursor forward
  131261. * @returns This path cursor
  131262. */
  131263. moveAhead(step?: number): PathCursor;
  131264. /**
  131265. * Moves the cursor behind by the step amount
  131266. * @param step The amount to move the cursor back
  131267. * @returns This path cursor
  131268. */
  131269. moveBack(step?: number): PathCursor;
  131270. /**
  131271. * Moves the cursor by the step amount
  131272. * If the step amount is greater than one, an exception is thrown
  131273. * @param step The amount to move the cursor
  131274. * @returns This path cursor
  131275. */
  131276. move(step: number): PathCursor;
  131277. /**
  131278. * Ensures that the value is limited between zero and one
  131279. * @returns This path cursor
  131280. */
  131281. private ensureLimits;
  131282. /**
  131283. * Runs onchange callbacks on change (used by the animation engine)
  131284. * @returns This path cursor
  131285. */
  131286. private raiseOnChange;
  131287. /**
  131288. * Executes a function on change
  131289. * @param f A path cursor onchange callback
  131290. * @returns This path cursor
  131291. */
  131292. onchange(f: (cursor: PathCursor) => void): PathCursor;
  131293. }
  131294. }
  131295. declare module BABYLON {
  131296. /** @hidden */
  131297. export var blurPixelShader: {
  131298. name: string;
  131299. shader: string;
  131300. };
  131301. }
  131302. declare module BABYLON {
  131303. /** @hidden */
  131304. export var pointCloudVertexDeclaration: {
  131305. name: string;
  131306. shader: string;
  131307. };
  131308. }
  131309. // Mixins
  131310. interface Window {
  131311. mozIndexedDB: IDBFactory;
  131312. webkitIndexedDB: IDBFactory;
  131313. msIndexedDB: IDBFactory;
  131314. webkitURL: typeof URL;
  131315. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  131316. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  131317. WebGLRenderingContext: WebGLRenderingContext;
  131318. MSGesture: MSGesture;
  131319. CANNON: any;
  131320. AudioContext: AudioContext;
  131321. webkitAudioContext: AudioContext;
  131322. PointerEvent: any;
  131323. Math: Math;
  131324. Uint8Array: Uint8ArrayConstructor;
  131325. Float32Array: Float32ArrayConstructor;
  131326. mozURL: typeof URL;
  131327. msURL: typeof URL;
  131328. VRFrameData: any; // WebVR, from specs 1.1
  131329. DracoDecoderModule: any;
  131330. setImmediate(handler: (...args: any[]) => void): number;
  131331. }
  131332. interface HTMLCanvasElement {
  131333. requestPointerLock(): void;
  131334. msRequestPointerLock?(): void;
  131335. mozRequestPointerLock?(): void;
  131336. webkitRequestPointerLock?(): void;
  131337. /** Track wether a record is in progress */
  131338. isRecording: boolean;
  131339. /** Capture Stream method defined by some browsers */
  131340. captureStream(fps?: number): MediaStream;
  131341. }
  131342. interface CanvasRenderingContext2D {
  131343. msImageSmoothingEnabled: boolean;
  131344. }
  131345. interface MouseEvent {
  131346. mozMovementX: number;
  131347. mozMovementY: number;
  131348. webkitMovementX: number;
  131349. webkitMovementY: number;
  131350. msMovementX: number;
  131351. msMovementY: number;
  131352. }
  131353. interface Navigator {
  131354. mozGetVRDevices: (any: any) => any;
  131355. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131356. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131357. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131358. webkitGetGamepads(): Gamepad[];
  131359. msGetGamepads(): Gamepad[];
  131360. webkitGamepads(): Gamepad[];
  131361. }
  131362. interface HTMLVideoElement {
  131363. mozSrcObject: any;
  131364. }
  131365. interface Math {
  131366. fround(x: number): number;
  131367. imul(a: number, b: number): number;
  131368. }
  131369. interface WebGLRenderingContext {
  131370. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  131371. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  131372. vertexAttribDivisor(index: number, divisor: number): void;
  131373. createVertexArray(): any;
  131374. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  131375. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  131376. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  131377. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  131378. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  131379. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  131380. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  131381. // Queries
  131382. createQuery(): WebGLQuery;
  131383. deleteQuery(query: WebGLQuery): void;
  131384. beginQuery(target: number, query: WebGLQuery): void;
  131385. endQuery(target: number): void;
  131386. getQueryParameter(query: WebGLQuery, pname: number): any;
  131387. getQuery(target: number, pname: number): any;
  131388. MAX_SAMPLES: number;
  131389. RGBA8: number;
  131390. READ_FRAMEBUFFER: number;
  131391. DRAW_FRAMEBUFFER: number;
  131392. UNIFORM_BUFFER: number;
  131393. HALF_FLOAT_OES: number;
  131394. RGBA16F: number;
  131395. RGBA32F: number;
  131396. R32F: number;
  131397. RG32F: number;
  131398. RGB32F: number;
  131399. R16F: number;
  131400. RG16F: number;
  131401. RGB16F: number;
  131402. RED: number;
  131403. RG: number;
  131404. R8: number;
  131405. RG8: number;
  131406. UNSIGNED_INT_24_8: number;
  131407. DEPTH24_STENCIL8: number;
  131408. MIN: number;
  131409. MAX: number;
  131410. /* Multiple Render Targets */
  131411. drawBuffers(buffers: number[]): void;
  131412. readBuffer(src: number): void;
  131413. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131414. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131415. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131416. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131417. // Occlusion Query
  131418. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131419. ANY_SAMPLES_PASSED: number;
  131420. QUERY_RESULT_AVAILABLE: number;
  131421. QUERY_RESULT: number;
  131422. }
  131423. interface WebGLProgram {
  131424. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131425. }
  131426. interface EXT_disjoint_timer_query {
  131427. QUERY_COUNTER_BITS_EXT: number;
  131428. TIME_ELAPSED_EXT: number;
  131429. TIMESTAMP_EXT: number;
  131430. GPU_DISJOINT_EXT: number;
  131431. QUERY_RESULT_EXT: number;
  131432. QUERY_RESULT_AVAILABLE_EXT: number;
  131433. queryCounterEXT(query: WebGLQuery, target: number): void;
  131434. createQueryEXT(): WebGLQuery;
  131435. beginQueryEXT(target: number, query: WebGLQuery): void;
  131436. endQueryEXT(target: number): void;
  131437. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131438. deleteQueryEXT(query: WebGLQuery): void;
  131439. }
  131440. interface WebGLUniformLocation {
  131441. _currentState: any;
  131442. }
  131443. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131444. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131445. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131446. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131447. interface WebGLRenderingContext {
  131448. readonly RASTERIZER_DISCARD: number;
  131449. readonly DEPTH_COMPONENT24: number;
  131450. readonly TEXTURE_3D: number;
  131451. readonly TEXTURE_2D_ARRAY: number;
  131452. readonly TEXTURE_COMPARE_FUNC: number;
  131453. readonly TEXTURE_COMPARE_MODE: number;
  131454. readonly COMPARE_REF_TO_TEXTURE: number;
  131455. readonly TEXTURE_WRAP_R: number;
  131456. readonly HALF_FLOAT: number;
  131457. readonly RGB8: number;
  131458. readonly RED_INTEGER: number;
  131459. readonly RG_INTEGER: number;
  131460. readonly RGB_INTEGER: number;
  131461. readonly RGBA_INTEGER: number;
  131462. readonly R8_SNORM: number;
  131463. readonly RG8_SNORM: number;
  131464. readonly RGB8_SNORM: number;
  131465. readonly RGBA8_SNORM: number;
  131466. readonly R8I: number;
  131467. readonly RG8I: number;
  131468. readonly RGB8I: number;
  131469. readonly RGBA8I: number;
  131470. readonly R8UI: number;
  131471. readonly RG8UI: number;
  131472. readonly RGB8UI: number;
  131473. readonly RGBA8UI: number;
  131474. readonly R16I: number;
  131475. readonly RG16I: number;
  131476. readonly RGB16I: number;
  131477. readonly RGBA16I: number;
  131478. readonly R16UI: number;
  131479. readonly RG16UI: number;
  131480. readonly RGB16UI: number;
  131481. readonly RGBA16UI: number;
  131482. readonly R32I: number;
  131483. readonly RG32I: number;
  131484. readonly RGB32I: number;
  131485. readonly RGBA32I: number;
  131486. readonly R32UI: number;
  131487. readonly RG32UI: number;
  131488. readonly RGB32UI: number;
  131489. readonly RGBA32UI: number;
  131490. readonly RGB10_A2UI: number;
  131491. readonly R11F_G11F_B10F: number;
  131492. readonly RGB9_E5: number;
  131493. readonly RGB10_A2: number;
  131494. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131495. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131496. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131497. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131498. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131499. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131500. 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;
  131501. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131502. readonly TRANSFORM_FEEDBACK: number;
  131503. readonly INTERLEAVED_ATTRIBS: number;
  131504. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131505. createTransformFeedback(): WebGLTransformFeedback;
  131506. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131507. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131508. beginTransformFeedback(primitiveMode: number): void;
  131509. endTransformFeedback(): void;
  131510. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131511. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131512. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131513. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131514. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131515. }
  131516. interface ImageBitmap {
  131517. readonly width: number;
  131518. readonly height: number;
  131519. close(): void;
  131520. }
  131521. interface WebGLQuery extends WebGLObject {
  131522. }
  131523. declare var WebGLQuery: {
  131524. prototype: WebGLQuery;
  131525. new(): WebGLQuery;
  131526. };
  131527. interface WebGLSampler extends WebGLObject {
  131528. }
  131529. declare var WebGLSampler: {
  131530. prototype: WebGLSampler;
  131531. new(): WebGLSampler;
  131532. };
  131533. interface WebGLSync extends WebGLObject {
  131534. }
  131535. declare var WebGLSync: {
  131536. prototype: WebGLSync;
  131537. new(): WebGLSync;
  131538. };
  131539. interface WebGLTransformFeedback extends WebGLObject {
  131540. }
  131541. declare var WebGLTransformFeedback: {
  131542. prototype: WebGLTransformFeedback;
  131543. new(): WebGLTransformFeedback;
  131544. };
  131545. interface WebGLVertexArrayObject extends WebGLObject {
  131546. }
  131547. declare var WebGLVertexArrayObject: {
  131548. prototype: WebGLVertexArrayObject;
  131549. new(): WebGLVertexArrayObject;
  131550. };
  131551. // Type definitions for WebVR API
  131552. // Project: https://w3c.github.io/webvr/
  131553. // Definitions by: six a <https://github.com/lostfictions>
  131554. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131555. interface VRDisplay extends EventTarget {
  131556. /**
  131557. * Dictionary of capabilities describing the VRDisplay.
  131558. */
  131559. readonly capabilities: VRDisplayCapabilities;
  131560. /**
  131561. * z-depth defining the far plane of the eye view frustum
  131562. * enables mapping of values in the render target depth
  131563. * attachment to scene coordinates. Initially set to 10000.0.
  131564. */
  131565. depthFar: number;
  131566. /**
  131567. * z-depth defining the near plane of the eye view frustum
  131568. * enables mapping of values in the render target depth
  131569. * attachment to scene coordinates. Initially set to 0.01.
  131570. */
  131571. depthNear: number;
  131572. /**
  131573. * An identifier for this distinct VRDisplay. Used as an
  131574. * association point in the Gamepad API.
  131575. */
  131576. readonly displayId: number;
  131577. /**
  131578. * A display name, a user-readable name identifying it.
  131579. */
  131580. readonly displayName: string;
  131581. readonly isConnected: boolean;
  131582. readonly isPresenting: boolean;
  131583. /**
  131584. * If this VRDisplay supports room-scale experiences, the optional
  131585. * stage attribute contains details on the room-scale parameters.
  131586. */
  131587. readonly stageParameters: VRStageParameters | null;
  131588. /**
  131589. * Passing the value returned by `requestAnimationFrame` to
  131590. * `cancelAnimationFrame` will unregister the callback.
  131591. * @param handle Define the hanle of the request to cancel
  131592. */
  131593. cancelAnimationFrame(handle: number): void;
  131594. /**
  131595. * Stops presenting to the VRDisplay.
  131596. * @returns a promise to know when it stopped
  131597. */
  131598. exitPresent(): Promise<void>;
  131599. /**
  131600. * Return the current VREyeParameters for the given eye.
  131601. * @param whichEye Define the eye we want the parameter for
  131602. * @returns the eye parameters
  131603. */
  131604. getEyeParameters(whichEye: string): VREyeParameters;
  131605. /**
  131606. * Populates the passed VRFrameData with the information required to render
  131607. * the current frame.
  131608. * @param frameData Define the data structure to populate
  131609. * @returns true if ok otherwise false
  131610. */
  131611. getFrameData(frameData: VRFrameData): boolean;
  131612. /**
  131613. * Get the layers currently being presented.
  131614. * @returns the list of VR layers
  131615. */
  131616. getLayers(): VRLayer[];
  131617. /**
  131618. * Return a VRPose containing the future predicted pose of the VRDisplay
  131619. * when the current frame will be presented. The value returned will not
  131620. * change until JavaScript has returned control to the browser.
  131621. *
  131622. * The VRPose will contain the position, orientation, velocity,
  131623. * and acceleration of each of these properties.
  131624. * @returns the pose object
  131625. */
  131626. getPose(): VRPose;
  131627. /**
  131628. * Return the current instantaneous pose of the VRDisplay, with no
  131629. * prediction applied.
  131630. * @returns the current instantaneous pose
  131631. */
  131632. getImmediatePose(): VRPose;
  131633. /**
  131634. * The callback passed to `requestAnimationFrame` will be called
  131635. * any time a new frame should be rendered. When the VRDisplay is
  131636. * presenting the callback will be called at the native refresh
  131637. * rate of the HMD. When not presenting this function acts
  131638. * identically to how window.requestAnimationFrame acts. Content should
  131639. * make no assumptions of frame rate or vsync behavior as the HMD runs
  131640. * asynchronously from other displays and at differing refresh rates.
  131641. * @param callback Define the eaction to run next frame
  131642. * @returns the request handle it
  131643. */
  131644. requestAnimationFrame(callback: FrameRequestCallback): number;
  131645. /**
  131646. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  131647. * Repeat calls while already presenting will update the VRLayers being displayed.
  131648. * @param layers Define the list of layer to present
  131649. * @returns a promise to know when the request has been fulfilled
  131650. */
  131651. requestPresent(layers: VRLayer[]): Promise<void>;
  131652. /**
  131653. * Reset the pose for this display, treating its current position and
  131654. * orientation as the "origin/zero" values. VRPose.position,
  131655. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  131656. * updated when calling resetPose(). This should be called in only
  131657. * sitting-space experiences.
  131658. */
  131659. resetPose(): void;
  131660. /**
  131661. * The VRLayer provided to the VRDisplay will be captured and presented
  131662. * in the HMD. Calling this function has the same effect on the source
  131663. * canvas as any other operation that uses its source image, and canvases
  131664. * created without preserveDrawingBuffer set to true will be cleared.
  131665. * @param pose Define the pose to submit
  131666. */
  131667. submitFrame(pose?: VRPose): void;
  131668. }
  131669. declare var VRDisplay: {
  131670. prototype: VRDisplay;
  131671. new(): VRDisplay;
  131672. };
  131673. interface VRLayer {
  131674. leftBounds?: number[] | Float32Array | null;
  131675. rightBounds?: number[] | Float32Array | null;
  131676. source?: HTMLCanvasElement | null;
  131677. }
  131678. interface VRDisplayCapabilities {
  131679. readonly canPresent: boolean;
  131680. readonly hasExternalDisplay: boolean;
  131681. readonly hasOrientation: boolean;
  131682. readonly hasPosition: boolean;
  131683. readonly maxLayers: number;
  131684. }
  131685. interface VREyeParameters {
  131686. /** @deprecated */
  131687. readonly fieldOfView: VRFieldOfView;
  131688. readonly offset: Float32Array;
  131689. readonly renderHeight: number;
  131690. readonly renderWidth: number;
  131691. }
  131692. interface VRFieldOfView {
  131693. readonly downDegrees: number;
  131694. readonly leftDegrees: number;
  131695. readonly rightDegrees: number;
  131696. readonly upDegrees: number;
  131697. }
  131698. interface VRFrameData {
  131699. readonly leftProjectionMatrix: Float32Array;
  131700. readonly leftViewMatrix: Float32Array;
  131701. readonly pose: VRPose;
  131702. readonly rightProjectionMatrix: Float32Array;
  131703. readonly rightViewMatrix: Float32Array;
  131704. readonly timestamp: number;
  131705. }
  131706. interface VRPose {
  131707. readonly angularAcceleration: Float32Array | null;
  131708. readonly angularVelocity: Float32Array | null;
  131709. readonly linearAcceleration: Float32Array | null;
  131710. readonly linearVelocity: Float32Array | null;
  131711. readonly orientation: Float32Array | null;
  131712. readonly position: Float32Array | null;
  131713. readonly timestamp: number;
  131714. }
  131715. interface VRStageParameters {
  131716. sittingToStandingTransform?: Float32Array;
  131717. sizeX?: number;
  131718. sizeY?: number;
  131719. }
  131720. interface Navigator {
  131721. getVRDisplays(): Promise<VRDisplay[]>;
  131722. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  131723. }
  131724. interface Window {
  131725. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  131726. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  131727. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  131728. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131729. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131730. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  131731. }
  131732. interface Gamepad {
  131733. readonly displayId: number;
  131734. }
  131735. type XRSessionMode =
  131736. | "inline"
  131737. | "immersive-vr"
  131738. | "immersive-ar";
  131739. type XRReferenceSpaceType =
  131740. | "viewer"
  131741. | "local"
  131742. | "local-floor"
  131743. | "bounded-floor"
  131744. | "unbounded";
  131745. type XREnvironmentBlendMode =
  131746. | "opaque"
  131747. | "additive"
  131748. | "alpha-blend";
  131749. type XRVisibilityState =
  131750. | "visible"
  131751. | "visible-blurred"
  131752. | "hidden";
  131753. type XRHandedness =
  131754. | "none"
  131755. | "left"
  131756. | "right";
  131757. type XRTargetRayMode =
  131758. | "gaze"
  131759. | "tracked-pointer"
  131760. | "screen";
  131761. type XREye =
  131762. | "none"
  131763. | "left"
  131764. | "right";
  131765. interface XRSpace extends EventTarget {
  131766. }
  131767. interface XRRenderState {
  131768. depthNear?: number;
  131769. depthFar?: number;
  131770. inlineVerticalFieldOfView?: number;
  131771. baseLayer?: XRWebGLLayer;
  131772. }
  131773. interface XRInputSource {
  131774. handedness: XRHandedness;
  131775. targetRayMode: XRTargetRayMode;
  131776. targetRaySpace: XRSpace;
  131777. gripSpace: XRSpace | undefined;
  131778. gamepad: Gamepad | undefined;
  131779. profiles: Array<string>;
  131780. }
  131781. interface XRSession {
  131782. addEventListener: Function;
  131783. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131784. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  131785. requestAnimationFrame: Function;
  131786. end(): Promise<void>;
  131787. renderState: XRRenderState;
  131788. inputSources: Array<XRInputSource>;
  131789. }
  131790. interface XRReferenceSpace extends XRSpace {
  131791. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  131792. onreset: any;
  131793. }
  131794. interface XRFrame {
  131795. session: XRSession;
  131796. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  131797. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  131798. }
  131799. interface XRViewerPose extends XRPose {
  131800. views: Array<XRView>;
  131801. }
  131802. interface XRPose {
  131803. transform: XRRigidTransform;
  131804. emulatedPosition: boolean;
  131805. }
  131806. declare var XRWebGLLayer: {
  131807. prototype: XRWebGLLayer;
  131808. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  131809. };
  131810. interface XRWebGLLayer {
  131811. framebuffer: WebGLFramebuffer;
  131812. framebufferWidth: number;
  131813. framebufferHeight: number;
  131814. getViewport: Function;
  131815. }
  131816. interface XRRigidTransform {
  131817. position: DOMPointReadOnly;
  131818. orientation: DOMPointReadOnly;
  131819. matrix: Float32Array;
  131820. inverse: XRRigidTransform;
  131821. }
  131822. interface XRView {
  131823. eye: XREye;
  131824. projectionMatrix: Float32Array;
  131825. transform: XRRigidTransform;
  131826. }
  131827. interface XRInputSourceChangeEvent {
  131828. session: XRSession;
  131829. removed: Array<XRInputSource>;
  131830. added: Array<XRInputSource>;
  131831. }